org.qi4j.spi.query
Interface NamedQueryDescriptor

All Known Implementing Classes:
NamedSolrDescriptor, NamedSparqlDescriptor

public interface NamedQueryDescriptor

Descriptor of Named Query.

Named queries are a way to support native complex queries that are not possible to express with the Fluent Query API.

The upside is that Named Queries can express arbitrarily complex queries, at the expense of being tied to the query language(s) supported by the indexing engine AND that the storage format of the indexing engine must be known since the named query is not expressed in domain model terms.

Named queries must be declared at bootstrap, and can not be added adhoc while the application is running. This is to ensure that programmers don't litter the domain code with index engine specific code, making a change much harder.

Named Queries are indexing engine specific, and aggregated to the NamedQueries class. For the standard Sparql indexing engine, it would look like this;


 NamedQueries namedQueries = new NamedQueries();

 NamedQueryDescriptor queryDescriptor = new NamedSparqlDescriptor( queryString );

 namedQueries.addQuery( queryName, queryDescriptor );

 module.services( RdfIndexerExporterComposite.class ).setMetaInfo( namedQueries );

 


Method Summary
 String compose(Map<String,Object> variables, OrderBy[] orderBySegments, Integer firstResult, Integer maxResults)
          Creates a valid Query string.
 String language()
          Returns the name of the query language.
 String name()
          Returns the name of the query.
 List<String> variableNames()
          Returns a list of variable names allowed in the query.
 

Method Detail

name

String name()
Returns the name of the query.

Returns:
the name of the query as it is declared.

compose

String compose(Map<String,Object> variables,
               OrderBy[] orderBySegments,
               Integer firstResult,
               Integer maxResults)
Creates a valid Query string.

Parameters:
variables - The variables used, and their values.
orderBySegments - The list of OrderBy instrctions.
firstResult - The offset into the resultset.
maxResults - The maximum number of results to be returned.
Returns:
A valid query in the language given.

language

String language()
Returns the name of the query language.

Returns:
The formal name of the query language.

variableNames

List<String> variableNames()
Returns a list of variable names allowed in the query.

Returns:
a list of variable names allowed in the query.