/** * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression) */ @Override public Expression replaceExpression(Expression element) { if (element instanceof ElementSymbol) { return getMappedElement((ElementSymbol)element); } return element; }
/** * <p> This method looks up the symbol map for a physical <code>ElementSymbol</code> * given a virtual <code>ElementSymbol</code> object.</p> * @param obj The virtual <code>ElementSymbol</code> object whose physical counterpart is returned * @return The physical <code>ElementSymbol</code> object or null if the object could not be mapped */ private ElementSymbol getMappedElement(ElementSymbol obj) { ElementSymbol element = (ElementSymbol) getMappedSymbol(obj); if(element != null) { return element; } markUnmapped(obj); return obj; }
/** * Swap each ElementSymbol referenced by AllInGroupSymbol * @param obj Object to remap */ public void visit(MultipleElementSymbol obj) { List<ElementSymbol> oldSymbols = obj.getElementSymbols(); if(oldSymbols != null && oldSymbols.size() > 0) { List<ElementSymbol> newSymbols = new ArrayList<ElementSymbol>(oldSymbols.size()); Iterator<ElementSymbol> iter = oldSymbols.iterator(); while(iter.hasNext()) { ElementSymbol es = iter.next(); ElementSymbol mappedSymbol = getMappedElement(es); newSymbols.add( mappedSymbol ); } obj.setElementSymbols(newSymbols); } if (obj.getGroup() == null) { return; } obj.setGroup(getMappedGroup(obj.getGroup())); }
/** * Swap group in unary from clause. * @param obj Object to remap */ public void visit(UnaryFromClause obj) { GroupSymbol srcGroup = obj.getGroup(); obj.setGroup(getMappedGroup(srcGroup)); }
/** * Swap each ElementSymbol referenced by AllInGroupSymbol * @param obj Object to remap */ public void visit(MultipleElementSymbol obj) { List<ElementSymbol> oldSymbols = obj.getElementSymbols(); if(oldSymbols != null && oldSymbols.size() > 0) { List<ElementSymbol> newSymbols = new ArrayList<ElementSymbol>(oldSymbols.size()); Iterator<ElementSymbol> iter = oldSymbols.iterator(); while(iter.hasNext()) { ElementSymbol es = iter.next(); ElementSymbol mappedSymbol = getMappedElement(es); newSymbols.add( mappedSymbol ); } obj.setElementSymbols(newSymbols); } if (obj.getGroup() == null) { return; } obj.setGroup(getMappedGroup(obj.getGroup())); }
/** * Swap group in unary from clause. * @param obj Object to remap */ public void visit(UnaryFromClause obj) { GroupSymbol srcGroup = obj.getGroup(); obj.setGroup(getMappedGroup(srcGroup)); }
/** * <p> This method looks up the symbol map for a physical <code>ElementSymbol</code> * given a virtual <code>ElementSymbol</code> object.</p> * @param obj The virtual <code>ElementSymbol</code> object whose physical counterpart is returned * @return The physical <code>ElementSymbol</code> object or null if the object could not be mapped */ private ElementSymbol getMappedElement(ElementSymbol obj) { ElementSymbol element = (ElementSymbol) getMappedSymbol(obj); if(element != null) { return element; } markUnmapped(obj); return obj; }
/** * Swap each ElementSymbol referenced by AllInGroupSymbol * @param obj Object to remap */ public void visit(MultipleElementSymbol obj) { List<ElementSymbol> oldSymbols = obj.getElementSymbols(); if(oldSymbols != null && oldSymbols.size() > 0) { List<ElementSymbol> newSymbols = new ArrayList<ElementSymbol>(oldSymbols.size()); Iterator<ElementSymbol> iter = oldSymbols.iterator(); while(iter.hasNext()) { ElementSymbol es = iter.next(); ElementSymbol mappedSymbol = getMappedElement(es); newSymbols.add( mappedSymbol ); } obj.setElementSymbols(newSymbols); } if (obj.getGroup() == null) { return; } obj.setGroup(getMappedGroup(obj.getGroup())); }
/** * <p> This method updates the <code>Delete</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Delete object to be updated with physical groups */ public void visit(Delete obj) { // get the GroupSymbol on the delete GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); }
/** * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression) */ @Override public Expression replaceExpression(Expression element) { if (element instanceof ElementSymbol) { return getMappedElement((ElementSymbol)element); } return element; }
/** * <p> This method looks up the symbol map for a physical <code>GroupSymbol</code> * given a virtual <code>GroupSymbol</code> object.</p> * @param obj The virtual <code>GroupSymbol</code> object whose physical counterpart is returned * @return The physical <code>GroupSymbol</code> object or null if the object could not be mapped */ private GroupSymbol getMappedGroup(GroupSymbol obj) { GroupSymbol group = (GroupSymbol) getMappedSymbol(obj); if(group != null) { return group; } markUnmapped(obj); return obj; }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
/** * <p> This method updates the <code>Update</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Update object to be updated with physical groups */ public void visit(Update obj) { // get the GroupSymbol on the update GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); }
/** * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression) */ @Override public Expression replaceExpression(Expression element) { if (element instanceof ElementSymbol) { return getMappedElement((ElementSymbol)element); } return element; }
/** * <p> This method looks up the symbol map for a physical <code>GroupSymbol</code> * given a virtual <code>GroupSymbol</code> object.</p> * @param obj The virtual <code>GroupSymbol</code> object whose physical counterpart is returned * @return The physical <code>GroupSymbol</code> object or null if the object could not be mapped */ private GroupSymbol getMappedGroup(GroupSymbol obj) { GroupSymbol group = (GroupSymbol) getMappedSymbol(obj); if(group != null) { return group; } markUnmapped(obj); return obj; }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
/** * Swap group in unary from clause. * @param obj Object to remap */ public void visit(UnaryFromClause obj) { GroupSymbol srcGroup = obj.getGroup(); obj.setGroup(getMappedGroup(srcGroup)); }
public void visit(SetClause obj) { obj.setSymbol(getMappedElement(obj.getSymbol())); }
/** * <p> This method looks up the symbol map for a physical <code>GroupSymbol</code> * given a virtual <code>GroupSymbol</code> object.</p> * @param obj The virtual <code>GroupSymbol</code> object whose physical counterpart is returned * @return The physical <code>GroupSymbol</code> object or null if the object could not be mapped */ private GroupSymbol getMappedGroup(GroupSymbol obj) { GroupSymbol group = (GroupSymbol) getMappedSymbol(obj); if(group != null) { return group; } markUnmapped(obj); return obj; }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }