Search in sources :

Example 6 with TableEntryLocation

use of org.talend.designer.xmlmap.ui.expressionutil.TableEntryLocation in project tdi-studio-se by Talend.

the class XmlMapUtil method updateTargetExpression.

public static void updateTargetExpression(AbstractNode renamedNode, String oldExpression, String newExpression, XmlMapExpressionManager expressionManager) {
    TableEntryLocation previousLocation = expressionManager.parseTableEntryLocation(oldExpression).get(0);
    TableEntryLocation newLocation = expressionManager.parseTableEntryLocation(newExpression).get(0);
    List<INodeConnection> connections = new ArrayList<INodeConnection>();
    connections.addAll(renamedNode.getOutgoingConnections());
    if (renamedNode instanceof TreeNode) {
        connections.addAll(((TreeNode) renamedNode).getLookupOutgoingConnections());
    }
    for (INodeConnection connection : connections) {
        AbstractNode target = connection.getTarget();
        List<TableEntryLocation> targetLocaitons = expressionManager.parseTableEntryLocation(target.getExpression());
        for (TableEntryLocation current : targetLocaitons) {
            if (current.equals(previousLocation)) {
                String replaced = expressionManager.replaceExpression(target.getExpression(), current, newLocation);
                target.setExpression(replaced);
            }
        }
    }
    for (FilterConnection connection : renamedNode.getFilterOutGoingConnections()) {
        AbstractInOutTree target = connection.getTarget();
        List<TableEntryLocation> targetLocaitons = expressionManager.parseTableEntryLocation(target.getExpressionFilter());
        for (TableEntryLocation current : targetLocaitons) {
            if (current.equals(previousLocation)) {
                String replaced = expressionManager.replaceExpression(target.getExpressionFilter(), current, newLocation);
                target.setExpressionFilter(replaced);
            }
        }
    }
}
Also used : INodeConnection(org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TableEntryLocation(org.talend.designer.xmlmap.ui.expressionutil.TableEntryLocation) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)

Aggregations

TableEntryLocation (org.talend.designer.xmlmap.ui.expressionutil.TableEntryLocation)6 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)4 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)4 ArrayList (java.util.ArrayList)3 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)3 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)3 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)2 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)2 INodeConnection (org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection)2 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)2 XmlMapExpressionManager (org.talend.designer.xmlmap.ui.expressionutil.XmlMapExpressionManager)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 Shell (org.eclipse.swt.widgets.Shell)1 JavaType (org.talend.core.model.metadata.types.JavaType)1 GlobalMapNode (org.talend.designer.xmlmap.model.emf.xmlmap.GlobalMapNode)1 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)1 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)1 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)1