Search in sources :

Example 26 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode 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 27 with OutputTreeNode

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

the class TreeNodeEditPart method performRequest.

@Override
public void performRequest(Request req) {
    if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
        Figure figure = null;
        DirectEditRequest drequest = (DirectEditRequest) req;
        Point figureLocation = drequest.getLocation();
        if (getFigure() instanceof TableTreeEntityFigure) {
            XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
            ArrayList collection = new ArrayList();
            collection.add(treeNodeFigure.getExpressionFigure());
            collection.add(treeNodeFigure.getBranchContent());
            figure = (Figure) treeNodeFigure.findFigureAt(figureLocation.x, figureLocation.y, new FigureSearch(collection));
        }
        if (figure instanceof IWidgetCell) {
            directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(figure, this));
        }
        if (directEditManager != null) {
            TreeNode outputTreeNode = (TreeNode) getModel();
            if (figure instanceof ExpressionFigure) {
                if (XmlMapUtil.isExpressionEditable(outputTreeNode)) {
                    Point location = drequest.getLocation();
                    if (figure.containsPoint(location)) {
                        directEditManager.show();
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
                    }
                }
            } else if (!(((TreeNode) getModel()).eContainer() instanceof AbstractInOutTree)) {
            // disable for RC2
            // directEditManager.show();
            // ((XmlMapGraphicViewer)
            // getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
            }
        }
    }
    super.performRequest(req);
}
Also used : XmlMapNodeDirectEditManager(org.talend.designer.xmlmap.parts.directedit.XmlMapNodeDirectEditManager) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) Point(org.eclipse.draw2d.geometry.Point) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) IFigure(org.eclipse.draw2d.IFigure) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Figure(org.eclipse.draw2d.Figure) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IWidgetCell(org.talend.designer.gefabstractmap.figures.cells.IWidgetCell)

Example 28 with OutputTreeNode

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

the class XmlMapComponent method checkNeededRoutines.

@Override
public List<String> checkNeededRoutines(List<String> possibleRoutines, String additionalString) {
    List<String> routinesToAdd = new ArrayList<String>();
    XmlMapData xmlMapData = (XmlMapData) getExternalEmfData();
    for (String routine : possibleRoutines) {
        List<OutputXmlTree> listOutput = xmlMapData.getOutputTrees();
        for (OutputXmlTree outTable : listOutput) {
            List<OutputTreeNode> listOutEntry = outTable.getNodes();
            if (listOutEntry != null && !listOutEntry.isEmpty()) {
                for (OutputTreeNode outEntry : listOutEntry) {
                    String expression = outEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
            String filter = outTable.getExpressionFilter();
            if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
                routinesToAdd.add(routine);
            }
        }
        List<InputXmlTree> listInput = xmlMapData.getInputTrees();
        for (InputXmlTree inputTable : listInput) {
            List<TreeNode> listInEntry = inputTable.getNodes();
            if (listInEntry != null && !listInEntry.isEmpty()) {
                for (TreeNode inEntry : listInEntry) {
                    String expression = inEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
            String filter = inputTable.getExpressionFilter();
            if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
                routinesToAdd.add(routine);
            }
        }
        List<VarTable> listVar = xmlMapData.getVarTables();
        for (VarTable varTable : listVar) {
            List<VarNode> listVarEntry = varTable.getNodes();
            if (listVarEntry != null && !listVarEntry.isEmpty()) {
                for (VarNode varEntry : listVarEntry) {
                    String expression = varEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
        }
    }
    return routinesToAdd;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) ArrayList(java.util.ArrayList) 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)

Example 29 with OutputTreeNode

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

the class XmlMapService method cloneTreeNode.

private EObject cloneTreeNode(EObject node) {
    if (node instanceof AbstractInOutTree) {
        AbstractInOutTree source = null;
        AbstractInOutTree oriSource = null;
        if (node instanceof InputXmlTree) {
            oriSource = (InputXmlTree) node;
            source = XmlmapFactory.eINSTANCE.createInputXmlTree();
            ((InputXmlTree) source).setActivateGlobalMap(((InputXmlTree) oriSource).isActivateGlobalMap());
            ((InputXmlTree) source).setInnerJoin(((InputXmlTree) oriSource).isInnerJoin());
            ((InputXmlTree) source).setLookup(((InputXmlTree) oriSource).isLookup());
            ((InputXmlTree) source).setLookupMode(((InputXmlTree) oriSource).getLookupMode());
            ((InputXmlTree) source).setMatchingMode(((InputXmlTree) oriSource).getMatchingMode());
            ((InputXmlTree) source).setPersistent(((InputXmlTree) oriSource).isPersistent());
        } else if (node instanceof OutputXmlTree) {
            oriSource = (OutputXmlTree) node;
            source = XmlmapFactory.eINSTANCE.createOutputXmlTree();
            ((OutputXmlTree) source).setAllInOne(((OutputXmlTree) oriSource).isAllInOne());
            ((OutputXmlTree) source).setEnableEmptyElement(((OutputXmlTree) oriSource).isEnableEmptyElement());
            ((OutputXmlTree) source).setErrorReject(((OutputXmlTree) oriSource).isErrorReject());
            ((OutputXmlTree) source).setReject(((OutputXmlTree) oriSource).isReject());
            ((OutputXmlTree) source).setRejectInnerJoin(((OutputXmlTree) oriSource).isRejectInnerJoin());
        }
        source.setActivateCondensedTool(oriSource.isActivateCondensedTool());
        source.setActivateExpressionFilter(oriSource.isActivateExpressionFilter());
        source.setExpressionFilter(oriSource.getExpressionFilter());
        source.setMinimized(oriSource.isMinimized());
        source.setMultiLoops(oriSource.isMultiLoops());
        source.setName(oriSource.getName());
        return source;
    } else if (node instanceof VarNode) {
        VarNode oriSource = (VarNode) node;
        VarNode source = XmlmapFactory.eINSTANCE.createVarNode();
        source.setExpression(oriSource.getExpression());
        source.setName(oriSource.getName());
        source.setNullable(oriSource.isNullable());
        source.setType(oriSource.getType());
        return source;
    } else if (node instanceof TreeNode) {
        TreeNode source = null;
        TreeNode oriSource = null;
        if (node instanceof OutputTreeNode) {
            oriSource = (OutputTreeNode) node;
            source = XmlmapFactory.eINSTANCE.createOutputTreeNode();
            ((OutputTreeNode) source).setAggregate(((OutputTreeNode) oriSource).isAggregate());
            ((OutputTreeNode) source).setInputLoopNodesTable(((OutputTreeNode) oriSource).getInputLoopNodesTable());
        } else if (node instanceof GlobalMapNode) {
            oriSource = (GlobalMapNode) node;
            source = XmlmapFactory.eINSTANCE.createGlobalMapNode();
            return source;
        } else {
            oriSource = (TreeNode) node;
            source = XmlmapFactory.eINSTANCE.createTreeNode();
        }
        source.setChoice(oriSource.isChoice());
        source.setDefaultValue(oriSource.getDefaultValue());
        source.setExpression(oriSource.getExpression());
        source.setGroup(oriSource.isGroup());
        source.setKey(oriSource.isKey());
        source.setLoop(oriSource.isLoop());
        source.setMain(oriSource.isMain());
        source.setName(oriSource.getName());
        source.setNodeType(oriSource.getNodeType());
        source.setNullable(oriSource.isNullable());
        source.setOptional(oriSource.isOptional());
        source.setPattern(oriSource.getPattern());
        source.setSubstitution(oriSource.isSubstitution());
        source.setType(oriSource.getType());
        source.setXpath(oriSource.getXpath());
        return source;
    }
    return null;
}
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) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) GlobalMapNode(org.talend.designer.xmlmap.model.emf.xmlmap.GlobalMapNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 30 with OutputTreeNode

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

the class XmlMapUtilTest method testUpdateXPathAndExpression.

@Test
public void testUpdateXPathAndExpression() {
    XmlMapData data = XmlmapFactory.eINSTANCE.createXmlMapData();
    InputXmlTree inputTree = XmlmapFactory.eINSTANCE.createInputXmlTree();
    inputTree.setName("row1");
    OutputXmlTree outputTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
    outputTree.setName("out1");
    data.getInputTrees().add(inputTree);
    data.getOutputTrees().add(outputTree);
    TreeNode doc = XmlmapFactory.eINSTANCE.createTreeNode();
    initTreeNode(doc, "doc", "id_Document", NodeType.ELEMENT, "row1/doc", "");
    inputTree.getNodes().add(doc);
    TreeNode school = XmlmapFactory.eINSTANCE.createTreeNode();
    initTreeNode(school, "school", "id_String", NodeType.ELEMENT, "row1.doc:/school", "");
    doc.getChildren().add(school);
    TreeNode student = XmlmapFactory.eINSTANCE.createTreeNode();
    initTreeNode(student, "student", "id_String", NodeType.ELEMENT, "row1.doc:/school/student", "");
    school.getChildren().add(student);
    TreeNode name = XmlmapFactory.eINSTANCE.createTreeNode();
    initTreeNode(name, "name", "id_String", NodeType.ATTRIBUT, "row1.doc:/school/student/@name", "");
    student.getChildren().add(name);
    OutputTreeNode outColumn = XmlmapFactory.eINSTANCE.createOutputTreeNode();
    initTreeNode(outColumn, "outColumn", "id_String", NodeType.ELEMENT, "out1/outColumn", "[row1.doc:/school/student/@name]");
    outputTree.getNodes().add(outColumn);
    createConnection(data, name, outColumn);
    // rename schema column
    doc.setName("document");
    XmlMapUtil.updateXPathAndExpression(data, new XmlMapExpressionManager(), doc, "document", 2, true);
    assertTrue(doc.getXpath().equals("row1/document"));
    assertTrue(school.getXpath().equals("row1.document:/school"));
    assertTrue(student.getXpath().equals("row1.document:/school/student"));
    assertTrue(name.getXpath().equals("row1.document:/school/student/@name"));
    assertTrue(outColumn.getExpression().equals("[row1.document:/school/student/@name]"));
    // rename doc child
    school.setName("kindergarten");
    XmlMapUtil.updateXPathAndExpression(data, new XmlMapExpressionManager(), school, "kindergarten", 3, true);
    assertTrue(doc.getXpath().equals("row1/document"));
    assertTrue(school.getXpath().equals("row1.document:/kindergarten"));
    assertTrue(student.getXpath().equals("row1.document:/kindergarten/student"));
    assertTrue(name.getXpath().equals("row1.document:/kindergarten/student/@name"));
    assertTrue(outColumn.getExpression().equals("[row1.document:/kindergarten/student/@name]"));
}
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) XmlMapExpressionManager(org.talend.designer.xmlmap.ui.expressionutil.XmlMapExpressionManager) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData) Test(org.junit.Test)

Aggregations

OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)57 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)42 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)27 ArrayList (java.util.ArrayList)16 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)16 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)15 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)15 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)11 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)11 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)10 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)9 List (java.util.List)8 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)8 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)8 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)8 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)7 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)7 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5