Search in sources :

Example 11 with ParametersType

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

the class ProjectSettingManager method reloadStatsAndLogFromProjectSettings.

public static void reloadStatsAndLogFromProjectSettings(ParametersType processType, Project pro) {
    createStatsAndLogsElement(pro);
    ParametersType stats = pro.getEmfProject().getStatAndLogsSettings().getParameters();
    ElementParameter2ParameterType.loadElementParameters(processType, stats, EParameterName.STATANDLOG_USE_PROJECT_SETTINGS);
}
Also used : ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 12 with ParametersType

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

the class NewProcessWizard method createProcessItem.

@SuppressWarnings("unchecked")
protected void createProcessItem() {
    try {
        property.setId(repositoryFactory.getNextId());
        // changed by hqzhang for TDI-19527, label=displayName
        property.setLabel(property.getDisplayName());
        ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
        ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
        // add depended routines.
        List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
        parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
        process.setParameters(parameterType);
        processItem.setProcess(process);
        repositoryFactory.create(processItem, mainPage.getDestinationPath());
    } catch (PersistenceException e) {
        MessageDialog.openError(getShell(), Messages.getString("NewProcessWizard.failureTitle"), //$NON-NLS-1$
        Messages.getString("NewProcessWizard.failureText") + " : " + //$NON-NLS-1$ //$NON-NLS-2$
        e.getMessage());
        ExceptionHandler.process(e);
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) RoutinesParameterType(org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType) PersistenceException(org.talend.commons.exception.PersistenceException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 13 with ParametersType

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

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

the class UpgradeParameterHelper method upgradeItem.

/**
     * 
     * ggu Comment method "upgradeItem".
     * 
     * upgrade the item parameters.
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public static boolean upgradeItem(Item item) {
    if (item == null) {
        return false;
    }
    boolean changed = false;
    if (item instanceof ProcessItem) {
        // job
        ProcessType process = ((ProcessItem) item).getProcess();
        if (process != null) {
            ParametersType parameters = process.getParameters();
            if (parameters != null) {
                changed = upgradeMainParameters(parameters.getElementParameter());
            }
            changed = changed | upgradeNodes(process.getNode());
        }
    } else if (item instanceof JobletProcessItem) {
        // Joblet
        JobletProcess jobletProcess = ((JobletProcessItem) item).getJobletProcess();
        if (jobletProcess != null) {
            ParametersType parameters = jobletProcess.getParameters();
            if (parameters != null) {
                changed = upgradeMainParameters(parameters.getElementParameter());
            }
            changed = changed | upgradeNodes(jobletProcess.getNode());
        }
    }
    return changed;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) JobletProcess(org.talend.designer.joblet.model.JobletProcess)

Example 15 with ParametersType

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

the class AddRoutineDependenciesMigrationTask method execute.

@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
    if (!(item instanceof ProcessItem)) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        ProcessItem item2 = (ProcessItem) item;
        if (item2.getProcess().getParameters() == null || item2.getProcess().getParameters().getRoutinesParameter() == null) {
            ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
            item2.getProcess().setParameters(parameterType);
        }
        List<RoutinesParameterType> routinesDependencies = (List<RoutinesParameterType>) item2.getProcess().getParameters().getRoutinesParameter();
        List<RoutinesParameterType> neededRoutineDependencies = new ArrayList<RoutinesParameterType>();
        neededRoutineDependencies.addAll(RoutinesUtil.createJobRoutineDependencies(true));
        neededRoutineDependencies.addAll(RoutinesUtil.createJobRoutineDependencies(false));
        boolean modified = false;
        for (RoutinesParameterType added : neededRoutineDependencies) {
            boolean found = false;
            for (RoutinesParameterType type : routinesDependencies) {
                if (added.getId().equals(type.getId()) || added.getName().equals(type.getName())) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                routinesDependencies.add(added);
                modified = true;
            }
        }
        if (modified) {
            CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(item, true);
            RelationshipItemBuilder.getInstance().addOrUpdateItem(item, true);
            return ExecutionResult.SUCCESS_WITH_ALERT;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) RoutinesParameterType(org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) 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