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

Nepomuk

  • Nepomuk
  • Query
Classes | Typedefs | Enumerations | Functions
Nepomuk::Query Namespace Reference

Classes

class  AndTerm
 Match resource that match all sub terms. More...
class  ComparisonTerm
 A term matching the value of a property. More...
class  FileQuery
 A Nepomuk desktop query specialized for file searches. More...
class  GroupTerm
 
       Abstract base class for AndTerm and OrTerm which

maintains a list of sub-terms. More...

class  LiteralTerm
 Match literal properties via full text. More...
class  NegationTerm
 Negate an arbitrary term. More...
class  OptionalTerm
 Make a term optional. More...
class  OrTerm
 Match resource that match at least one of the sub terms. More...
class  Query
 A Nepomuk desktop query. More...
class  QueryParser
 Parser for desktop user queries. More...
class  QueryServiceClient
 Convenience frontend to the Nepomuk Query DBus Service. More...
class  ResourceTerm
 Matches exactly one resource. More...
class  ResourceTypeTerm
 Matching resources by type. More...
class  Result
 A single search result. More...
class  SimpleTerm
 
       Abstract base class for NegationTerm and ComparisonTerm

which maintains one sub-term. More...

class  Term
 The base class for all term types. More...

Typedefs

typedef QHash< QString,
Nepomuk::Types::Property > 
RequestPropertyMap

Enumerations

enum  DateRangeFlag { ModificationDate = 0x1, ContentDate = 0x2, UsageDate = 0x4, AllDates = ModificationDate|ContentDate|UsageDate }
enum  StandardQuery { LastModifiedFilesQuery, MostImportantResourcesQuery, NeverOpenedFilesQuery, ResourcesForActivityQuery }

Functions

Query dateRangeQuery (const QDate &start, const QDate &end, DateRangeFlags dateFlags=AllDates)
Query operator! (const Query &query)
Query operator&& (const Query &query, const Term &term)
Query operator|| (const Query &query, const Term &term)
Query parseQuery (const QString &s)
Term parseTerm (const QString &s)
uint qHash (const Nepomuk::Query::Term &)
uint qHash (const Nepomuk::Query::Query &)
QString serializeQuery (const Query &query)
QString serializeTerm (const Term &term)
Query standardQuery (StandardQuery query, const Term &subterm=Term())

Detailed Description

The Query namespace contains all classes that make up the Nepomuk Query API.

Constructing queries consists of creating and combining different types of Term subclasses or using the QueryParser to parse user queries (see the QueryParser documentation for details on the query syntax).

The constructed queries can then be executed on the nepomuk query service via the QueryServiceClient, used directly on a Soprano::Model (for example the Nepomuk main model which can be retrieved via ResourceManager::mainModel()), or listed via KIO (see Query::Query::toSearchUrl()).

Constructing Queries

Basically all one needs to know is that each Term matches a set of resources. Different types of terms do so in different ways. The simplest type is the ResourceTerm which matches exactly one resource by URI. The ComparisonTerm matches all resources that have a property with a certain value. The LiteralTerm by itselt matches all resources that contain the string value in one of their properties, and so on.

Thus, constructing a query means to combine all constraints that the results should fulfill using AndTerm and maybe OrTerm. Everything can also the nested and most importantly (this is the one real graph query thing in the API) ComparisonTerm can use any other term as object, meaning it can compare the value of a property (if it is not a literal value) to the results of a subquery. A simple example would be the following:

// match all EmailAddress instances with a specific email address:
Nepomuk::Query::ComparisonTerm email( Nepomuk::Vocabulary::NCO::emailAddress(), Soprano::LiteralValue( "trueg@kde.org" ) );
// match all nco:PersonContact instances
Nepomuk::Query::ResourceTypeTerm type( Nepomuk::Vocabulary::NCO::PersonContact() );
// match all person contacts with a specific email address
Nepomuk::Query::AndTerm( type, Nepomuk::Query::ComparisonTerm( Nepomuk::Vocabulary::NCO::hasEmailAddress(), email ) );

Fancy Operators

Starting with KDE SC 4.6 queries can be constructed using well known C++ operators. The above examples can now be written as:

// match all EmailAddress instances with a specific email address:
Nepomuk::Query::ComparisonTerm email = Nepomuk::Vocabulary::NCO::emailAddress() == Soprano::LiteralValue( "trueg@kde.org" );
// match all nco:PersonContact instances
Nepomuk::Query::ResourceTypeTerm type( Nepomuk::Vocabulary::NCO::PersonContact() );
// match all person contacts with a specific email address
Nepomuk::Query::AndTerm = type && ( Nepomuk::Vocabulary::NCO::hasEmailAddress() == email );

Furthermore literal comparisons can now be written as:

Nepomuk::Query::ComparisonTerm mtime
= Nepomuk::Vocabulary::NIE::lastModified() > Nepomuk::Query::LiteralTerm( QDateTime::currentDateTime().addDays(-7) );
See also:
Query Examples

Typedef Documentation

typedef QHash<QString, Nepomuk::Types::Property> Nepomuk::Query::RequestPropertyMap

Convinience definition for request property mappings as used in QueryServiceClient::sparqlQuery() and QueryServiceClient::blockingSparqlQuery().

Definition at line 41 of file query.h.


Enumeration Type Documentation

enum Nepomuk::Query::DateRangeFlag

Modificators to influence the behaviour of dateRangeQuery().

Since:
4.6
Enumerator:
ModificationDate 

Query for the modification date (nie:lastModified)

ContentDate 

Query for the content creation date (nie:contentCreated)

UsageDate 

Query for usage events referring to the resource.

AllDates 

Query for all possible dates.

Definition at line 76 of file standardqueries.h.

enum Nepomuk::Query::StandardQuery

A set of predefined queries that can be created via standardQuery().

Since:
4.6
Enumerator:
LastModifiedFilesQuery 

Creates a query that returns all files sorted by descending modification date.

The subterm parameter can be used to specify an application restricting the results to files created/opened with that application.

MostImportantResourcesQuery 

Creates a query that returns all resources sorted by descending score (as calculated by the DataMaintenanceService)

The subterm parameter can be used to specify an application restricting the results to files created/opened with that application.

NeverOpenedFilesQuery 

Creates a query that returns all files with a usage count of 0 sorted by descending modification date.

ResourcesForActivityQuery 

Get the resources related to a specific activity.

Use a ResourceTerm referring to the activity as parameter in standardQuery.

Definition at line 39 of file standardqueries.h.


Function Documentation

Query Nepomuk::Query::dateRangeQuery ( const QDate &  start,
const QDate &  end,
DateRangeFlags  dateFlags = AllDates 
)

Create a query that returns resources/files that have been modified/accessed in the range from start to end (including both full days).

The flags specified in dateFlags can be used to influence the type of dates that are queried.

Parameters:
startThe start date of the range, if invalid no start is used, i.e. everything before end matches.
endThe end date of the range, if invalid no end is used, i.e. everything after start matches.
dateFlagsOptional flags to influence the final query.
Since:
4.6
Query Nepomuk::Query::operator! ( const Query &  query)

Logical negation operator which negates the meaning of a query.

See also:
NegationTerm::negateTerm()
Since:
4.6
Query Nepomuk::Query::operator&& ( const Query &  query,
const Term &  term 
)

Logical and operator which combines term into the term of query to match both.

See also:
AndTerm
Since:
4.6
Query Nepomuk::Query::operator|| ( const Query &  query,
const Term &  term 
)

Logical or operator which combines term into the term of query to match either one.

See also:
OrTerm
Since:
4.6
Query Nepomuk::Query::parseQuery ( const QString &  s)
Term Nepomuk::Query::parseTerm ( const QString &  s)
uint Nepomuk::Query::qHash ( const Nepomuk::Query::Term &  )
uint Nepomuk::Query::qHash ( const Nepomuk::Query::Query &  )
QString Nepomuk::Query::serializeQuery ( const Query &  query)
QString Nepomuk::Query::serializeTerm ( const Term &  term)
Query Nepomuk::Query::standardQuery ( StandardQuery  query,
const Term &  subterm = Term() 
)

Create a standard query as defined by query.

Parameters:
queryThe query to be generated. See StandardQuery.
subtermAn optional subterm used for specific types of standard queries that need a parameter like ResourcesForActivityQuery.

To get a query that only returns files (this is already true for some of the predefined queries) use something like the following:

Query::FileQuery query = Query::standardQuery( Query::LastModifiedFilesQuery );

Be aware that queries can be combined. One can for example get the most important files related to an activity as follows:

Query query = Query::standardQuery( Query::ResourcesForActivityQuery, myActivity )
&& Query::standardQuery( Query::MostImportantResourcesQuery );
Since:
4.6
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Jul 23 2013 20:30:36 by doxygen 1.8.1.1 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-4.10.5 API Reference

Skip menu "kdelibs-4.10.5 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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