Dataquay 0.8
|
PropertyObject is a helper class for managing RDF properties of an object URI – that is, triples that share a common subject and possibly a common prefix for the predicate, and that have only one value for each subject-predicate combination. More...
#include <dataquay/PropertyObject.h>
Public Member Functions | |
PropertyObject (Store *s, Uri myUri) | |
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI. | |
PropertyObject (Store *s, QString myUri) | |
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI (which will be prefix expanded). | |
PropertyObject (Store *s, Node myNode) | |
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" node. | |
PropertyObject (Store *s, QString propertyPrefix, Uri myUri) | |
Construct a PropertyObject acting on the given Store, with the given default prefix (which will itself be prefix expanded) for properties and the given "subject" URI. | |
PropertyObject (Store *s, QString propertyPrefix, QString myUri) | |
Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given "subject" URI (which will be prefix expanded). | |
PropertyObject (Store *s, QString propertyPrefix, Node myNode) | |
Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given node as its subject. | |
~PropertyObject () | |
Node | getNode () const |
Return the node passed to the constructor (or derived from the URI passed to the constructor). | |
Uri | getObjectType () const |
Return the rdf:type of my URI, if any. | |
Uri | getObjectType (Transaction *tx) const |
Return the rdf:type of my URI, if any, querying through the given transaction. | |
bool | hasProperty (QString name) const |
Return true if the property object has the given property. | |
bool | hasProperty (Transaction *tx, QString name) const |
Return true if the property object has the given property, querying through the given transaction. | |
QVariant | getProperty (QString name) const |
Get the value of the given property. | |
QVariant | getProperty (Transaction *tx, QString name) const |
Get the value of the given property, querying through the given transaction. | |
QVariantList | getPropertyList (QString name) const |
Get the value of the given property as a list. | |
QVariantList | getPropertyList (Transaction *tx, QString name) const |
Get the value of the given property as a list, querying through the given transaction. | |
Node | getPropertyNode (QString name) const |
Get the node for the given property. | |
Node | getPropertyNode (Transaction *tx, QString name) const |
Get the node for the given property, querying through the given transaction. | |
Nodes | getPropertyNodeList (QString name) const |
Get the nodes for the given property. | |
Nodes | getPropertyNodeList (Transaction *tx, QString name) const |
Get the nodes for the given property, querying through the given transaction. | |
QStringList | getPropertyNames () const |
Get the names of this object's properties beginning with our property prefix. | |
QStringList | getPropertyNames (Transaction *tx) const |
Get the names of this object's properties beginning with our property prefix, querying through the given transaction. | |
void | setProperty (QString name, QVariant value) |
Set the given property to the given value. | |
void | setProperty (QString name, Uri uri) |
Set the given property to the given URI. | |
void | setProperty (QString name, Node node) |
Set the given property to the given node. | |
void | setProperty (Transaction *tx, QString name, QVariant value) |
Set the given property to the given value through the given transaction. | |
void | setProperty (Transaction *tx, QString name, Uri uri) |
Set the given property to the given URI through the given transaction. | |
void | setProperty (Transaction *tx, QString name, Node node) |
Set the given property to the given node through the given transaction. | |
void | setPropertyList (QString name, QVariantList values) |
Set the given property to the given values. | |
void | setPropertyList (Transaction *tx, QString name, QVariantList values) |
Set the given property to the given values through the given transaction. | |
void | setPropertyList (QString name, Nodes nodes) |
Set the given property to the given nodes. | |
void | setPropertyList (Transaction *tx, QString name, Nodes nodes) |
Set the given property to the given nodes through the given transaction. | |
void | removeProperty (QString name) |
Remove the given property. | |
void | removeProperty (Transaction *tx, QString name) |
Remove the given property. | |
Store * | getStore (Transaction *tx) const |
Return the Store object that will be used for modifications in the given transaction. | |
Uri | getPropertyUri (QString name) const |
Return the URI used for the "predicate" part of any triple referring to the given property name. | |
Static Public Member Functions | |
static void | setDefaultPropertyPrefix (QString prefix) |
Set the global default property prefix. | |
PropertyObject is a helper class for managing RDF properties of an object URI – that is, triples that share a common subject and possibly a common prefix for the predicate, and that have only one value for each subject-predicate combination.
This could be of use in situations where properties of a single object URI are referred to often. This class provides set and get methods that act directly upon the backing datastore, optionally using a transaction. See CacheingPropertyObject for a cacheing alternative.
PropertyObject is constructed using a "property prefix" (a string) and "my URI" (a URI). The URI is used by the property object as the subject for all RDF triples.
All the property handling methods then also take a "property name", which is a string. If this name contains no ':' character, it will be prefixed with the property prefix that was supplied to the PropertyObject constructor before being subjected to prefix expansion in the RDF store. The result is then used as the predicate for the RDF triple. If the name does contain a ':', it is passed for expansion directly (the prefix is not prepended first). As an exception, if the prefix is the special name "a", it will be expanded (by the store) as "rdf:type".
Example: If the property prefix is "myprops:" and the property name passed to getProperty is "some_property", the returned value from getProperty will be the result of matching on the triple (myUri, "myprops:some_property", ()). Hopefully, the RDF store will have already been told about the "myprops" prefix and will know how to expand it.
Example: If the property prefix is "http://example.com/property/" and the property name passed to getProperty is "some_property", the returned value from getProperty will be the result of matching on the triple (myUri, "http://example.com/property/some_property", ()).
Example: If the property prefix is "myprops:" and the property name passed to getProperty is "yourprops:some_property", the returned value from getProperty will be the result of matching on the triple (myUri, "yourprops:some_property", ()). The property prefix is not used at all in this example because the property name contains ':'.
Definition at line 96 of file PropertyObject.h.
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI.
Dataquay::PropertyObject::PropertyObject | ( | Store * | s, |
QString | myUri ) |
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI (which will be prefix expanded).
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" node.
This is provided so as to permit querying the properties of blank nodes or nodes returned from other queries.
Construct a PropertyObject acting on the given Store, with the given default prefix (which will itself be prefix expanded) for properties and the given "subject" URI.
Dataquay::PropertyObject::PropertyObject | ( | Store * | s, |
QString | propertyPrefix, | ||
QString | myUri ) |
Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given "subject" URI (which will be prefix expanded).
Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given node as its subject.
This is provided so as to permit querying the properties of blank nodes or nodes returned from other queries.
Dataquay::PropertyObject::~PropertyObject | ( | ) |
Node Dataquay::PropertyObject::getNode | ( | ) | const |
Return the node passed to the constructor (or derived from the URI passed to the constructor).
Uri Dataquay::PropertyObject::getObjectType | ( | ) | const |
Return the rdf:type of my URI, if any.
If more than one is defined, return the first one found.
Uri Dataquay::PropertyObject::getObjectType | ( | Transaction * | tx | ) | const |
Return the rdf:type of my URI, if any, querying through the given transaction.
If more than one is defined, return the first one found.
bool Dataquay::PropertyObject::hasProperty | ( | QString | name | ) | const |
Return true if the property object has the given property.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name.
bool Dataquay::PropertyObject::hasProperty | ( | Transaction * | tx, |
QString | name ) const |
Return true if the property object has the given property, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name.
QVariant Dataquay::PropertyObject::getProperty | ( | QString | name | ) | const |
Get the value of the given property.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, convert the object part of the first such matching triple to a QVariant via Node::toVariant and return that value. If there is no such match, return QVariant().
QVariant Dataquay::PropertyObject::getProperty | ( | Transaction * | tx, |
QString | name ) const |
Get the value of the given property, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, convert the object part of the first such matching triple to a QVariant via Node::toVariant and return that value. If there is no such match, return QVariant().
QVariantList Dataquay::PropertyObject::getPropertyList | ( | QString | name | ) | const |
Get the value of the given property as a list.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, convert the object parts of all such matching triples to QVariant via Node::toVariant and return a list of the resulting values. If there is no such match, return an empty list.
Note that the order of variants in the returned list is arbitrary and may change from one call to the next.
QVariantList Dataquay::PropertyObject::getPropertyList | ( | Transaction * | tx, |
QString | name ) const |
Get the value of the given property as a list, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, convert the object parts of all such matching triples to QVariant via Node::toVariant and return a list of the resulting values. If there is no such match, return QVariant().
Note that the order of variants in the returned list is arbitrary and may change from one call to the next.
Node Dataquay::PropertyObject::getPropertyNode | ( | QString | name | ) | const |
Get the node for the given property.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, return the object part of the first such matching triple. If there is no such match, return Node().
Node Dataquay::PropertyObject::getPropertyNode | ( | Transaction * | tx, |
QString | name ) const |
Get the node for the given property, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, return the object part of the first such matching triple. If there is no such match, return Node().
Nodes Dataquay::PropertyObject::getPropertyNodeList | ( | QString | name | ) | const |
Get the nodes for the given property.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, return the object parts of all such matching triples. If there is no such match, return an empty list.
Note that the order of nodes in the returned list is arbitrary and may change from one call to the next.
Nodes Dataquay::PropertyObject::getPropertyNodeList | ( | Transaction * | tx, |
QString | name ) const |
Get the nodes for the given property, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, return the object parts of all such matching triples. If there is no such match, return an empty list.
Note that the order of nodes in the returned list is arbitrary and may change from one call to the next.
!!! NB this is misnamed – this looks up a set rather than a list
QStringList Dataquay::PropertyObject::getPropertyNames | ( | ) | const |
Get the names of this object's properties beginning with our property prefix.
That is, find all triples in the store whose subject matches my URI and whose predicate begins with our property prefix, and return a list of the remainder of their predicate URIs following the property prefix.
QStringList Dataquay::PropertyObject::getPropertyNames | ( | Transaction * | tx | ) | const |
Get the names of this object's properties beginning with our property prefix, querying through the given transaction.
That is, find all triples in the store whose subject matches my URI and whose predicate begins with our property prefix, and return a list of the remainder of their predicate URIs following the property prefix.
void Dataquay::PropertyObject::setProperty | ( | QString | name, |
QVariant | value ) |
Set the given property to the given value.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the result of converting the given variant to a node via Node::fromVariant.
void Dataquay::PropertyObject::setProperty | ( | QString | name, |
Uri | uri ) |
Set the given property to the given URI.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the URI.
void Dataquay::PropertyObject::setProperty | ( | QString | name, |
Node | node ) |
Set the given property to the given node.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the node.
void Dataquay::PropertyObject::setProperty | ( | Transaction * | tx, |
QString | name, | ||
QVariant | value ) |
Set the given property to the given value through the given transaction.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the result of converting the given variant to a node via Node::fromVariant.
void Dataquay::PropertyObject::setProperty | ( | Transaction * | tx, |
QString | name, | ||
Uri | uri ) |
Set the given property to the given URI through the given transaction.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the URI.
void Dataquay::PropertyObject::setProperty | ( | Transaction * | tx, |
QString | name, | ||
Node | node ) |
Set the given property to the given node through the given transaction.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the node.
void Dataquay::PropertyObject::setPropertyList | ( | QString | name, |
QVariantList | values ) |
Set the given property to the given values.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple for each variant in the value list, whose object part is the result of converting that variant to a node via Node::fromVariant.
void Dataquay::PropertyObject::setPropertyList | ( | Transaction * | tx, |
QString | name, | ||
QVariantList | values ) |
Set the given property to the given values through the given transaction.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple for each variant in the value list, whose object part is the result of converting that variant to a node via Node::fromVariant.
void Dataquay::PropertyObject::setPropertyList | ( | QString | name, |
Nodes | nodes ) |
Set the given property to the given nodes.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple for each node in the list, whose object part is that node.
void Dataquay::PropertyObject::setPropertyList | ( | Transaction * | tx, |
QString | name, | ||
Nodes | nodes ) |
Set the given property to the given nodes through the given transaction.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple for each node in the list, whose object part is that node.
void Dataquay::PropertyObject::removeProperty | ( | QString | name | ) |
Remove the given property.
That is, remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name.
void Dataquay::PropertyObject::removeProperty | ( | Transaction * | tx, |
QString | name ) |
Remove the given property.
That is, remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name.
Store * Dataquay::PropertyObject::getStore | ( | Transaction * | tx | ) | const |
Uri Dataquay::PropertyObject::getPropertyUri | ( | QString | name | ) | const |
Return the URI used for the "predicate" part of any triple referring to the given property name.
See the general PropertyObject documentation for details of how these names are expanded.
|
static |
Set the global default property prefix.
This will be used as the prefix for all PropertyObjects subsequently constructed using the two-argument (prefixless) constructors.