Search in sources :

Example 1 with MDMConnectionItem

use of org.talend.core.model.properties.MDMConnectionItem 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 2 with MDMConnectionItem

use of org.talend.core.model.properties.MDMConnectionItem in project tdi-studio-se by Talend.

the class ComponentChooseDialog method isMdmOutput.

private boolean isMdmOutput(RepositoryNode selectedNode, ConnectionItem connectionItem) {
    boolean isMdmOutput = false;
    if (connectionItem instanceof MDMConnectionItem) {
        MDMConnectionItem mdmItem = (MDMConnectionItem) connectionItem;
        final MDMConnection connection = (MDMConnection) mdmItem.getConnection();
        final EList<Concept> schemas = connection.getSchemas();
        final Object properties = selectedNode.getProperties(EProperties.LABEL);
        Concept concept = null;
        for (int i = 0; i < schemas.size(); i++) {
            final String label = schemas.get(i).getLabel();
            if (label != null && label.equals(properties)) {
                concept = schemas.get(i);
                break;
            }
        }
        if (concept != null && MdmConceptType.OUTPUT.equals(concept.getConceptType())) {
            isMdmOutput = true;
        }
    }
    return isMdmOutput;
}
Also used : Concept(org.talend.core.model.metadata.builder.connection.Concept) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with MDMConnectionItem

use of org.talend.core.model.properties.MDMConnectionItem in project tdi-studio-se by Talend.

the class TalendDndHelper method filterNeededComponents.

public static List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    if (name == null) {
        return neededComponents;
    }
    String productNameWanted = filterProductNameWanted(name, item);
    boolean hl7Related = false;
    boolean hl7Output = false;
    if (item instanceof HL7ConnectionItem) {
        hl7Related = true;
        EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
        if (list != null && list.size() > 0) {
            hl7Output = true;
        }
    }
    // for mdm
    MdmConceptType mdmType = null;
    if (item instanceof MDMConnectionItem) {
        MDMConnectionItem mdmItem = (MDMConnectionItem) item;
        if (seletetedNode != null && seletetedNode.getObject() instanceof MetadataTableRepositoryObject) {
            MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) seletetedNode.getObject();
            if (mdmItem.getConnection() instanceof MDMConnection) {
                MDMConnection connection = (MDMConnection) mdmItem.getConnection();
                for (Object obj : connection.getSchemas()) {
                    if (obj instanceof Concept && object.getLabel().equals(((Concept) obj).getLabel())) {
                        mdmType = ((Concept) obj).getConceptType();
                    }
                }
            }
        }
    }
    Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
    EmfComponent emfComponent = null;
    for (IComponent component : components) {
        if (component instanceof EmfComponent) {
            emfComponent = (EmfComponent) component;
            String componentProductname = emfComponent.getRepositoryType();
            boolean value = true;
            if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
                if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
                    value = false;
                }
            }
            if (hl7Output && !component.getName().equals("tHL7Output")) {
                //$NON-NLS-1$
                value = false;
            } else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
                //$NON-NLS-N$ bug15632
                value = false;
            }
            boolean flag = filterComponent(component, name, type);
            if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
                Pattern pattern = Pattern.compile("^.*oracle.*$", Pattern.CASE_INSENSITIVE);
                if (pattern.matcher(name.getDBType()).matches() && (emfComponent.getName().equals("tAmazonOracleInput") || emfComponent.getName().equals("tAmazonOracleOutput"))) {
                    continue;
                }
                if (item instanceof MDMConnectionItem) {
                    if (MdmConceptType.INPUT.equals(mdmType) && emfComponent.getName().endsWith(INPUT)) {
                        neededComponents.add(emfComponent);
                    } else if (MdmConceptType.OUTPUT.equals(mdmType) && emfComponent.getName().endsWith(OUTPUT)) {
                        neededComponents.add(emfComponent);
                    } else if (MdmConceptType.RECEIVE.equals(mdmType) && emfComponent.getName().endsWith(RECEIVE)) {
                        neededComponents.add(emfComponent);
                    }
                } else {
                    neededComponents.add(emfComponent);
                }
            }
        }
    }
    return sortFilteredComponnents(item, seletetedNode, type, neededComponents);
}
Also used : Concept(org.talend.core.model.metadata.builder.connection.Concept) Pattern(java.util.regex.Pattern) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) EList(org.eclipse.emf.common.util.EList) MdmConceptType(org.talend.core.model.metadata.builder.connection.MdmConceptType) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) EmfComponent(org.talend.designer.core.model.components.EmfComponent) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection)

Example 4 with MDMConnectionItem

use of org.talend.core.model.properties.MDMConnectionItem in project tdi-studio-se by Talend.

the class MdmConceptMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (item instanceof MDMConnectionItem) {
        boolean modify = false;
        MDMConnectionItem mdmConnItem = (MDMConnectionItem) item;
        if (mdmConnItem.getConnection() instanceof MDMConnection) {
            MDMConnection mdmConnection = (MDMConnection) mdmConnItem.getConnection();
            final EList<Concept> schemas = mdmConnection.getSchemas();
            for (Concept concept : schemas) {
                if (!concept.isInputModel()) {
                    concept.setConceptType(MdmConceptType.OUTPUT);
                    modify = true;
                }
            }
        }
        if (modify) {
            try {
                ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
                return ExecutionResult.SUCCESS_WITH_ALERT;
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Concept(org.talend.core.model.metadata.builder.connection.Concept) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection)

Example 5 with MDMConnectionItem

use of org.talend.core.model.properties.MDMConnectionItem in project tdi-studio-se by Talend.

the class RepositoryXmlSelectionDialog method isSelectionValid.

@Override
protected boolean isSelectionValid(SelectionChangedEvent event) {
    boolean highlightOKButton = true;
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    if (selection == null || selection.size() != 1) {
        highlightOKButton = false;
    } else {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        if (node.getObject() == null || node.getObject().getProperty() == null) {
            return false;
        }
        if (node.getObject() instanceof Folder) {
            return false;
        }
        Item item = node.getObject().getProperty().getItem();
        if (item instanceof XmlFileConnectionItem) {
            ERepositoryObjectType t = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
            if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
                highlightOKButton = false;
            }
        } else if (item instanceof MDMConnectionItem) {
            if (node.getObject() instanceof MetadataTable) {
                highlightOKButton = true;
                updateErrorMessage(null);
            } else {
                highlightOKButton = false;
                updateErrorMessage(Messages.getString("RepositoryXmlSelectionDialog.UpdateErrorMessage"));
            }
        }
    }
    return highlightOKButton;
}
Also used : Item(org.talend.core.model.properties.Item) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) MetadataTable(org.talend.core.model.metadata.MetadataTable) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) RepositoryNode(org.talend.repository.model.RepositoryNode) Folder(org.talend.core.model.repository.Folder) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

MDMConnectionItem (org.talend.core.model.properties.MDMConnectionItem)5 MDMConnection (org.talend.core.model.metadata.builder.connection.MDMConnection)4 Concept (org.talend.core.model.metadata.builder.connection.Concept)3 Item (org.talend.core.model.properties.Item)2 XmlFileConnectionItem (org.talend.core.model.properties.XmlFileConnectionItem)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Pattern (java.util.regex.Pattern)1 Point (org.eclipse.draw2d.geometry.Point)1 EList (org.eclipse.emf.common.util.EList)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 IComponent (org.talend.core.model.components.IComponent)1 MetadataTable (org.talend.core.model.metadata.MetadataTable)1 HL7Connection (org.talend.core.model.metadata.builder.connection.HL7Connection)1 MdmConceptType (org.talend.core.model.metadata.builder.connection.MdmConceptType)1 XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)1