Search in sources :

Example 1 with IConnection

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

the class XmlMapTreeContainerLayout method getLookupConnectionSize.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.layout.TreeContainerLayout#getLookupConnectionSize()
     */
@Override
protected int getLookupConnectionSize(AbstractTableContainer tableContainer) {
    if (tableContainer instanceof InputXmlTreeFigure) {
        InputXmlTree inputModel = ((InputXmlTreeFigure) tableContainer).getInputXmlTree();
        List<TreeNode> nodeList = inputModel.getNodes();
        int maxSize = 0;
        List<IConnection> lookConnections = XmlMapUtil.getAllNodeLookConnections(inputModel);
        List<IConnection> filterConnections = XmlMapUtil.getInputTreeFilterConnections(inputModel);
        if (lookConnections.size() < filterConnections.size()) {
            maxSize = filterConnections.size();
        } else {
            maxSize = lookConnections.size();
        }
        return maxSize;
    }
    return 0;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure)

Example 2 with IConnection

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

the class XmlMapFilterConnectionPart method calculateConnOffset.

protected int calculateConnOffset() {
    FilterConnection model = (FilterConnection) getModel();
    if (model.getSource() == null) {
        return 0;
    }
    TreeNode sourceTreeNode = (TreeNode) model.getSource();
    AbstractInOutTree inputTreeNodeRoot = XmlMapUtil.getAbstractInOutTree(sourceTreeNode);
    List<IConnection> outConns = new ArrayList<IConnection>();
    if (inputTreeNodeRoot instanceof InputXmlTree) {
        outConns.addAll(XmlMapUtil.getInputTreeFilterConnections((InputXmlTree) inputTreeNodeRoot));
    }
    int indexOf = outConns.indexOf(model);
    if (indexOf != -1) {
        return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET_FILTER;
    }
    return 0;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)

Example 3 with IConnection

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

the class XmlMapDataImpl method equals.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated not
     */
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    XmlMapDataImpl dbObj = (XmlMapDataImpl) obj;
    EList<InputXmlTree> inputs = dbObj.getInputTrees();
    EList<OutputXmlTree> outputs = dbObj.getOutputTrees();
    EList<VarTable> vars = dbObj.getVarTables();
    EList<IConnection> conns = dbObj.getConnections();
    if (inputs.size() != getInputTrees().size()) {
        return false;
    }
    if (outputs.size() != getOutputTrees().size()) {
        return false;
    }
    if (vars.size() != getVarTables().size()) {
        return false;
    }
    if (getConnections().size() != conns.size()) {
        return false;
    }
    for (InputXmlTree inputTable : inputTrees) {
        boolean found = false;
        for (InputXmlTree input : inputs) {
            if (inputTable.getName().equals(input.getName())) {
                found = true;
                if (!inputTable.equals(input)) {
                    return false;
                }
                break;
            }
        }
        if (found == false) {
            return false;
        }
    }
    for (OutputXmlTree outputTable : outputTrees) {
        boolean found = false;
        for (OutputXmlTree output : outputs) {
            if (outputTable.getName().equals(output.getName())) {
                found = true;
                if (!outputTable.equals(output)) {
                    return false;
                }
                break;
            }
        }
        if (found == false) {
            return false;
        }
    }
    for (VarTable varTable : varTables) {
        boolean found = false;
        for (VarTable var : vars) {
            if (varTable.getName().equals(var.getName())) {
                found = true;
                if (!varTable.equals(var)) {
                    return false;
                }
                break;
            }
        }
        if (found == false) {
            return false;
        }
    }
    return true;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 4 with IConnection

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

the class XmlMapLookupConnectionPart method calculateConnOffset.

protected int calculateConnOffset() {
    LookupConnection model = (LookupConnection) getModel();
    if (model.getSource() == null) {
        return 0;
    }
    TreeNode sourceTreeNode = (TreeNode) model.getSource();
    List<IConnection> outConns = new ArrayList<IConnection>();
    TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(sourceTreeNode);
    if (inputTreeNodeRoot != null) {
        InputXmlTree inputTree = (InputXmlTree) inputTreeNodeRoot.eContainer();
        outConns.addAll(XmlMapUtil.getAllNodeLookConnections(inputTree));
    }
    int indexOf = outConns.indexOf(model);
    if (indexOf != -1) {
        return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET;
    }
    return 0;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)

Example 5 with IConnection

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

the class XmlMapService method externalEmfDataClone.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.core.service.IXmlMapService#externalEmfDataClone(org.talend.designer.core.model.utils.emf.talendfile
     * .AbstractExternalData)
     */
@Override
public AbstractExternalData externalEmfDataClone(AbstractExternalData externalEmfData) {
    if (!(externalEmfData instanceof XmlMapData)) {
        return externalEmfData;
    }
    Map<EObject, EObject> nodeMaps = new HashMap<EObject, EObject>();
    XmlMapData newXmlMapData = XmlmapFactory.eINSTANCE.createXmlMapData();
    XmlMapData xmlMapData = (XmlMapData) externalEmfData;
    EList<InputXmlTree> oriInputs = xmlMapData.getInputTrees();
    EList<OutputXmlTree> oriOutputs = xmlMapData.getOutputTrees();
    EList<VarTable> oriVars = xmlMapData.getVarTables();
    EList<IConnection> oriConns = xmlMapData.getConnections();
    for (IConnection oriConn : oriConns) {
        if (oriConn instanceof INodeConnection) {
            AbstractNode sourceNode = ((INodeConnection) oriConn).getSource();
            AbstractNode targetNode = ((INodeConnection) oriConn).getTarget();
            EObject source = null;
            if (nodeMaps.get(sourceNode) != null) {
                source = nodeMaps.get(sourceNode);
            } else {
                source = cloneTreeNode(sourceNode);
                nodeMaps.put(sourceNode, source);
            }
            EObject target = null;
            if (nodeMaps.get(targetNode) != null) {
                target = nodeMaps.get(targetNode);
            } else {
                target = cloneTreeNode(targetNode);
                nodeMaps.put(targetNode, target);
            }
            if (oriConn instanceof Connection) {
                new XmlMapConnectionBuilder().createConnection((AbstractNode) source, (AbstractNode) target, newXmlMapData);
            } else if (oriConn instanceof LookupConnection) {
                new XmlMapConnectionBuilder().createLookupConnection((TreeNode) source, (TreeNode) target, newXmlMapData);
            }
        } else if (oriConn instanceof FilterConnection) {
            AbstractNode sourceNode = ((FilterConnection) oriConn).getSource();
            AbstractInOutTree targetNode = ((FilterConnection) oriConn).getTarget();
            EObject source = null;
            if (nodeMaps.get(sourceNode) != null) {
                source = nodeMaps.get(sourceNode);
            } else {
                source = cloneTreeNode(sourceNode);
                nodeMaps.put(sourceNode, source);
            }
            EObject target = null;
            if (nodeMaps.get(targetNode) != null) {
                target = nodeMaps.get(targetNode);
            } else {
                target = cloneTreeNode(targetNode);
                nodeMaps.put(targetNode, target);
            }
            new XmlMapConnectionBuilder().createFilterConnection((AbstractNode) source, (AbstractInOutTree) target, newXmlMapData);
        }
    }
    for (InputXmlTree inputXml : oriInputs) {
        InputXmlTree newInputXml = null;
        if (nodeMaps.get(inputXml) == null) {
            newInputXml = (InputXmlTree) cloneTreeNode(inputXml);
        } else {
            newInputXml = (InputXmlTree) nodeMaps.get(inputXml);
        }
        if (inputXml.getNodes() != null) {
            for (TreeNode treeNode : inputXml.getNodes()) {
                EObject obj = nodeMaps.get(treeNode);
                if ((obj != null) && !newInputXml.getNodes().contains(obj)) {
                    newInputXml.getNodes().add((TreeNode) obj);
                }
            }
        }
        if (!newXmlMapData.getInputTrees().contains(newInputXml)) {
            newXmlMapData.getInputTrees().add(newInputXml);
        }
        nodeMaps.put(inputXml, newInputXml);
    }
    for (OutputXmlTree outputXml : oriOutputs) {
        OutputXmlTree newOutputXml = null;
        if (nodeMaps.get(outputXml) == null) {
            newOutputXml = (OutputXmlTree) cloneTreeNode(outputXml);
        } else {
            newOutputXml = (OutputXmlTree) nodeMaps.get(outputXml);
        }
        if (outputXml.getNodes() != null) {
            for (OutputTreeNode treeNode : outputXml.getNodes()) {
                EObject obj = nodeMaps.get(treeNode);
                if ((obj != null) && !newOutputXml.getNodes().contains(obj)) {
                    newOutputXml.getNodes().add((OutputTreeNode) obj);
                }
            }
        }
        // }
        if (!newXmlMapData.getOutputTrees().contains(newOutputXml)) {
            newXmlMapData.getOutputTrees().add(newOutputXml);
        }
        nodeMaps.put(outputXml, newOutputXml);
    }
    for (VarTable varXml : oriVars) {
        VarTable newVarXml = null;
        if (nodeMaps.get(varXml) == null) {
            newVarXml = XmlmapFactory.eINSTANCE.createVarTable();
            newVarXml.setMinimized(varXml.isMinimized());
            newVarXml.setName(varXml.getName());
            if (varXml.getNodes() != null) {
                for (VarNode treeNode : varXml.getNodes()) {
                    EObject obj = nodeMaps.get(treeNode);
                    if (obj != null) {
                        newVarXml.getNodes().add((VarNode) obj);
                    }
                }
            }
            if (!newXmlMapData.getVarTables().contains(newVarXml)) {
                newXmlMapData.getVarTables().add(newVarXml);
            }
            nodeMaps.put(varXml, newVarXml);
        }
    }
    return newXmlMapData;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) INodeConnection(org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) HashMap(java.util.HashMap) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) INodeConnection(org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) 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) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) XmlMapConnectionBuilder(org.talend.designer.xmlmap.util.XmlMapConnectionBuilder) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) EObject(org.eclipse.emf.ecore.EObject) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Aggregations

IConnection (org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)5 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)5 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)4 ArrayList (java.util.ArrayList)2 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)2 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)2 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)2 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)2 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)2 HashMap (java.util.HashMap)1 EObject (org.eclipse.emf.ecore.EObject)1 InputXmlTreeFigure (org.talend.designer.xmlmap.figures.InputXmlTreeFigure)1 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)1 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)1 INodeConnection (org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection)1 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)1 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)1 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)1 XmlMapConnectionBuilder (org.talend.designer.xmlmap.util.XmlMapConnectionBuilder)1