use of org.apache.cayenne.exp.parser.ASTObjPath in project cayenne by apache.
the class LikeExpressionHelperTest method testEscape_AltEscapeChar1.
@Test
public void testEscape_AltEscapeChar1() {
PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "a!%c");
LikeExpressionHelper.escape(node);
assertEquals("a!#%c", node.getOperand(1));
assertEquals('#', node.getEscapeChar());
}
use of org.apache.cayenne.exp.parser.ASTObjPath in project cayenne by apache.
the class PropertyTest method testExpressionConstructor.
@Test
public void testExpressionConstructor() {
Property<Integer> p = Property.create("testPath", new ASTObjPath("test.path"), Integer.class);
assertEquals("testPath", p.getName());
Expression ex = p.getExpression();
assertEquals("test.path", ex.toString());
}
use of org.apache.cayenne.exp.parser.ASTObjPath in project cayenne by apache.
the class EOQuery method initBindings.
private void initBindings(Map bindings, Entity entity, Map qualifier) {
if (qualifier == null) {
return;
}
if ("EOKeyValueQualifier".equals(qualifier.get("class"))) {
String key = (String) qualifier.get("key");
if (key == null) {
return;
}
Object value = qualifier.get("value");
if (!(value instanceof Map)) {
return;
}
Map valueMap = (Map) value;
if (!"EOQualifierVariable".equals(valueMap.get("class")) || !valueMap.containsKey("_key")) {
return;
}
String name = (String) valueMap.get("_key");
String className = null;
// so we will use Object type for all DB path...
try {
Object lastObject = new ASTObjPath(key).evaluate(entity);
if (lastObject instanceof ObjAttribute) {
className = ((ObjAttribute) lastObject).getType();
} else if (lastObject instanceof ObjRelationship) {
ObjEntity target = ((ObjRelationship) lastObject).getTargetEntity();
if (target != null) {
className = target.getClassName();
}
}
} catch (ExpressionException ex) {
className = "java.lang.Object";
}
if (className == null) {
className = "java.lang.Object";
}
bindings.put(name, className);
return;
}
List children = (List) qualifier.get("qualifiers");
if (children != null) {
Iterator it = children.iterator();
while (it.hasNext()) {
initBindings(bindings, entity, (Map) it.next());
}
}
}
Aggregations