Search in sources :

Example 26 with ParametersType

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

the class ChangeLocalModeForSparkConfiguration 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_MODE".equals(param.getName())) {
                        //$NON-NLS-1$
                        modified = true;
                        ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType();
                        //$NON-NLS-1$
                        property.setName("SPARK_LOCAL_MODE");
                        //$NON-NLS-1$
                        property.setField("CHECK");
                        //$NON-NLS-1$
                        property.setValue("false");
                        if ("LOCAL".equalsIgnoreCase(param.getValue())) {
                            //$NON-NLS-1$
                            //$NON-NLS-1$
                            param.setValue("CLUSTER");
                            //$NON-NLS-1$
                            property.setValue("true");
                        }
                        elementParameters.add(property);
                        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 27 with ParametersType

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

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

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

the class AbstractJobSettingsPage method performOk.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.preference.PreferencePage#performOk()
     */
@Override
public boolean performOk() {
    if (mComposite != null && (mComposite.isCommandExcute() || isConnectionChanged)) {
        // save to the memory
        ParametersType parametersType = getParametersType();
        if (parametersType != null) {
            ElementParameter2ParameterType.saveElementParameters(elem, parametersType);
        }
        ProjectSettingManager.saveProject();
        save();
    }
    // }
    return super.performOk();
}
Also used : ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 30 with ParametersType

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

the class StatLogsAndImplicitcontextTreeViewPage method saveProcess.

private void saveProcess(RepositoryNode node, String paramName, Boolean isUseProjectSettings, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
    Property property = node.getObject().getProperty();
    ProcessItem pItem = (ProcessItem) property.getItem();
    ParametersType pType = pItem.getProcess().getParameters();
    if (isOpenProcess(node)) {
        Process process = getProcess(opendProcess, node);
        LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, paramName, isUseProjectSettings);
        exeCommand(process, command);
        Element elem = null;
        String propertyName = "";
        String propertyTypeName = "";
        if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
            elem = (Element) pro.getInitialContextLoad();
            propertyName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
            propertyTypeName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.PROPERTY_TYPE.getName();
        } else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
            elem = (Element) pro.getStatsAndLog();
            propertyName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
            propertyTypeName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.PROPERTY_TYPE.getName();
        }
        IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (ptParam != null) {
            IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
            Object proValue = propertyElem.getValue();
            if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
                IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                String value = (String) repositoryElem.getValue();
                ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
                if (connectionItem != null) {
                    Connection connection = connectionItem.getConnection();
                    ChangeValuesFromRepository cmd = new ChangeValuesFromRepository(process, connection, addContextModel ? propertyName : propertyTypeName, value);
                    cmd.ignoreContextMode(true);
                    exeCommand(process, cmd);
                }
            }
        }
        monitor.worked(100);
    } else {
        ElementParameter2ParameterType.setParameterValue(pType, paramName, isUseProjectSettings);
        if (isUseProjectSettings) {
            if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
                ProjectSettingManager.reloadImplicitValuesFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
            } else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
                ProjectSettingManager.reloadStatsAndLogFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
            }
        }
        if (addContextModel && contextVars != null && !contextVars.isEmpty() && ContextUtils.getAllContextItem() != null) {
            ContextUtils.addInContextModelForProcessItem(pItem, contextVars, ContextUtils.getAllContextItem());
        }
        try {
            factory.save(pItem);
            monitor.worked(100);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : LoadProjectSettingsCommand(org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Element(org.talend.core.model.process.Element) Connection(org.talend.core.model.metadata.builder.connection.Connection) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) ProcessItem(org.talend.core.model.properties.ProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) Property(org.talend.core.model.properties.Property)

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