/** * Creates a copy of this expression node, without copying children. */ @Override public Expression shallowCopy() { ASTDbPath copy = new ASTDbPath(id); copy.path = path; return copy; }
protected Object evaluateNode(Object o) throws Exception { // TODO: implement resolving DB_PATH for DataObjects if (o instanceof Entity) { return evaluateEntityNode((Entity) o); } Map map = toMap(o); return (map != null) ? map.get(path) : null; }
public ASTDbPath(Object value) { super(ExpressionParserTreeConstants.JJTDBPATH); setPath(value); }
private Map<?, ?> toMap_AttachedObject(ObjectContext context, Persistent persistent) { return path.indexOf('.') >= 0 ? toMap_AttchedObject_MultiStepPath(context, persistent) : toMap_AttchedObject_SingleStepPath(context, persistent); }
protected Map<?, ?> toMap(Object o) { if (o instanceof Map) { return (Map<?, ?>) o; } else if (o instanceof ObjectId) { return ((ObjectId) o).getIdSnapshot(); } else if (o instanceof Persistent) { Persistent persistent = (Persistent) o; // before reading full snapshot, check if we can use smaller ID // snapshot ... it is much cheaper... return persistent.getObjectContext() != null ? toMap_AttachedObject(persistent.getObjectContext(), persistent) : toMap_DetachedObject(persistent); } else { return null; } }
prefetch.setEntityName(targetRel.getSourceEntity().getName()); String labelPrefix = dbPrefetch.getPath(); Set<String> seenNames = new HashSet<>(); for (ObjAttribute oa : targetEntity.getAttributes()) {
private Map<?, ?> toMap_AttchedObject_SingleStepPath(ObjectContext context, Persistent persistent) { ObjectId oid = persistent.getObjectId(); // TODO: snapshotting API should not be limited to DataContext... if (context instanceof DataContext) { return ((DataContext) context).currentSnapshot(persistent); } if (oid != null) { return SelectById.dataRowQuery(persistent.getObjectId()).selectOne(context); } // fallback to ID snapshot as a last resort return toMap_DetachedObject(persistent); }
/** * @param pathSpec a String db: path. * @since 4.0 * @return a new "db:" path expression for the specified String path. */ public static Expression dbPathExp(String pathSpec) { return new ASTDbPath(pathSpec); }
@Override protected Object evaluateNode(Object o) throws Exception { if (o instanceof Entity) { return evaluateEntityNode((Entity) o); } Map<?, ?> map = toMap(o); int finalDotIndex = path.lastIndexOf('.'); String finalPathComponent = finalDotIndex == -1 ? path : path.substring(finalDotIndex + 1); return (map != null) ? map.get(finalPathComponent) : null; }
public ASTDbPath(Object value) { super(ExpressionParserTreeConstants.JJTDBPATH); setPath(value); }
/** * Creates a copy of this expression node, without copying children. */ public Expression shallowCopy() { ASTDbPath copy = new ASTDbPath(id); copy.path = path; return copy; }
/** * A convenience method to create an DB_PATH "less than" expression. * * @since 3.0 */ public static Expression lessDbExp(String pathSpec, Object value) { return new ASTLess(new ASTDbPath(pathSpec), value); }
/** * A convenience shortcut for building BETWEEN expressions. * * @since 3.0 */ public static Expression betweenDbExp(String pathSpec, Object value1, Object value2) { return new ASTBetween(new ASTDbPath(pathSpec), value1, value2); }
/** * A convenience shortcut for building NOT_BETWEEN expressions. * * @since 3.0 */ public static Expression notBetweenDbExp(String pathSpec, Object value1, Object value2) { return new ASTNotBetween(new ASTDbPath(pathSpec), value1, value2); }
/** * A convenience method to create an DB_PATH "not equal to" expression. */ public static Expression noMatchDbExp(String pathSpec, Object value) { return new ASTNotEqual(new ASTDbPath(pathSpec), value); }
/** * A convenience method to create an DB_PATH "less than or equal to" * expression. * * @since 3.0 */ public static Expression lessOrEqualDbExp(String pathSpec, Object value) { return new ASTLessOrEqual(new ASTDbPath(pathSpec), value); }
/** * A convenience shortcut for building LIKE DB_PATH expression. * * @since 3.0 */ public static Expression likeDbExp(String pathSpec, Object value) { return new ASTLike(new ASTDbPath(pathSpec), value); }