Search in sources :

Example 91 with NodeType

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

the class UpdateCJMSProjectMigrationTask method updateJMSComponent.

/**
 * Update cJMS, add cMQConnectionFactory.
 *
 * @param item
 * @throws PersistenceException
 */
@SuppressWarnings("unchecked")
private void updateJMSComponent(Item item) throws PersistenceException {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return;
    }
    boolean modified = false;
    List<NodeType> nodes = new ArrayList<NodeType>();
    for (Object o : processType.getNode()) {
        if (o instanceof NodeType) {
            NodeType currentNode = (NodeType) o;
            if ("cJMS".equals(currentNode.getComponentName())) {
                modified = true;
                NodeType cfNode = createConnectionFactoryNode(currentNode);
                nodes.add(cfNode);
            }
        }
    }
    if (modified) {
        locateNodes(processType, nodes);
        processType.getNode().addAll(nodes);
        REPO_FACTORY.save(item, true);
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) ArrayList(java.util.ArrayList)

Example 92 with NodeType

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

the class UpdateCJMSProjectMigrationTask method locateNodes.

/**
 * Compute the location of cMQConnectionFactory Node
 *
 * @param processType
 * @param nodes
 */
private void locateNodes(ProcessType processType, List<NodeType> nodes) {
    int maxY = getMaxY(processType);
    int index = 1;
    for (NodeType node : nodes) {
        node.setPosX(100 * index);
        node.setPosY(maxY + 100);
        index++;
    }
}
Also used : NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 93 with NodeType

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

the class NormalizeDataServiceJobBuildTypeMigrationTask method execute.

/*
    * (non-Javadoc)
    *
    * @see
    * org.talend.core.model.migration.AbstractDataserviceMigrationTask#execute(org
    * .talend.core.model.properties.Item)
    */
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    boolean modified = false;
    for (String name : ESB_COMPONENTS) {
        IComponentFilter filter = new NameComponentFilter(name);
        List<NodeType> c = searchComponent(processType, filter);
        if (!c.isEmpty()) {
            Object buildType = item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
            if (BUILD_TYPE_ROUTE.equals(buildType)) {
                item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_OSGI);
                try {
                    save(item);
                    modified |= true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, item, null, "Build Type", BUILD_TYPE_ROUTE, BUILD_TYPE_OSGI));
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                    return ExecutionResult.FAILURE;
                }
                return ExecutionResult.SUCCESS_NO_ALERT;
            }
        }
    }
    if (modified) {
        return ExecutionResult.SUCCESS_NO_ALERT;
    } else {
        return ExecutionResult.NOTHING_TO_DO;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder)

Example 94 with NodeType

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

the class AbstractRouteItemComponentMigrationTask method execute.

/*
	 *
	 */
/* (non-Javadoc)
	 * @see org.talend.camel.designer.migration.AbstractRouteItemMigrationTask#execute(org.talend.camel.core.model.camelProperties.CamelProcessItem)
	 */
@Override
public final ExecutionResult execute(CamelProcessItem item) {
    this.routeItem = item;
    List<NodeType> nodes = findComponentNodesRegex(item, getComponentNameRegex());
    if (nodes.isEmpty()) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        boolean needSave = false;
        for (NodeType node : nodes) {
            needSave |= execute(node);
        }
        if (needSave) {
            saveItem(item);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } else {
            return ExecutionResult.NOTHING_TO_DO;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 95 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)

Aggregations

NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)198 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)157 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)127 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)112 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)111 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)110 PersistenceException (org.talend.commons.exception.PersistenceException)93 ProcessItem (org.talend.core.model.properties.ProcessItem)25 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)21 List (java.util.List)20 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)18 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 IComponent (org.talend.core.model.components.IComponent)10 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)9 Property (org.talend.core.model.properties.Property)8