Search in sources :

Example 16 with OutputXmlTree

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

the class InputLoopTableUtil method getInputLoopNodesTable.

private static InputLoopNodesTable getInputLoopNodesTable(OutputTreeNode outputNode) {
    InputLoopNodesTable inputLoopNodesTable = null;
    AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(outputNode);
    List<InputLoopNodesTable> listInputLoopNodesTablesEntry = ((OutputXmlTree) abstractTree).getInputLoopNodesTables();
    if (!XmlMapUtil.hasDocument(abstractTree)) {
        if (listInputLoopNodesTablesEntry.size() == 0) {
            inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
            listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
        } else if (listInputLoopNodesTablesEntry != null && listInputLoopNodesTablesEntry.size() == 1) {
            inputLoopNodesTable = listInputLoopNodesTablesEntry.get(0);
        }
    } else {
        OutputTreeNode loopParentOutputTreeNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode(outputNode);
        if (loopParentOutputTreeNode != null) {
            inputLoopNodesTable = loopParentOutputTreeNode.getInputLoopNodesTable();
            if (inputLoopNodesTable == null) {
                inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
                loopParentOutputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
                listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
            }
        }
    }
    return inputLoopNodesTable;
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 17 with OutputXmlTree

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

the class XmlmapBranchContent method createContent.

@Override
protected void createContent() {
    super.createContent();
    statusFigure = new Label();
    statusFigure.setForegroundColor(ColorConstants.red);
    statusFigure.setText(getStatus());
    defaultValue = new Label();
    defaultValue.setForegroundColor(ColorConstants.blue);
    defaultValue.setText(getDefaultValue());
    ImageInfo infor = ImageInfo.SETLOOPFUNCTION_BUTTON;
    if (treeNode instanceof OutputTreeNode) {
        InputLoopNodesTable inputLoopNodesTable = ((OutputTreeNode) treeNode).getInputLoopNodesTable();
        infor = (inputLoopNodesTable == null || inputLoopNodesTable.getInputloopnodes().isEmpty()) ? ImageInfo.SETLOOPFUNCTION_BUTTON_ERROR : ImageInfo.SETLOOPFUNCTION_BUTTON;
    }
    loopButtonFigure = new ToolBarButtonImageFigure(ImageProviderMapper.getImage(infor));
    loopButtonFigure.addMouseListener(new MouseListener.Stub() {

        @Override
        public void mousePressed(MouseEvent me) {
            OutputTreeNode outputTreeNode = (OutputTreeNode) treeNode;
            List<TreeNode> loopNodes = new ArrayList<TreeNode>();
            if (manager.isMainTableMultiLoop()) {
                loopNodes.addAll(XmlMapUtil.getMultiLoopsForXmlTree(manager.getMainInputTree()));
            }
            InputLoopNodesTable inputLoopNodesTable = null;
            if (outputTreeNode.getInputLoopNodesTable() != null) {
                inputLoopNodesTable = outputTreeNode.getInputLoopNodesTable();
            } else {
                inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
                outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
                AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(outputTreeNode);
                if (abstractInOutTree != null) {
                    ((OutputXmlTree) abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
                }
            }
            SetLoopFunctionDialog nsDialog = new SetLoopFunctionDialog(null, outputTreeNode.getInputLoopNodesTable(), loopNodes);
            if (nsDialog.open() == Window.OK) {
                manager.getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
                manager.getMapperUI().updateStatusBar();
            }
        }
    });
    if (treeNode != null && treeNode instanceof OutputTreeNode) {
        // display loop setup button only when input main is multiloop
        if (treeNode.isLoop() && manager.isMainTableMultiLoop()) {
            this.add(loopButtonFigure);
        }
    }
    this.add(statusFigure);
    this.add(defaultValue);
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) ToolBarButtonImageFigure(org.talend.designer.gefabstractmap.figures.treetools.ToolBarButtonImageFigure) MouseEvent(org.eclipse.draw2d.MouseEvent) Label(org.eclipse.draw2d.Label) SetLoopFunctionDialog(org.talend.designer.xmlmap.ui.dialog.SetLoopFunctionDialog) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) MouseListener(org.eclipse.draw2d.MouseListener) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) List(java.util.List) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) ImageInfo(org.talend.designer.gefabstractmap.resource.ImageInfo)

Example 18 with OutputXmlTree

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

the class AutoMapper method map.

/**
     * DOC amaumont Comment method "map".
     */
public void map() {
    EList<InputXmlTree> inputTrees = xmlMapData.getInputTrees();
    EList<OutputXmlTree> outputTrees = xmlMapData.getOutputTrees();
    /*
         * non-document node , if name is the same ,automap document node , check xpath first , if can't find ,check the
         * name
         */
    for (OutputXmlTree outputTree : outputTrees) {
        List<TreeNode> outputEntries = getAllEntities(outputTree);
        for (TreeNode outputEntry : outputEntries) {
            if ((outputEntry.getExpression() == null || "".equals(outputEntry.getExpression())) && XmlMapUtil.isExpressionEditable(outputEntry)) {
                String xpath = outputEntry.getXpath();
                String outputNodePath = xpath.substring(outputTree.getName().length() + 1, xpath.length());
                TreeNode inputSameXpath = null;
                TreeNode inputSameName = null;
                out: for (InputXmlTree inputTable : inputTrees) {
                    List<TreeNode> inputColumnEntries = getAllEntities(inputTable);
                    in: for (TreeNode inputEntry : inputColumnEntries) {
                        // check if input tree node can be mapped
                        if (XmlMapUtil.isExpressionEditable(inputEntry)) {
                            String inputXpath = inputEntry.getXpath();
                            String inputNodePath = inputXpath.substring(inputTable.getName().length() + 1, inputXpath.length());
                            if (outputNodePath.equals(inputNodePath)) {
                                inputSameXpath = inputEntry;
                                break out;
                            }
                            // if the same name , find the first matched node , don't overwrite
                            if (inputSameName == null && outputEntry.getName() != null && outputEntry.getName().equals(inputEntry.getName())) {
                                inputSameName = inputEntry;
                            }
                        }
                    }
                }
                TreeNode inputEntryToMap = null;
                if (inputSameXpath != null) {
                    inputEntryToMap = inputSameXpath;
                } else if (inputSameName != null) {
                    inputEntryToMap = inputSameName;
                }
                if (inputEntryToMap != null) {
                    String expression = outputEntry.getExpression();
                    String convertToExpression = XmlMapUtil.convertToExpression(inputEntryToMap.getXpath());
                    if (expression != null && expression.indexOf(convertToExpression) != -1) {
                        continue;
                    } else {
                        if (expression == null) {
                            expression = "";
                        }
                        expression = expression + convertToExpression;
                    }
                    outputEntry.setExpression(expression);
                    Connection conn = XmlmapFactory.eINSTANCE.createConnection();
                    conn.setSource(inputEntryToMap);
                    conn.setTarget(outputEntry);
                    outputEntry.getIncomingConnections().add(conn);
                    inputEntryToMap.getOutgoingConnections().add(conn);
                    xmlMapData.getConnections().add(conn);
                }
            }
        }
    }
}
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) List(java.util.List) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 19 with OutputXmlTree

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

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, Figure>> searchMaps, String searchValue) {
    if (searchValue.equals("") || searchValue == null) {
        return;
    }
    List<InputXmlTree> inputTrees = mapperManager.getExternalData().getInputTrees();
    List<VarTable> varTables = mapperManager.getExternalData().getVarTables();
    List<OutputXmlTree> outputTrees = mapperManager.getExternalData().getOutputTrees();
    matcher.setPattern("*" + searchValue.trim() + "*");
    int index = -1;
    // for the InputTables
    for (InputXmlTree inputXmlTree : inputTrees) {
        // ExpressionFilter
        if (inputXmlTree.getExpressionFilter() != null && matcher.matches(inputXmlTree.getExpressionFilter())) {
            EList<Adapter> adapter = inputXmlTree.eAdapters();
            if (adapter.size() > 0) {
                if (adapter.get(0) instanceof InputXmlTreeEditPart) {
                    InputXmlTreeEditPart inputXmlTreeEditPart = (InputXmlTreeEditPart) adapter.get(0);
                    if (inputXmlTreeEditPart != null && inputXmlTreeEditPart.getFigure() != null && inputXmlTreeEditPart.getFigure() instanceof InputXmlTreeFigure) {
                        InputXmlTreeFigure inputXmlTreeFigure = (InputXmlTreeFigure) inputXmlTreeEditPart.getFigure();
                        Map<Integer, Figure> map = new HashMap<Integer, Figure>();
                        map.put(0, inputXmlTreeFigure.getFilterContainer());
                        index++;
                        searchMaps.put(index, map);
                    }
                }
            }
        }
        // TreeNode
        for (TreeNode node : inputXmlTree.getNodes()) {
            // id_Document type
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
                    if (getMatcherNodeFigure(nodeTemp).size() > 0) {
                        index++;
                        searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
                    }
                }
            }
            if (getMatcherNodeFigure(node).size() > 0) {
                index++;
                searchMaps.put(index, getMatcherNodeFigure(node));
            }
        }
    }
    // for the VarsTables
    for (VarTable varTable : varTables) {
        for (VarNode node : varTable.getNodes()) {
            if (getMatcherNodeFigure(node).size() > 0) {
                index++;
                searchMaps.put(index, getMatcherNodeFigure(node));
            }
        }
    }
    // for the OutputTables
    for (OutputXmlTree outputXmlTree : outputTrees) {
        // ExpressionFilter
        if (outputXmlTree.getExpressionFilter() != null && matcher.matches(outputXmlTree.getExpressionFilter())) {
            EList<Adapter> adapter = outputXmlTree.eAdapters();
            if (adapter.size() > 0) {
                if (adapter.get(0) instanceof OutputXmlTreeEditPart) {
                    OutputXmlTreeEditPart outputXmlTreeEditPart = (OutputXmlTreeEditPart) adapter.get(0);
                    if (outputXmlTreeEditPart != null && outputXmlTreeEditPart.getFigure() != null && outputXmlTreeEditPart.getFigure() instanceof OutputXmlTreeFigure) {
                        OutputXmlTreeFigure outputXmlTreeFigure = (OutputXmlTreeFigure) outputXmlTreeEditPart.getFigure();
                        Map<Integer, Figure> map = new HashMap<Integer, Figure>();
                        map.put(0, outputXmlTreeFigure.getFilterContainer());
                        index++;
                        searchMaps.put(index, map);
                    }
                }
            }
        }
        // OutputTreeNode
        for (OutputTreeNode node : outputXmlTree.getNodes()) {
            // id_Document type
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
                    if (getMatcherNodeFigure(nodeTemp).size() > 0) {
                        index++;
                        searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
                    }
                }
            } else {
                if (getMatcherNodeFigure(node).size() > 0) {
                    index++;
                    searchMaps.put(index, getMatcherNodeFigure(node));
                }
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) HashMap(java.util.HashMap) Adapter(org.eclipse.emf.common.notify.Adapter) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) IFigure(org.eclipse.draw2d.IFigure) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) VarNodeFigure(org.talend.designer.xmlmap.figures.varnode.VarNodeFigure) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) 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) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure)

Example 20 with OutputXmlTree

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

the class TreeToolBarContainer method createToolbar.

@Override
protected void createToolbar() {
    super.createToolbar();
    condensedButton = new CondensedButton(ImageProviderMapper.getImage(ImageInfo.CONDENSED_TOOL_ICON));
    condensedButton.setSelected(getTableManager().isActivateCondensedTool());
    setTooltips(condensedButton, "tXmlMap settings");
    expressionFilterButton = new ExpressionFilterButton(ImageProviderMapper.getImage(ImageInfo.ACTIVATE_FILTER_ICON));
    expressionFilterButton.setSelected(getTableManager().isActivateExpressionFilter());
    setTooltips(expressionFilterButton, "Enable/disable expression filter");
    inputMainTable = ((MapperManager) getTableManager().getGraphicalViewer().getMapperManager()).getMainInputTree();
    abstractTree = getTableManager().getModel();
    if (abstractTree instanceof OutputXmlTree) {
        ImageInfo info = ImageInfo.SETLOOPFUNCTION_BUTTON;
        EList<InputLoopNodesTable> inputLoopNodesTables = ((OutputXmlTree) abstractTree).getInputLoopNodesTables();
        if (!inputLoopNodesTables.isEmpty() && inputLoopNodesTables.get(0) != null) {
            if (inputLoopNodesTables.get(0).getInputloopnodes().isEmpty()) {
                info = ImageInfo.SETLOOPFUNCTION_BUTTON_ERROR;
            }
        }
        setLoopFunctionButton = new SetLoopFunctionButton(ImageProviderMapper.getImage(info));
        setTooltips(setLoopFunctionButton, "set Loop Function");
        this.add(setLoopFunctionButton);
        if (inputMainTable == null || !inputMainTable.isMultiLoops()) {
            setLoopFunctionButton.setVisible(false);
        }
    }
    // TDI-22087
    if (abstractTree instanceof OutputXmlTree || (abstractTree instanceof InputXmlTree && ((InputXmlTree) abstractTree).isLookup())) {
        this.add(condensedButton);
        this.add(expressionFilterButton);
    }
    boolean isErrorReject = false;
    if (abstractTree instanceof OutputXmlTree) {
        isErrorReject = ((OutputXmlTree) abstractTree).isErrorReject();
    }
    if (isErrorReject) {
        condensedButton.setEnabled(false);
        expressionFilterButton.setEnabled(false);
    }
    this.add(min_size);
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) ImageInfo(org.talend.designer.gefabstractmap.resource.ImageInfo)

Aggregations

OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)49 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)30 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)26 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)26 ArrayList (java.util.ArrayList)17 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)15 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)13 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)12 List (java.util.List)11 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)9 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)9 OutputXmlTreeEditPart (org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)7 EList (org.eclipse.emf.common.util.EList)6 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)6 HashMap (java.util.HashMap)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)4 EditPart (org.eclipse.gef.EditPart)3 Command (org.eclipse.gef.commands.Command)3