Search in sources :

Example 36 with OutputXmlTree

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

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

the class XmlMapUtil method removeloopInOutputTree.

/**
     * 
     * DOC WCHEN Remove source loops refrenced from input main
     * 
     * @param mapData
     * @param mainInput
     * @param oldLoopsFromInput
     * @param checkProblem
     */
public static void removeloopInOutputTree(XmlMapData mapData, InputXmlTree mainInput, List<TreeNode> oldLoopsFromInput, boolean checkProblem) {
    boolean isMainInputMultiLoop = mainInput == null ? false : mainInput.isMultiLoops();
    EList<OutputXmlTree> outputTrees = mapData.getOutputTrees();
    for (OutputXmlTree outputTree : outputTrees) {
        if (isMainInputMultiLoop) {
            for (TreeNode oldLoop : oldLoopsFromInput) {
                EList<InputLoopNodesTable> inputLoopNodesTables = outputTree.getInputLoopNodesTables();
                for (InputLoopNodesTable inputLoopTable : inputLoopNodesTables) {
                    inputLoopTable.getInputloopnodes().remove(oldLoop);
                }
            }
        } else {
            List<TreeNode> multiLoopsForXmlTree = getMultiLoopsForXmlTree(outputTree);
            for (TreeNode loop : multiLoopsForXmlTree) {
                ((OutputTreeNode) loop).setInputLoopNodesTable(null);
            }
            outputTree.getInputLoopNodesTables().clear();
        }
    }
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) 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) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 38 with OutputXmlTree

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

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

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

the class XmlMapNodeDirectEditManager method createCellEditorOn.

@Override
protected CellEditor createCellEditorOn(Composite composite) {
    Composite parent = (Composite) source.getViewer().getControl();
    CellEditor cellEditor = null;
    Figure figure = null;
    if (this.locator instanceof XmlMapNodeCellEditorLocator) {
        XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
        figure = lo.getFigure();
    }
    if (figure instanceof IComboCell) {
        try {
            // tree setting can be edit or not
            if (source instanceof InputXmlTreeEditPart) {
                InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) source).getModel();
                if (DirectEditType.JOIN_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasAtLeastOneHashKey(inputTree)) {
                        return null;
                    }
                }
                if (DirectEditType.PERSISTENT_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
                    if (LOOKUP_MODE.CACHE_OR_RELOAD.toString().equals(inputTree.getLookupMode())) {
                        return null;
                    }
                }
            }
            if (source instanceof OutputXmlTreeEditPart) {
                OutputXmlTree outputTree = (OutputXmlTree) ((OutputXmlTreeEditPart) source).getModel();
                if (DirectEditType.ALL_IN_ONE.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasDocument(outputTree)) {
                        return null;
                    }
                    boolean hasAggregate = false;
                    for (int i = 0; i < outputTree.getNodes().size(); i++) {
                        OutputTreeNode outputTreeNode = outputTree.getNodes().get(i);
                        hasAggregate = hasAggreage(outputTreeNode);
                        if (hasAggregate) {
                            break;
                        }
                    }
                    if (hasAggregate) {
                        return null;
                    }
                } else if (DirectEditType.ENABLE_EMPTY_ELEMENT.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasDocument(outputTree)) {
                        return null;
                    }
                }
            }
            cellEditor = new XmlComboCellEditor();
            cellEditor.create(composite);
            ((XmlComboCellEditor) cellEditor).setItems(getComboItemsByType(((IComboCell) figure).getDirectEditType()));
            cellAndType.put(cellEditor, ((IComboCell) figure).getDirectEditType());
        } catch (Exception e) {
            return null;
        }
    } else if (figure instanceof ITextCell) {
        // this one is created for direct doc child name , no use anymore...
        cellEditor = new TextCellEditor(composite);
        cellAndType.put(cellEditor, ((ITextCell) figure).getDirectEditType());
        // for the search
        XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
        if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
            figure = (VarNodeTextLabel) lo.getFigure();
            if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
                XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
                if (searchZone.getSearchMaps().size() > 0) {
                    searchZone.getSearchZoneMapper().hightlightAll(searchZone.getSearchMaps(), false);
                    searchZone.getSearchZoneMapper().setHightlightAll(false);
                    searchZone.getSearchMaps().clear();
                    searchZone.hightLightAll.setSelected(false);
                }
            }
        }
    } else if (figure instanceof IExpressionBuilderCell && model instanceof AbstractNode) {
        IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
        CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
        ((ExpressionCellEditor) cellEditor).setOwnerId(((AbstractNode) model).getExpression());
        IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
        behavior.setCellEditorDialog(dialog);
    } else if (figure instanceof ITextAreaCell) {
        TextAreaBehavior behavior = new TextAreaBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION_FILTER);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION_FILTER);
    } else if (figure instanceof IExpressionBuilderCell && model instanceof InputXmlTree) {
        IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
        CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
        ((ExpressionCellEditor) cellEditor).setOwnerId(((InputXmlTree) model).getLookupMode());
        IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
        behavior.setCellEditorDialog(dialog);
    }
    // }
    return cellEditor;
}
Also used : IExpressionBuilderDialogService(org.talend.core.runtime.services.IExpressionBuilderDialogService) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) CellEditor(org.eclipse.jface.viewers.CellEditor) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IExpressionBuilderDialogController(org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) XmlMapSearchZoneToolBar(org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar) ITextAreaCell(org.talend.designer.gefabstractmap.figures.cells.ITextAreaCell) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) ITextCell(org.talend.designer.gefabstractmap.figures.cells.ITextCell) IService(org.talend.core.IService) Composite(org.eclipse.swt.widgets.Composite) IExpressionBuilderCell(org.talend.designer.gefabstractmap.figures.cells.IExpressionBuilderCell) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) Figure(org.eclipse.draw2d.Figure) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) CellEditorDialogBehavior(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IComboCell(org.talend.designer.gefabstractmap.figures.cells.IComboCell)

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