Search in sources :

Example 1 with ElementParameterTypeImpl

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

the class EncryptPasswordInProjectSettingsMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
     */
@Override
public ExecutionResult execute(Project project) {
    org.talend.core.model.properties.Project emfProject = project.getEmfProject();
    StatAndLogsSettings statAndLogs = emfProject.getStatAndLogsSettings();
    boolean modified = false;
    if (statAndLogs != null && statAndLogs.getParameters() != null) {
        ParametersType parameters = statAndLogs.getParameters();
        List elementParameter = parameters.getElementParameter();
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterType) {
                ElementParameterType parameterType = (ElementParameterType) object;
                String name = parameterType.getName();
                // variable name used for Stat&Logs
                if ("PASS".equals(name)) {
                    //$NON-NLS-1$
                    try {
                        if (encryptValueIfNeeded(parameterType)) {
                            modified = true;
                        }
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
    }
    ImplicitContextSettings implicitContext = emfProject.getImplicitContextSettings();
    if (implicitContext != null && implicitContext.getParameters() != null) {
        ParametersType parameters = implicitContext.getParameters();
        List elementParameter = parameters.getElementParameter();
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterType parameterType = (ElementParameterType) object;
                String name = parameterType.getName();
                // variable name used for implicit context
                if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    try {
                        if (encryptValueIfNeeded(parameterType)) {
                            modified = true;
                        }
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
            prf.saveProject(project);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) PersistenceException(org.talend.commons.exception.PersistenceException) List(java.util.List) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 2 with ElementParameterTypeImpl

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

the class UnifyPasswordEncryption4ProjectSettingsMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
     */
@Override
public ExecutionResult execute(Project project) {
    org.talend.core.model.properties.Project emfProject = project.getEmfProject();
    StatAndLogsSettings statAndLogs = emfProject.getStatAndLogsSettings();
    boolean modified = false;
    if (statAndLogs != null && statAndLogs.getParameters() != null) {
        ParametersType parameters = statAndLogs.getParameters();
        List elementParameter = parameters.getElementParameter();
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterType) {
                ElementParameterType parameterType = (ElementParameterType) object;
                String name = parameterType.getName();
                // variable name used for Stat&Logs
                if ("PASS".equals(name)) {
                    //$NON-NLS-1$
                    parameterType.setField(EParameterFieldType.PASSWORD.getName());
                    try {
                        if (reencryptValueIfNeeded(parameterType)) {
                            modified = true;
                        }
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
    }
    ImplicitContextSettings implicitContext = emfProject.getImplicitContextSettings();
    if (implicitContext != null && implicitContext.getParameters() != null) {
        ParametersType parameters = implicitContext.getParameters();
        List elementParameter = parameters.getElementParameter();
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterType parameterType = (ElementParameterType) object;
                String name = parameterType.getName();
                // variable name used for implicit context
                if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    parameterType.setField(EParameterFieldType.PASSWORD.getName());
                    try {
                        if (reencryptValueIfNeeded(parameterType)) {
                            modified = true;
                        }
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            factory.saveProject(project);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) PersistenceException(org.talend.commons.exception.PersistenceException) List(java.util.List) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 3 with ElementParameterTypeImpl

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

the class UpdateJobSettingsForMysqlMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType.getParameters() != null) {
        @SuppressWarnings("rawtypes") EList elementParameter = processType.getParameters().getElementParameter();
        boolean modified = false;
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
                if ("DB_VERSION".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
        if (modified) {
            try {
                FACTORY.save(item, true);
                return ExecutionResult.SUCCESS_NO_ALERT;
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) EList(org.eclipse.emf.common.util.EList) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 4 with ElementParameterTypeImpl

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

the class UpdateJobSettingsForOracleMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType.getParameters() != null) {
        @SuppressWarnings("rawtypes") EList elementParameter = processType.getParameters().getElementParameter();
        boolean modified = false;
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
                if ("DB_VERSION".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
        if (modified) {
            try {
                FACTORY.save(item, true);
                return ExecutionResult.SUCCESS_NO_ALERT;
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) EList(org.eclipse.emf.common.util.EList) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 5 with ElementParameterTypeImpl

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

the class AddConnectionVersionForJobsettingMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType.getParameters() != null) {
        EList elementParameter = processType.getParameters().getElementParameter();
        String dbTypeImplicit = "";
        String dbTypeStatsLog = "";
        String dbImplicitVersionRepository = "";
        String dbStasLogVersionRepository = "";
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("DB_TYPE_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-N$
                    dbTypeImplicit = parameterType.getValue();
                }
                if ("DB_TYPE".equals(name)) {
                    //$NON-NLS-N$
                    dbTypeStatsLog = parameterType.getValue();
                }
                if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-N$
                    dbImplicitVersionRepository = parameterType.getValue();
                }
                if ("DB_VERSION".equals(name)) {
                    //$NON-NLS-N$
                    dbStasLogVersionRepository = parameterType.getValue();
                }
            }
        }
        boolean implicitSame = sameDB(dbTypeImplicit, dbImplicitVersionRepository);
        boolean stasLogSame = sameDB(dbTypeStatsLog, dbStasLogVersionRepository);
        if (!implicitSame) {
            if (dbTypeImplicit.toUpperCase().contains("MYSQL")) {
                //$NON-NLS-N$
                //$NON-NLS-N$//$NON-NLS-N$
                setParameterValue(elementParameter, "DB_VERSION_IMPLICIT_CONTEXT", "mysql-connector-java-5.1.0-bin.jar");
            } else if (dbTypeImplicit.toUpperCase().contains("ORACLE")) {
                //$NON-NLS-N$
                //$NON-NLS-N$//$NON-NLS-N$
                setParameterValue(elementParameter, "DB_VERSION_IMPLICIT_CONTEXT", "ojdbc14-10g.jar");
            } else if (dbTypeImplicit.toUpperCase().contains("ACCESS")) {
                //$NON-NLS-N$
                //$NON-NLS-N$//$NON-NLS-N$
                setParameterValue(elementParameter, "DB_VERSION_IMPLICIT_CONTEXT", "ACCESS_2003");
            }
        }
        if (!stasLogSame) {
            if (dbTypeStatsLog.toUpperCase().contains("MYSQL")) {
                //$NON-NLS-N$
                //$NON-NLS-N$//$NON-NLS-N$
                setParameterValue(elementParameter, "DB_VERSION", "mysql-connector-java-5.1.0-bin.jar");
            } else if (dbTypeStatsLog.toUpperCase().contains("ORACLE")) {
                //$NON-NLS-N$
                //$NON-NLS-N$//$NON-NLS-N$
                setParameterValue(elementParameter, "DB_VERSION", "ojdbc14-10g.jar");
            } else if (dbTypeStatsLog.toUpperCase().contains("ACCESS")) {
                //$NON-NLS-N$
                //$NON-NLS-N$//$NON-NLS-N$
                setParameterValue(elementParameter, "DB_VERSION", "ACCESS_2007");
            }
        }
        if (!implicitSame || !stasLogSame) {
            try {
                FACTORY.save(item, true);
                return ExecutionResult.SUCCESS_NO_ALERT;
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) EList(org.eclipse.emf.common.util.EList) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Aggregations

ElementParameterTypeImpl (org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)16 PersistenceException (org.talend.commons.exception.PersistenceException)11 EList (org.eclipse.emf.common.util.EList)7 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)6 List (java.util.List)5 ImplicitContextSettings (org.talend.core.model.properties.ImplicitContextSettings)5 StatAndLogsSettings (org.talend.core.model.properties.StatAndLogsSettings)5 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)5 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)5 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)1 ElementValueTypeImpl (org.talend.designer.core.model.utils.emf.talendfile.impl.ElementValueTypeImpl)1 IRepositoryService (org.talend.repository.model.IRepositoryService)1