Class JsonQueryElement
- Direct Known Subclasses:
JsonQueryContext,JsonQueryEntitySchema,JsonQueryERElement,JsonQueryPropertySchema,JsonQueryQueryTemplate,JsonQueryRelationSchema
Covers every collection queryable via the JSON Query engine, whether or not it
participates in graph relation traversal. Relation-traversal-specific concerns
(edge direction, back-reference traversal) live exclusively in
JsonQueryERElement, the subclass used by Resources/Facets/Relations — a flat,
standalone collection (e.g. QueryTemplate, Context) extends this class directly.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.gcube.informationsystem.base.reference.AccessTypeThe access type category of the query element.protected StringContains the alias if needed by the classThe prefixes of the backend fields linking an Entity to its Relations.The backend fields linking a Relation to its source and target.protected static final StringThe backend property holding the Type name of an element, which the representation namesElement.TYPE_PROPERTY.protected List<JsonQueryElement>The chain of callers of this instance analyzer.protected static final StringThe path of the identity of the creator, sensitive for the callers that read it redacted.protected final DeclaredPropertyResolverThe resolver of the declared property domains, owned by the entry-point element.protected static final PatternThe index of an element in a field name.protected StringThe bound names of the Encrypted Type and of its subtypes,nulluntil a predicate needs them; owned by the entry-point element.protected booleanWhether this query element represents the root entry point of the query.protected static final StringThe condition emitted for a predicate that never matches.protected static final PatternThe grammar of a field name: a dot-separated path of plain identifiers, each optionally followed by the index of an element.The set of field names to ignore/remove during query translation.This field is used by entry point only.protected static final StringThe condition suffix emitted for a directnullvalue.protected final org.gcube.com.fasterxml.jackson.databind.JsonNodeThe JSON query subtree node representing this element.protected static final StringThe path of the identity of the last updater, sensitive for the callers that read it redacted.protected org.slf4j.LoggerThe logger instance for query generation auditing.protected booleanWhether the caller reads the sensitive metadata identity fields redacted; owned by the entry-point element.protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapperIn-use Jackson object mapper.protected final OperandValidatorThe validator of the operator operands.static final StringThe prefix of every query operator and directive key.protected booleanWhether the root match may include registered subtypes.protected intThe breadcrumb.size() provide the level of nesting.protected booleanInstruct the JSON query analyzer if it is a projection.protected intMonotonic parameter index owned by the entry-point element.Caller-supplied scalar values bound to the generated OrientDB query.protected static final StringThe prefix of the backend record attributes, none of which is a field of the representation.protected intit indicates the number of properties in this.jsonNode This number is manipulated while analyzing the jsonNode to properly create the query.protected final StringThe schema type name of the query element.The fields of the query element that a query can neither filter on nor project, each with the reason reported to the caller. -
Constructor Summary
ConstructorsConstructorDescriptionJsonQueryElement(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonQuery, org.gcube.informationsystem.base.reference.AccessType accessType) Creates a newJsonQueryElementinstance for the specified JSON query subtree. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringBufferaddComparisonConstraint(ComparisonOperator comparisonOperator, org.gcube.com.fasterxml.jackson.databind.JsonNode operand, String fieldNamePrefix) Builds the condition of a comparison, presence, collection or map operator applied to the property identified by the field name prefix.protected StringBufferaddConstraints(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldNamePrefix) Builds the conjunction of the constraints expressed by the fields of a JSON object.protected voidaddFieldToEmit(String fieldToEmit) Adds a field to emit to the entry point, which generates the RETURN clause of the query.protected StringBufferaddLogicalConstraints(LogicalOperator logicalOperator, org.gcube.com.fasterxml.jackson.databind.JsonNode operand, String fieldNamePrefix) Builds the condition of a logical operator.createMatchQuery(StringBuffer stringBuffer) Builds and appends the complete SQL MATCH query for this subtree.createQuery(StringBuffer stringBuffer) Translates this query element into a corresponding SQL query buffer (defaults to MATCH query).protected StringBufferevaluateNode(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldName, String fieldNamePrefix) Evaluates a single JSON property node and appends its filter condition to the query.protected StringBufferexcludeEncrypted(String key, PropertyDomain domain, StringBuffer condition) Makes a predicate on a field the Type definition does not declare false wherever the field, or a field its path goes through, holds an Encrypted value.protected StringBufferReturns the unique alias buffer for this query element.getAlias()Returns the alias associated with this element.getAlias(boolean generateifNull) Returns the alias associated with this element, optionally generating it if not present.Returns the list of parent query elements visited.protected List<JsonQueryElement>Returns the list of query elements visited down to the current node.protected StringgetFieldOperand(String key) Returns the left-hand operand of a predicate on a field: the field itself, or the bound constantElement.REDACTEDwhen the caller reads the field redacted, so that the predicate never depends on the stored identity.protected StringgetFieldReference(String key) Returns the SQL reference of a projected field: the field of this element, or the bound constantElement.REDACTEDwhen the caller reads the field redacted.protected StringFormats and returns a fully-qualified property field key path.intReturns the position level of this element.protected PropertyDomaingetPropertyDomain(String key) Returns the domain the Type definition of this element declares for a field.Returns a snapshot of the parameters generated while translating this query tree.static StringgetRequiredType(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonQuery) Returns thetypedeclared by a level of the query that describes an instance.protected StringgetScalarValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode) Binds a single scalar JSON node value as an OrientDB named parameter.protected StringgetScalarValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, PropertyDomain domain) Binds a single scalar JSON node value, compared with a property of the given declared domain, as an OrientDB named parameter.protected abstract StringBuffergetSpecificMatchQuery(List<JsonQueryElement> childrenBreadcrumb) Generates the specific MATCH query snippet for this element's subclass (subclass hook).getType()Returns the schema type name of this element.protected StringgetValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, PropertyDomain domain) Converts a JSON value to one or more OrientDB named-parameter placeholders.booleanReturns whether this query element represents the root entry point of the query.booleanReturns whether this query element is part of a projection.protected booleanisSensitiveField(String key) Returns whether the caller reads the field as the constantElement.REDACTED: themetadata.createdByandmetadata.lastUpdateByof the element of this level, when the query is evaluated for a caller who is shown them redacted.protected StringresolveFieldName(String fieldName) Validates a field name and returns the name written in the generated query.voidsetBreadcrumb(List<JsonQueryElement> breadcrumb) Sets the list of parent query elements visited.voidsetEntryPoint(boolean entryPoint) Sets whether this query element represents the root entry point of the query.voidsetMaskMetadata(boolean maskMetadata) Configures the representation the query is evaluated on.voidsetPolymorphic(boolean polymorphic) Configures whether the entry-point match includes registered subtypes.voidsetPosition(int position) Sets the position level of this element.voidsetProjection(boolean projection) Sets whether this query element is part of a projection.protected voidRejects the projection of a path inside an Encrypted property: an Encrypted property is projected as a whole, so that its value is returned encrypted for the caller as a read does.protected voidvalidateLogicalCondition(LogicalOperator logicalOperator, org.gcube.com.fasterxml.jackson.databind.JsonNode condition, String fieldNamePrefix) Rejects, in a condition object of a logical operator, the keys that do not express a predicate: the structural keys of the query element (e.g.static voidvalidateType(String type, org.gcube.informationsystem.base.reference.AccessType requiredAccessType) Validates whether the specified schema type belongs to the required access type category.protected StringBufferwrapMatchQuery(StringBuffer buffer) Wraps and formats the completed MATCH query snippet with standard SELECT / EXPAND / RETURN blocks.
-
Field Details
-
logger
protected org.slf4j.Logger loggerThe logger instance for query generation auditing. -
OPERATOR_PREFIX
The prefix of every query operator and directive key.- See Also:
-
FALSE_CONDITION
The condition emitted for a predicate that never matches.- See Also:
-
IS_NULL
The condition suffix emitted for a directnullvalue.- See Also:
-
CREATED_BY_PATH
The path of the identity of the creator, sensitive for the callers that read it redacted.- See Also:
-
LAST_UPDATE_BY_PATH
The path of the identity of the last updater, sensitive for the callers that read it redacted.- See Also:
-
FIELD_NAME_PATTERN
The grammar of a field name: a dot-separated path of plain identifiers, each optionally followed by the index of an element. -
ELEMENT_INDEX_PATTERN
The index of an element in a field name. -
BACKEND_TYPE_NAME_FIELD
The backend property holding the Type name of an element, which the representation namesElement.TYPE_PROPERTY.- See Also:
-
RECORD_ATTRIBUTE_PREFIX
The prefix of the backend record attributes, none of which is a field of the representation.- See Also:
-
BACKEND_LINK_FIELDS
The backend fields linking a Relation to its source and target. -
BACKEND_LINK_FIELD_PREFIXES
The prefixes of the backend fields linking an Entity to its Relations. -
objectMapper
protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapper objectMapperIn-use Jackson object mapper. -
operandValidator
The validator of the operator operands. -
type
The schema type name of the query element. -
jsonNode
protected final org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNodeThe JSON query subtree node representing this element. -
accessType
protected final org.gcube.informationsystem.base.reference.AccessType accessTypeThe access type category of the query element. -
fieldNamesToRemove
The set of field names to ignore/remove during query translation. -
unqueryableFields
The fields of the query element that a query can neither filter on nor project, each with the reason reported to the caller. -
entryPoint
protected boolean entryPointWhether this query element represents the root entry point of the query. -
polymorphic
protected boolean polymorphicWhether the root match may include registered subtypes. -
projection
protected boolean projectionInstruct the JSON query analyzer if it is a projection. It is set on the level carrying the projection and on the entry point. -
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 positionThe 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
Contains the alias if needed by the class -
fieldsToEmit
This field is used by entry point only. Any class at any level can retrieve the entry point using getRootElement(); -
queryParameters
Caller-supplied scalar values bound to the generated OrientDB query. -
queryParameterIndex
protected int queryParameterIndexMonotonic parameter index owned by the entry-point element. -
maskMetadata
protected boolean maskMetadataWhether the caller reads the sensitive metadata identity fields redacted; owned by the entry-point element. -
declaredPropertyResolver
The resolver of the declared property domains, owned by the entry-point element. -
encryptedTypeParameters
The bound names of the Encrypted Type and of its subtypes,nulluntil a predicate needs them; owned by the entry-point element. -
size
protected int sizeit indicates the number of properties in this.jsonNode This number is manipulated while analyzing the jsonNode to properly create the query.
-
-
Constructor Details
-
JsonQueryElement
public JsonQueryElement(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 Creates a newJsonQueryElementinstance for the specified JSON query subtree.- Parameters:
jsonQuery- the JSON query node representing this elementaccessType- the access type category- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if schema validation failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or lookup error
-
-
Method Details
-
getRequiredType
public static String getRequiredType(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonQuery) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException Returns thetypedeclared by a level of the query that describes an instance.- Parameters:
jsonQuery- the JSON object of the level- Returns:
- the declared type name
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the level is not a JSON object or does not declare a stringtype
-
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 Validates whether the specified schema type belongs to the required access type category.- Parameters:
type- the schema type name to validaterequiredAccessType- the expected access type category- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if the schema type is not registeredorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
getType
Returns the schema type name of this element.- Returns:
- the schema type name
-
isEntryPoint
public boolean isEntryPoint()Returns whether this query element represents the root entry point of the query.- Returns:
trueif this is the entry point,falseotherwise
-
setEntryPoint
public void setEntryPoint(boolean entryPoint) Sets whether this query element represents the root entry point of the query.- Parameters:
entryPoint-trueif this is the entry point,falseotherwise
-
setPolymorphic
public void setPolymorphic(boolean polymorphic) Configures whether the entry-point match includes registered subtypes.- Parameters:
polymorphic-truefor polymorphic matching;falsefor the exact Type
-
setMaskMetadata
public void setMaskMetadata(boolean maskMetadata) Configures the representation the query is evaluated on. When set on the entry point, every predicate and projection of the query tree readsmetadata.createdByandmetadata.lastUpdateByas the constantElement.REDACTED, the value the caller is shown, instead of the stored identity.- Parameters:
maskMetadata-trueif the caller reads the sensitive metadata identity fields redacted
-
isProjection
public boolean isProjection()Returns whether this query element is part of a projection.- Returns:
trueif this is a projection,falseotherwise
-
setProjection
public void setProjection(boolean projection) Sets whether this query element is part of a projection.- Parameters:
projection-trueif this is a projection,falseotherwise
-
getBreadcrumb
Returns the list of parent query elements visited.- Returns:
- the list of parent query elements
-
setBreadcrumb
Sets the list of parent query elements visited.- Parameters:
breadcrumb- the list of parent query elements to set
-
getQueryParameters
Returns a snapshot of the parameters generated while translating this query tree.- Returns:
- generated OrientDB named parameters
-
getPosition
public int getPosition()Returns the position level of this element.- Returns:
- the position level
-
setPosition
public void setPosition(int position) Sets the position level of this element.- Parameters:
position- the position level to set
-
getAlias
Returns the alias associated with this element.- Returns:
- the alias string
-
getAlias
Returns the alias associated with this element, optionally generating it if not present.- Parameters:
generateifNull-trueto generate alias if null- Returns:
- the alias string
-
generateAlias
Returns the unique alias buffer for this query element.- Returns:
- the alias string buffer
-
addFieldToEmit
Adds a field to emit to the entry point, which generates the RETURN clause of the query.- Parameters:
fieldToEmit- the field name or alias to emit in projection
-
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 Translates this query element into a corresponding SQL query buffer (defaults to MATCH query).- Parameters:
stringBuffer- the buffer to append to- Returns:
- the SQL query string buffer
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException- if the schema type is not registeredorg.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if query syntax or constraints are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if schema traversal failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
addConstraints
protected StringBuffer addConstraints(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldNamePrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Builds the conjunction of the constraints expressed by the fields of a JSON object.An empty result means that the object adds no constraint, i.e. it always matches.
- Parameters:
jsonNode- the JSON object holding the constraintsfieldNamePrefix- the field name prefix,nullat the level of the query element- Returns:
- the formatted constraints string buffer
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the constraints are invalid or syntactically incorrectorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
addLogicalConstraints
protected StringBuffer addLogicalConstraints(LogicalOperator logicalOperator, org.gcube.com.fasterxml.jackson.databind.JsonNode operand, String fieldNamePrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Builds the condition of a logical operator._andand_orjoin their condition objects,_notnegates its single condition object. A condition object that adds no constraint always matches: it is skipped by_and, makes_oralways match, and makes_notnever match.- Parameters:
logicalOperator- the logical operatoroperand- the operand of the logical operatorfieldNamePrefix- the field name prefix,nullat the level of the query element- Returns:
- the formatted condition string buffer; empty when the condition always matches
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the operand or one of its conditions is invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
validateLogicalCondition
protected void validateLogicalCondition(LogicalOperator logicalOperator, org.gcube.com.fasterxml.jackson.databind.JsonNode condition, String fieldNamePrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException Rejects, in a condition object of a logical operator, the keys that do not express a predicate: the structural keys of the query element (e.g.type,consistsOf,source) and the projection directives.- Parameters:
logicalOperator- the logical operator owning the conditioncondition- the condition objectfieldNamePrefix- the property the operator is placed in,nullat the level of the query element- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the condition contains a key that is not a predicate
-
addComparisonConstraint
protected StringBuffer addComparisonConstraint(ComparisonOperator comparisonOperator, org.gcube.com.fasterxml.jackson.databind.JsonNode operand, String fieldNamePrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Builds the condition of a comparison, presence, collection or map operator applied to the property identified by the field name prefix.- Parameters:
comparisonOperator- the operatoroperand- the operand of the operatorfieldNamePrefix- the property the operator applies to- Returns:
- the formatted condition string buffer; empty when the condition always matches
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the operand is invalid, the operator is not applied to a property, or it does not apply to the declared domain of the propertyorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
excludeEncrypted
protected StringBuffer excludeEncrypted(String key, PropertyDomain domain, StringBuffer condition) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Makes a predicate on a field the Type definition does not declare false wherever the field, or a field its path goes through, holds an Encrypted value. Which value an undeclared field holds is known only instance by instance, so the predicate cannot be rejected as the one on a declared Encrypted property is: it is kept from comparing the content of the Encrypted value instead.- Parameters:
key- the fully-qualified field keydomain- the declared domain of the field,nullif the Type definition does not declare itcondition- the condition of the predicate- Returns:
- the condition, false where the path meets an Encrypted value
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
resolveFieldName
protected String resolveFieldName(String fieldName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException Validates a field name and returns the name written in the generated query. A field name is a dot-separated path of plain identifiers, each optionally followed by the index of an element, naming a field of the representation. The backend record attributes (every name with an@-prefixed segment) and the backend fields linking Entities and Relations are not fields of the representation.- Parameters:
fieldName- the field name as written in the query- Returns:
- the field name to write in the generated query
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the field name is not valid
-
isSensitiveField
Returns whether the caller reads the field as the constantElement.REDACTED: themetadata.createdByandmetadata.lastUpdateByof the element of this level, when the query is evaluated for a caller who is shown them redacted.Only the element's own metadata is masked, i.e. the key that is exactly
metadata.createdByormetadata.lastUpdateByfrom the element of the level (written dotted or as a nestedmetadataobject, in a predicate, in_emitor as an operand): that is the only place where the representation holds the identity of who wrote an element, and the only one the read path redacts. A key with the same name deeper in a path (e.g.details.metadata.createdBy) lies inside an untyped custom object: it is data the user wrote, the read path returns it as it is, and so the query reads it as it is. No other path reaches the metadata of another element: every level of a query masks its own, and the backend link fields (in,out,in_*,out_*) that could traverse to another element cannot be named in a query (seeresolveFieldName(String)).- Parameters:
key- the fully-qualified field key, from the element of this level- Returns:
trueif the field must be read as the redacted constant
-
getFieldOperand
Returns the left-hand operand of a predicate on a field: the field itself, or the bound constantElement.REDACTEDwhen the caller reads the field redacted, so that the predicate never depends on the stored identity.- Parameters:
key- the fully-qualified field key- Returns:
- the SQL operand
-
getPropertyDomain
protected PropertyDomain getPropertyDomain(String key) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Returns the domain the Type definition of this element declares for a field. A path addressing one element of a collection by its index has no declared domain, unless it addresses an Encrypted value.- Parameters:
key- the fully-qualified field key- Returns:
- the declared domain, or
nullif the Type definition does not declare the field - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
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, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Evaluates a single JSON property node and appends its filter condition to the query.- Parameters:
jsonNode- the JSON value nodefieldName- the property field namefieldNamePrefix- the property field name prefix,nullat the level of the query element- Returns:
- the formatted filter condition string buffer;
nullor empty when the node adds no constraint - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the property value is invalid or unsupportedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
getKey
Formats and returns a fully-qualified property field key path.- Parameters:
fieldName- the property field namefieldNamePrefix- the property field name prefix- Returns:
- the fully-qualified field key string
-
getValue
protected String getValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, PropertyDomain domain) Converts a JSON value to one or more OrientDB named-parameter placeholders.Array nodes (the right-hand operand of collection operators like
_in,_containsAll,_containsAny) are formatted as an OrientDB collection expression (e.g.[:queryValue0, :queryValue1]), with every element bound viagetScalarValue(JsonNode, PropertyDomain). Scalar nodes produce one placeholder.- Parameters:
jsonNode- the JSON value nodedomain- the declared domain of the compared property,nullif it is not declared- Returns:
- the generated named-parameter expression
-
getScalarValue
Binds a single scalar JSON node value as an OrientDB named parameter.- Parameters:
jsonNode- the JSON scalar value node- Returns:
- the named parameter placeholder
-
getScalarValue
protected String getScalarValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, PropertyDomain domain) Binds a single scalar JSON node value, compared with a property of the given declared domain, as an OrientDB named parameter. A value compared with a Date is bound as a Date, so that the comparison is chronological.- Parameters:
jsonNode- the JSON scalar value nodedomain- the declared domain of the compared property,nullif it is not declared- Returns:
- the named parameter placeholder
-
getFieldReference
Returns the SQL reference of a projected field: the field of this element, or the bound constantElement.REDACTEDwhen the caller reads the field redacted.- Parameters:
key- the fully-qualified field key- Returns:
- the SQL reference
-
validateEmittedField
protected void validateEmittedField(String key) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Rejects the projection of a path inside an Encrypted property: an Encrypted property is projected as a whole, so that its value is returned encrypted for the caller as a read does.- Parameters:
key- the fully-qualified field key- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the key is a path inside an Encrypted propertyorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
getChildrenBreadcrumb
Returns the list of query elements visited down to the current node.- Returns:
- the list of visited query elements
-
wrapMatchQuery
protected StringBuffer wrapMatchQuery(StringBuffer buffer) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Wraps and formats the completed MATCH query snippet with standard SELECT / EXPAND / RETURN blocks.- Parameters:
buffer- the accumulated MATCH query snippet- Returns:
- the fully formatted SQL MATCH query string buffer
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query parameters or projection is invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
getSpecificMatchQuery
protected abstract StringBuffer getSpecificMatchQuery(List<JsonQueryElement> childrenBreadcrumb) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Generates the specific MATCH query snippet for this element's subclass (subclass hook).- Parameters:
childrenBreadcrumb- the list of child query elements visited- Returns:
- the MATCH query snippet string buffer
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if schema validation failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
createMatchQuery
public StringBuffer createMatchQuery(StringBuffer stringBuffer) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Builds and appends the complete SQL MATCH query for this subtree.- Parameters:
stringBuffer- the buffer to append to- Returns:
- the complete SQL MATCH query string buffer
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if schema traversal failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-