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 org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy
    Contexts inclusion policy applied to the returned instances.
    protected boolean
    Whether the query results include descendant Contexts.
    protected MembershipView
    The view that selects the memberships listed by the contexts map of each instance.
    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
    setContextsPolicy(org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy)
    Sets the contexts inclusion policy applied to results when rawResult is false.
    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
    Sets the view that selects the memberships listed by the contexts map of each result 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.
    • contextsPolicy

      protected org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy
      Contexts inclusion policy applied to the returned instances.
    • membershipView

      protected MembershipView membershipView
      The view that selects the memberships listed by the contexts map of each instance.
    • 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
    • setContextsPolicy

      public void setContextsPolicy(org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy)
      Description copied from interface: DBQuery
      Sets the contexts inclusion policy applied to results when rawResult is false. Ignored when rawResult is true.
      Specified by:
      setContextsPolicy in interface DBQuery
      Parameters:
      contextsPolicy - the contexts policy
    • setMembershipView

      public void setMembershipView(MembershipView membershipView)
      Description copied from interface: DBQuery
      Sets the view that selects the memberships listed by the contexts map of each result when rawResult is false. Ignored when rawResult is true.
      Specified by:
      setMembershipView in interface DBQuery
      Parameters:
      membershipView - the membership view
    • 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