Search in sources :

Example 6 with InputXmlTree

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

Example 7 with InputXmlTree

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

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

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

the class ImportTreeFromRepository method run.

@Override
public void run() {
    targetAbsolutePath = null;
    loopNode = null;
    xpathAndOrder.clear();
    RepositoryXmlSelectionDialog reviewDialog = new RepositoryXmlSelectionDialog(shell, new String[] { "XML", "MDM" });
    if (reviewDialog.open() == Window.OK) {
        TreeNode treeNodeRoot = XmlMapUtil.getTreeNodeRoot(schemaNode);
        XmlMapUtil.detachNodeConnections(treeNodeRoot, mapperManager.getExternalData(), true);
        RepositoryNode repositoryNode = reviewDialog.getResult();
        Item item = repositoryNode.getObject().getProperty().getItem();
        String detailedMessage = "";
        try {
            if (item instanceof XmlFileConnectionItem) {
                XmlFileConnectionItem xmlitem = (XmlFileConnectionItem) item;
                XmlFileConnection connection = (XmlFileConnection) xmlitem.getConnection();
                prepareEmfTreeFromXml(connection);
            } else if (item instanceof MDMConnectionItem) {
                String selectedSchema = (String) repositoryNode.getProperties(EProperties.LABEL);
                MDMConnection connection = (MDMConnection) ((MDMConnectionItem) item).getConnection();
                prepareEmfTreeFromMdm(connection, selectedSchema);
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
            StringBuffer sb = new StringBuffer();
            sb.append(e.toString());
            sb.append("\n");
            if (e.getStackTrace() != null) {
                for (StackTraceElement trace : e.getStackTrace()) {
                    sb.append(trace.toString());
                    sb.append("\n");
                }
            }
            detailedMessage = sb.toString();
        }
        boolean childrenEmpty = false;
        if (schemaNode.getChildren().isEmpty()) {
            childrenEmpty = true;
            TreeNode rootNode = createModel();
            rootNode.setName("root");
            rootNode.setNodeType(NodeType.ELEMENT);
            rootNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
            rootNode.setXpath(XmlMapUtil.getXPath(schemaNode.getXpath(), "root", NodeType.ELEMENT));
            schemaNode.getChildren().add(rootNode);
            if (loopNode == null) {
                schemaNode.getChildren().get(0).setLoop(true);
                schemaNode.getChildren().get(0).setMain(true);
            }
        }
        if (childrenEmpty || (detailedMessage != null && !"".equals(detailedMessage))) {
            showError(detailedMessage);
        }
        AbstractInOutTree tree = null;
        if (schemaNode.eContainer() instanceof InputXmlTree) {
            XmlMapConnectionBuilder connectionBuilder = new XmlMapConnectionBuilder();
            connectionBuilder.setCheckRootNodePrefix(true);
            connectionBuilder.rebuildLinks(schemaNode, mapperManager.getExternalData());
            mapperManager.refreshTreeSchemaEditor((InputXmlTree) schemaNode.eContainer());
            // mapperManager.inputTreeSchemaBeanListModified();
            tree = (InputXmlTree) schemaNode.eContainer();
        } else if (schemaNode.eContainer() instanceof OutputXmlTree) {
            // mapperManager.outputTreeSchemaBeanListModified();
            mapperManager.refreshTreeSchemaEditor((OutputXmlTree) schemaNode.eContainer());
            tree = (OutputXmlTree) schemaNode.eContainer();
        }
        if (tree != null) {
            mapperManager.getProblemsAnalyser().checkProblems(tree);
            mapperManager.getMapperUI().updateStatusBar();
        }
    }
}
Also used : RepositoryXmlSelectionDialog(org.talend.designer.xmlmap.ui.dialog.RepositoryXmlSelectionDialog) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) Item(org.talend.core.model.properties.Item) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) XmlMapConnectionBuilder(org.talend.designer.xmlmap.util.XmlMapConnectionBuilder) FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 10 with InputXmlTree

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

the class TreeSettingDirectEditCommand method execute.

@Override
public void execute() {
    try {
        if (model instanceof InputXmlTree) {
            InputXmlTree inputTree = (InputXmlTree) model;
            if (type != null) {
                switch(type) {
                    case LOOKUP_MODEL:
                        inputTree.setLookupMode(getLookupModelByLabel((String) newValue));
                        break;
                    case MATCH_MODEL:
                        inputTree.setMatchingMode(getMatchModelByLabel((String) newValue));
                        break;
                    case JOIN_MODEL:
                        if (TreeSettingsConstant.INNER_JOIN.equals(newValue)) {
                            inputTree.setInnerJoin(true);
                        } else {
                            inputTree.setInnerJoin(false);
                        }
                        break;
                    case PERSISTENT_MODEL:
                        inputTree.setPersistent(Boolean.valueOf((String) newValue));
                        break;
                    case EXPRESSION_FILTER:
                        calculateFilterConnections(inputTree, (String) newValue);
                        inputTree.setExpressionFilter((String) newValue);
                        break;
                    default:
                        break;
                }
            }
        } else if (model instanceof OutputXmlTree) {
            OutputXmlTree outputTree = (OutputXmlTree) model;
            if (type != null) {
                switch(type) {
                    case OUTPUT_REJECT:
                        outputTree.setReject(Boolean.valueOf((String) newValue));
                        break;
                    case LOOK_UP_INNER_JOIN_REJECT:
                        outputTree.setRejectInnerJoin(Boolean.valueOf((String) newValue));
                        break;
                    case EXPRESSION_FILTER:
                        calculateFilterConnections(outputTree, (String) newValue);
                        outputTree.setExpressionFilter((String) newValue);
                        break;
                    case ALL_IN_ONE:
                        outputTree.setAllInOne(Boolean.valueOf((String) newValue));
                        break;
                    case ENABLE_EMPTY_ELEMENT:
                        outputTree.setEnableEmptyElement(Boolean.valueOf((String) newValue));
                }
            }
        }
    } catch (PatternSyntaxException ex) {
    // Syntax error in the regular expression
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Aggregations

InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)52 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)34 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)28 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)18 ArrayList (java.util.ArrayList)17 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)12 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)9 List (java.util.List)5 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)5 IConnection (org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)4 HashMap (java.util.HashMap)3 Point (org.eclipse.draw2d.geometry.Point)3 EList (org.eclipse.emf.common.util.EList)3 ExpressionFigure (org.talend.designer.gefabstractmap.figures.ExpressionFigure)3 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)3 Iterator (java.util.Iterator)2