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 org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicyContexts inclusion policy applied to the returned instances.protected booleanWhether the query results include descendant Contexts.protected MembershipViewThe view that selects the memberships listed by thecontextsmap of each instance.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.voidsetContextsPolicy(org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy) Sets the contexts inclusion policy applied to results whenrawResultisfalse.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.voidsetMembershipView(MembershipView membershipView) Sets the view that selects the memberships listed by thecontextsmap of each result 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. -
contextsPolicy
protected org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicyContexts inclusion policy applied to the returned instances. -
membershipView
The view that selects the memberships listed by thecontextsmap of each instance. -
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
-
setContextsPolicy
public void setContextsPolicy(org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy) Description copied from interface:DBQuerySets the contexts inclusion policy applied to results whenrawResultisfalse. Ignored whenrawResultistrue.- Specified by:
setContextsPolicyin interfaceDBQuery- Parameters:
contextsPolicy- the contexts policy
-
setMembershipView
Description copied from interface:DBQuerySets the view that selects the memberships listed by thecontextsmap of each result whenrawResultisfalse. Ignored whenrawResultistrue.- Specified by:
setMembershipViewin interfaceDBQuery- Parameters:
membershipView- the membership view
-
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
-