@Override public JsonNode visitBinaryOperator(final BinaryOperatorKind operator, final JsonNode left, final JsonNode right) throws ExpressionVisitException, ODataApplicationException { ObjectNode result = nodeFactory.objectNode() .put(NODE_TYPE_NAME, BINARY_NAME) .put(OPERATOR_NAME, operator.toString()) .put(TYPE_NAME, getType(operator)); result.set(LEFT_NODE_NAME, left); result.set(RIGHT_NODE_NAME, right); return result; }
@Override public String toString() { return "{" + left + " " + operator.name() + " " + right + '}'; } }
/** * URI syntax to enumeration value * @param operator Operator in the syntax used in the URI * @return Operator kind which represents the given syntax */ public static BinaryOperatorKind get(final String operator) { for (BinaryOperatorKind op : BinaryOperatorKind.values()) { if (op.toString().equals(operator)) { return op; } } return null; }
@Override public Expression<Boolean> convert(@SuppressWarnings("rawtypes") final JPAComparisonOperatorImp jpaOperator) throws ODataApplicationException { if (jpaOperator.getOperator().equals(BinaryOperatorKind.HAS)) { /* * HAS requires an bitwise AND. This is not part of SQL and so not part of the criterion builder. Different * databases have different ways to support this. On group uses a function, which is called BITAND e.g. H2, * HSQLDB, SAP HANA, DB2 * or ORACLE, others have created an operator '&' like PostgesSQL or MySQL. * TO provide a unique, but slightly slower, solution a workaround is used, see * https://stackoverflow.com/questions/20570481/jpa-oracle-bit-operations-using-criteriabuilder#25508741 */ Long n = ((JPAEnumerationOperator) jpaOperator.getRight()).getValue().longValue(); @SuppressWarnings("unchecked") Expression<Integer> div = cb.quot(jpaOperator.getLeft(), n); Expression<Integer> mod = cb.mod(div, 2); return cb.equal(mod, 1); } throw new ODataJPAFilterException(ODataJPAFilterException.MessageKeys.NOT_SUPPORTED_OPERATOR, HttpStatusCode.NOT_IMPLEMENTED, jpaOperator.getOperator().name()); }
@Override public JsonNode visitBinaryOperator(final BinaryOperatorKind operator, final JsonNode left, final JsonNode right) throws ExpressionVisitException, ODataApplicationException { ObjectNode result = nodeFactory.objectNode() .put(NODE_TYPE_NAME, BINARY_NAME) .put(OPERATOR_NAME, operator.toString()) .put(TYPE_NAME, getType(operator)); result.set(LEFT_NODE_NAME, left); result.set(RIGHT_NODE_NAME, right); return result; }
/** * URI syntax to enumeration value * @param operator Operator in the syntax used in the URI * @return Operator kind which represents the given syntax */ public static BinaryOperatorKind get(final String operator) { for (BinaryOperatorKind op : BinaryOperatorKind.values()) { if (op.toString().equals(operator)) { return op; } } return null; }
@Override public String toString() { return "{" + left + " " + operator.name() + " " + right + '}'; } }
@Override public <T extends Number> Expression<T> convert(final JPAArithmeticOperator jpaOperator) throws ODataApplicationException { throw new ODataJPAFilterException(ODataJPAFilterException.MessageKeys.NOT_SUPPORTED_OPERATOR, HttpStatusCode.NOT_IMPLEMENTED, jpaOperator.getOperator().name()); }
debugger.stopRuntimeMeasurement(handle); throw new ODataJPAFilterException(ODataJPAFilterException.MessageKeys.NOT_SUPPORTED_OPERATOR, HttpStatusCode.NOT_IMPLEMENTED, operator.name());