Search in sources :

Example 71 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory 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 72 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory 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 73 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory 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)

Example 74 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.

the class RenameSparkVersions method execute.

@Override
public ExecutionResult execute(Item item) {
    try {
        ProcessType processType = getProcessType(item);
        if (processType != null) {
            final ParametersType parameters = processType.getParameters();
            if (parameters != null) {
                boolean modified = false;
                EList<ElementParameterType> elementParameters = parameters.getElementParameter();
                for (int i = 0; i < elementParameters.size(); i++) {
                    ElementParameterType param = elementParameters.get(i);
                    if ("SPARK_VERSION".equals(param.getName())) {
                        //$NON-NLS-1$
                        if ("Cloudera_CDH51".equals(param.getValue())) {
                            //$NON-NLS-1$
                            //$NON-NLS-1$
                            param.setValue("Cloudera_CDH5_1");
                            modified = true;
                        }
                        if ("MAPR_410".equals(param.getValue())) {
                            //$NON-NLS-1$
                            //$NON-NLS-1$
                            param.setValue("MAPR410");
                            modified = true;
                        }
                        break;
                    }
                }
                if (modified) {
                    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                    factory.save(item, true);
                    return ExecutionResult.SUCCESS_NO_ALERT;
                }
            }
        }
    } catch (PersistenceException e) {
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.NOTHING_TO_DO;
}
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) PersistenceException(org.talend.commons.exception.PersistenceException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Aggregations

ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)74 PersistenceException (org.talend.commons.exception.PersistenceException)32 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)25 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)22 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)18 EList (org.eclipse.emf.common.util.EList)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)11 Project (org.talend.core.model.general.Project)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 BusinessException (org.talend.commons.exception.BusinessException)8 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)8 ArrayList (java.util.ArrayList)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 Path (org.eclipse.core.runtime.Path)6 EConnectionType (org.talend.core.model.process.EConnectionType)6 ConnectionItem (org.talend.core.model.properties.ConnectionItem)6 List (java.util.List)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)5