• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Nepomuk

Nepomuk::Resource

Nepomuk::Resource Class Reference

Resource is the central object type in Nepomuk. More...

#include <Nepomuk/Resource>

Inheritance diagram for Nepomuk::Resource:

Inheritance graph
[legend]

List of all members.


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)
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
Resource & operator= (const QUrl &)
Resource & operator= (const Resource &)
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)
 Resource (ResourceData *)
 Resource (const QUrl &uri, const QUrl &type=QUrl())
KDE_DEPRECATED 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)
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
Author:
Sebastian Trueg <trueg@kde.org>

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 ( const Resource &   ) 

Nepomuk::Resource::Resource ( const QString &  uriOrIdentifier,
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:
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 guaranteed 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)
Example:

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.

KDE_DEPRECATED Nepomuk::Resource::Resource ( const QString &  uriOrIdentifier,
const QString &  type 
)

Deprecated:
use Resource( const QString&, const QUrl& )

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.
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'.

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

Deprecated:
Use properties()

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.

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'.

See also:
ResourceManager::allResourcesWithProperty

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

Deprecated:
use hasProperty( const QUrl& ) 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'.

See also:
ResourceManager::allResourcesWithProperty

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'.

Resource& Nepomuk::Resource::operator= ( const QUrl &   ) 

Reimplemented in Nepomuk::Thing.

Resource& Nepomuk::Resource::operator= ( const Resource &   ) 

Reimplemented in 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 (  ) 

Get or create the PIMO thing that relates to this resource.

If this resource itself is a pimo:Thing, a reference to this is returned. If a pimo:Thing exists with has as occurrence this resource, the thing is returned. Otherwise a new thing is created.

Since:
4.2

QHash<QUrl, Variant> Nepomuk::Resource::properties (  )  const

Returns:
A list of all defined properties

KDE_DEPRECATED Variant Nepomuk::Resource::property ( const QString &  uri  )  const

Deprecated:
use property( const QUrl& ) 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  ) 

Deprecated:
use removeProperty( const QUrl& )

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.

See also:
name(), hasType(), types()

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().

See also:
name(), hasType(), types()
Deprecated:
use resourceType instead

QList<QUrl> Nepomuk::Resource::types (  )  const

Returns:
The list of all stored types for this resource. This may also include types that lie in the same hierachy.
See also:
type(), hasType()

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:
  • resource.h

Nepomuk

Skip menu "Nepomuk"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal