Search in sources :

Example 6 with ElementParameterTypeImpl

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

the class ChangeMysqlVersionForProjectSetting 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 ElementParameterTypeImpl) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("ON_DATABASE_FLAG".equals(name) && !Boolean.valueOf(parameterType.getValue())) {
                    //$NON-NLS-1$
                    break;
                }
                if ("DB_VERSION".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
    }
    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) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("FROM_DATABASE_FLAG_IMPLICIT_CONTEXT".equals(name) && !Boolean.valueOf(parameterType.getValue())) {
                    //$NON-NLS-1$
                    break;
                }
                if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
    }
    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 : ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings) 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 7 with ElementParameterTypeImpl

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

the class ChangeOracleVersionForProjectSetting 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 ElementParameterTypeImpl) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("ON_DATABASE_FLAG".equals(name) && !Boolean.valueOf(parameterType.getValue())) {
                    //$NON-NLS-1$
                    break;
                }
                if ("DB_VERSION".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
    }
    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) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("FROM_DATABASE_FLAG_IMPLICIT_CONTEXT".equals(name) && !Boolean.valueOf(parameterType.getValue())) {
                    //$NON-NLS-1$
                    break;
                }
                if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
    }
    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 : ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings) 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 8 with ElementParameterTypeImpl

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

the class UpdateJobSettingsForOracleMigrationTask2 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 9 with ElementParameterTypeImpl

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

the class UpdateJobSettingsForPostgresMigrationTask method updateValueWhenUseImplicit.

private boolean updateValueWhenUseImplicit(EList elementParameter) {
    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) && parameterType.getValue().startsWith("tPostgresql")) {
                for (int j = 0; j < elementParameter.size(); j++) {
                    final Object innerObject = elementParameter.get(j);
                    if (innerObject instanceof ElementParameterTypeImpl) {
                        ElementParameterTypeImpl innerParameterType = (ElementParameterTypeImpl) innerObject;
                        String innerName = innerParameterType.getName();
                        if ("DB_VERSION_IMPLICIT_CONTEXT".equals(innerName)) {
                            String value = innerParameterType.getValue();
                            if (value.equals(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue()) || value.equals(EDatabaseVersion4Drivers.PSQL_V9_X.getVersionValue())) {
                            // do nothing
                            } else {
                                innerParameterType.setValue(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue());
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 10 with ElementParameterTypeImpl

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

the class UpdateJobSettingsForPostgresMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType.getParameters() != null) {
        @SuppressWarnings("rawtypes") EList elementParameter = processType.getParameters().getElementParameter();
        boolean modified = false;
        boolean havePostgresStat = false, havePostgresImplicit = 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 ("FROM_DATABASE_FLAG_IMPLICIT_CONTEXT".equals(name) && parameterType.getValue().equalsIgnoreCase("true")) {
                    modified = updateValueWhenUseImplicit(elementParameter) || modified;
                }
                if ("DB_TYPE".equals(name) && parameterType.getValue().startsWith("tPostgresql")) {
                    //$NON-NLS-1$
                    modified = updateJarValue(elementParameter) || 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)

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