Search in sources :

Example 21 with OutputXmlTree

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

the class XmlMapOutputZoneToolBar method addTable.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#addTable()
     */
@Override
protected void addTable() {
    final OutputXmlTree createOutputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
    CommandStack commandStack = externalPart.getViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            if (externalPart.getViewer() instanceof XmlMapGraphicViewer) {
                XmlMapGraphicViewer viewer = (XmlMapGraphicViewer) externalPart.getViewer();
                MapperManager manager = viewer.getMapperManager();
                String outputName = manager.getMapperUI().openNewOutputCreationDialog();
                if (outputName == null) {
                    return;
                }
                createOutputXmlTree.setName(outputName);
                externalData.getOutputTrees().add(createOutputXmlTree);
                MetadataTable metadataTable = new MetadataTable();
                metadataTable.setLabel(outputName);
                metadataTable.setTableName(outputName);
                mapperComponent.getMetadataList().add(metadataTable);
                mapperComponent.getProcess().addUniqueConnectionName(outputName);
                int indexOf = externalPart.getModelChildren().indexOf(createOutputXmlTree);
                if (indexOf != -1) {
                    externalPart.getViewer().select((EditPart) externalPart.getChildren().get(indexOf));
                }
                if (!min_size.isEnabled()) {
                    min_size.setEnabled(true);
                }
                // check problem for created output incase input main is multiloop
                mapperManger.getProblemsAnalyser().checkProblems(createOutputXmlTree);
                mapperManger.getMapperUI().updateStatusBar();
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) Command(org.eclipse.gef.commands.Command) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 22 with OutputXmlTree

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

the class XmlMapOutputZoneToolBar method removeTable.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#removeTable()
     */
@Override
protected void removeTable() {
    CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            OutputXmlTreeEditPart currentSelectedOutputXmlTree = graphicViewer.getFiguresManager().getCurrentSelectedOutputTable();
            if (currentSelectedOutputXmlTree != null) {
                OutputXmlTree outputTree = (OutputXmlTree) currentSelectedOutputXmlTree.getModel();
                int indexOf = externalPart.getModelChildren().indexOf(outputTree);
                mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
                removeMetadataTableByName(outputTree.getName());
                for (OutputTreeNode treeNode : outputTree.getNodes()) {
                    XmlMapUtil.detachConnectionsSouce(treeNode, externalData);
                }
                externalData.getOutputTrees().remove(outputTree);
                XmlMapUtil.detachFilterSource(outputTree, externalData);
                indexOf = indexOf - 1;
                if (indexOf > -1 && (EditPart) externalPart.getChildren().get(indexOf) instanceof OutputXmlTreeEditPart) {
                    graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
                } else if (indexOf > -1 && indexOf + 1 < externalPart.getChildren().size() && (EditPart) externalPart.getChildren().get(indexOf + 1) instanceof OutputXmlTreeEditPart) {
                    graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf + 1));
                } else {
                    mapperManger.getMapperUI().getTabFolderEditors().getOutputMetaEditorView().setMetadataTableEditor(null);
                }
                mapperManger.getProblemsAnalyser().clearProblemsForTree(outputTree);
                mapperManger.getMapperUI().updateStatusBar();
            }
            if (externalData.getOutputTrees().isEmpty() && min_size.isEnabled()) {
                min_size.setEnabled(false);
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) Command(org.eclipse.gef.commands.Command) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)

Example 23 with OutputXmlTree

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

the class TXMLMapChangeAllInOneValueMigrationTask method execute.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
	 * (org .talend.core.model.properties.Item)
	 */
@Override
public ExecutionResult execute(Item item) {
    IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    ProcessType processType = getProcessType(item);
    boolean modified = false;
    if (processType != null) {
        for (Object obj : processType.getNode()) {
            NodeType nodeType = (NodeType) obj;
            if (nodeType.getComponentName().startsWith("tXMLMap")) {
                XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
                EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
                EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
                boolean hasDocumentInTheMainInputTable = false;
                for (InputXmlTree inputTable : inputTables) {
                    if (!(inputTable.isLookup())) {
                        for (TreeNode inputEntry : inputTable.getNodes()) {
                            if ("id_Document".equals(inputEntry.getType())) {
                                hasDocumentInTheMainInputTable = true;
                            }
                        }
                    }
                }
                if (hasDocumentInTheMainInputTable) {
                    for (OutputXmlTree outputTable : outputTables) {
                        for (TreeNode outputEntry : outputTable.getNodes()) {
                            if ("id_Document".equals(outputEntry.getType())) {
                                if (!outputTable.isAllInOne()) {
                                    outputTable.setAllInOne(true);
                                    modified = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    try {
        if (modified) {
            factory.save(item, true);
            return ExecutionResult.SUCCESS_WITH_ALERT;
        } else {
            return ExecutionResult.SUCCESS_NO_ALERT;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 24 with OutputXmlTree

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

the class SetLoopAction method run.

@Override
public void run() {
    TreeNode model = (TreeNode) nodePart.getModel();
    TreeNode docRoot = XmlMapUtil.getTreeNodeRoot(model);
    AbstractInOutTree abstractTree = (AbstractInOutTree) docRoot.eContainer();
    boolean isLookup = abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
    // remove old group
    if (model instanceof OutputTreeNode) {
        OutputTreeNode outputNode = (OutputTreeNode) model;
        if (docRoot != null) {
            XmlMapUtil.cleanSubGroup(outputNode);
            List<TreeNode> newLoopUpGroups = new ArrayList<TreeNode>();
            findUpGroupNode(newLoopUpGroups, outputNode);
            // clean all groups except the ancestor of new loop
            XmlMapUtil.cleanSubGroup(docRoot, newLoopUpGroups);
            // reset the group in case some element ancestor of loop element are not group but under the group
            if (!newLoopUpGroups.isEmpty()) {
                TreeNode rootGroup = newLoopUpGroups.get(newLoopUpGroups.size() - 1);
                upsetGroup(outputNode, rootGroup);
            }
        }
    }
    if (!isLookup) {
        // TDI-20147
        List<TreeNode> loopNodes = new ArrayList<TreeNode>();
        checkSubElementIsLoop(model, loopNodes);
        checkParentElementIsLoop(model, loopNodes);
        if (!loopNodes.isEmpty()) {
            if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.getString("SetLoopAction.cleanSubLoopTitle"), Messages.getString("SetLoopAction.cleanSubLoopMessages"))) {
            } else {
                return;
            }
        }
        for (TreeNode treeNode : loopNodes) {
            treeNode.setLoop(false);
        }
        model.setLoop(true);
        XmlMapUtil.clearMainNode(model);
        XmlMapUtil.upsetMainNode(model);
        abstractTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(abstractTree));
        if (input) {
            // check if child is mapped to output remove the old loop in output node
            XmlMapUtil.removeloopInOutputTree(mapperManager, loopNodes);
        // disable the function to add sourceloop into InputLoopNodesTable automatically
        // add input loopNodes to InputLoopNodesTable
        // addInputLoopNodesToOutput(model, model);
        } else {
            // clean the InputLoopNodesTable for the old loops
            InputXmlTree mainInput = mapperManager.getMainInputTree();
            XmlMapUtil.removeLoopTableForOutput((OutputXmlTree) abstractTree, loopNodes, mainInput == null ? false : mainInput.isMultiLoops());
        }
    } else {
        if (docRoot != null) {
            cleanSubLoop(docRoot);
        }
        model.setLoop(true);
        XmlMapUtil.clearMainNode(docRoot);
        XmlMapUtil.upsetMainNode(model);
    }
    if (abstractTree != null) {
        mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
        mapperManager.getMapperUI().updateStatusBar();
    }
}
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) 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 25 with OutputXmlTree

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

the class SetAggregateAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    Object s = getSelectedObjects().get(0);
    if (s instanceof List && !((List) s).isEmpty()) {
        List selectedarts = (List) s;
        Object obj = selectedarts.get(selectedarts.size() - 1);
        if (obj instanceof OutputTreeNodeEditPart) {
            nodePart = (OutputTreeNodeEditPart) obj;
            OutputTreeNode model = (OutputTreeNode) nodePart.getModel();
            // root can't be aggregate
            if (NodeType.NAME_SPACE.equals(model.getNodeType()) || !(model.eContainer() instanceof OutputTreeNode) || model.isChoice() || model.isSubstitution()) {
                return false;
            }
            if (!XmlMapUtil.isExpressionEditable(model)) {
                return false;
            }
            boolean isInputMultiLoops = false;
            if (mapperManager.getMainInputTree() != null && mapperManager.getMainInputTree().isMultiLoops()) {
                isInputMultiLoops = true;
            }
            AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(model);
            if (abstractTree instanceof OutputXmlTree) {
                OutputXmlTree outputTree = ((OutputXmlTree) abstractTree);
                if (outputTree.isAllInOne()) {
                    return false;
                }
                // fixed for TDI-20808 ,disable group and aggregate for 501
                if (isInputMultiLoops && outputTree.isMultiLoops()) {
                    return false;
                }
            }
            if (!model.isAggregate()) {
                setText("As aggregate element");
            } else {
                setText("Remove aggregate element");
            }
        } else {
            return false;
        }
    }
    return true;
}
Also used : AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) List(java.util.List) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

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