Enum Class MatemathicsOperator
java.lang.Object
java.lang.Enum<MatemathicsOperator>
org.gcube.informationsystem.resourceregistry.queries.operators.MatemathicsOperator
- All Implemented Interfaces:
Serializable,Comparable<MatemathicsOperator>,Constable
- Author:
- Luca Frosini (ISTI - CNR) OrientDB supports the eval() function to execute complex operations. Example: SELECT eval( "amount * 120 / 100 - discount" ) as finalPrice from Order See https://www.orientdb.com/docs/3.0.x/sql/SQL-Where.html#mathematics-operators https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#math-operators https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#math-operators-precedence https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#array-concatenation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceResolves the SQL operand of a field named among the values of a mathematics operator.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe array concatenation operator (||).The bitwise AND operator (&).The bitwise left shift operator (<<).The bitwise OR operator (|).The bitwise right shift operator (>>).The bitwise XOR operator (^).The mathematical division operator (/).The mathematical subtraction operator (-).The mathematical modulo operator (%).The mathematical multiplication operator (*).The mathematical sum operator (+). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe JSON property key for alias.protected final StringThe database operator symbol.protected final StringThe operator description.protected static org.slf4j.LoggerThe logger instance.The keys accepted in the object of an operator.protected final StringThe internal operator key.static final StringThe JSON property key for separator.static final StringThe JSON property key for values. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringBufferaddFieldPrefix(StringBuffer sb, String fieldPrefix) Helper method to append the field name prefix to the SQL buffer.generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldPrefix) Generates and returns the database SQL math expression representation of the JSON operator.generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, MatemathicsOperator.FieldReference fieldReference) Generates and returns the database SQL math expression representation of the JSON operator.protected StringBuffergenerateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.node.ArrayNode arrayNode, String fieldsSeparator, MatemathicsOperator.FieldReference fieldReference) Helper method to generate SQL math expressions for array elements.protected StringReturns the database operator symbol.Returns the operator description.protected StringThrows a bad request exception indicating a query validation error.static MatemathicsOperatorgetOperator(String key) Returns the matchingMatemathicsOperatorfor the specified key.protected StringReturns the internal operator key.Returns the set of all recognized operator keys.static MatemathicsOperatorReturns the enum constant of this class with the specified name.static MatemathicsOperator[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SUM
The mathematical sum operator (+). -
MINUS
The mathematical subtraction operator (-). -
MULTIPLY
The mathematical multiplication operator (*). -
DIVIDE
The mathematical division operator (/). -
MODULE
The mathematical modulo operator (%). -
BITWISE_RIGHT_SHIFT
The bitwise right shift operator (>>). -
BITWISE_LEFT_SHIFT
The bitwise left shift operator (<<). -
BITWISE_AND
The bitwise AND operator (&). -
BITWISE_OR
The bitwise OR operator (|). -
BITWISE_XOR
The bitwise XOR operator (^). -
ARRAY_CONCATENATION
The array concatenation operator (||).
-
-
Field Details
-
logger
protected static org.slf4j.Logger loggerThe logger instance. -
VALUES_KEY
The JSON property key for values.- See Also:
-
SEPARATOR_KEY
The JSON property key for separator.- See Also:
-
AS_KEY
The JSON property key for alias.- See Also:
-
OPERATOR_OBJECT_KEYS
The keys accepted in the object of an operator. -
operatorKey
The internal operator key. -
dbOperator
The database operator symbol. -
description
The operator description.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getOperatorKey
Returns the internal operator key.- Returns:
- the operator key string
-
getDbOperator
Returns the database operator symbol.- Returns:
- the database operator symbol string
-
getDescription
Returns the operator description.- Returns:
- the operator description string
-
getOperators
Returns the set of all recognized operator keys.- Returns:
- the set of operator keys
-
getOperator
Returns the matchingMatemathicsOperatorfor the specified key.- Parameters:
key- the operator key- Returns:
- the matching operator, or
nullif not found
-
getError
Throws a bad request exception indicating a query validation error.- Parameters:
key- the field keyclazz- the expected class typemandatory-trueif the field is mandatory- Returns:
- the error message string (unreachable as it always throws)
-
generateFieldToEmit
public String generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldPrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Generates and returns the database SQL math expression representation of the JSON operator.- Parameters:
jsonNode- the JSON node defining the operator and its valuesfieldPrefix- the field name prefix to apply- Returns:
- the generated SQL math expression string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if a nested operator is not validorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
generateFieldToEmit
public String generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, MatemathicsOperator.FieldReference fieldReference) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Generates and returns the database SQL math expression representation of the JSON operator.- Parameters:
jsonNode- the JSON node defining the operator and its valuesfieldReference- the resolver of the SQL operand of each named field- Returns:
- the generated SQL math expression string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if a field name or a nested operator is not validorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-
addFieldPrefix
Helper method to append the field name prefix to the SQL buffer.- Parameters:
sb- the SQL bufferfieldPrefix- the prefix to apply- Returns:
- the updated SQL buffer
-
generateFieldToEmit
protected StringBuffer generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.node.ArrayNode arrayNode, String fieldsSeparator, MatemathicsOperator.FieldReference fieldReference) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Helper method to generate SQL math expressions for array elements.- Parameters:
arrayNode- the array of elements to processfieldsSeparator- the separator to apply for string fieldsfieldReference- the resolver of the SQL operand of each named field- Returns:
- the updated SQL buffer
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if a field name or a nested operator is not validorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a Type definition cannot be read
-