@Override public From clone() { From clone = new From(this.parser, this.id); if (getClauses() != null) clone.setClauses(cloneList(getClauses())); return clone; }
private QueryCommand buildSubquery(Expression projected) { Criteria criteria = null; for (ForeignKey fk : this.childTable.getForeignKeys()) { if (fk.getPrimaryKey().getParent().equals(this.parent)) { List<String> refColumns = fk.getReferenceColumns(); if (refColumns == null) { refColumns = ODataSQLBuilder.getColumnNames(childTable.getPrimaryKey().getColumns()); } List<String> pkColumns = ODataSQLBuilder.getColumnNames(parent.getPrimaryKey().getColumns()); List<Criteria> critList = new ArrayList<Criteria>(); for (int i = 0; i < refColumns.size(); i++) { critList.add( new CompareCriteria( new ElementSymbol(pkColumns.get(i), this.parentGroup), CompareCriteria.EQ, new ElementSymbol(refColumns.get(i), this.childGroup))); } criteria = critList.get(0); for (int i = 1; i < critList.size(); i++) { criteria = new CompoundCriteria(CompoundCriteria.AND, criteria, critList.get(i)); } } } Select s1 = new Select(); s1.addSymbol(projected); From f1 = new From(); f1.addGroup(this.childGroup); Query q1 = new Query(); q1.setSelect(s1); q1.setFrom(f1); q1.setCriteria(criteria); return q1; }
@Override public void visit(From obj) { preVisitVisitor(obj); visitNodes(obj.getClauses()); postVisitVisitor(obj); }