SMWStore Class Reference
[SMWStore]

The abstract base class for all classes that implement access to some semantic store. More...

Inherited by SMWSQLStore2, and SMWSQLStoreLight.

List of all members.

Public Member Functions

 getSemanticData (SMWDIWikiPage $subject, $filter=false)
 Retrieve all data stored about the given subject and return it as a SMWSemanticData container.
 getPropertyValues ($subject, SMWDIProperty $property, $requestoptions=null)
 Get an array of all property values stored for the given subject and property.
 getPropertySubjects (SMWDIProperty $property, $value, $requestoptions=null)
 Get an array of all subjects that have the given value for the given property.
 getAllPropertySubjects (SMWDIProperty $property, $requestoptions=null)
 Get an array of all subjects that have some value for the given property.
 getProperties (SMWDIWikiPage $subject, $requestoptions=null)
 Get an array of all properties for which the given subject has some value.
 getInProperties (SMWDataItem $object, $requestoptions=null)
 Get an array of all properties for which there is some subject that relates to the given value.
 getWikiPageSortKey (SMWDIWikiPage $wikiPage)
 Convenience method to find the sortkey of an SMWDIWikiPage.
 getRedirectTarget (SMWDataItem $dataItem)
 Convenience method to find the redirect target of an SMWDIWikiPage or SMWDIProperty object.
 deleteSubject (Title $subject)
 Delete all semantic properties that the given subject has.
 doDataUpdate (SMWSemanticData $data)
 Update the semantic data stored for some individual.
 updateData (SMWSemanticData $data)
 Update the semantic data stored for some individual.
 clearData (SMWDIWikiPage $di)
 Clear all semantic data specified for some page.
 changeTitle (Title $oldtitle, Title $newtitle, $pageid, $redirid=0)
 Update the store to reflect a renaming of some article.
 getQueryResult (SMWQuery $query)
 Execute the provided query and return the result as an SMWQueryResult if the query was a usual instance retrieval query.
 getPropertiesSpecial ($requestoptions=null)
 Return all properties that have been used on pages in the wiki.
 getUnusedPropertiesSpecial ($requestoptions=null)
 Return all properties that have been declared in the wiki but that are not used on any page.
 getWantedPropertiesSpecial ($requestoptions=null)
 Return all properties that are used on some page but that do not have any page describing them.
 getStatistics ()
 Return statistical information as an associative array with the following keys:
  • 'PROPUSES': Number of property instances (value assignments) in the datatbase
  • 'USEDPROPS': Number of properties that are used with at least one value
  • 'DECLPROPS': Number of properties that have been declared (i.e.

 setup ($verbose=true)
 Setup all storage structures properly for using the store.
 drop ($verbose=true)
 Drop (delete) all storage structures created by setup().
 refreshData (&$index, $count, $namespaces=false, $usejobs=true)
 Refresh some objects in the store, addressed by numerical ids.

Static Public Member Functions

static formatDebugOutput ($storeName, array $entries, $query=null)
 Generate textual debug output that shows an arbitrary list of informative fields.


Detailed Description

The abstract base class for all classes that implement access to some semantic store.

Besides the relevant interface, this class provides default implementations for some optional methods, which inform the caller that these methods are not implemented.

Author:
Markus Krötzsch

Definition at line 141 of file SMW_Store.php.


Member Function Documentation

SMWStore::getSemanticData ( SMWDIWikiPage subject,
filter = false 
) [abstract]

Retrieve all data stored about the given subject and return it as a SMWSemanticData container.

There are no options: it just returns all available data as shown in the page's Factbox. $filter is an array of strings that are datatype IDs. If given, the function will avoid any work that is not necessary if only properties of these types are of interest.

Note:
There is no guarantee that the store does not retrieve more data than requested when a filter is used. Filtering just ensures that only necessary requests are made, i.e. it improves performance.

Reimplemented in SMWSQLStore2.

SMWStore::getPropertyValues ( subject,
SMWDIProperty property,
requestoptions = null 
) [abstract]

Get an array of all property values stored for the given subject and property.

The result is an array of SMWDataItem objects.

If called with $subject == null, all values for the given property are returned.

Parameters:
$subject mixed SMWDIWikiPage or null
$property SMWDIProperty
$requestoptions SMWRequestOptions
Returns:
array of SMWDataItem

Reimplemented in SMWSQLStore2.

Referenced by getRedirectTarget(), SDUtils::getSMWPropertyValues(), and getWikiPageSortKey().

SMWStore::getPropertySubjects ( SMWDIProperty property,
value,
requestoptions = null 
) [abstract]

Get an array of all subjects that have the given value for the given property.

The result is an array of SMWDIWikiPage objects. If null is given as a value, all subjects having that property are returned.

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getAllPropertySubjects ( SMWDIProperty property,
requestoptions = null 
) [abstract]

Get an array of all subjects that have some value for the given property.

The result is an array of SMWDIWikiPage objects.

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getProperties ( SMWDIWikiPage subject,
requestoptions = null 
) [abstract]

Get an array of all properties for which the given subject has some value.

The result is an array of SMWDIProperty objects.

Parameters:
$subject SMWDIWikiPage denoting the subject
$requestoptions SMWRequestOptions optionally defining further options

Reimplemented in SMWSQLStore2.

SMWStore::getInProperties ( SMWDataItem object,
requestoptions = null 
) [abstract]

Get an array of all properties for which there is some subject that relates to the given value.

The result is an array of SMWDIWikiPage objects.

Note:
In some stores, this function might be implemented partially so that only values of type Page (_wpg) are supported.

Reimplemented in SMWSQLStore2.

SMWStore::getWikiPageSortKey ( SMWDIWikiPage wikiPage  ) 

Convenience method to find the sortkey of an SMWDIWikiPage.

The result is based on the contents of this store, and may differ from the MediaWiki database entry about a Title objects sortkey. If no sortkey is stored, the default sortkey (title string) is returned.

Parameters:
$wikiPage SMWDIWikiPage to find the sortkey for
Returns:
string sortkey

Definition at line 214 of file SMW_Store.php.

References getPropertyValues().

Referenced by SMWSQLStore2::applyRequestOptions().

SMWStore::getRedirectTarget ( SMWDataItem dataItem  ) 

Convenience method to find the redirect target of an SMWDIWikiPage or SMWDIProperty object.

Returns a dataitem of the same type that the input redirects to, or the input itself if there is no redirect.

Parameters:
$dataItem SMWDataItem to find the redirect for.
Returns:
SMWDataItem

Definition at line 232 of file SMW_Store.php.

References getPropertyValues(), SMWDataItem::TYPE_PROPERTY, and SMWDataItem::TYPE_WIKIPAGE.

SMWStore::deleteSubject ( Title $  subject  )  [abstract]

Delete all semantic properties that the given subject has.

This includes relations, attributes, and special properties. This does not delete the respective text from the wiki, but only clears the stored data.

Parameters:
Title $subject

Reimplemented in SMWSparqlStore, SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::doDataUpdate ( SMWSemanticData data  )  [abstract]

Update the semantic data stored for some individual.

The data is given as a SMWSemanticData object, which contains all semantic data for one particular subject.

Parameters:
SMWSemanticData $data

Reimplemented in SMWSparqlStore, SMWSQLStore2, and SMWSQLStoreLight.

Referenced by updateData().

SMWStore::updateData ( SMWSemanticData data  ) 

Update the semantic data stored for some individual.

The data is given as a SMWSemanticData object, which contains all semantic data for one particular subject.

Parameters:
$data SMWSemanticData

Definition at line 284 of file SMW_Store.php.

References $smwgAutoRefreshSubject, doDataUpdate(), and portalocker::timestamp.

Referenced by clearData().

SMWStore::clearData ( SMWDIWikiPage di  ) 

Clear all semantic data specified for some page.

Parameters:
SMWDIWikiPage $di

Definition at line 313 of file SMW_Store.php.

References updateData().

SMWStore::changeTitle ( Title $  oldtitle,
Title $  newtitle,
pageid,
redirid = 0 
) [abstract]

Update the store to reflect a renaming of some article.

Normally this happens when moving pages in the wiki, and in this case there is also a new redirect page generated at the old position. The title objects given are only used to specify the name of the title before and after the move -- do not use their IDs for anything! The ID of the moved page is given in $pageid, and the ID of the newly created redirect, if any, is given by $redirid. If no new page was created, $redirid will be 0.

Reimplemented in SMWSparqlStore, SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getQueryResult ( SMWQuery query  )  [abstract]

Execute the provided query and return the result as an SMWQueryResult if the query was a usual instance retrieval query.

In the case that the query asked for a plain string (querymode MODE_COUNT or MODE_DEBUG) a plain wiki and HTML-compatible string is returned.

Parameters:
SMWQuery $query
Returns:
SMWQueryResult

Reimplemented in SMWSparqlStore, SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getPropertiesSpecial ( requestoptions = null  )  [abstract]

Return all properties that have been used on pages in the wiki.

The result is an array of arrays, each containing a property title and a count. The expected order is alphabetical w.r.t. to property title texts.

Parameters:
SMWRequestOptions $requestoptions
Returns:
array

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getUnusedPropertiesSpecial ( requestoptions = null  )  [abstract]

Return all properties that have been declared in the wiki but that are not used on any page.

Stores might restrict here to those properties that have been given a type if they have no efficient means of accessing the set of all pages in the property namespace.

Parameters:
SMWRequestOptions $requestoptions
Returns:
array of SMWDIProperty

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getWantedPropertiesSpecial ( requestoptions = null  )  [abstract]

Return all properties that are used on some page but that do not have any page describing them.

Stores that have no efficient way of accessing the set of all existing pages can extend this list to all properties that are used but do not have a type assigned to them.

Parameters:
SMWRequestOptions $requestoptions
Returns:
array of array( SMWDIProperty, int )

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::getStatistics (  )  [abstract]

Return statistical information as an associative array with the following keys:

  • 'PROPUSES': Number of property instances (value assignments) in the datatbase
  • 'USEDPROPS': Number of properties that are used with at least one value
  • 'DECLPROPS': Number of properties that have been declared (i.e.

assigned a type)

Returns:
array

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::setup ( verbose = true  )  [abstract]

Setup all storage structures properly for using the store.

This function performs tasks like creation of database tables. It is called upon installation as well as on upgrade: hence it must be able to upgrade existing storage structures if needed. It should return "true" if successful and return a meaningful string error message otherwise.

The parameter $verbose determines whether the procedure is allowed to report on its progress. This is doen by just using print and possibly ob_flush/flush. This is also relevant for preventing timeouts during long operations. All output must be valid in an HTML context, but should preferrably be plain text, possibly with some linebreaks and weak markup.

Parameters:
boolean $verbose

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::drop ( verbose = true  )  [abstract]

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

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

Parameters:
boolean $verbose

Reimplemented in SMWSparqlStore, SMWSQLStore2, and SMWSQLStoreLight.

SMWStore::refreshData ( &$  index,
count,
namespaces = false,
usejobs = true 
) [abstract]

Refresh some objects in the store, addressed by numerical ids.

The meaning of the ids is private to the store, and does not need to reflect the use of IDs elsewhere (e.g. page ids). The store is to refresh $count objects starting from the given $index. Typically, updates are achieved by generating update jobs. After the operation, $index is set to the next index that should be used for continuing refreshing, or to -1 for signaling that no objects of higher index require refresh. The method returns a decimal number between 0 and 1 to indicate the overall progress of the refreshing (e.g. 0.7 if 70% of all objects were refreshed).

The optional parameter $namespaces may contain an array of namespace constants. If given, only objects from those namespaces will be refreshed. The default value FALSE disables this feature.

The optional parameter $usejobs indicates whether updates should be processed later using MediaWiki jobs, instead of doing all updates immediately. The default is TRUE.

Parameters:
$index integer
$count integer
$namespaces mixed array or false
$usejobs boolean
Returns:
decimal between 0 and 1 to indicate the overall progress of the refreshing

Reimplemented in SMWSQLStore2, and SMWSQLStoreLight.

static SMWStore::formatDebugOutput ( storeName,
array $  entries,
query = null 
) [static]

Generate textual debug output that shows an arbitrary list of informative fields.

Used for formatting query debug output.

Note:
All strings given must be usable and safe in wiki and HTML contexts.
Parameters:
$storeName string name of the storage backend for which this is generated
$entries array of name => value of informative entries to display
$query SMWQuery or null, if given add basic data about this query as well
Returns:
string

Definition at line 463 of file SMW_Store.php.

Referenced by SMWSQLStore2QueryEngine::getDebugQueryResult(), and SMWSparqlStoreQueryEngine::getDebugQueryResult().


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

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