Search in sources :

Example 31 with ProxyRepositoryFactory

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

the class RenameCustomerColumnOftGenKey method changeCustomerColumn.

private void changeCustomerColumn(Item item) throws PersistenceException {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return;
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    for (Object o : processType.getNode()) {
        NodeType node = (NodeType) o;
        for (Object o2 : node.getMetadata()) {
            MetadataType metadata = (MetadataType) o2;
            for (Object o3 : metadata.getColumn()) {
                ColumnType column = (ColumnType) o3;
                if ("T_WINDOW_KEY".equals(column.getName())) {
                    column.setName("T_GEN_KEY");
                    modified = true;
                }
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Example 32 with ProxyRepositoryFactory

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

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

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

the class RenameConnectionRunErrorToComponentErrorTask method renameConnections.

/**
     * yzhang Comment method "renameConnections".
     * 
     * @param item
     * @param processType 
     */
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("RUN_ERROR")) {
            //$NON-NLS-1$
            currentConnection.setConnectorName(EConnectionType.ON_COMPONENT_ERROR.getName());
            currentConnection.setLabel(EConnectionType.ON_COMPONENT_ERROR.getDefaultLinkName());
            currentConnection.setLineStyle(EConnectionType.ON_COMPONENT_ERROR.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 35 with ProxyRepositoryFactory

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

the class RenameConnectionRunIfOkToOnComponentOkTask 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("RUN_OK")) {
            //$NON-NLS-1$
            currentConnection.setConnectorName(EConnectionType.ON_COMPONENT_OK.getName());
            currentConnection.setLabel(EConnectionType.ON_COMPONENT_OK.getDefaultLinkName());
            currentConnection.setLineStyle(EConnectionType.ON_COMPONENT_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)

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