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

Nepomuk

  • Nepomuk
  • Resource
Public Member Functions | Static Public Member Functions | List of all members
Nepomuk::Resource Class Reference

#include <Nepomuk/Resource>

Inheritance diagram for Nepomuk::Resource:
Inheritance graph
[legend]

Public Member Functions

 Resource ()
 
 Resource (ResourceManager *manager)
 
 Resource (const Resource &)
 
 Resource (const QString &pathOrIdentifier, const QUrl &type=QUrl())
 
 Resource (const QString &pathOrIdentifier, const QUrl &type, ResourceManager *manager)
 
 Resource (const QString &pathOrIdentifier, const QString &type)
 
 Resource (const QUrl &uri, const QUrl &type=QUrl())
 
 Resource (const QUrl &uri, const QUrl &type, ResourceManager *manager)
 
 Resource (ResourceData *)
 
virtual ~Resource ()
 
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)
 
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 QUrl &uri) const
 
bool hasProperty (const Types::Property &p, const Variant &v) const
 
bool hasProperty (const QString &uri) const
 
bool hasType (const QUrl &typeUri) const
 
QStringList identifiers () const
 
void increaseUsageCount ()
 
bool isFile () const
 
QList< Resource > isRelatedOf () const
 
QList< Resource > isRelateds () const
 
QList< Resource > isTopicOfs () const
 
bool isValid () const
 
QString label () const
 
ResourceManager * manager () const
 
bool operator!= (const Resource &) const
 
Resource & operator= (const Resource &other)
 
Resource & operator= (const QUrl &uri)
 
bool operator== (const Resource &) const
 
Thing pimoThing ()
 
QHash< QUrl, Variant > properties () const
 
Variant property (const QUrl &uri) const
 
Variant property (const QString &uri) const
 
quint32 rating () const
 
void remove ()
 
void removeProperty (const QUrl &uri)
 
void removeProperty (const QUrl &uri, const Variant &value)
 
void removeProperty (const QString &uri)
 
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 QUrl &uri, const Variant &value)
 
void setProperty (const QString &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
 
File toFile () const
 
QList< Resource > topics () const
 
QString type () const
 
QList< QUrl > types () const
 
QString uri () const
 
int usageCount () const
 

Static Public Member Functions

static QList< Resource > allResources ()
 
static QString altLabelUri ()
 
static QString annotationUri ()
 
static QString descriptionUri ()
 
static Resource fromResourceUri (const KUrl &uri, const Nepomuk::Types::Class &type=Nepomuk::Types::Class(), ResourceManager *manager=0)
 
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

Special case: file URLs

file:/ URLs are handled as a special case in Nepomuk. Starting with KDE 4.4 they are no longer used to identify the Nepomuk resource but only stored as nie:url property. All resources have nepomuk:/res/ <UUID> URIs. The Resource constructors handle this automatically. Thus, one can still use file URLs to construct the objects. But be aware of the following example:

KUrl fileUrl("file:///home/foobar/example.txt");
Nepomuk::Resource fileRes(fileUrl);
QUrl fileResUri = fileRes.resourceUri();

Here fileUrl and fileResUri are NOT equal. The latter is the resource URI of the form nepomuk:/res/ <UUID>.

Author
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org

Definition at line 94 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
managerThe 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
pathOrIdentifierThe 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.
  • 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.
typeThe 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
managerThe resource manager to use. This allows to mix resources from different managers and, thus, different models.
Since
4.3
Nepomuk::Resource::Resource ( const QString &  pathOrIdentifier,
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
uriThe 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.

See the Special case: file URLs Special file URL handling.

Parameters
typeThe 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
managerThe 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
uriThe URI identifying the property.
valueThe 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 path 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
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.

See also
ResourceManager::allResources
Warning
This list will be very big. Usage of this method is discouraged. Use Query::QueryServiceClient in combination with an empty Query::Query instead.
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.
static Resource Nepomuk::Resource::fromResourceUri ( const KUrl &  uri,
const Nepomuk::Types::Class &  type = Nepomuk::Types::Class(),
ResourceManager *  manager = 0 
)
static

Allows to quickly load a resource from its resource URI without any additional checks.

This is mostly used for optimized code within Nepomuk.

In most situations the construtor Resource( QUrl, QUrl ) is better suited.

Since
4.5
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.
bool Nepomuk::Resource::hasProperty ( const QUrl &  uri) const

Check if property identified by uri is defined for this resource.

Parameters
uriThe URI identifying the property.
Returns
true if property uri has a value set.
bool Nepomuk::Resource::hasProperty ( const Types::Property &  p,
const Variant &  v 
) const

Check if the resource has a property p with value v.

Since
4.5
bool Nepomuk::Resource::hasProperty ( const QString &  uri) const
Deprecated:
use hasProperty( const QUrl& ) const
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'.
void Nepomuk::Resource::increaseUsageCount ( )

Increase the usage count of this resource and also update the last used date to the current date and time.

Since
4.5
bool Nepomuk::Resource::isFile ( ) const
Returns
true if this resource represents a file. Use toFile() to retrieve the corresponding file resource which provides convinience methods to handle file resources.
Since
4.6
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'.
ResourceManager* Nepomuk::Resource::manager ( ) const

The Resource manager that manages this resource.

Since
4.3
bool Nepomuk::Resource::operator!= ( const Resource &  ) const

Operator to compare two Resource objects.

Since
4.4
Resource& Nepomuk::Resource::operator= ( const Resource &  other)

Makes this instance of Resource a copy of other.

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

Same as operator=( Resource( uri ) )

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

Operator to compare two Resource objects.

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
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
uriThe URI identifying the property.
Variant Nepomuk::Resource::property ( const QString &  uri) const
Deprecated:
use property( const QUrl& ) const
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 QUrl &  uri)

Remove property uri from this resource object.

Parameters
uriThe URI identifying the property.
void Nepomuk::Resource::removeProperty ( const QUrl &  uri,
const Variant &  value 
)

Remove value from property uri of this resource object.

Parameters
uriThe URI identifying the property.
valueThe value to remove
Since
4.3
void Nepomuk::Resource::removeProperty ( const QString &  uri)
Deprecated:
use removeProperty( const QUrl& )
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.

Returns
The resource URI of the resource or an empty url if the resource does not exist() yet.
See also
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'.

void Nepomuk::Resource::setProperty ( const QUrl &  uri,
const Variant &  value 
)

Set a property of the resource.

Parameters
uriThe URI identifying the property.
valueThe value of the property (i.e. the object of the RDF triple(s))
void Nepomuk::Resource::setProperty ( const QString &  uri,
const Variant &  value 
)
Deprecated:
use setProperty( const QUrl& )
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 path 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 path 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'.
File Nepomuk::Resource::toFile ( ) const

Convert this resource into a File resource to have access to the convinience methods provided by the File class.

Since
4.6
QList<Resource> Nepomuk::Resource::topics ( ) const

Get property 'Topic'.

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

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()
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
int Nepomuk::Resource::usageCount ( ) const
Returns
The usage count stored for this resource.
See also
increaseUsageCount()
Since
4.5

The documentation for this class was generated from the following file:
  • resource.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal