java.lang.Object
org.gcube.informationsystem.resourceregistry.queries.json.TypeQueryExecutor

public class TypeQueryExecutor extends Object
Executes a JSON Query-By-Example against the Types collection (schema definitions).

Wraps a JsonQuery builder to obtain the SQL query text (query-text generation is generic across collections; execution is not), then opens the shared TypeEnvironment, runs the query, and serializes each matched record via the appropriate concrete *SchemaDefinitionManagement class, resolved from the literal type name declared in the query (e.g. ResourceSchema, FacetSchema, IsRelatedToSchema, ConsistsOfSchema, PropertySchema).

Author:
Luca Frosini (ISTI - CNR)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Integer
    The descendant-closure depth for Type-name matching (0 = exact name only, N = N levels of descendants, -1 = all descendants recursively).
    protected final JsonQuery
    The underlying query-text builder.
    protected Integer
    The pagination limit for the query.
    protected boolean
    Whether privacy-sensitive metadata values must be masked.
    protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy
    The metadata inclusion policy.
    protected com.orientechnologies.orient.core.db.document.ODatabaseDocument
    The active OrientDB database session.
    protected Integer
    The pagination offset for the query.
    protected boolean
    Whether the last query returned _emit projection rows.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new TypeQueryExecutor instance with default configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Reports whether the last query returned flat _emit projection rows.
    Executes the JSON query against the Types collection.
    void
    Sets the descendant-closure depth for Type-name matching.
    void
    setJsonQuery(String jsonQuery)
    Parses and sets the input JSON query string.
    void
    Sets the pagination limit.
    void
    setMaskMetadata(boolean maskMetadata)
    Configures privacy masking for full Type representations and _emit aliases.
    void
    setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy)
    Sets the metadata inclusion policy.
    void
    Sets the pagination offset.

    Methods inherited from class java.lang.Object

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

    • jsonQueryBuilder

      protected final JsonQuery jsonQueryBuilder
      The underlying query-text builder.
    • oDatabaseDocument

      protected com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument
      The active OrientDB database session.
    • limit

      protected Integer limit
      The pagination limit for the query.
    • offset

      protected Integer offset
      The pagination offset for the query.
    • metadataPolicy

      protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy
      The metadata inclusion policy.
    • depth

      protected Integer depth
      The descendant-closure depth for Type-name matching (0 = exact name only, N = N levels of descendants, -1 = all descendants recursively).
    • maskMetadata

      protected boolean maskMetadata
      Whether privacy-sensitive metadata values must be masked.
    • projection

      protected boolean projection
      Whether the last query returned _emit projection rows.
  • Constructor Details

    • TypeQueryExecutor

      public TypeQueryExecutor()
      Creates a new TypeQueryExecutor instance with default configuration.
  • Method Details

    • setJsonQuery

      public void setJsonQuery(String jsonQuery) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Parses and sets the input JSON query string.
      Parameters:
      jsonQuery - the JSON query string
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if the JSON string is invalid
    • setLimit

      public void setLimit(Integer limit)
      Sets the pagination limit.
      Parameters:
      limit - the limit to set
    • setOffset

      public void setOffset(Integer offset)
      Sets the pagination offset.
      Parameters:
      offset - the offset to set
    • setMetadataPolicy

      public void setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy)
      Sets the metadata inclusion policy.
      Parameters:
      metadataPolicy - the metadata policy to set
    • setDepth

      public void setDepth(Integer depth)
      Sets the descendant-closure depth for Type-name matching.
      Parameters:
      depth - 0 = exact name only, N = N levels of descendants, -1 = all descendants recursively
    • setMaskMetadata

      public void setMaskMetadata(boolean maskMetadata)
      Configures privacy masking for full Type representations and _emit aliases.
      Parameters:
      maskMetadata - true to redact sensitive metadata identity fields
    • isProjection

      public boolean isProjection()
      Reports whether the last query returned flat _emit projection rows.
      Returns:
      true when the executed query contained an _emit projection
    • query

      public String query() throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Executes the JSON query against the Types collection.
      Returns:
      JSON array string of matching Type definitions
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if the query is invalid, syntactically incorrect, or targets a Type category that is not queryable
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database error