Nepomuk
Nepomuk::Resource Class Reference
#include <Nepomuk/Resource>

Detailed Description
Resource is the central object type in Nepomuk.It represents a piece of information of any kind.
Resources are identified by their unique URI (which correlates directly with the URI in the local NEPOMUK RDF storage.
Resource objects with the same URI share their data.
All methods in Resource are thread-safe.
See Using Nepomuk for details on how to use Resource.
- See also:
- ResourceManager
Definition at line 71 of file resource.h.
Public Member Functions | |
void | addAltLabel (const QString &value) |
void | addAnnotation (const Resource &value) |
void | addIdentifier (const QString &value) |
void | addIsRelated (const Resource &value) |
void | addIsTopicOf (const Resource &value) |
void | addSymbol (const QString &value) |
void | addTag (const Tag &value) |
void | addTopic (const Resource &value) |
QHash< QString, Variant > | allProperties () const |
QStringList | altLabels () const |
QList< Resource > | annotationOf () const |
QList< Resource > | annotations () const |
QString | className () const |
QString | description () const |
bool | exists () const |
QString | genericDescription () const |
QString | genericIcon () const |
QString | genericLabel () const |
bool | hasProperty (const QString &uri) const |
bool | hasProperty (const QUrl &uri) const |
bool | hasType (const QUrl &typeUri) const |
QStringList | identifiers () const |
QList< Resource > | isRelatedOf () const |
QList< Resource > | isRelateds () const |
QList< Resource > | isTopicOfs () const |
bool | isValid () const |
QString | label () const |
Resource & | operator= (const Resource &) |
bool | operator== (const Resource &) const |
QHash< QUrl, Variant > | properties () const |
Variant | property (const QString &uri) const |
Variant | property (const QUrl &uri) const |
quint32 | rating () const |
void | remove () |
void | removeProperty (const QString &uri) |
void | removeProperty (const QUrl &uri) |
Resource (ResourceData *) | |
Resource (const QUrl &uri, const QUrl &type=QUrl()) | |
Resource (const QString &uriOrIdentifier, const QString &type) | |
Resource (const QString &uriOrIdentifier, const QUrl &type=QUrl()) | |
Resource (const Resource &) | |
Resource () | |
QUrl | resourceType () const |
QUrl | resourceUri () const |
void | setAltLabels (const QStringList &value) |
void | setAnnotations (const QList< Resource > &value) |
void | setDescription (const QString &value) |
void | setIdentifiers (const QStringList &value) |
void | setIsRelateds (const QList< Resource > &value) |
void | setIsTopicOfs (const QList< Resource > &value) |
void | setLabel (const QString &value) |
void | setProperty (const QString &uri, const Variant &value) |
void | setProperty (const QUrl &uri, const Variant &value) |
void | setRating (const quint32 &value) |
void | setSymbols (const QStringList &value) |
void | setTags (const QList< Tag > &value) |
void | setTopics (const QList< Resource > &value) |
QStringList | symbols () const |
QList< Tag > | tags () const |
QList< Resource > | topics () const |
QString | type () const |
QList< QUrl > | types () const |
QString | uri () const |
virtual | ~Resource () |
Static Public Member Functions | |
static QList< Resource > | allResources () |
static QString | altLabelUri () |
static QString | annotationUri () |
static QString | descriptionUri () |
static QString | identifierUri () |
static QString | isRelatedUri () |
static QString | isTopicOfUri () |
static QString | labelUri () |
static QString | ratingUri () |
static QString | symbolUri () |
static QString | tagUri () |
static QString | topicUri () |
Constructor & Destructor Documentation
Nepomuk::Resource::Resource | ( | ) |
Creates an empty invalid Resource.
An invalid resource will become valid (i.e. get a new random URI) once setProperty is called.
Nepomuk::Resource::Resource | ( | const Resource & | ) |
Creates a new Resource object.
The actual resource data is loaded on demand. Thus, it is possible to work with Resources as if they were in memory all the time.
- Parameters:
-
uriOrIdentifier The unique URI or an arbitrary identifier of the resource. If it exists as a resource URI in the RDF store it is used to load the related properties. If not the passed string is treated as an identifier. If a resource exists in the store which has this identifier set this resource's properties are loaded. Otherwise the resource is created in the store with a new random URI which can be accessed through uri after the resource has been synced. The resource can later again be found through the same identifier. In Nepomuk there are two ways of identifying a resource uniquely: - The URI of the resource which is generated randomly by the framework and can only be accessed in a read-only fashion.
- An identifier in combination with the resource type (Be aware that this identification can only be guranteed if identifiers are never set manually via addIdentifier but only through the constructor.
type The URI identifying the type of the resource. If it is empty Resource falls back to http://www.w3.org/2000/01/rdf-schema#Resource or in case the resource already exists the type will be read from the store. (This is a QString instead of a QUrl for historical reasons)
The best way to understand the URI and identifier system is through file resources. When a Resource object is created with the local path of the file as an identifier:
Resource myfile( "/tmp/testfile.txt" );
Now the URI of the resource in the store representing metadata for the file /tmp/testfile.txt is referred to by myfile.uri() which differs from the path of the file. However, the path of the file is saved as a hasIdentifier relation which means that it can be used to easily find the related resource.
Creates a new Resource object.
- Parameters:
-
url The URI of the resource. If no resource with this URI exists, a new one is created. type The URI identifying the type of the resource. If it is empty Resource falls back to http://www.w3.org/2000/01/rdf-schema#Resource or in case the resource already exists the type will be read from the store.
Nepomuk::Resource::Resource | ( | ResourceData * | ) |
Constructor used internally.
virtual Nepomuk::Resource::~Resource | ( | ) | [virtual] |
Member Function Documentation
void Nepomuk::Resource::addAltLabel | ( | const QString & | value | ) |
Add a value to property 'altLabel'.
void Nepomuk::Resource::addAnnotation | ( | const Resource & | value | ) |
Add a value to property 'annotation'.
void Nepomuk::Resource::addIdentifier | ( | const QString & | value | ) |
Add a value to property 'identifier'.
void Nepomuk::Resource::addIsRelated | ( | const Resource & | value | ) |
Add a value to property 'isRelated'.
void Nepomuk::Resource::addIsTopicOf | ( | const Resource & | value | ) |
Add a value to property 'isTopicOf'.
void Nepomuk::Resource::addSymbol | ( | const QString & | value | ) |
Add a value to property 'Symbol'.
Each resource can have a symbol assigned. For now this is a simple string which can either be the patch to an actual pixmap file or just the name of an icon as defined by the freedesktop.org standard.
void Nepomuk::Resource::addTag | ( | const Tag & | value | ) |
Add a value to property 'Tag'.
Each Resource can be tagged with an arbitrary number of Tags. This allows a simple grouping of resources.
void Nepomuk::Resource::addTopic | ( | const Resource & | value | ) |
Add a value to property 'Topic'.
QStringList Nepomuk::Resource::altLabels | ( | ) | const |
Get property 'altLabel'.
static QString Nepomuk::Resource::altLabelUri | ( | ) | [static] |
- Returns:
- The URI of the property 'altLabel'.
Get all resources that have this resource set as property 'annotation'.
static QString Nepomuk::Resource::annotationUri | ( | ) | [static] |
- Returns:
- The URI of the property 'annotation'.
QString Nepomuk::Resource::className | ( | ) | const |
The name of the class this Resource represents an object of.
The classname is derived from the type URI (see Resource::uri). For a translated user readable name of the resource see Ontology::typeName.
- See also:
- type()
QString Nepomuk::Resource::description | ( | ) | const |
Get property 'description'.
Everything can be annotated with a simple string comment.
static QString Nepomuk::Resource::descriptionUri | ( | ) | [static] |
- Returns:
- The URI of the property 'description'.
bool Nepomuk::Resource::exists | ( | ) | const |
- Returns:
- true if this resource (i.e.
the uri of this resource) exists in the local NEPOMUK RDF store.
QString Nepomuk::Resource::genericDescription | ( | ) | const |
Tries very hard to find a suitable human-readable description of the resource.
This description is supposed to be longer than text() and includes such properties as nao:description, xesam:comment, rdfs:comment
- Returns:
- A human readable description of the resource or an empty string if none could be found.
QString Nepomuk::Resource::genericIcon | ( | ) | const |
Tries very hard to find an icon suitable for this resource.
- Returns:
- An icon name to be used with KIcon or an empty string if none was found.
QString Nepomuk::Resource::genericLabel | ( | ) | const |
Tries very hard to find a suitable human-readable label for this resource.
It looks for properties such as nao:prefLabel, rdfs:label, or nao:identifier, or even the fileName of File resources.
- Returns:
- A human readable label or if all fails the URI of the resource.
bool Nepomuk::Resource::hasProperty | ( | const QString & | uri | ) | const |
bool Nepomuk::Resource::hasProperty | ( | const QUrl & | uri | ) | const |
Check if property identified by uri is defined for this resource.
- Parameters:
-
uri The URI identifying the property.
- Returns:
- true if property uri has a value set.
bool Nepomuk::Resource::hasType | ( | const QUrl & | typeUri | ) | const |
Check if the resource is of a certain type.
The type hierarchy is checked including subclass relations.
QStringList Nepomuk::Resource::identifiers | ( | ) | const |
Get property 'identifier'.
static QString Nepomuk::Resource::identifierUri | ( | ) | [static] |
- Returns:
- The URI of the property 'identifier'.
Get all resources that have this resource set as property 'isRelated'.
static QString Nepomuk::Resource::isRelatedUri | ( | ) | [static] |
- Returns:
- The URI of the property 'isRelated'.
static QString Nepomuk::Resource::isTopicOfUri | ( | ) | [static] |
- Returns:
- The URI of the property 'isTopicOf'.
bool Nepomuk::Resource::isValid | ( | ) | const |
- Returns:
- true if this Resource object is valid, i.e.
has a proper URI and type and can be synced with the local NEPOMUK RDF store.
An invalid resource will become valid (i.e. get a new random URI) once setProperty is called.
QString Nepomuk::Resource::label | ( | ) | const |
Get property 'label'.
static QString Nepomuk::Resource::labelUri | ( | ) | [static] |
- Returns:
- The URI of the property 'label'.
bool Nepomuk::Resource::operator== | ( | const Resource & | ) | const |
Operator to compare two Resource objects.
Normally one does not need this. It is mainly intended for testing and debugging purposes.
- Returns:
- A list of all defined properties
Retrieve the value of property uri.
If the property is not defined for this resource an invalid, empty Variant object is returned.
- Parameters:
-
uri The URI identifying the property.
quint32 Nepomuk::Resource::rating | ( | ) | const |
Get property 'Rating'.
static QString Nepomuk::Resource::ratingUri | ( | ) | [static] |
- Returns:
- The URI of the property 'Rating'.
void Nepomuk::Resource::remove | ( | ) |
Remove this resource completely.
CAUTION: After calling this method the resource will have been removed from the store without any trace.
void Nepomuk::Resource::removeProperty | ( | const QString & | uri | ) |
void Nepomuk::Resource::removeProperty | ( | const QUrl & | uri | ) |
Remove property uri from this resource object.
- Parameters:
-
uri The URI identifying the property.
QUrl Nepomuk::Resource::resourceType | ( | ) | const |
The main type of the resource.
Nepomuk tries hard to make this the type furthest down the hierarchy. In case the resource has only one type, this is no problem. However, if the resource has multiple types from different type hierarchies, there is no guarantee which one will be used here.
QUrl Nepomuk::Resource::resourceUri | ( | ) | const |
The URI of the resource, uniquely identifying it.
This URI in most cases is a virtual one which has been created from a generic base namespace and some identifier.
the most important thing to remember is that the URI of for example a file does not necessarily have a relation to its local path. (Although Nepomuk tries to keep the URI of file resources in sync with the file URL for convenience.)
- See also:
- uri, getIdentifiers
void Nepomuk::Resource::setAltLabels | ( | const QStringList & | value | ) |
Set property 'altLabel'.
Set property 'annotation'.
void Nepomuk::Resource::setDescription | ( | const QString & | value | ) |
Set property 'description'.
Everything can be annotated with a simple string comment.
void Nepomuk::Resource::setIdentifiers | ( | const QStringList & | value | ) |
Set property 'identifier'.
void Nepomuk::Resource::setLabel | ( | const QString & | value | ) |
Set property 'label'.
- Deprecated:
- use setProperty( const QUrl& )
Set a property of the resource.
- Parameters:
-
uri The URI identifying the property. value The value of the property (i.e. the object of the RDF triple(s))
void Nepomuk::Resource::setRating | ( | const quint32 & | value | ) |
Set property 'Rating'.
void Nepomuk::Resource::setSymbols | ( | const QStringList & | value | ) |
Set property 'Symbol'.
Each resource can have a symbol assigned. For now this is a simple string which can either be the patch to an actual pixmap file or just the name of an icon as defined by the freedesktop.org standard.
Set property 'Tag'.
Each Resource can be tagged with an arbitrary number of Tags. This allows a simple grouping of resources.
QStringList Nepomuk::Resource::symbols | ( | ) | const |
Get property 'Symbol'.
Each resource can have a symbol assigned. For now this is a simple string which can either be the patch to an actual pixmap file or just the name of an icon as defined by the freedesktop.org standard.
static QString Nepomuk::Resource::symbolUri | ( | ) | [static] |
- Returns:
- The URI of the property 'Symbol'.
Get property 'Tag'.
Each Resource can be tagged with an arbitrary number of Tags. This allows a simple grouping of resources.
static QString Nepomuk::Resource::tagUri | ( | ) | [static] |
- Returns:
- The URI of the property 'Tag'.
static QString Nepomuk::Resource::topicUri | ( | ) | [static] |
- Returns:
- The URI of the property 'Topic'.
QString Nepomuk::Resource::type | ( | ) | const |
The main type of the resource.
Nepomuk tries hard to make this the type furthest down the hierarchy. In case the resource has only one type, this is no problem. However, if the resource has multiple types from different type hierarchies, there is no guarantee which one will be used here.
For historical reasons the method does return a URI as QString instead of QUrl. The value equals resourceType().toString().
- Deprecated:
- use resourceType instead
QString Nepomuk::Resource::uri | ( | ) | const |
The URI of the resource, uniquely identifying it.
This URI in most cases is a virtual one which has been created from a generic base namespace and some identifier.
the most important thing to remember is that the URI of for example a file does not necessarily have a relation to its local path. (Although Nepomuk tries to keep the URI of file resources in sync with the file URL for convenience.)
For historical reasons the method does return a URI as QString instead of QUrl. The value equals resourceUri().toString().
- See also:
- resourceUri, getIdentifiers
- Deprecated:
- use resourceUri instead
The documentation for this class was generated from the following file: