Search in sources :

Example 16 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class RenamePasswordParaForLdapMigrationTask method renamePasswordName.

private void renamePasswordName(Item item) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    ProcessType processType = getProcessType(item);
    for (Object object : processType.getNode()) {
        if (object instanceof NodeType) {
            NodeType currentNode = (NodeType) object;
            if (currentNode.getComponentName().startsWith("tLDAP")) {
                //$NON-NLS-1$
                for (Object o : currentNode.getElementParameter()) {
                    ElementParameterType para = (ElementParameterType) o;
                    if ("PASSWD".equals(para.getName())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        para.setName("PASS");
                        modified = true;
                        break;
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            factory.save(item, true);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 17 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class RenameSchemaParameterForMSSqlConnectionMigrationTask method renamePasswordName.

private void renamePasswordName(Item item) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    ProcessType processType = getProcessType(item);
    for (Object object : processType.getNode()) {
        if (object instanceof NodeType) {
            NodeType currentNode = (NodeType) object;
            if (currentNode.getComponentName().startsWith("tMSSqlConnection")) {
                //$NON-NLS-1$
                for (Object o : currentNode.getElementParameter()) {
                    ElementParameterType para = (ElementParameterType) o;
                    if ("DB_SCHEMA".equals(para.getName())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        para.setName("SCHEMA_DB");
                        modified = true;
                        break;
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            factory.save(item, true);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 18 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.

the class AbstractRouteItemMigrationTask method findComponentNodes.

private List<NodeType> findComponentNodes(CamelProcessItem item, String search, boolean isRegex) {
    if (search == null) {
        throw new RuntimeException("Can't search component node by \"null\" in " + this.getClass());
    }
    ProcessType processType = item.getProcess();
    if (processType == null) {
        return Collections.emptyList();
    }
    List<NodeType> returnList = new ArrayList<NodeType>();
    for (Object o : processType.getNode()) {
        if (o instanceof NodeType) {
            NodeType currentNode = (NodeType) o;
            String componentName = currentNode.getComponentName();
            if (isRegex) {
                if (componentName.matches(search)) {
                    returnList.add(currentNode);
                }
            } else {
                if (componentName.equals(search)) {
                    returnList.add(currentNode);
                }
            }
        }
    }
    return returnList;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) CamelRepositoryNodeType(org.talend.camel.model.CamelRepositoryNodeType) ArrayList(java.util.ArrayList)

Example 19 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.

the class DisconnectErroHandlerMigrationTask method findAllErrorHandlerIds.

private List<String> findAllErrorHandlerIds(ProcessType pt) {
    List<String> errorHandlers = new ArrayList<String>();
    for (Object o : pt.getNode()) {
        if (!(o instanceof NodeType)) {
            continue;
        }
        NodeType nt = (NodeType) o;
        if (!"cErrorHandler".equals(nt.getComponentName())) {
            continue;
        }
        EList elementParameter = nt.getElementParameter();
        for (Object e : elementParameter) {
            if (!(e instanceof ElementParameterType)) {
                continue;
            }
            ElementParameterType ept = (ElementParameterType) e;
            if ("UNIQUE_NAME".equals(ept.getName())) {
                errorHandlers.add(ept.getValue());
            }
        }
    }
    return errorHandlers;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) ArrayList(java.util.ArrayList)

Example 20 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.

the class ConsumerFaultResponseMigrationTask method addMoreFaultResponseMessage.

private void addMoreFaultResponseMessage(Item item) throws PersistenceException {
    if (item instanceof ProcessItem) {
        ProcessType processType = ((ProcessItem) item).getProcess();
        for (Object o : processType.getNode()) {
            if (o instanceof NodeType) {
                NodeType currentNode = (NodeType) o;
                if ("tESBConsumer".equals(currentNode.getComponentName())) {
                    Iterator<?> iterator = currentNode.getMetadata().iterator();
                    while (iterator.hasNext()) {
                        MetadataType metadataType = (MetadataType) iterator.next();
                        if ("FAULT".equals(metadataType.getConnector())) {
                            EList<?> column = metadataType.getColumn();
                            addColumn(column, faultActor);
                            addColumn(column, faultCode);
                            addColumn(column, faultNode);
                            addColumn(column, faultRole);
                        }
                    }
                }
            }
        }
        FACTORY.save(item, true);
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Aggregations

NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)190 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)152 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)126 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)111 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)109 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)108 PersistenceException (org.talend.commons.exception.PersistenceException)91 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ProcessItem (org.talend.core.model.properties.ProcessItem)21 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)21 List (java.util.List)20 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)17 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)13 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)13 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)9 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)8 IOException (java.io.IOException)7