Search in sources :

Example 26 with ProxyRepositoryFactory

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

the class AddConnectorNameInConnections method addConnectorName.

/**
     * DOC nrousseau Comment method "addConnectorName".
     * 
     * @param item
     * @return
     */
private boolean addConnectorName(Item item) throws PersistenceException {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return false;
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    for (Object o : processType.getConnection()) {
        ConnectionType currentConnection = (ConnectionType) o;
        if (currentConnection.getConnectorName() == null) {
            EConnectionType connectionType = EConnectionType.getTypeFromId(currentConnection.getLineStyle());
            currentConnection.setConnectorName(connectionType.getName());
            modified = true;
        }
    }
    if (modified) {
        factory.save(item, true);
    }
    return modified;
}
Also used : 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) EConnectionType(org.talend.core.model.process.EConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 27 with ProxyRepositoryFactory

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

the class AddDdColumnMigrationTask method removeDbColumn.

private void removeDbColumn(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 (column.getOriginalDbColumnName() != null) {
                    column.setOriginalDbColumnName(null);
                    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 28 with ProxyRepositoryFactory

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

the class QuoteWraptSSHcommandMigrationTask method wrapQuot.

private boolean wrapQuot(Item item, ProcessType processType) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    EList node = processType.getNode();
    for (Object n : node) {
        NodeType type = (NodeType) n;
        if (type.getComponentName().equals("tSSH")) {
            //$NON-NLS-1$
            EList elementParameterList = type.getElementParameter();
            for (Object elem : elementParameterList) {
                ElementParameterType elemType = (ElementParameterType) elem;
                if (elemType.getName().equals("COMMANDS")) {
                    //$NON-NLS-1$
                    EList elemValue = elemType.getElementValue();
                    for (Object eVal : elemValue) {
                        ElementValueType elemVal = (ElementValueType) eVal;
                        String originV = elemVal.getValue();
                        //$NON-NLS-1$ //$NON-NLS-2$
                        elemVal.setValue("\"" + originV + "\"");
                        modified = true;
                    }
                }
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
    return modified;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 29 with ProxyRepositoryFactory

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

the class RemoveSpaceInJobNameMigrationTask method renameJobs.

/**
     * Rename jobs if needed, remove spaces and replace them by "_". Note that this migration is only for 1.0 or 1.1 to
     * more recent version, after the 1.1 it was not possible to add some spaces.
     * 
     * @throws PersistenceException
     */
private void renameJobs(Item item) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (item.getProperty().getLabel().contains(" ")) {
        // if the job contain some spaces //$NON-NLS-1$
        //$NON-NLS-1$ //$NON-NLS-2$
        item.getProperty().setLabel(item.getProperty().getLabel().replaceAll(" ", "_"));
        factory.save(item, true);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory)

Example 30 with ProxyRepositoryFactory

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

the class MysqlOutputDBVersionForBug13250 method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
public ExecutionResult execute(Item item) {
    if (item instanceof DatabaseConnectionItem) {
        boolean modify = false;
        DatabaseConnectionItem mysqlConnItem = (DatabaseConnectionItem) item;
        if (mysqlConnItem.getConnection() instanceof DatabaseConnection) {
            DatabaseConnection mysqlConnection = (DatabaseConnection) mysqlConnItem.getConnection();
            if ("MySQL".equalsIgnoreCase(mysqlConnection.getDatabaseType())) {
                if (mysqlConnection.getDbVersionString() == null || "".equals(mysqlConnection.getDbVersionString())) {
                    mysqlConnection.setDbVersionString("MYSQL_5");
                    modify = true;
                }
            }
        }
        if (modify) {
            try {
                ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
                return ExecutionResult.SUCCESS_WITH_ALERT;
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

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