Search in sources :

Example 26 with XmlMapData

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

the class XmlMapFiguresManager method getInputTables.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.manager.FiguresManager#getInputTables()
     */
@Override
protected List<MapperTable> getInputTables() {
    List<MapperTable> inputTables = new ArrayList<MapperTable>();
    XmlMapData mapData = (XmlMapData) getRootEditPart().getModel();
    inputTables.addAll(mapData.getInputTrees());
    return inputTables;
}
Also used : MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 27 with XmlMapData

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

the class VarToolBarFigure method removeVar.

@Override
protected void removeVar() {
    CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
            final List<VarNode> toRemove = new ArrayList<VarNode>();
            int minIndex = parentTable.getNodes().size() - 1;
            for (Object obj : selectedEditParts) {
                if (obj instanceof VarNodeEditPart) {
                    VarNode model = (VarNode) ((VarNodeEditPart) obj).getModel();
                    toRemove.add(model);
                    XmlMapUtil.detachNodeConnections(model, (XmlMapData) parentTable.eContainer(), true);
                    int index = parentTable.getNodes().indexOf(model);
                    if (index < minIndex) {
                        minIndex = index;
                    }
                }
            }
            parentTable.getNodes().removeAll(toRemove);
            if (!tablePart.getChildren().isEmpty()) {
                if (minIndex > tablePart.getChildren().size() - 1) {
                    minIndex = tablePart.getChildren().size() - 1;
                }
                tablePart.getViewer().select((EditPart) tablePart.getChildren().get(minIndex));
            } else {
                remove.setEnabled(false);
            }
        }
    });
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CommandStack(org.eclipse.gef.commands.CommandStack) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) Command(org.eclipse.gef.commands.Command) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) EditPart(org.eclipse.gef.EditPart) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 28 with XmlMapData

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

the class XmlMapFiguresManager method getOutputTables.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.manager.FiguresManager#getOutputTables()
     */
@Override
protected List<MapperTable> getOutputTables() {
    List<MapperTable> outputTables = new ArrayList<MapperTable>();
    XmlMapData mapData = (XmlMapData) getRootEditPart().getModel();
    outputTables.addAll(mapData.getOutputTrees());
    return outputTables;
}
Also used : MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 29 with XmlMapData

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

the class XmlMapComponent method isRunRefSubProcessAtStart.

@Override
public boolean isRunRefSubProcessAtStart(String connectionName) {
    XmlMapData externalEmfData = (XmlMapData) getExternalEmfData();
    List<InputXmlTree> inputTrees = new ArrayList<InputXmlTree>(externalEmfData.getInputTrees());
    for (InputXmlTree table : inputTrees) {
        if (table.getName().equals(connectionName)) {
            String lookupMode = table.getLookupMode();
            if (XML_MAP_LOOKUP_MODE.RELOAD.name().equals(lookupMode) || XML_MAP_LOOKUP_MODE.CACHE_OR_RELOAD.name().equals(lookupMode)) {
                return false;
            }
        }
    }
    return true;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ArrayList(java.util.ArrayList) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 30 with XmlMapData

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

the class XmlMapService method checkXMLMapDifferents.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.service.IXmlMapService#checkXMLMapDifferents(org.talend.core.model.process.INode,
     * org.talend.core.model.process.INode)
     */
@Override
public boolean checkXMLMapDifferents(INode testNode, INode originalNode) {
    AbstractExternalData oriExternalData = originalNode.getExternalNode().getExternalEmfData();
    AbstractExternalData testExternalData = testNode.getExternalNode().getExternalEmfData();
    if (oriExternalData == null && testExternalData == null) {
        return false;
    }
    if (oriExternalData == null || testExternalData == null) {
        return true;
    }
    if (!(oriExternalData instanceof XmlMapData) || !(testExternalData instanceof XmlMapData)) {
        return false;
    }
    Map<String, String> inputConnNameMap = getInputConnectionNameMap(testNode);
    XmlMapData oriXmlData = (XmlMapData) oriExternalData;
    XmlMapData testXmlData = (XmlMapData) testExternalData;
    EList<InputXmlTree> oriInputs = oriXmlData.getInputTrees();
    EList<OutputXmlTree> oriOutputs = oriXmlData.getOutputTrees();
    EList<VarTable> oriVars = oriXmlData.getVarTables();
    EList<InputXmlTree> testInputs = testXmlData.getInputTrees();
    EList<OutputXmlTree> testOutputs = testXmlData.getOutputTrees();
    EList<VarTable> testVars = testXmlData.getVarTables();
    if (oriInputs.size() != testInputs.size()) {
        return true;
    }
    if (oriOutputs.size() != testOutputs.size()) {
        return true;
    }
    if (oriVars.size() != testVars.size()) {
        return true;
    }
    for (InputXmlTree oriInput : oriInputs) {
        String oriName = oriInput.getName();
        InputXmlTree testInput = null;
        for (InputXmlTree input : testInputs) {
            if (input.getName().equals(oriName)) {
                testInput = input;
                break;
            }
        }
        if (testInput == null) {
            testInput = getInputXmlTree(testNode, testInputs, oriName);
        }
        if (testInput == null) {
            return true;
        }
        if (oriInput.isActivateExpressionFilter() != testInput.isActivateExpressionFilter()) {
            return true;
        }
        if (oriInput.getExpressionFilter() != testInput.getExpressionFilter()) {
            return true;
        }
        if (oriInput.isMinimized() != testInput.isMinimized()) {
            return true;
        }
        if (oriInput.isActivateCondensedTool() != testInput.isActivateCondensedTool()) {
            return true;
        }
        EList<TreeNode> oriEntrys = oriInput.getNodes();
        EList<TreeNode> testEntrys = testInput.getNodes();
        if (oriEntrys.size() != testEntrys.size()) {
            return true;
        }
        for (TreeNode oriEntry : oriEntrys) {
            String oriEntryName = oriEntry.getName();
            boolean found = false;
            for (TreeNode testEntry : testEntrys) {
                if (oriEntryName.equals(testEntry.getName())) {
                    found = true;
                    if (checkExpression(oriEntry.getExpression(), testEntry.getExpression(), inputConnNameMap)) {
                        return true;
                    }
                    break;
                }
            }
            if (!found) {
                return true;
            }
        }
    }
    for (OutputXmlTree oriOutput : oriOutputs) {
        String oriName = oriOutput.getName();
        OutputXmlTree testOutput = null;
        for (OutputXmlTree output : testOutputs) {
            if (output.getName().equals(oriName)) {
                testOutput = output;
                break;
            }
        }
        if (testOutput == null) {
            testOutput = getOutputXmlTree(testNode, testOutputs, oriName);
        }
        if (testOutput == null) {
            return true;
        }
        if (oriOutput.isActivateExpressionFilter() != testOutput.isActivateExpressionFilter()) {
            return true;
        }
        if (oriOutput.getExpressionFilter() != testOutput.getExpressionFilter()) {
            return true;
        }
        if (oriOutput.isMinimized() != testOutput.isMinimized()) {
            return true;
        }
        if (oriOutput.isActivateCondensedTool() != testOutput.isActivateCondensedTool()) {
            return true;
        }
        EList<OutputTreeNode> oriEntrys = oriOutput.getNodes();
        EList<OutputTreeNode> testEntrys = testOutput.getNodes();
        if (oriEntrys.size() != testEntrys.size()) {
            return true;
        }
        for (OutputTreeNode oriEntry : oriEntrys) {
            String oriEntryName = oriEntry.getName();
            boolean found = false;
            for (OutputTreeNode testEntry : testEntrys) {
                if (oriEntryName.equals(testEntry.getName())) {
                    found = true;
                    if (found) {
                        if (checkChildOutputTreeNode(oriEntry, testEntry, inputConnNameMap)) {
                            return true;
                        }
                    }
                    break;
                }
            }
            if (!found) {
                return true;
            }
        }
    }
    for (VarTable oriVar : oriVars) {
        String oriName = oriVar.getName();
        VarTable testVar = null;
        for (VarTable var : testVars) {
            if (var.getName().equals(oriName)) {
                testVar = var;
                break;
            }
        }
        if (testVar == null) {
            return true;
        }
        if (oriVar.isMinimized() != testVar.isMinimized()) {
            return true;
        }
        EList<VarNode> oriEntrys = oriVar.getNodes();
        EList<VarNode> testEntrys = testVar.getNodes();
        if (oriEntrys.size() != testEntrys.size()) {
            return true;
        }
        for (VarNode oriEntry : oriEntrys) {
            String oriEntryName = oriEntry.getName();
            boolean found = false;
            for (VarNode testEntry : testEntrys) {
                if (oriEntryName.equals(testEntry.getName())) {
                    found = true;
                    if (checkExpression(oriEntry.getExpression(), testEntry.getExpression(), inputConnNameMap)) {
                        return true;
                    }
                }
            }
            if (!found) {
                return true;
            }
        }
    }
    return false;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) AbstractExternalData(org.talend.designer.core.model.utils.emf.talendfile.AbstractExternalData) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Aggregations

XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)36 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)18 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)17 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)15 ArrayList (java.util.ArrayList)14 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)14 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)8 List (java.util.List)7 EList (org.eclipse.emf.common.util.EList)6 HashMap (java.util.HashMap)5 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)5 IConnection (org.talend.core.model.process.IConnection)4 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)4 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)3 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)3 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 CCombo (org.eclipse.swt.custom.CCombo)2 Test (org.junit.Test)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)2 MapperTable (org.talend.designer.gefabstractmap.model.abstractmap.MapperTable)2