Search in sources :

Example 46 with ProcessType

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

the class MigrateOracleJobSettingsParameterMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@SuppressWarnings("unchecked")
@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 (param.getName().equals("DB_TYPE_IMPLICIT_CONTEXT") || param.getName().equals("DB_TYPE")) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    if (ORACLE_INPUT.equals(param.getValue())) {
                        param.setValue(ORACLE_INPUT + ORACLE_SID);
                        modified = true;
                    } else if (ORACLE_OUTPUT.equals(param.getValue())) {
                        param.setValue(ORACLE_OUTPUT + ORACLE_SID);
                        modified = true;
                    }
                }
            }
        }
        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)

Example 47 with ProcessType

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

the class EncryptPasswordInJobSettingsMigrationTask 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);
    try {
        boolean modified = false;
        if (processType.getParameters() != null) {
            for (Object oElemParam : processType.getParameters().getElementParameter()) {
                ElementParameterType param = (ElementParameterType) oElemParam;
                // variable name used for Stat&Logs
                if ("PASS".equals(param.getName())) {
                    //$NON-NLS-1$
                    modified = encryptValueIfNeeded(param);
                }
                // variable name used for implicit context
                if ("PASS_IMPLICIT_CONTEXT".equals(param.getName())) {
                    //$NON-NLS-1$
                    modified = encryptValueIfNeeded(param);
                }
            }
        }
        if (modified) {
            ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            factory.save(item, true);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
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)

Example 48 with ProcessType

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

the class CorrectBatchModeForDBComponents 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 (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    List<String> filterList = Arrays.asList("tOracleOutput");
    IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
            if (useExistingConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
            }
            //Use Existing Conn == true
            ElementParameterType useBatchAndUseConnPara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
            if (useBatchAndUseConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
            }
            boolean useExistConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").getValue().equalsIgnoreCase("true");
            ElementParameterType elementParaType = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
            if (elementParaType == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
            }
            if (!useExistConn) {
                if (elementParaType != null && elementParaType.getValue().equalsIgnoreCase("false")) {
                    elementParaType.setValue("true");
                    ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("0");
                }
            }
        }
    };
    for (String componentName : filterList) {
        IComponentFilter filter = new NameComponentFilter(componentName);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 49 with ProcessType

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

the class CorrectBatchModeForJDBCOutput 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 (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    //groupx
    List<String> filterList = Arrays.asList("tJDBCOutput");
    IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
            if (useExistingConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
            }
            ElementParameterType useBatchSizePara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
            if (useBatchSizePara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
            }
            ElementParameterType useBatchAndUseConnPara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
            if (useBatchAndUseConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
            }
        }
    };
    for (String componentName : filterList) {
        IComponentFilter filter = new NameComponentFilter(componentName);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 50 with ProcessType

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

the class CorrectBatchModeForTeradataOutput 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 (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    //groupx
    List<String> filterList = Arrays.asList("tTeradataOutput");
    IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
            if (useExistingConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
            }
            boolean useExistConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").getValue().equalsIgnoreCase("true");
            ElementParameterType useBatchSizePara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
            if (useBatchSizePara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
            }
            boolean useBatchExistAndCheckForPreviousVersion = useBatchSizePara != null && useBatchSizePara.getValue().equalsIgnoreCase("true");
            ElementParameterType useBatchAndUseConnPara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
            if (useBatchAndUseConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue(useBatchExistAndCheckForPreviousVersion ? "true" : "false");
            }
            boolean useBatchExistAndUncheckForPreviousVersion = useBatchSizePara != null && useBatchSizePara.getValue().equalsIgnoreCase("false");
            if (useExistConn) {
                if (useBatchExistAndUncheckForPreviousVersion) {
                    ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("true");
                    ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("0");
                }
            } else {
                if (useBatchExistAndUncheckForPreviousVersion) {
                    useBatchSizePara.setValue("true");
                    ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("0");
                }
            }
        }
    };
    for (String componentName : filterList) {
        IComponentFilter filter = new NameComponentFilter(componentName);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)244 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)157 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)155 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)153 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)145 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)115 PersistenceException (org.talend.commons.exception.PersistenceException)109 ProcessItem (org.talend.core.model.properties.ProcessItem)29 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)22 List (java.util.List)18 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)16 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)14 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)14 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)12 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)12 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)12 HashMap (java.util.HashMap)10 IComponent (org.talend.core.model.components.IComponent)10