SMWSparqlStore Class Reference
[SMWStore]

Storage access class for using SMW's SPARQL database for keeping semantic data. More...

Inherits SMWSQLStore2.

List of all members.

Public Member Functions

 deleteSubject (Title $subject)
 changeTitle (Title $oldtitle, Title $newtitle, $pageid, $redirid=0)
 Implementation of SMWStore::changeTitle().
 doDataUpdate (SMWSemanticData $data)
 getQueryResult (SMWQuery $query)
 drop ($verbose=true)
 Drop (delete) all storage structures created by setup().

Protected Member Functions

 prepareUpdateExpData (SMWSemanticData $data)
 Prepare an array of SMWExpData elements that should be written to the SPARQL store.
 expandUpdateExpElement (SMWExpElement $expElement, array &$auxiliaryExpData)
 Find a normalized representation of the given SMWExpElement that can be used in an update of the stored data.
 expandUpdateExpResource (SMWExpResource $expResource, array &$auxiliaryExpData)
 Find a normalized representation of the given SMWExpResource that can be used in an update of the stored data.
 expandUpdateExpData (SMWExpData $expData, array &$auxiliaryExpData, $expandSubject)
 Find a normalized representation of the given SMWExpData that can be used in an update of the stored data.
 getSparqlRedirectTarget (SMWExpNsResource $expNsResource, &$exists)
 Find the redirect target of an SMWExpNsResource.
 deleteSparqlData (SMWExpResource $expResource)
 Delete from the SPARQL database all data that is associated with the given resource.


Detailed Description

Storage access class for using SMW's SPARQL database for keeping semantic data.

Since:
1.6
Note:
For now, the store keeps an underlying SMWSQLStore2 running for completeness. This might change in the future.

Definition at line 23 of file SMW_SparqlStore.php.


Member Function Documentation

SMWSparqlStore::deleteSubject ( Title $  subject  ) 

See also:
SMWStore::deleteSubject
Parameters:
Title $subject

FIXME: if a property page is deleted, more pages may need to be updated by jobs! TODO: who is responsible for these updates? Some update jobs are currently created in SMW_Hooks, some internally in the store TODO: Possibly delete ID here (at least for non-properties/categories, if not used in any place in rels2) FIXME: clean internal caches here

Reimplemented from SMWSQLStore2.

Definition at line 25 of file SMW_SparqlStore.php.

References deleteSparqlData(), SMWExporter::getDataItemExpElement(), and SMWDIWikiPage::newFromTitle().

SMWSparqlStore::changeTitle ( Title $  oldtitle,
Title $  newtitle,
pageid,
redirid = 0 
)

Implementation of SMWStore::changeTitle().

In contrast to updateRedirects(), this function does not simply write a redirect from the old page to the new one, but also deletes all data that may already be stored for the new title (normally the new title should belong to an empty page that has no data but at least it could have a redirect to the old page), and moves all data that exists for the old title to the new location. Thus, the function executes three steps: delete data at newtitle, move data from oldtitle to newtitle, and set redirect from oldtitle to newtitle. In some cases, the goal can be achieved more efficiently, e.g. if the new title does not occur in SMW yet: then we can just change the ID records for the titles instead of changing all data tables

Note that the implementation ignores the MediaWiki IDs since this store has its own ID management. Also, the function requires that both titles are local, i.e. have empty interwiki prefix.

TODO: Currently the sortkey is not moved with the remaining data. It is not possible to move it reliably in all cases: we cannot distinguish an unset sortkey from one that was set to the name of oldtitle. Maybe use update jobs right away?

Parameters:
Title $oldtitle
Title $newtitle
integer $pageid
integer $redirid

NOTE: there is the (bad) case that the moved page is a redirect. As chains of redirects are not supported by MW or SMW, the above is maximally correct in this case too. NOTE: this temporarily leaves existing redirects to oldtitle point to newtitle as well, which will be lost after the next update. Since double redirects are an error anyway, this is not a bad behaviour: everything will continue to work until the existing redirects are updated, which will hopefully be done to fix the double redirect.

TODO: may not be optimal for the standard case that newtitle existed and redirected to oldtitle (PERFORMANCE)

Reimplemented from SMWSQLStore2.

Definition at line 32 of file SMW_SparqlStore.php.

References SMWExporter::getDataItemExpElement(), SMWTurtleSerializer::getTurtleNameForExpElement(), SMWDIWikiPage::newFromTitle(), and smwfGetSparqlDatabase().

SMWSparqlStore::doDataUpdate ( SMWSemanticData data  ) 

SMWSparqlStore::prepareUpdateExpData ( SMWSemanticData data  )  [protected]

Prepare an array of SMWExpData elements that should be written to the SPARQL store.

The result is empty if no updates should be done. Note that this is different from writing an SMWExpData element that has no content. Otherwise, the first SMWExpData object in the array is a translation of the given input data, but with redirects resolved. Further SMWExpData objects might be included in the resulting list to capture necessary stub declarations for objects that do not have any data in the RDF store yet.

Parameters:
$data SMWSemanticData object containing the update data
Returns:
array of SMWExpData

Definition at line 95 of file SMW_SparqlStore.php.

References expandUpdateExpData(), and SMWExporter::makeExportData().

Referenced by doDataUpdate().

SMWSparqlStore::expandUpdateExpElement ( SMWExpElement expElement,
array &$  auxiliaryExpData 
) [protected]

Find a normalized representation of the given SMWExpElement that can be used in an update of the stored data.

Normalization uses redirects. The type of the ExpElement might change, especially into SMWExpData in order to store auxiliary properties. Moreover, the method records any auxiliary data that should be written to the store when including this SMWExpElement into updates. This auxiliary data is collected in a call-by-ref array.

Parameters:
$expElement SMWExpElement object containing the update data
$auxiliaryExpData array of SMWExpData
Returns:
SMWExpElement

Definition at line 116 of file SMW_SparqlStore.php.

References expandUpdateExpData(), and expandUpdateExpResource().

Referenced by expandUpdateExpData().

SMWSparqlStore::expandUpdateExpResource ( SMWExpResource expResource,
array &$  auxiliaryExpData 
) [protected]

Find a normalized representation of the given SMWExpResource that can be used in an update of the stored data.

Normalization uses redirects. The type of the ExpElement might change, especially into SMWExpData in order to store auxiliary properties. Moreover, the method records any auxiliary data that should be written to the store when including this SMWExpElement into updates. This auxiliary data is collected in a call-by-ref array.

Parameters:
$expResource SMWExpResource object containing the update data
$auxiliaryExpData array of SMWExpData
Returns:
SMWExpElement

Definition at line 141 of file SMW_SparqlStore.php.

References SMWExpElement::getDataItem(), getSparqlRedirectTarget(), and SMWExporter::makeExportDataForSubject().

Referenced by expandUpdateExpElement().

SMWSparqlStore::expandUpdateExpData ( SMWExpData expData,
array &$  auxiliaryExpData,
expandSubject 
) [protected]

Find a normalized representation of the given SMWExpData that can be used in an update of the stored data.

Normalization uses redirects. Moreover, the method records any auxiliary data that should be written to the store when including this SMWExpElement into updates. This auxiliary data is collected in a call-by-ref array.

Parameters:
$expData SMWExpData object containing the update data
$auxiliaryExpData array of SMWExpData
$expandSubject boolean controls if redirects/auxiliary data should also be sought for subject
Returns:
SMWExpData

Definition at line 173 of file SMW_SparqlStore.php.

References expandUpdateExpElement(), SMWSQLStore2::getProperties(), and SMWExpData::getSubject().

Referenced by expandUpdateExpElement(), and prepareUpdateExpData().

SMWSparqlStore::getSparqlRedirectTarget ( SMWExpNsResource expNsResource,
&$  exists 
) [protected]

Find the redirect target of an SMWExpNsResource.

Returns an SMWExpNsResource object the input redirects to, the input itself if there is no redirect (or it cannot be used for making a resource with a prefix).

Parameters:
$expNsResource string URI to check
$exists boolean that is set to true if $expNsResource is in the store; always false for blank nodes; always true for subobjects
Returns:
SMWExpNsResource

Definition at line 208 of file SMW_SparqlStore.php.

References SMWExporter::getNamespaceUri(), SMWExporter::getSpecialPropertyResource(), SMWTurtleSerializer::getTurtleNameForExpElement(), SMWExpResource::getUri(), and smwfGetSparqlDatabase().

Referenced by expandUpdateExpResource().

SMWSparqlStore::deleteSparqlData ( SMWExpResource expResource  )  [protected]

Delete from the SPARQL database all data that is associated with the given resource.

Parameters:
$expResource SMWExpResource
Returns:
boolean success

Definition at line 254 of file SMW_SparqlStore.php.

References SMWExporter::getSpecialNsResource(), SMWTurtleSerializer::getTurtleNameForExpElement(), and smwfGetSparqlDatabase().

Referenced by deleteSubject(), and doDataUpdate().

SMWSparqlStore::getQueryResult ( SMWQuery query  ) 

See also:
SMWStore::getQueryResult
Parameters:
$query SMWQuery
Returns:
mixed: depends on $query->querymode

Reimplemented from SMWSQLStore2.

Definition at line 273 of file SMW_SparqlStore.php.

References $smwgIgnoreQueryErrors, SMWQuery::MODE_COUNT, SMWQuery::MODE_DEBUG, and SMWQuery::MODE_NONE.

SMWSparqlStore::drop ( verbose = true  ) 

Drop (delete) all storage structures created by setup().

This will delete all semantic data and possibly leave the wiki uninitialised.

Parameters:
boolean $verbose

Reimplemented from SMWSQLStore2.

Definition at line 296 of file SMW_SparqlStore.php.

References smwfGetSparqlDatabase().


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

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6