Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes

PD_RDFSemanticItem Class Reference

Base class for C++ objects which represent RDF at a higher level. More...

#include <pd_DocumentRDF.h>

Inheritance diagram for PD_RDFSemanticItem:
PD_RDFContact PD_RDFEvent PD_RDFLocation AP_RDFContact AP_RDFEvent AP_RDFLocation AP_RDFSemanticItemGTKInjected< AP_RDFContact > AP_RDFSemanticItemGTKInjected< AP_RDFEvent > AP_RDFSemanticItemGTKInjected< AP_RDFLocation > AP_RDFContactGTK AP_RDFEventGTK AP_RDFLocationGTK

List of all members.

Public Types

enum  RelationType { RELATION_FOAF_KNOWS = 1 }

Public Member Functions

 PD_RDFSemanticItem (PD_DocumentRDFHandle rdf, PD_ResultBindings_t::iterator &it)
virtual ~PD_RDFSemanticItem ()
PD_DocumentRDFHandle getRDF () const
PD_DocumentRDFMutationHandle createMutation ()
std::string requestExportFileNameByDialog ()
virtual PD_URI linkingSubject () const
 For an item like a contact, event, location, if there is a subject, common::idref xml:id triple that can be used to link into the document content, return that subject node here for the common base class methods to use.
virtual std::string name () const
 A simple description of the semantic item that can be shown to the user.
virtual void setName (const std::string &n)
virtual std::string getDisplayLabel () const
 Something that can be used on a notebook tab to describe this semantic item eg, Contact, Event etc.
virtual std::set< std::string > getXMLIDs () const
 A Semantic Item can appear multiple times in a document.
virtual void * createEditor ()=0
 Create a Widget that can edit the SemanticItem.
virtual void showEditorWindow (const PD_RDFSemanticItemHandle &c)
 Create a top level dialog allowing the user to edit this semitem.
virtual void showEditorWindow (const PD_RDFSemanticItems &cl)
void updateFromEditorData ()
 Update the SemanticItem from the edited dialog that was created using createEditor.
virtual void updateFromEditorData (PD_DocumentRDFMutationHandle m)=0
virtual void importFromData (std::istream &iss, PD_DocumentRDFHandle rdf, PD_DocumentRange *pDocRange=0)=0
 Import the data in iss to the semnatic item.
virtual void exportToFile (const std::string &filename="") const =0
 Export to a file in whatever format is the most useful for the semantic item.
virtual void importFromFile (const std::string &filename="")
 Import from a file in whatever format is the most useful for the semantic item.
std::pair< PT_DocPosition,
PT_DocPosition
insert (PD_DocumentRDFMutationHandle m, FV_View *pView)
 Insert a reference to this semantic item at the cursor location of pView.
std::pair< PT_DocPosition,
PT_DocPosition
insert (FV_View *pView)
virtual void setupStylesheetReplacementMapping (std::map< std::string, std::string > &m)
PD_RDFSemanticStylesheetHandle findStylesheetByUuid (const std::string &uuid) const
 Unambiguiously find a stylesheet by its UUID.
PD_RDFSemanticStylesheetHandle findStylesheetByName (const std::string &sheetType, const std::string &n) const
 Find a user/system stylesheet by name.
PD_RDFSemanticStylesheetHandle findStylesheetByName (const PD_RDFSemanticStylesheets &ssl, const std::string &n) const
 Find a user/system stylesheet by name.
PD_RDFSemanticStylesheetHandle defaultStylesheet () const
 Get the default stylesheet for this subclass of Semantic Item.
virtual PD_RDFSemanticStylesheets stylesheets () const =0
 Get the system semantic stylesheets that are supported for this particular semantic item subclass.
virtual std::string className () const =0
void relationAdd (PD_RDFSemanticItemHandle si, RelationType rt)
PD_RDFSemanticItems relationFind (RelationType rt)

Static Public Member Functions

static std::set< std::string > getXMLIDsForLinkingSubject (PD_DocumentRDFHandle rdf, const std::string &linkingSubj)
 Given a linking subject, find all the xmlids that are referenced by it ie, return all ?xmlid from the form:
static PD_RDFSemanticItemHandle createSemanticItem (PD_DocumentRDFHandle rdf, const std::string &semanticClass)
 Create a SemanticItem subclass using its name from getClassNames().
static PD_RDFSemanticItemHandle createSemanticItem (PD_DocumentRDFHandle rdf, PD_ResultBindings_t::iterator it, const std::string &semanticClass)
static std::list< std::string > getClassNames ()
 Gets a list of SemanticItem subclasses that can be created.

Protected Types

typedef std::list< std::map
< std::string, std::string > > 
PD_ResultBindings_t

Protected Member Functions

virtual std::string getImportFromFileName (const std::string &filename_const, std::list< std::pair< std::string, std::string > > types) const
virtual std::list< std::pair
< std::string, std::string > > 
getImportTypes () const
virtual std::string getExportToFileName (const std::string &filename_const, std::string defaultExtension, std::list< std::pair< std::string, std::string > > types) const
virtual std::list< std::pair
< std::string, std::string > > 
getExportTypes () const
virtual std::string getDefaultExtension () const
std::string getProperty (std::string subj, std::string pred, std::string defVal) const
std::pair< PT_DocPosition,
PT_DocPosition
insertTextWithXMLID (const std::string &textconst, const std::string &xmlid)
virtual void importFromDataComplete (std::istream &iss, PD_DocumentRDFHandle rdf, PD_DocumentRDFMutationHandle m, PD_DocumentRange *pDocRange=0)
 The importFromData() method can use this method to finish an import.
std::string bindingAsString (PD_ResultBindings_t::iterator &it, const std::string k)
std::string optionalBindingAsString (PD_ResultBindings_t::iterator &it, const std::string k)
PD_URIhandleSubjectDefaultArgument (PD_URI &subj)
virtual PD_URI context () const
 Return the graph context that contains this SematicItem's Rdf statements.
void setRDFType (PD_DocumentRDFMutationHandle m, const std::string &type, PD_URI subj=PD_URI())
 Ensure the Rdf Type of the subject or linkingSubject() by default is what you want After this method, the Rdf will have the following: linkingSubject() rdf:type type.
void setRDFType (const std::string &type, PD_URI subj=PD_URI())
void updateTriple (PD_DocumentRDFMutationHandle m, std::string &toModify, const std::string &newValue, const PD_URI &predString)
 When a subclass wants to update a triple in the RDF store to reflect a change, for example, the phone number of a contact, it should call here to set toModify = newValue.
void updateTriple (PD_DocumentRDFMutationHandle m, time_t &toModify, time_t newValue, const PD_URI &predString)
void updateTriple (PD_DocumentRDFMutationHandle m, double &toModify, double newValue, const PD_URI &predString)
void updateTriple (PD_DocumentRDFMutationHandle m, double &toModify, double newValue, const PD_URI &predString, PD_URI linkingSubject)
void updateTriple (std::string &toModify, const std::string &newValue, const PD_URI &predString)
void updateTriple (time_t &toModify, time_t newValue, const PD_URI &predString)
void updateTriple (double &toModify, double newValue, const PD_URI &predString)
PD_URI createUUIDNode ()
 Create a bnode with a uuid.
void updateTriple_remove (PD_DocumentRDFMutationHandle m, const PD_URI &toModify, const PD_URI &predString, const PD_URI &explicitLinkingSubject)
 The updateTriple() methods all call remove() then add() to perform their work.
void updateTriple_add (PD_DocumentRDFMutationHandle m, const PD_URI &toModify, const PD_URI &predString, const PD_URI &explicitLinkingSubject)
 After updateTriple() calls remove() it can set toModify to the new value and call this method to add the new value to the RDF store.

Protected Attributes

std::string m_name
PD_URI m_linkingSubject

Private Attributes

PD_DocumentRDFHandle m_rdf
PD_URI m_context

Detailed Description

Base class for C++ objects which represent RDF at a higher level.

Author:
Ben Martin

Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
RELATION_FOAF_KNOWS 

Constructor & Destructor Documentation

PD_RDFSemanticItem::PD_RDFSemanticItem ( PD_DocumentRDFHandle  rdf,
PD_ResultBindings_t::iterator &  it 
)

References bindingAsString(), and m_name.

PD_RDFSemanticItem::~PD_RDFSemanticItem (  )  [virtual]

Member Function Documentation

std::string PD_RDFSemanticItem::bindingAsString ( PD_ResultBindings_t::iterator &  it,
const std::string  k 
) [protected]
virtual std::string PD_RDFSemanticItem::className (  )  const [pure virtual]

Implemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

Referenced by defaultStylesheet().

PD_URI PD_RDFSemanticItem::context (  )  const [protected, virtual]

Return the graph context that contains this SematicItem's Rdf statements.

Used by the updateTriple()s to remove and add updated information. The default is the manifest.rdf file.

References m_context.

Referenced by updateTriple_add().

virtual void* PD_RDFSemanticItem::createEditor (  )  [pure virtual]

Create a Widget that can edit the SemanticItem.

Note that the widget will show the data and allow editing of it for the SemanticItem, but to make changes permenant, the updateFromEditorData() method must be used. A typical senario is to add the widget from createEditor to a dialog and when the user affirms the dialog call updateFromEditorData() to update the document.

See also:
updateFromEditorData()

Implemented in AP_RDFContactGTK, AP_RDFEventGTK, and AP_RDFLocationGTK.

PD_DocumentRDFMutationHandle PD_RDFSemanticItem::createMutation (  ) 

References m_rdf.

Referenced by setRDFType(), and updateTriple().

PD_RDFSemanticItemHandle PD_RDFSemanticItem::createSemanticItem ( PD_DocumentRDFHandle  rdf,
const std::string &  semanticClass 
) [static]

Create a SemanticItem subclass using its name from getClassNames().

Useful for menus and other places that want to allow the user to create new SemanticItem Objects.

Referenced by Defun1(), IE_Imp_RDF_Calendar::pasteFromBufferSS(), and IE_Imp_RDF_VCard::pasteFromBufferSS().

PD_RDFSemanticItemHandle PD_RDFSemanticItem::createSemanticItem ( PD_DocumentRDFHandle  rdf,
PD_ResultBindings_t::iterator  it,
const std::string &  semanticClass 
) [static]
PD_URI PD_RDFSemanticItem::createUUIDNode (  )  [protected]

Create a bnode with a uuid.

References XAP_App::createUUIDString(), and XAP_App::getApp().

PD_RDFSemanticStylesheetHandle PD_RDFSemanticItem::defaultStylesheet (  )  const

Get the default stylesheet for this subclass of Semantic Item.

If you want to know which stylesheet is in use by a particular reference to a semantic item, use KoRdfSemanticItemViewSite::stylesheet()

See also:
KoRdfSemanticItemViewSite
KoRdfSemanticItemViewSite::stylesheet()

References className(), findStylesheetByName(), findStylesheetByUuid(), getProperty(), RDF_SEMANTIC_STYLESHEET_NAME, PD_RDFSemanticStylesheet::stylesheetTypeSystem(), and type.

virtual void PD_RDFSemanticItem::exportToFile ( const std::string &  filename = ""  )  const [pure virtual]

Export to a file in whatever format is the most useful for the semantic item.

Prompt for a filename if none is given.

Implemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

PD_RDFSemanticStylesheetHandle PD_RDFSemanticItem::findStylesheetByName ( const PD_RDFSemanticStylesheets ssl,
const std::string &  n 
) const

Find a user/system stylesheet by name.

ssl is either stylesheets() or userStylesheets() n is the name of the stylesheet you want.

PD_RDFSemanticStylesheetHandle PD_RDFSemanticItem::findStylesheetByName ( const std::string &  sheetType,
const std::string &  n 
) const

Find a user/system stylesheet by name.

sheetType is one of TYPE_SYSTEM/TYPE_USER. n is the name of the stylesheet you want.

References stylesheets().

Referenced by defaultStylesheet().

PD_RDFSemanticStylesheetHandle PD_RDFSemanticItem::findStylesheetByUuid ( const std::string &  uuid  )  const

Unambiguiously find a stylesheet by its UUID.

The sheet can be either user or system as long as it has the uuid you want.

References stylesheets().

Referenced by defaultStylesheet().

std::list< std::string > PD_RDFSemanticItem::getClassNames (  )  [static]

Gets a list of SemanticItem subclasses that can be created.

Any of the strings in the return value can be created using createSemanticItem().

See also:
createSemanticItem()
std::string PD_RDFSemanticItem::getDefaultExtension (  )  const [protected, virtual]
std::string PD_RDFSemanticItem::getDisplayLabel (  )  const [virtual]

Something that can be used on a notebook tab to describe this semantic item eg, Contact, Event etc.

Reimplemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

std::string PD_RDFSemanticItem::getExportToFileName ( const std::string &  filename_const,
std::string  defaultExtension,
std::list< std::pair< std::string, std::string > >  types 
) const [protected, virtual]
std::list< std::pair< std::string, std::string > > PD_RDFSemanticItem::getExportTypes (  )  const [protected, virtual]
std::string PD_RDFSemanticItem::getImportFromFileName ( const std::string &  filename_const,
std::list< std::pair< std::string, std::string > >  types 
) const [protected, virtual]
std::list< std::pair< std::string, std::string > > PD_RDFSemanticItem::getImportTypes (  )  const [protected, virtual]

Reimplemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

Referenced by importFromFile().

std::string PD_RDFSemanticItem::getProperty ( std::string  subj,
std::string  pred,
std::string  defVal 
) const [protected]

References PD_URI::empty(), m_rdf, and PD_URI::toString().

Referenced by defaultStylesheet().

std::set< std::string > PD_RDFSemanticItem::getXMLIDs (  )  const [virtual]

A Semantic Item can appear multiple times in a document.

For example, the person Frodo can be referenced 20 times in a short book review. This method gives all the xmlid values where the semantic item is referenced in the document.

The list of xmlid values can in turn be used by PD_DocumentRDF::getIDRange() and PD_DocumentRDF::getRDFForID() to inspect or perform actions at the various places the semanitc item appears in the document.

Reimplemented in PD_RDFLocation.

References linkingSubject(), and m_rdf.

std::set< std::string > PD_RDFSemanticItem::getXMLIDsForLinkingSubject ( PD_DocumentRDFHandle  rdf,
const std::string &  linkingSubj 
) [static]

Given a linking subject, find all the xmlids that are referenced by it ie, return all ?xmlid from the form:

?linkingSubj pkg:idref ?xmlid

References d, PD_RDFQuery::executeQuery(), and UT_DEBUGMSG.

Referenced by relationFind().

PD_URI & PD_RDFSemanticItem::handleSubjectDefaultArgument ( PD_URI subj  )  [protected]

References linkingSubject(), and PD_URI::toString().

Referenced by setRDFType().

virtual void PD_RDFSemanticItem::importFromData ( std::istream &  iss,
PD_DocumentRDFHandle  rdf,
PD_DocumentRange pDocRange = 0 
) [pure virtual]

Import the data in iss to the semnatic item.

This is used for D&D Drop events to create a new semnatic item. Subclasses should set their internal state based on the data in 'iss' and then call importFromDataComplete() at the end of the method to update the RDF and insert the semantic item into the document.

??? maybe not ??? importFromDataComplete() calls also insert() which links the ??? semanticItem with the document object m_rdf.

Implemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

Referenced by importFromFile().

void PD_RDFSemanticItem::importFromDataComplete ( std::istream &  iss,
PD_DocumentRDFHandle  rdf,
PD_DocumentRDFMutationHandle  m,
PD_DocumentRange pDocRange = 0 
) [protected, virtual]

The importFromData() method can use this method to finish an import.

Text is also inserted into the document to show the user the new semantic object. The semanticObjectAdded signal is emitted so that UI elements have a chance to update themselves to reflect the newly added SemanticItem in the document.

This method uses createEditor() followed by updateFromEditorData() to actually put the RDF triples into the store. So a subclass does not have to explicitly handle the import if it can present a GUI to edit itself. The GUI is not shown to the user.

Basically a subclass reads the data in importFromData and sets local member variables from it. Then calls importFromDataComplete() which makes an editor using the member variables and commits the editor which in turn updates the RDF for the document.

Reimplemented in AP_RDFSemanticItemGTKInjected< AP_RDFEvent >, AP_RDFSemanticItemGTKInjected< AP_RDFLocation >, and AP_RDFSemanticItemGTKInjected< AP_RDFContact >.

References UT_DEBUGMSG.

Referenced by PD_RDFEvent::importFromData(), and PD_RDFContact::importFromData().

void PD_RDFSemanticItem::importFromFile ( const std::string &  filename = ""  )  [virtual]

Import from a file in whatever format is the most useful for the semantic item.

The default implemenation uses importFromData() to perform this import, so all a subclass needs to do is override the getImportTypes() method to let an import dialog know what types are OK.

References getImportFromFileName(), getImportTypes(), importFromData(), and m_rdf.

std::pair< PT_DocPosition, PT_DocPosition > PD_RDFSemanticItem::insert ( PD_DocumentRDFMutationHandle  m,
FV_View pView 
)

Insert a reference to this semantic item at the cursor location of pView.

This should only be called after creating a new sem item with createSemanticItem().

References XAP_App::createUUIDString(), XAP_App::getApp(), insertTextWithXMLID(), m_linkingSubject, m_rdf, name(), and PD_URI::toString().

Referenced by insert().

std::pair< PT_DocPosition, PT_DocPosition > PD_RDFSemanticItem::insert ( FV_View pView  ) 

References insert(), and m_rdf.

std::pair< PT_DocPosition, PT_DocPosition > PD_RDFSemanticItem::insertTextWithXMLID ( const std::string &  textconst,
const std::string &  xmlid 
) [protected]
PD_URI PD_RDFSemanticItem::linkingSubject (  )  const [virtual]

For an item like a contact, event, location, if there is a subject, common::idref xml:id triple that can be used to link into the document content, return that subject node here for the common base class methods to use.

For example, in the FOAF vocabulary the ?person node from the SPARQL query fragment below will be the linkingSubject() ?person rdf:type foaf:Person

References m_linkingSubject.

Referenced by getXMLIDs(), handleSubjectDefaultArgument(), relationAdd(), relationFind(), AP_RDFLocationGTK::updateFromEditorData(), AP_RDFContactGTK::updateFromEditorData(), and updateTriple().

std::string PD_RDFSemanticItem::name (  )  const [virtual]

A simple description of the semantic item that can be shown to the user.

References m_name.

Referenced by PD_RDFLocation::exportToFile(), and insert().

std::string PD_RDFSemanticItem::optionalBindingAsString ( PD_ResultBindings_t::iterator &  it,
const std::string  k 
) [protected]
void PD_RDFSemanticItem::relationAdd ( PD_RDFSemanticItemHandle  si,
RelationType  rt 
)
std::string PD_RDFSemanticItem::requestExportFileNameByDialog (  ) 
void PD_RDFSemanticItem::setName ( const std::string &  n  )  [virtual]

References m_name.

void PD_RDFSemanticItem::setRDFType ( PD_DocumentRDFMutationHandle  m,
const std::string &  type,
PD_URI  subj = PD_URI() 
) [protected]

Ensure the Rdf Type of the subject or linkingSubject() by default is what you want After this method, the Rdf will have the following: linkingSubject() rdf:type type.

References handleSubjectDefaultArgument(), and updateTriple().

Referenced by setRDFType(), AP_RDFEventGTK::updateFromEditorData(), and AP_RDFContactGTK::updateFromEditorData().

void PD_RDFSemanticItem::setRDFType ( const std::string &  type,
PD_URI  subj = PD_URI() 
) [protected]

References createMutation(), and setRDFType().

void PD_RDFSemanticItem::setupStylesheetReplacementMapping ( std::map< std::string, std::string > &  m  )  [virtual]

Reimplemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

void PD_RDFSemanticItem::showEditorWindow ( const PD_RDFSemanticItemHandle c  )  [virtual]

Create a top level dialog allowing the user to edit this semitem.

References UT_DEBUG_ONLY_ARG, and UT_DEBUGMSG.

void PD_RDFSemanticItem::showEditorWindow ( const PD_RDFSemanticItems cl  )  [virtual]

References UT_DEBUG_ONLY_ARG, and UT_DEBUGMSG.

virtual PD_RDFSemanticStylesheets PD_RDFSemanticItem::stylesheets (  )  const [pure virtual]

Get the system semantic stylesheets that are supported for this particular semantic item subclass.

Implemented in PD_RDFContact, PD_RDFEvent, and PD_RDFLocation.

Referenced by findStylesheetByName(), and findStylesheetByUuid().

void PD_RDFSemanticItem::updateFromEditorData (  ) 

Update the SemanticItem from the edited dialog that was created using createEditor.

See also:
createEditor()

References m_rdf.

virtual void PD_RDFSemanticItem::updateFromEditorData ( PD_DocumentRDFMutationHandle  m  )  [pure virtual]
void PD_RDFSemanticItem::updateTriple ( PD_DocumentRDFMutationHandle  m,
std::string &  toModify,
const std::string &  newValue,
const PD_URI predString 
) [protected]

When a subclass wants to update a triple in the RDF store to reflect a change, for example, the phone number of a contact, it should call here to set toModify = newValue.

This is done both in the C++ objects and the Rdf model. The RDF will be changed from linkingSubject() predString toModify to linkingSubject() predString newValue

Note that rounding errors and other serialization issues that crop up are handled by these methods, so you should try very hard not to directly update the PD_RDFModelHandle outside these methods.

Note that if you do not supply a mutationhandle the method to create/commit a mutation for you.

References linkingSubject(), updateTriple_add(), and updateTriple_remove().

Referenced by setRDFType(), AP_RDFLocationGTK::updateFromEditorData(), AP_RDFEventGTK::updateFromEditorData(), AP_RDFContactGTK::updateFromEditorData(), and updateTriple().

void PD_RDFSemanticItem::updateTriple ( PD_DocumentRDFMutationHandle  m,
double &  toModify,
double  newValue,
const PD_URI predString 
) [protected]
void PD_RDFSemanticItem::updateTriple ( time_t &  toModify,
time_t  newValue,
const PD_URI predString 
) [protected]

References createMutation(), and updateTriple().

void PD_RDFSemanticItem::updateTriple ( std::string &  toModify,
const std::string &  newValue,
const PD_URI predString 
) [protected]

References createMutation(), and updateTriple().

void PD_RDFSemanticItem::updateTriple ( PD_DocumentRDFMutationHandle  m,
time_t &  toModify,
time_t  newValue,
const PD_URI predString 
) [protected]
void PD_RDFSemanticItem::updateTriple ( PD_DocumentRDFMutationHandle  m,
double &  toModify,
double  newValue,
const PD_URI predString,
PD_URI  linkingSubject 
) [protected]
void PD_RDFSemanticItem::updateTriple ( double &  toModify,
double  newValue,
const PD_URI predString 
) [protected]

References createMutation(), and updateTriple().

void PD_RDFSemanticItem::updateTriple_add ( PD_DocumentRDFMutationHandle  m,
const PD_URI toModify,
const PD_URI predString,
const PD_URI explicitLinkingSubject 
) [protected]

After updateTriple() calls remove() it can set toModify to the new value and call this method to add the new value to the RDF store.

References context(), PD_URI::empty(), and PD_URI::toString().

Referenced by updateTriple().

void PD_RDFSemanticItem::updateTriple_remove ( PD_DocumentRDFMutationHandle  m,
const PD_URI toModify,
const PD_URI predString,
const PD_URI explicitLinkingSubject 
) [protected]

The updateTriple() methods all call remove() then add() to perform their work.

These lower level functions accept PD_URI to remove/add. Note that corner cases like "double" values are explicitly handled by these methods. For example, at times a double will undergo some rounding during serialization, so you can not just call mutation->remove() because you have to take rounding errors into account for the value you are intending to remove.

References m_rdf, s, and PD_URI::toString().

Referenced by updateTriple().


Member Data Documentation


The documentation for this class was generated from the following files: