Search in sources :

Example 26 with ConnectionType

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

the class RenameFieldNameFortLineChart method searchSourceComponents.

// search all components that tLineChart linked directly or indirectly
private void searchSourceComponents(Item item) {
    ProcessType processType = getProcessType(item);
    for (Object o : processType.getConnection()) {
        if (o instanceof ConnectionType) {
            ConnectionType currentConnection = (ConnectionType) o;
            String connectorName = currentConnection.getConnectorName();
            if (listComponent.contains(currentConnection.getTarget())) {
                String sourceComponentName = currentConnection.getSource();
                if (!"ITERATE".equals(connectorName) && !"SUBJOB_OK".equals(connectorName) && !"SUBJOB_ERROR".equals(connectorName) && !"COMPONENT_OK".equals(connectorName) && !"COMPONENT_ERROR".equals(connectorName) && !"RUN_IF".equals(connectorName)) {
                    if (!listSourceComponent.contains(sourceComponentName)) {
                        listSourceComponent.add(sourceComponentName);
                    }
                    if (!listComponent.contains(sourceComponentName)) {
                        listComponent.add(sourceComponentName);
                        searchSourceComponents(item);
                    }
                }
            }
        }
    }
// end search
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)

Example 27 with ConnectionType

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

the class RenameConnectionNameofSalesforceOutput method renameConnections.

private void renameConnections(Item item, ProcessType processType) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    for (Object o : processType.getConnection()) {
        ConnectionType currentConnection = (ConnectionType) o;
        if ("FLOW".equals(currentConnection.getConnectorName())) {
            //$NON-NLS-1$
            String nodeUniqueName = currentConnection.getSource();
            for (Object n : processType.getNode()) {
                NodeType node = (NodeType) n;
                if ("tSalesforceOutput".equals(node.getComponentName())) {
                    for (Object e : node.getElementParameter()) {
                        ElementParameterType p = (ElementParameterType) e;
                        if ("UNIQUE_NAME".equals(p.getName()) && nodeUniqueName.equals(p.getValue())) {
                            //$NON-NLS-1$
                            //$NON-NLS-1$
                            currentConnection.setConnectorName("MAIN");
                            modified = true;
                        }
                    }
                }
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 28 with ConnectionType

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

the class RenameConnectionThenRunToOnSubjobOkTask method renameConnections.

/**
     * yzhang Comment method "renameConnections".
     * 
     * @param item
     * @param processType 
     * @throws PersistenceException
     */
private void renameConnections(Item item, ProcessType processType) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    for (Object o : processType.getConnection()) {
        ConnectionType currentConnection = (ConnectionType) o;
        if (currentConnection.getConnectorName().equals("THEN_RUN")) {
            //$NON-NLS-1$
            currentConnection.setConnectorName(EConnectionType.ON_SUBJOB_OK.getName());
            currentConnection.setLabel(EConnectionType.ON_SUBJOB_OK.getDefaultLinkName());
            currentConnection.setLineStyle(EConnectionType.ON_SUBJOB_OK.getId());
            modified = true;
        }
    }
    if (modified) {
        factory.save(item, true);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 29 with ConnectionType

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

the class MoveStartsLinkFromPartitionerToDepartitioner method replaceConnections.

public boolean replaceConnections(Item item) throws PersistenceException {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return false;
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean replaceDone = false;
    boolean modified = false;
    for (Object o : processType.getConnection()) {
        ConnectionType currentConnection = (ConnectionType) o;
        if (currentConnection.getConnectorName() != null && STARTS_CONNECTOR_NAME.equals(currentConnection.getConnectorName())) {
            String source = currentConnection.getSource();
            String target = currentConnection.getTarget();
            NodeType recollectorNode = null;
            NodeType departitionerNode = null;
            NodeType partitionerNode = null;
            for (Object obj : processType.getNode()) {
                NodeType currentNode = (NodeType) obj;
                if (currentNode.getComponentName().equals("tPartitioner") && source.equals(ComponentUtilities.getNodeUniqueName(currentNode))) {
                    partitionerNode = currentNode;
                } else if (currentNode.getComponentName().equals("tRecollector") && target.equals(ComponentUtilities.getNodeUniqueName(currentNode))) {
                    recollectorNode = currentNode;
                }
            }
            if (recollectorNode != null && partitionerNode != null) {
                //know we need to migrate this one.
                ElementParameterType linkedDepartitioner = ComponentUtilities.getNodeProperty(recollectorNode, "DEPART_COMPONENT");
                currentConnection.setSource(linkedDepartitioner.getValue());
                modified = true;
            }
        }
    }
    if (modified) {
        factory.save(item, true);
        replaceDone = true;
    }
    return replaceDone;
}
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) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Aggregations

ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)29 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)14 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)13 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)13 EConnectionType (org.talend.core.model.process.EConnectionType)12 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)11 List (java.util.List)7 ArrayList (java.util.ArrayList)6 PersistenceException (org.talend.commons.exception.PersistenceException)5 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)5 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)5 HashMap (java.util.HashMap)4 Point (org.eclipse.draw2d.geometry.Point)4 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)4 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)4 EList (org.eclipse.emf.common.util.EList)3 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)3 Matcher (java.util.regex.Matcher)2 MalformedPatternException (org.apache.oro.text.regex.MalformedPatternException)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2