Search in sources :

Example 41 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method detachLookupSource.

public static void detachLookupSource(TreeNode treeNode, XmlMapData mapData, boolean detachChildren) {
    for (LookupConnection connection : treeNode.getLookupIncomingConnections()) {
        TreeNode source = (TreeNode) connection.getSource();
        if (source.getLookupOutgoingConnections().contains(connection)) {
            source.getLookupOutgoingConnections().remove(connection);
            mapData.getConnections().remove(connection);
        }
    }
    treeNode.getLookupIncomingConnections().clear();
    if (detachChildren) {
        if (!treeNode.getChildren().isEmpty()) {
            for (TreeNode child : treeNode.getChildren()) {
                detachLookupSource(child, mapData, detachChildren);
            }
        }
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)

Example 42 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method detachLookupTarget.

public static void detachLookupTarget(TreeNode treeNode, XmlMapData mapData, boolean detachChildren) {
    for (LookupConnection connection : treeNode.getLookupOutgoingConnections()) {
        if (connection.getTarget() instanceof TreeNode) {
            TreeNode target = (TreeNode) connection.getTarget();
            if (target.getLookupIncomingConnections().contains(connection)) {
                target.getLookupIncomingConnections().remove(connection);
                mapData.getConnections().remove(connection);
            }
        }
    }
    treeNode.getLookupOutgoingConnections().clear();
    if (detachChildren) {
        if (!treeNode.getChildren().isEmpty()) {
            for (TreeNode child : treeNode.getChildren()) {
                detachLookupTarget(child, mapData, detachChildren);
            }
        }
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)

Example 43 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method updateXPathAndExpression.

public static void updateXPathAndExpression(XmlMapData mapperData, XmlMapExpressionManager expressionManager, TreeNode treeNode, String newName, int xpathReplaceLocation, boolean updateTargetExpression) {
    String xpath = treeNode.getXpath();
    int xPathLength = getXPathLength(xpath);
    String newXPath = "";
    // tree child xpath eg : row1.newColum:/class/student/name
    if (xpath.split(CHILDREN_SEPARATOR).length == 2) {
        String[] split = xpath.split(CHILDREN_SEPARATOR);
        // change the root node part eg : row1.newColum
        if (xpathReplaceLocation <= 2) {
            String[] subSplit = split[0].split(EXPRESSION_SEPARATOR_SPLIT);
            if (subSplit.length == 2 && xpathReplaceLocation - 1 >= 0) {
                subSplit[xpathReplaceLocation - 1] = newName;
                newXPath = subSplit[0] + EXPRESSION_SEPARATOR + subSplit[1] + CHILDREN_SEPARATOR + split[1];
            }
        } else {
            // change the child part eg : class/student/name
            String[] subSplit = split[1].split(XPATH_SEPARATOR);
            if (xpathReplaceLocation == xPathLength) {
                String typeString = "";
                if (NodeType.ATTRIBUT.equals(treeNode.getNodeType())) {
                    typeString = XPATH_ATTRIBUTE;
                } else if (NodeType.NAME_SPACE.equals(treeNode.getNodeType())) {
                    typeString = XPATH_NAMESPACE;
                }
                subSplit[xpathReplaceLocation - 2 - 1] = typeString + newName;
            } else {
                subSplit[xpathReplaceLocation - 2 - 1] = newName;
            }
            newXPath = split[0] + CHILDREN_SEPARATOR;
            for (String string : subSplit) {
                newXPath = newXPath + string + XPATH_SEPARATOR;
            }
            newXPath = newXPath.substring(0, newXPath.length() - 1);
        }
    } else if (xpath.split(XPATH_SEPARATOR).length == 2) {
        // normal column
        String[] split = xpath.split(XPATH_SEPARATOR);
        if (xpathReplaceLocation <= xPathLength && xpathReplaceLocation - 1 >= 0) {
            split[xpathReplaceLocation - 1] = newName;
        }
        newXPath = split[0] + XPATH_SEPARATOR + split[1];
    } else {
        throw new IllegalArgumentException("Invalid xpath");
    }
    treeNode.setXpath(newXPath);
    if (updateTargetExpression) {
        updateTargetExpression(treeNode, xpath, expressionManager);
    } else {
        if (mapperData == null) {
            return;
        }
        XmlMapUtil.detachNodeConnections(treeNode, mapperData, true);
    }
    if (!treeNode.getChildren().isEmpty()) {
        for (TreeNode child : treeNode.getChildren()) {
            updateXPathAndExpression(mapperData, expressionManager, child, newName, xpathReplaceLocation, updateTargetExpression);
        }
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)

Example 44 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method cleanGroup.

public static boolean cleanGroup(List<? extends TreeNode> nodes) {
    boolean changed = false;
    for (TreeNode obj : nodes) {
        OutputTreeNode outputNode = (OutputTreeNode) obj;
        if (outputNode.isGroup()) {
            outputNode.setGroup(false);
            changed = true;
        }
        if (!outputNode.getChildren().isEmpty()) {
            changed = cleanGroup(outputNode.getChildren()) || changed;
        }
    }
    return changed;
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 45 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method cleanSubGroup.

public static void cleanSubGroup(TreeNode node, List<TreeNode> newLoopUpGroups) {
    for (TreeNode treeNode : node.getChildren()) {
        TreeNode child = treeNode;
        if (child.isGroup()) {
            if (newLoopUpGroups == null || newLoopUpGroups.isEmpty()) {
                child.setGroup(false);
            } else {
                boolean found = false;
                for (TreeNode group : newLoopUpGroups) {
                    if (child == group) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    child.setGroup(false);
                }
            }
        }
        cleanSubGroup(child, newLoopUpGroups);
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)

Aggregations

TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)119 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)88 ArrayList (java.util.ArrayList)39 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)34 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)25 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)22 List (java.util.List)21 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)19 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)17 EList (org.eclipse.emf.common.util.EList)15 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)14 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)13 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)12 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)11 FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)10 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)9 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)9 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)8