Class OrientDBQuery
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.queries.OrientDBQuery
- All Implemented Interfaces:
DBQuery
Executes admin raw queries against the OrientDB backend.
Authorization is enforced by the caller (a PolicyEnforcementPoint
restricted to globally-privileged administrator roles) before this class is
ever invoked, per the contract of DBQuery.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the query results include descendant Contexts.protected booleanWhether to include Context membership in the returned instances.protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicyMetadata inclusion policy applied to the returned instances.protected booleanWhether the last execution returned at least one scalar or projection row.protected StringThe raw OrientDB SQL query to execute.protected booleanWhether to return the raw OrientDB result set instead of unmarshalled instances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the last execution produced at least one non-element row.query()Executes the configured query against the database backend.voidsetHierarchical(boolean hierarchical) Sets whether the query should be evaluated across the caller's token Context and all of its descendants, rather than the token Context alone.voidsetIncludeContexts(boolean includeContexts) Sets whether to include thecontextsmap on results whenrawResultisfalse.voidsetMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Sets the metadata inclusion policy applied to results whenrawResultisfalse.voidSets the SQL-like query text to execute.voidsetRawResult(boolean rawResult) Sets whether to return the raw database result representation (true) or the standard Information System projection (false).
-
Field Details
-
query
The raw OrientDB SQL query to execute. -
rawResult
protected boolean rawResultWhether to return the raw OrientDB result set instead of unmarshalled instances. -
hierarchical
protected boolean hierarchicalWhether the query results include descendant Contexts. -
metadataPolicy
protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicyMetadata inclusion policy applied to the returned instances. -
includeContexts
protected boolean includeContextsWhether to include Context membership in the returned instances. -
nonElementResults
protected boolean nonElementResultsWhether the last execution returned at least one scalar or projection row.
-
-
Constructor Details
-
OrientDBQuery
public OrientDBQuery()Creates a newOrientDBQueryinstance with default settings.
-
-
Method Details
-
setQuery
Description copied from interface:DBQuerySets the SQL-like query text to execute. -
setRawResult
public void setRawResult(boolean rawResult) Description copied from interface:DBQuerySets whether to return the raw database result representation (true) or the standard Information System projection (false).- Specified by:
setRawResultin interfaceDBQuery- Parameters:
rawResult- the raw-result flag
-
setHierarchical
public void setHierarchical(boolean hierarchical) Description copied from interface:DBQuerySets whether the query should be evaluated across the caller's token Context and all of its descendants, rather than the token Context alone.- Specified by:
setHierarchicalin interfaceDBQuery- Parameters:
hierarchical- the hierarchical flag
-
setMetadataPolicy
public void setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Description copied from interface:DBQuerySets the metadata inclusion policy applied to results whenrawResultisfalse. Ignored whenrawResultistrue.- Specified by:
setMetadataPolicyin interfaceDBQuery- Parameters:
metadataPolicy- the metadata policy
-
setIncludeContexts
public void setIncludeContexts(boolean includeContexts) Description copied from interface:DBQuerySets whether to include thecontextsmap on results whenrawResultisfalse. Ignored whenrawResultistrue.- Specified by:
setIncludeContextsin interfaceDBQuery- Parameters:
includeContexts- the includeContexts flag
-
hasNonElementResults
public boolean hasNonElementResults()Description copied from interface:DBQueryReturns whether the last execution produced at least one non-element row.- Specified by:
hasNonElementResultsin interfaceDBQuery- Returns:
truewhen scalar or projection rows were returned
-
query
public String query() throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from interface:DBQueryExecutes the configured query against the database backend.- Specified by:
queryin interfaceDBQuery- Returns:
- JSON array string of query results
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query syntax is invalid or if it contains mutationsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a result cannot be serialized completely
-