for(AtomicExpression ae : andExpr.getAtomicExprList()) { if(ae.getKeyType() == TokenType.ID) { final String fieldName = parseEntityAttribute(ae.getKey()); if (fieldName == null) {
for (AtomicExpression ae : andExpr.getAtomicExprList()) { if (ae.getKeyType() == TokenType.ID) { final String fieldName = parseEntityAttribute(ae.getKey()); if (fieldName == null) {
private Class<?> locateColumnType(AtomicExpression atomic) { String columnName = null; if(atomic.getKeyType().equals(TokenType.ID)){ columnName = parseEntityAttribute(atomic.getKey()); }else if(atomic.getValueType().equals(TokenType.ID)){ columnName = parseEntityAttribute(atomic.getValue()); } if(jdbcEntityDefinition.getInternal().getDisplayNameMap().containsKey(columnName)){ try { return jdbcEntityDefinition.getColumnType(columnName); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } }else{ return null; } }
private Class<?> locateColumnType(AtomicExpression atomic) { String columnName = null; if(atomic.getKeyType().equals(TokenType.ID)){ columnName = parseEntityAttribute(atomic.getKey()); }else if(atomic.getValueType().equals(TokenType.ID)){ columnName = parseEntityAttribute(atomic.getValue()); } if(jdbcEntityDefinition.getInternal().getDisplayNameMap().containsKey(columnName)){ try { return jdbcEntityDefinition.getColumnType(columnName); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } }else{ return null; } }
if (ae.getKeyType() == TokenType.ID) { fieldName = parseEntityAttribute(fieldName); if (fieldName == null) { TokenType keyType = ae.getKeyType(); TokenType valueType = ae.getValueType(); QualifierFilterEntity entry = new QualifierFilterEntity(fieldName, value, op, keyType,
if(ae.getKeyType() == TokenType.ID){ fieldName = parseEntityAttribute(fieldName); if(fieldName == null){ TokenType keyType = ae.getKeyType(); TokenType valueType = ae.getValueType(); QualifierFilterEntity entry = new QualifierFilterEntity(fieldName,value,op,keyType,valueType);
kv.setKey(postProcessNode(id.getText(),kv.getKeyType()));
kv.setKey(postProcessNode(id.getText(),kv.getKeyType()));
private Criterion toAtomicCriterion(AtomicExpression atomic){ Class<?> columnType = locateColumnType(atomic); Object left = toColumn(atomic.getKeyType(), atomic.getKey(),atomic.getOp(),columnType); Object right = toColumn(atomic.getValueType(), atomic.getValue(), atomic.getOp(),columnType); SqlEnum op = toSqlEnum(atomic.getOp()); return new Criterion(left,right,op); }
private Criterion toAtomicCriterion(AtomicExpression atomic){ Class<?> columnType = locateColumnType(atomic); Object left = toColumn(atomic.getKeyType(), atomic.getKey(),atomic.getOp(),columnType); Object right = toColumn(atomic.getValueType(), atomic.getValue(), atomic.getOp(),columnType); SqlEnum op = toSqlEnum(atomic.getOp()); return new Criterion(left,right,op); }
@Test public void testComplexExpressionWithAndCondition() { String query = "(EXP{@a + @b} > 3) AND (@b >10)"; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); ANDExpression and = or.getANDExprList().get(0); Assert.assertEquals(2, and.getAtomicExprList().size()); Assert.assertEquals("a + b>3", and.getAtomicExprList().get(0).toString()); Assert.assertEquals("@b>10", and.getAtomicExprList().get(1).toString()); AtomicExpression leftExpression = and.getAtomicExprList().get(0); Assert.assertEquals("a + b", leftExpression.getKey()); Assert.assertEquals(TokenType.EXP, leftExpression.getKeyType()); Assert.assertEquals(">", leftExpression.getOp().toString()); Assert.assertEquals("3", leftExpression.getValue()); Assert.assertEquals(TokenType.NUMBER, leftExpression.getValueType()); AtomicExpression rightExpression = and.getAtomicExprList().get(1); Assert.assertEquals("@b", rightExpression.getKey()); Assert.assertEquals(TokenType.ID, rightExpression.getKeyType()); Assert.assertEquals(">", rightExpression.getOp().toString()); Assert.assertEquals("10",rightExpression.getValue()); Assert.assertEquals(TokenType.NUMBER, rightExpression.getValueType()); }