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

Nepomuk-Core

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

Classes

class  AndTerm
 
class  ComparisonTerm
 
class  CountQueryRunnable
 
class  FileQuery
 
class  Folder
 
class  FolderConnection
 
class  GroupTerm
 
class  LiteralTerm
 
class  NegationTerm
 
class  OptionalTerm
 
class  OrTerm
 
class  Query
 
class  QueryParser
 
class  QueryService
 
class  QueryServiceClient
 
class  ResourceTerm
 
class  ResourceTypeTerm
 
class  Result
 
class  ResultIterator
 
class  SearchRunnable
 
class  SimpleTerm
 
class  Term
 

Typedefs

typedef QHash< QString,
Nepomuk2::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 Result &)
 
uint qHash (const Nepomuk2::Query::Query &)
 
uint qHash (const Nepomuk2::Query::Term &)
 
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:
Nepomuk2::Query::ComparisonTerm email( Nepomuk2::Vocabulary::NCO::emailAddress(), Soprano::LiteralValue( "trueg@kde.org" ) );
// match all nco:PersonContact instances
Nepomuk2::Query::ResourceTypeTerm type( Nepomuk2::Vocabulary::NCO::PersonContact() );
// match all person contacts with a specific email address
Nepomuk2::Query::AndTerm( type, Nepomuk2::Query::ComparisonTerm( Nepomuk2::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:
Nepomuk2::Query::ComparisonTerm email = Nepomuk2::Vocabulary::NCO::emailAddress() == Soprano::LiteralValue( "trueg@kde.org" );
// match all nco:PersonContact instances
Nepomuk2::Query::ResourceTypeTerm type( Nepomuk2::Vocabulary::NCO::PersonContact() );
// match all person contacts with a specific email address
Nepomuk2::Query::AndTerm = type && ( Nepomuk2::Vocabulary::NCO::hasEmailAddress() == email );

Furthermore literal comparisons can now be written as:

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

Typedef Documentation

typedef QHash<QString, Nepomuk2::Types::Property> Nepomuk2::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 Nepomuk2::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 Nepomuk2::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

Nepomuk2::Query::Query Nepomuk2::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

Definition at line 97 of file standardqueries.cpp.

Nepomuk2::Query::Query Nepomuk2::Query::operator! ( const Query &  query)

Logical negation operator which negates the meaning of a query.

See also
NegationTerm::negateTerm()
Since
4.6

Definition at line 724 of file query.cpp.

Nepomuk2::Query::Query Nepomuk2::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

Definition at line 708 of file query.cpp.

Nepomuk2::Query::Query Nepomuk2::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

Definition at line 716 of file query.cpp.

Query Nepomuk2::Query::parseQuery ( const QString &  s)

Definition at line 411 of file queryserializer.cpp.

Term Nepomuk2::Query::parseTerm ( const QString &  s)

Definition at line 485 of file queryserializer.cpp.

uint Nepomuk2::Query::qHash ( const Result &  result)

Definition at line 326 of file folder.cpp.

uint Nepomuk2::Query::qHash ( const Nepomuk2::Query::Query &  query)

Definition at line 738 of file query.cpp.

uint Nepomuk2::Query::qHash ( const Nepomuk2::Query::Term &  term)

Definition at line 486 of file term.cpp.

QString Nepomuk2::Query::serializeQuery ( const Query &  query)

Definition at line 352 of file queryserializer.cpp.

QString Nepomuk2::Query::serializeTerm ( const Term &  term)

Definition at line 471 of file queryserializer.cpp.

Nepomuk2::Query::Query Nepomuk2::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

Definition at line 40 of file standardqueries.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • 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