Search in sources :

Example 21 with ParametersType

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

the class MigrateDeprecatedHadoopDistribution1 method changeMRConfiguration.

private void changeMRConfiguration(ProcessType processType, Item item) throws PersistenceException {
    boolean modified = false;
    final ParametersType parameters = processType.getParameters();
    if (parameters != null) {
        EList elementParameters = parameters.getElementParameter();
        for (int i = 0; i < elementParameters.size(); i++) {
            ElementParameterType param = (ElementParameterType) elementParameters.get(i);
            if ("MR_VERSION".equals(param.getName())) {
                //$NON-NLS-1$ 
                if (values.containsKey(param.getValue())) {
                    param.setValue(values.get(param.getValue()));
                    modified = true;
                }
                break;
            }
        }
    }
    if (modified) {
        ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        factory.save(item, true);
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 22 with ParametersType

use of org.talend.designer.core.model.utils.emf.talendfile.ParametersType 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)

Example 23 with ParametersType

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

the class ChangeDefaultSparkSerializer method changeSparkConfiguration.

private void changeSparkConfiguration(ProcessType processType, Item item) throws PersistenceException {
    boolean modified = false;
    final ParametersType parameters = processType.getParameters();
    if (parameters != null) {
        EList elementParameters = parameters.getElementParameter();
        ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType();
        //$NON-NLS-1$
        property.setName("CUSTOMIZE_SPARK_SERIALIZER");
        //$NON-NLS-1$
        property.setField("CHECK");
        //$NON-NLS-1$
        property.setValue("true");
        elementParameters.add(property);
        property = TalendFileFactory.eINSTANCE.createElementParameterType();
        //$NON-NLS-1$
        property.setName("SPARK_SERIALIZER");
        //$NON-NLS-1$
        property.setField("TEXT");
        //$NON-NLS-1$
        property.setValue("\"org.apache.spark.serializer.JavaSerializer\"");
        elementParameters.add(property);
        for (int i = 0; i < elementParameters.size(); i++) {
            ElementParameterType param = (ElementParameterType) elementParameters.get(i);
            if ("ADVANCED_SETTINGS_CHECK".equals(param.getName())) {
                //$NON-NLS-1$ 
                //$NON-NLS-1$
                param.setValue("true");
                modified = true;
                break;
            }
        }
    }
    if (modified) {
        ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        factory.save(item, true);
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 24 with ParametersType

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

the class UnifyPasswordEncryption4ParametersInJobMigrationTask method checkJobsettintsParameter.

protected boolean checkJobsettintsParameter(Item item, ProcessType processType) throws Exception {
    boolean modified = false;
    ParametersType parameters = processType.getParameters();
    for (Object p : parameters.getElementParameter()) {
        if (p instanceof ElementParameterType) {
            ElementParameterType param = (ElementParameterType) p;
            // variable name used for Stat&Logs
            if ("PASS".equals(param.getName())) {
                //$NON-NLS-1$
                param.setField(EParameterFieldType.PASSWORD.getName());
                if (reencryptValueIfNeeded(param)) {
                    modified = true;
                }
            }
            // variable name used for implicit context
            if ("PASS_IMPLICIT_CONTEXT".equals(param.getName())) {
                //$NON-NLS-1$
                param.setField(EParameterFieldType.PASSWORD.getName());
                if (reencryptValueIfNeeded(param)) {
                    modified = true;
                }
            }
        }
    }
    return modified;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 25 with ParametersType

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

the class RemoveUseHadoopPropertiesFortMRConfiguration method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType != null) {
        boolean modified = false;
        final ParametersType parameters = processType.getParameters();
        if (parameters != null) {
            EList elementParameters = parameters.getElementParameter();
            for (int i = 0; i < elementParameters.size(); i++) {
                ElementParameterType param = (ElementParameterType) elementParameters.get(i);
                if ("USE_HADOOP_PROPERTIES".equals(param.getName())) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    if ("false".equalsIgnoreCase(param.getValue())) {
                        for (int j = 0; j < elementParameters.size(); j++) {
                            ElementParameterType hadoopProps = (ElementParameterType) elementParameters.get(j);
                            if ("HADOOP_ADVANCED_PROPERTIES".equalsIgnoreCase(hadoopProps.getName())) {
                                hadoopProps.getElementValue().clear();
                            }
                        }
                    }
                    elementParameters.remove(param);
                    modified = true;
                    break;
                }
            }
        }
        if (modified) {
            try {
                ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
            return ExecutionResult.SUCCESS_NO_ALERT;
        }
    }
    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) EList(org.eclipse.emf.common.util.EList) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Aggregations

ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)37 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)15 ProcessItem (org.talend.core.model.properties.ProcessItem)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)10 EList (org.eclipse.emf.common.util.EList)9 List (java.util.List)8 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)8 RoutinesParameterType (org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType)7 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 ImplicitContextSettings (org.talend.core.model.properties.ImplicitContextSettings)6 Property (org.talend.core.model.properties.Property)6 StatAndLogsSettings (org.talend.core.model.properties.StatAndLogsSettings)6 ElementParameterTypeImpl (org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)5 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)4 ArrayList (java.util.ArrayList)3 Path (org.eclipse.core.runtime.Path)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 IPath (org.eclipse.core.runtime.IPath)2 Element (org.talend.core.model.process.Element)2