Esempio n. 1
0
  @Override
  public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp)
      throws ExpressionException {

    // resolve DB_PATH if we can
    if (pathExp.getType() == Expression.DB_PATH) {
      if (getDbEntity() == null) {
        throw new ExpressionException(
            "Can't resolve DB_PATH '" + pathExp + "', DbEntity is not set.");
      }

      return getDbEntity().resolvePathComponents(pathExp);
    }

    if (pathExp.getType() == Expression.OBJ_PATH) {
      return new PathIterator((String) pathExp.getOperand(0));
    }

    throw new ExpressionException(
        "Invalid expression type: '" + pathExp.expName() + "',  OBJ_PATH is expected.");
  }
Esempio n. 2
0
  /**
   * Returns an Iterable instance over expression path components based on this entity.
   *
   * @since 3.0
   */
  @Override
  @SuppressWarnings("unchecked")
  public Iterable<PathComponent<ObjAttribute, ObjRelationship>> resolvePath(
      final Expression pathExp, final Map aliasMap) {

    if (pathExp.getType() == Expression.OBJ_PATH) {

      return new Iterable<PathComponent<ObjAttribute, ObjRelationship>>() {

        public Iterator iterator() {
          return new PathComponentIterator(
              ObjEntity.this, (String) pathExp.getOperand(0), aliasMap);
        }
      };
    }

    throw new ExpressionException(
        "Invalid expression type: '" + pathExp.expName() + "',  OBJ_PATH is expected.");
  }
Esempio n. 3
0
    public Object transform(Object input) {

      if (!(input instanceof Expression)) {
        return input;
      }

      Expression expression = (Expression) input;

      if (expression.getType() != Expression.OBJ_PATH) {
        return input;
      }

      // convert obj_path to db_path

      String converted = toDbPath(createPathIterator((String) expression.getOperand(0)));
      Expression exp = ExpressionFactory.expressionOfType(Expression.DB_PATH);
      exp.setOperand(0, converted);
      return exp;
    }