java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.queries.OrientDBQuery
All Implemented Interfaces:
DBQuery

public class OrientDBQuery extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Whether the query results include descendant Contexts.
    protected boolean
    Whether to include Context membership in the returned instances.
    protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy
    Metadata inclusion policy applied to the returned instances.
    protected boolean
    Whether the last execution returned at least one scalar or projection row.
    protected String
    The raw OrientDB SQL query to execute.
    protected boolean
    Whether to return the raw OrientDB result set instead of unmarshalled instances.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new OrientDBQuery instance with default settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether the last execution produced at least one non-element row.
    Executes the configured query against the database backend.
    void
    setHierarchical(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.
    void
    setIncludeContexts(boolean includeContexts)
    Sets whether to include the contexts map on results when rawResult is false.
    void
    setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy)
    Sets the metadata inclusion policy applied to results when rawResult is false.
    void
    Sets the SQL-like query text to execute.
    void
    setRawResult(boolean rawResult)
    Sets whether to return the raw database result representation (true) or the standard Information System projection (false).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • query

      protected String query
      The raw OrientDB SQL query to execute.
    • rawResult

      protected boolean rawResult
      Whether to return the raw OrientDB result set instead of unmarshalled instances.
    • hierarchical

      protected boolean hierarchical
      Whether the query results include descendant Contexts.
    • metadataPolicy

      protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy
      Metadata inclusion policy applied to the returned instances.
    • includeContexts

      protected boolean includeContexts
      Whether to include Context membership in the returned instances.
    • nonElementResults

      protected boolean nonElementResults
      Whether the last execution returned at least one scalar or projection row.
  • Constructor Details

    • OrientDBQuery

      public OrientDBQuery()
      Creates a new OrientDBQuery instance with default settings.
  • Method Details

    • setQuery

      public void setQuery(String query)
      Description copied from interface: DBQuery
      Sets the SQL-like query text to execute.
      Specified by:
      setQuery in interface DBQuery
      Parameters:
      query - the query text
    • setRawResult

      public void setRawResult(boolean rawResult)
      Description copied from interface: DBQuery
      Sets whether to return the raw database result representation (true) or the standard Information System projection (false).
      Specified by:
      setRawResult in interface DBQuery
      Parameters:
      rawResult - the raw-result flag
    • setHierarchical

      public void setHierarchical(boolean hierarchical)
      Description copied from interface: DBQuery
      Sets 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:
      setHierarchical in interface DBQuery
      Parameters:
      hierarchical - the hierarchical flag
    • setMetadataPolicy

      public void setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy)
      Description copied from interface: DBQuery
      Sets the metadata inclusion policy applied to results when rawResult is false. Ignored when rawResult is true.
      Specified by:
      setMetadataPolicy in interface DBQuery
      Parameters:
      metadataPolicy - the metadata policy
    • setIncludeContexts

      public void setIncludeContexts(boolean includeContexts)
      Description copied from interface: DBQuery
      Sets whether to include the contexts map on results when rawResult is false. Ignored when rawResult is true.
      Specified by:
      setIncludeContexts in interface DBQuery
      Parameters:
      includeContexts - the includeContexts flag
    • hasNonElementResults

      public boolean hasNonElementResults()
      Description copied from interface: DBQuery
      Returns whether the last execution produced at least one non-element row.
      Specified by:
      hasNonElementResults in interface DBQuery
      Returns:
      true when 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.ResourceRegistryException
      Description copied from interface: DBQuery
      Executes the configured query against the database backend.
      Specified by:
      query in interface DBQuery
      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 mutations
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if a result cannot be serialized completely