Search in sources :

Example 36 with InputXmlTree

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

the class DropContextAnalyzer method checkDropInputValid.

private boolean checkDropInputValid(Object target) {
    if (objects.getType() == TransferdType.INPUT) {
        for (Object obj : objects.getToTransfer()) {
            TreeNodeEditPart part = (TreeNodeEditPart) obj;
            AbstractInOutTree srouceTree = XmlMapUtil.getAbstractInOutTree((TreeNode) part.getModel());
            AbstractInOutTree targetTree = null;
            if (target instanceof InputXmlTree) {
                targetTree = (InputXmlTree) target;
            } else {
                targetTree = XmlMapUtil.getAbstractInOutTree((TreeNode) target);
            }
            if (srouceTree == targetTree) {
                return false;
            }
            if (srouceTree.eContainer() instanceof XmlMapData) {
                XmlMapData mapdata = ((XmlMapData) srouceTree.eContainer());
                int indexSource = mapdata.getInputTrees().indexOf(srouceTree);
                int indexTarget = mapdata.getInputTrees().indexOf(targetTree);
                if (indexTarget < indexSource) {
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData) Point(org.eclipse.draw2d.geometry.Point)

Example 37 with InputXmlTree

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

the class XmlMapUtil method checkMultiLoopsStatus.

public static boolean checkMultiLoopsStatus(AbstractInOutTree tree) {
    // set multiloops to true only if one doc schema have more then one loops , if a table have two doc schema but
    // each one only have one loop,multiloops should be false
    List<? extends TreeNode> children = new ArrayList<TreeNode>();
    if (tree instanceof InputXmlTree) {
        children = ((InputXmlTree) tree).getNodes();
    } else if (tree instanceof OutputXmlTree) {
        children = ((OutputXmlTree) tree).getNodes();
    }
    List<TreeNode> docChildren = new ArrayList<TreeNode>();
    for (TreeNode child : children) {
        if (DOCUMENT.equals(child.getType())) {
            docChildren.add(child);
        }
    }
    List<TreeNode> loopNodes = new ArrayList<TreeNode>();
    for (TreeNode doc : docChildren) {
        getChildLoops(loopNodes, doc.getChildren());
        if (loopNodes.size() > 1) {
            return true;
        }
    }
    return false;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 38 with InputXmlTree

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

the class ProblemsAnalyser method checkProblems.

public void checkProblems(AbstractInOutTree abstractTree) {
    // clear problems for the tree before recheck it
    if (treeAndProblems.get(abstractTree) != null) {
        treeAndProblems.get(abstractTree).clear();
    }
    // check problems for InputLoopTable in output
    final XmlMapData copyOfMapData = mapperManager.getExternalData();
    // check problems for InputLoopTable in output
    InputXmlTree mainInputTree = mapperManager.getMainInputTree();
    if (abstractTree instanceof OutputXmlTree) {
        checkInputLoopTablesProblem((OutputXmlTree) abstractTree, mainInputTree);
    }
    isMultipleDocType = false;
    List<? extends TreeNode> nodes = null;
    if (abstractTree instanceof InputXmlTree) {
        nodes = ((InputXmlTree) abstractTree).getNodes();
    } else if (abstractTree instanceof OutputXmlTree) {
        nodes = ((OutputXmlTree) abstractTree).getNodes();
    }
    if (nodes != null) {
        checkTreeNodesProblem(abstractTree, nodes);
    }
    if (treeAndProblems.get(abstractTree) == null || treeAndProblems.get(abstractTree).isEmpty()) {
        treeAndProblems.remove(abstractTree);
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 39 with InputXmlTree

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

the class XmlMapConnectionBuilder method rebuildLink.

private void rebuildLink(int inputTreeIndex, List<TreeNode> children, XmlMapData mapData) {
    for (TreeNode treeNode : children) {
        if (XmlMapUtil.isDragable(treeNode)) {
            String expression = XmlMapUtil.convertToExpression(treeNode.getXpath());
            XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
            TableEntryLocation sourceLocation = expressionManager.parseTableEntryLocation(expression).get(0);
            // LOOKUP ,FILTER
            for (int i = inputTreeIndex; i < mapData.getInputTrees().size(); i++) {
                InputXmlTree treeTarget = mapData.getInputTrees().get(i);
                if (hasMaptchedLocation(expressionManager, sourceLocation, treeTarget, ExpressionType.EXPRESSION_FILTER)) {
                    createFilterConnection(treeNode, treeTarget, mapData);
                }
                checkTargetChildren(expressionManager, treeTarget.getNodes(), treeNode, sourceLocation, mapData);
            }
            // VAR
            for (VarNode varNode : mapData.getVarTables().get(0).getNodes()) {
                if (hasMaptchedLocation(expressionManager, sourceLocation, varNode, ExpressionType.EXPRESSION)) {
                    createConnection(treeNode, varNode, mapData);
                }
            }
            // OUTPUT,FILTER
            for (int i = 0; i < mapData.getOutputTrees().size(); i++) {
                OutputXmlTree outputTree = mapData.getOutputTrees().get(i);
                if (hasMaptchedLocation(expressionManager, sourceLocation, outputTree, ExpressionType.EXPRESSION_FILTER)) {
                    createFilterConnection(treeNode, outputTree, mapData);
                }
                checkTargetChildren(expressionManager, outputTree.getNodes(), treeNode, sourceLocation, mapData);
            }
        }
        if (!treeNode.getChildren().isEmpty()) {
            rebuildLink(inputTreeIndex, treeNode.getChildren(), mapData);
        }
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) XmlMapExpressionManager(org.talend.designer.xmlmap.ui.expressionutil.XmlMapExpressionManager) TableEntryLocation(org.talend.designer.xmlmap.ui.expressionutil.TableEntryLocation) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 40 with InputXmlTree

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

the class ProblemsAnalyser method checkNodeInputLookTableProblem.

private boolean checkNodeInputLookTableProblem(OutputTreeNode outputNode, InputXmlTree mainInputTree, boolean checkChildren) {
    for (Connection connection : outputNode.getIncomingConnections()) {
        if (connection.getSource() instanceof TreeNode) {
            TreeNode source = (TreeNode) connection.getSource();
            InputXmlTree abstractInOutTree = (InputXmlTree) XmlMapUtil.getAbstractInOutTree(source);
            if (abstractInOutTree == mainInputTree) {
                return true;
            } else {
                EList<LookupConnection> lookupIncomingConnections = source.getLookupIncomingConnections();
                for (LookupConnection lookupConn : lookupIncomingConnections) {
                    TreeNode sourceNode = (TreeNode) lookupConn.getSource();
                    AbstractInOutTree abstractInOutTree2 = XmlMapUtil.getAbstractInOutTree(sourceNode);
                    if (abstractInOutTree2 == mainInputTree) {
                        return true;
                    }
                }
            }
            if (checkChildren && !outputNode.getChildren().isEmpty()) {
                for (TreeNode child : outputNode.getChildren()) {
                    if (checkNodeInputLookTableProblem((OutputTreeNode) child, mainInputTree, checkChildren)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)

Aggregations

InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)52 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)34 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)28 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)18 ArrayList (java.util.ArrayList)17 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)12 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)9 List (java.util.List)5 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)5 IConnection (org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)4 HashMap (java.util.HashMap)3 Point (org.eclipse.draw2d.geometry.Point)3 EList (org.eclipse.emf.common.util.EList)3 ExpressionFigure (org.talend.designer.gefabstractmap.figures.ExpressionFigure)3 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)3 Iterator (java.util.Iterator)2