Nepomuk
Nepomuk::Resource Class Reference
Resource is the central object type in Nepomuk. More...
#include <Nepomuk/Resource>

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 | addProperty (const QUrl &uri, const Variant &value) |
void | addSymbol (const QString &value) |
void | addTag (const Tag &value) |
void | addTopic (const Resource &value) |
void | addType (const QUrl &type) |
KDE_DEPRECATED 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 |
KDE_DEPRECATED 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 |
ResourceManager * | manager () const |
Resource & | operator= (const QUrl &uri) |
Resource & | operator= (const Resource &other) |
bool | operator== (const Resource &) const |
Thing | pimoThing () |
QHash< QUrl, Variant > | properties () const |
KDE_DEPRECATED Variant | property (const QString &uri) const |
Variant | property (const QUrl &uri) const |
quint32 | rating () const |
void | remove () |
KDE_DEPRECATED void | removeProperty (const QString &uri) |
void | removeProperty (const QUrl &uri, const Variant &value) |
void | removeProperty (const QUrl &uri) |
Resource (ResourceData *) | |
Resource (const QUrl &uri, const QUrl &type, ResourceManager *manager) | |
Resource (const QUrl &uri, const QUrl &type=QUrl()) | |
KDE_DEPRECATED | Resource (const QString &pathOrIdentifier, const QString &type) |
Resource (const QString &pathOrIdentifier, const QUrl &type, ResourceManager *manager) | |
Resource (const QString &pathOrIdentifier, const QUrl &type=QUrl()) | |
Resource (const Resource &) | |
Resource (ResourceManager *manager) | |
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) |
KDE_DEPRECATED 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) |
void | setTypes (const QList< QUrl > &types) |
QStringList | symbols () const |
QList< Tag > | tags () const |
QList< Resource > | topics () const |
KDE_DEPRECATED QString | type () const |
QList< QUrl > | types () const |
KDE_DEPRECATED 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 () |
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 70 of file resource.h.
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 | ( | ResourceManager * | manager | ) |
Creates an empty invalid Resource.
An invalid resource will become valid (i.e. get a new random URI) once setProperty is called.
- Parameters:
-
manager The resource manager to use. This allows to mix resources from different managers and, thus, different models.
- Since:
- 4.3
Nepomuk::Resource::Resource | ( | const Resource & | ) |
Copy constructor.
Nepomuk::Resource::Resource | ( | const QString & | pathOrIdentifier, | |
const QUrl & | type = QUrl() | |||
) |
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:
-
pathOrIdentifier The path to a file or an arbitrary identifier of the resource. The following cases are handled: - A local file path is converted to a local file URL
- A URI which already exist in Nepomuk results in loading of that particular resource.
- A string which already exists as the nao:identifier of a resource results in loading of that particular resource.
- A URI which does not exist yet is used to create a new resource (Caution: due to encoding weirdness using KUrl::url or QUrl::toString here might result in unwanted behaviour. It is recommended to always use the Resource(QUrl,QUrl) constructor if possible)
- Any other string is used as nao:identifier for a new resource. This resource can later be loaded again by using the same identifier with this 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.
Example:
The best way to understand the path or identifier system is through tags. There are two ways to create a resource that represents an existing tag. The first is the low level one: use the unique URI of the tag with the Resource(QUrl,QUrl) constructor. The second one is to use this constructor with the name of the tag as its identifier:
Resource myTag( "Nepomuk" );
This will result in Resource loading the tag with nao:identifier "Nepomuk".
Nepomuk::Resource::Resource | ( | const QString & | pathOrIdentifier, | |
const QUrl & | type, | |||
ResourceManager * | manager | |||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
manager The resource manager to use. This allows to mix resources from different managers and, thus, different models.
- Since:
- 4.3
KDE_DEPRECATED Nepomuk::Resource::Resource | ( | const QString & | pathOrIdentifier, | |
const QString & | type | |||
) |
Nepomuk::Resource::Resource | ( | const QUrl & | uri, | |
const QUrl & | type = QUrl() | |||
) |
Creates a new Resource object.
- Parameters:
-
uri The URI of the resource. If no resource with this URI exists, a new one is created. Using an empty QUrl will result in a new resource with a random URI being created on the first call to setProperty. 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 | ( | const QUrl & | uri, | |
const QUrl & | type, | |||
ResourceManager * | manager | |||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
manager The resource manager to use. This allows to mix resources from different managers and, thus, different models.
- Since:
- 4.3
Nepomuk::Resource::Resource | ( | ResourceData * | ) |
Constructor used internally.
virtual Nepomuk::Resource::~Resource | ( | ) | [virtual] |
Destructor.
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::addProperty | ( | const QUrl & | uri, | |
const Variant & | value | |||
) |
Add a property value to the existing values.
- Parameters:
-
uri The URI identifying the property. value The value of the property (i.e. the object of the RDF triple(s))
- Since:
- 4.3
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'.
void Nepomuk::Resource::addType | ( | const QUrl & | type | ) |
Add a type to the list of types.
- Since:
- 4.2
KDE_DEPRECATED QHash<QString, Variant> Nepomuk::Resource::allProperties | ( | ) | const |
static QList<Resource> Nepomuk::Resource::allResources | ( | ) | [static] |
Retrieve a list of all available Resource resources.
This list consists of all resource of type Resource that are stored in the local Nepomuk meta data storage and any changes made locally. Be aware that in some cases this list can get very big. Then it might be better to use libKNep directly.
- See also:
- ResourceManager::allResources
QStringList Nepomuk::Resource::altLabels | ( | ) | const |
Get property 'altLabel'.
static QString Nepomuk::Resource::altLabelUri | ( | ) | [static] |
- Returns:
- The URI of the property 'altLabel'.
QList<Resource> Nepomuk::Resource::annotationOf | ( | ) | const |
Get all resources that have this resource set as property 'annotation'.
QList<Resource> Nepomuk::Resource::annotations | ( | ) | const |
Get 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 genericLabel() 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.
KDE_DEPRECATED 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'.
QList<Resource> Nepomuk::Resource::isRelatedOf | ( | ) | const |
Get all resources that have this resource set as property 'isRelated'.
QList<Resource> Nepomuk::Resource::isRelateds | ( | ) | const |
Get property 'isRelated'.
static QString Nepomuk::Resource::isRelatedUri | ( | ) | [static] |
- Returns:
- The URI of the property 'isRelated'.
QList<Resource> Nepomuk::Resource::isTopicOfs | ( | ) | const |
Get property 'isTopicOf'.
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'.
ResourceManager* Nepomuk::Resource::manager | ( | ) | const |
The Resource manager that manages this resource.
- Since:
- 4.3
Resource& Nepomuk::Resource::operator= | ( | const QUrl & | uri | ) |
Same as operator=( Resource( uri ) ).
Reimplemented in Nepomuk::Thing.
Makes this instance of Resource a copy of other.
Reimplemented in Nepomuk::Tag, and Nepomuk::Thing.
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.
Thing Nepomuk::Resource::pimoThing | ( | ) |
QHash<QUrl, Variant> Nepomuk::Resource::properties | ( | ) | const |
- Returns:
- A list of all defined properties
KDE_DEPRECATED Variant Nepomuk::Resource::property | ( | const QString & | uri | ) | const |
Variant Nepomuk::Resource::property | ( | const QUrl & | uri | ) | const |
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.
KDE_DEPRECATED void Nepomuk::Resource::removeProperty | ( | const QString & | uri | ) |
void Nepomuk::Resource::removeProperty | ( | const QUrl & | uri, | |
const Variant & | value | |||
) |
Remove value from property uri of this resource object.
- Parameters:
-
uri The URI identifying the property. value The value to remove
- Since:
- 4.3
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'.
void Nepomuk::Resource::setAnnotations | ( | const QList< Resource > & | value | ) |
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::setIsRelateds | ( | const QList< Resource > & | value | ) |
Set property 'isRelated'.
void Nepomuk::Resource::setIsTopicOfs | ( | const QList< Resource > & | value | ) |
Set property 'isTopicOf'.
void Nepomuk::Resource::setLabel | ( | const QString & | value | ) |
Set property 'label'.
KDE_DEPRECATED void Nepomuk::Resource::setProperty | ( | const QString & | uri, | |
const Variant & | value | |||
) |
- Deprecated:
- use setProperty( const QUrl& )
void Nepomuk::Resource::setProperty | ( | const QUrl & | uri, | |
const Variant & | value | |||
) |
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.
void Nepomuk::Resource::setTags | ( | const QList< Tag > & | value | ) |
Set property 'Tag'.
Each Resource can be tagged with an arbitrary number of Tags. This allows a simple grouping of resources.
void Nepomuk::Resource::setTopics | ( | const QList< Resource > & | value | ) |
Set property 'Topic'.
void Nepomuk::Resource::setTypes | ( | const QList< QUrl > & | types | ) |
Set the types of the resource.
Previous types will be overwritten.
- Since:
- 4.2
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'.
QList<Tag> Nepomuk::Resource::tags | ( | ) | const |
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'.
QList<Resource> Nepomuk::Resource::topics | ( | ) | const |
Get property 'Topic'.
static QString Nepomuk::Resource::topicUri | ( | ) | [static] |
- Returns:
- The URI of the property 'Topic'.
KDE_DEPRECATED 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
QList<QUrl> Nepomuk::Resource::types | ( | ) | const |
KDE_DEPRECATED 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: