java.lang.Object
org.gcube.informationsystem.resourceregistry.queries.json.base.JsonQueryERElement
Direct Known Subclasses:
JsonQueryEntity, JsonQueryRelation

public abstract class JsonQueryERElement extends Object
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • logger

      protected org.slf4j.Logger logger
    • objectMapper

      protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • type

      protected final String type
    • jsonNode

      protected final org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode
    • accessType

      protected final org.gcube.informationsystem.base.reference.AccessType accessType
    • fieldNamesToRemove

      protected final Set<String> fieldNamesToRemove
    • direction

      protected org.gcube.informationsystem.base.reference.Direction direction
    • entryPoint

      protected boolean entryPoint
    • projection

      protected boolean projection
      Instruct the JSON query analyzer if it is a projection
    • position

      protected int position
      The breadcrumb.size() provide the level of nesting. The position which element number at the same level. E.g. the index of a ConsistsOf when the caller is a Resource. It is used in conjunction with breadcrumb.size() to attach a number to the alias. This allows to generate a predictive not clashing alias instead of using random string/number. This is useful for testing purposes.
    • alias

      protected String alias
      Contains the alias if needed by the class
    • fieldsToEmit

      protected List<String> fieldsToEmit
      This field is used by entry point only. Any class at any level can retrieve the entry point using breadcrumb.get(0);
    • size

      protected int size
      it indicates the number of properties in this.jsonNode This number is manipulated while analyzing the jsonNode to properly create the query.
    • traverseBack

      protected boolean traverseBack
  • Constructor Details

    • JsonQueryERElement

      public JsonQueryERElement(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonQuery, org.gcube.informationsystem.base.reference.AccessType accessType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
  • Method Details

    • validateType

      public static void validateType(String type, org.gcube.informationsystem.base.reference.AccessType requiredAccessType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
    • getType

      public String getType()
    • getDirection

      public org.gcube.informationsystem.base.reference.Direction getDirection()
    • setDirection

      public void setDirection(org.gcube.informationsystem.base.reference.Direction direction)
    • isEntryPoint

      public boolean isEntryPoint()
    • setEntryPoint

      public void setEntryPoint(boolean entryPoint)
    • isProjection

      public boolean isProjection()
    • setProjection

      public void setProjection(boolean projection)
    • getBreadcrumb

      public List<JsonQueryERElement> getBreadcrumb()
    • setBreadcrumb

      public void setBreadcrumb(List<JsonQueryERElement> breadcrumb)
    • getPosition

      public int getPosition()
    • setPosition

      public void setPosition(int position)
    • getAlias

      public String getAlias()
    • getAlias

      public String getAlias(boolean generateifNull)
    • generateAlias

      protected StringBuffer generateAlias()
    • addFieldToEmit

      protected void addFieldToEmit(String fieldToEmit)
      Add a field to emit only if this instance is the entry point
      Parameters:
      fieldToEmit -
    • isTraverseBack

      public boolean isTraverseBack()
    • setTraverseBack

      public void setTraverseBack(boolean traverseBack)
    • createQuery

      public StringBuffer createQuery(StringBuffer stringBuffer) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
    • createTraversalQuery

      public abstract StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
    • addConstraints

      protected StringBuffer addConstraints(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, LogicalOperator queryLogicalOperator, String fieldNamePrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
    • evaluateNode

      protected StringBuffer evaluateNode(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldName, String fieldNamePrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
    • getKey

      protected String getKey(String fieldName, String fieldNamePrefix)
    • getValue

      protected String getValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode)
    • getChildrenBreadcrumb

      protected List<JsonQueryERElement> getChildrenBreadcrumb()
    • wrapMatchQuery

      protected StringBuffer wrapMatchQuery(StringBuffer buffer) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
    • getSpecificMatchQuery

      protected abstract StringBuffer getSpecificMatchQuery(List<JsonQueryERElement> childrenBreadcrumb) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
    • createMatchQuery

      public StringBuffer createMatchQuery(StringBuffer stringBuffer) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException