Search in sources :

Example 6 with ParametersType

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

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

the class AbstractMultiPageTalendEditor method codeSync.

private void codeSync() {
    IProcess2 process = getProcess();
    if (!(process.getProperty().getItem() instanceof ProcessItem)) {
        // shouldn't work for joblet
        return;
    }
    if (jobletEditor == getEditor(oldPageIndex)) {
        // added for routines code generated switch editor 0 to 3.
        ProcessItem processItem = (ProcessItem) process.getProperty().getItem();
        covertJobscriptOnPageChange();
        ParametersType parameters = processItem.getProcess().getParameters();
        if (parameters != null && parameters.getRoutinesParameter() != null && parameters.getRoutinesParameter().size() == 0) {
            try {
                List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
                parameters.getRoutinesParameter().addAll(dependenciesInPreference);
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    // if some code has been generated already, for the editor we should need only the main job, not the childs.
    try {
        boolean lastGeneratedWithStats = ProcessorUtilities.getLastGeneratedWithStats(process.getId());
        boolean lastGeneratedWithTrace = ProcessorUtilities.getLastGeneratedWithTrace(process.getId());
        if (processor.isCodeGenerated()) {
            ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), lastGeneratedWithStats, lastGeneratedWithTrace, true, ProcessorUtilities.GENERATE_MAIN_ONLY);
        } else {
            ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), lastGeneratedWithStats, lastGeneratedWithTrace, true, ProcessorUtilities.GENERATE_WITH_FIRST_CHILD);
        }
    } catch (ProcessorException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) RoutinesParameterType(org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 8 with ParametersType

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

the class ProjectSettingManager method loadImplicitContextLoadPreferenceToProject.

/**
     *
     * Load ImplicitContextLoad Preference setting to Project only Load Once
     *
     * @param pro
     */
private static void loadImplicitContextLoadPreferenceToProject(Project pro) {
    TalendFileFactory talendF = TalendFileFactory.eINSTANCE;
    ImplicitContextSettings implicit = PropertiesFactory.eINSTANCE.createImplicitContextSettings();
    pro.getEmfProject().setImplicitContextSettings(implicit);
    implicit.setParameters(talendF.createParametersType());
    ParametersType pType = implicit.getParameters();
    IElement elem = pro.getInitialContextLoad();
    if (elem == null) {
        elem = new ImplicitContextLoadElement();
        ProjectSettingManager.createImplicitContextLoadParameters((ImplicitContextLoadElement) elem);
        pro.setInitialContextLoad(elem);
    }
    ElementParameter2ParameterType.saveElementParameters((Element) elem, pType);
}
Also used : IElement(org.talend.core.model.process.IElement) TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings)

Example 9 with ParametersType

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

the class ProjectSettingManager method reloadImplicitValuesFromProjectSettings.

public static void reloadImplicitValuesFromProjectSettings(ParametersType processType, Project pro) {
    createImplicitContextLoadElement(pro);
    ParametersType implicitType = pro.getEmfProject().getImplicitContextSettings().getParameters();
    ElementParameter2ParameterType.loadElementParameters(processType, implicitType, EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS);
}
Also used : ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 10 with ParametersType

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

the class ProjectSettingManager method saveImplicitValuesToProjectSettings.

public static void saveImplicitValuesToProjectSettings(Element process, Project pro) {
    createImplicitContextLoadElement(pro);
    ParametersType implicitType = pro.getEmfProject().getImplicitContextSettings().getParameters();
    // load the project settings to process
    ElementParameter2ParameterType.saveElementParameters(process, implicitType);
    saveProject();
}
Also used : 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