Class JsonQueryERElement
- 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 Summary
Fields Modifier and Type Field Description protected org.gcube.informationsystem.base.reference.AccessTypeaccessTypeprotected StringaliasContains the alias if needed by the classprotected List<JsonQueryERElement>breadcrumbThe chain of callers of this instance analyzer.protected org.gcube.informationsystem.base.reference.Directiondirectionprotected booleanentryPointprotected Set<String>fieldNamesToRemoveprotected List<String>fieldsToEmitThis field is used by entry point only.protected org.gcube.com.fasterxml.jackson.databind.JsonNodejsonNodeprotected org.slf4j.Loggerloggerprotected org.gcube.com.fasterxml.jackson.databind.ObjectMapperobjectMapperprotected intpositionThe breadcrumb.size() provide the level of nesting.protected booleanprojectionInstruct the JSON query analyzer if it is a projectionprotected intsizeit indicates the number of properties in this.jsonNode This number is manipulated while analyzing the jsonNode to properly create the query.protected booleantraverseBackprotected Stringtype
-
Constructor Summary
Constructors Constructor Description JsonQueryERElement(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonQuery, org.gcube.informationsystem.base.reference.AccessType accessType)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringBufferaddConstraints(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, LogicalOperator queryLogicalOperator, String fieldNamePrefix)protected voidaddFieldToEmit(String fieldToEmit)Add a field to emit only if this instance is the entry pointStringBuffercreateMatchQuery(StringBuffer stringBuffer)StringBuffercreateQuery(StringBuffer stringBuffer)abstract StringBuffercreateTraversalQuery(StringBuffer stringBuffer)protected StringBufferevaluateNode(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldName, String fieldNamePrefix)protected StringBuffergenerateAlias()StringgetAlias()StringgetAlias(boolean generateifNull)List<JsonQueryERElement>getBreadcrumb()protected List<JsonQueryERElement>getChildrenBreadcrumb()org.gcube.informationsystem.base.reference.DirectiongetDirection()protected StringgetKey(String fieldName, String fieldNamePrefix)intgetPosition()protected abstract StringBuffergetSpecificMatchQuery(List<JsonQueryERElement> childrenBreadcrumb)StringgetType()protected StringgetValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode)booleanisEntryPoint()booleanisProjection()booleanisTraverseBack()voidsetBreadcrumb(List<JsonQueryERElement> breadcrumb)voidsetDirection(org.gcube.informationsystem.base.reference.Direction direction)voidsetEntryPoint(boolean entryPoint)voidsetPosition(int position)voidsetProjection(boolean projection)voidsetTraverseBack(boolean traverseBack)static voidvalidateType(String type, org.gcube.informationsystem.base.reference.AccessType requiredAccessType)protected StringBufferwrapMatchQuery(StringBuffer buffer)
-
-
-
Field Detail
-
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
-
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
-
breadcrumb
protected List<JsonQueryERElement> breadcrumb
The chain of callers of this instance analyzer. breadcrumb.get(breadcrumb.size-1) == caller breadcrumb is empty if this instance is an entry point
-
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 Detail
-
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.SchemaExceptionorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
-
-
Method Detail
-
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.SchemaExceptionorg.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.SchemaNotFoundExceptionorg.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryExceptionorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaExceptionorg.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.SchemaNotFoundExceptionorg.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryExceptionorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaExceptionorg.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
-
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.SchemaExceptionorg.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.SchemaExceptionorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
-
-