Search in sources :

Example 6 with ImplicitContextSettings

use of org.talend.core.model.properties.ImplicitContextSettings 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 7 with ImplicitContextSettings

use of org.talend.core.model.properties.ImplicitContextSettings 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 8 with ImplicitContextSettings

use of org.talend.core.model.properties.ImplicitContextSettings in project tdi-studio-se by Talend.

the class ProjectSettingManager method defaultUseProjectSetting.

/**
     *
     * when create a new job default use project settings
     *
     * @param pItem
     */
public static void defaultUseProjectSetting(org.talend.designer.core.ui.editor.process.Process process) {
    if (process == null) {
        return;
    }
    ImplicitContextSettings implicit = ProjectManager.getInstance().getCurrentProject().getEmfProject().getImplicitContextSettings();
    Boolean bImplicit = false;
    if (implicit != null) {
        String v = ElementParameter2ParameterType.getParameterValue(implicit.getParameters(), EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName());
        if (v != null && Boolean.valueOf(v)) {
            bImplicit = Boolean.valueOf(v);
        }
    }
    if (bImplicit) {
        ElementParameter2ParameterType.setParameterValue(process, EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName(), bImplicit);
        reloadImplicitValuesFromProjectSettings(process, ProjectManager.getInstance().getCurrentProject(), null);
    }
    // stat and log
    StatAndLogsSettings stat = ProjectManager.getInstance().getCurrentProject().getEmfProject().getStatAndLogsSettings();
    Boolean bStat = false;
    if (stat != null) {
        String v = ElementParameter2ParameterType.getParameterValue(stat.getParameters(), EParameterName.STATS_DEFAULT_PROJECTSETTING.getName());
        if (v != null || Boolean.valueOf(v)) {
            bStat = Boolean.valueOf(v);
        }
    }
    if (bStat) {
        ElementParameter2ParameterType.setParameterValue(process, EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName(), bStat);
        reloadStatsAndLogFromProjectSettings(process, ProjectManager.getInstance().getCurrentProject(), null);
    }
}
Also used : StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings)

Example 9 with ImplicitContextSettings

use of org.talend.core.model.properties.ImplicitContextSettings in project tdi-studio-se by Talend.

the class JobSettingProjectSettingPage method init.

private void init() {
    ImplicitContextSettings implicit = pro.getEmfProject().getImplicitContextSettings();
    if (implicit != null) {
        String v = ElementParameter2ParameterType.getParameterValue(implicit.getParameters(), EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName());
        if (v != null)
            implicitBtn.setSelection(Boolean.valueOf(v));
        else
            implicitBtn.setSelection(true);
    }
    StatAndLogsSettings stat = pro.getEmfProject().getStatAndLogsSettings();
    if (stat != null) {
        String v = ElementParameter2ParameterType.getParameterValue(stat.getParameters(), EParameterName.STATS_DEFAULT_PROJECTSETTING.getName());
        if (v != null)
            statBtn.setSelection(Boolean.valueOf(v));
        else
            statBtn.setSelection(true);
    }
}
Also used : StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings)

Example 10 with ImplicitContextSettings

use of org.talend.core.model.properties.ImplicitContextSettings in project tdi-studio-se by Talend.

the class ProjectSettingManager method createImplicitContextLoadElement.

/**
     *
     * create implicitContextLoad Element for project
     *
     * @param pro
     * @return
     */
public static Element createImplicitContextLoadElement(Project pro) {
    ImplicitContextSettings implicit = pro.getEmfProject().getImplicitContextSettings();
    if (implicit == null) {
        loadImplicitContextLoadPreferenceToProject(pro);
    }
    Element elem = (Element) pro.getInitialContextLoad();
    if (elem == null) {
        elem = new ImplicitContextLoadElement();
        ProjectSettingManager.createImplicitContextLoadParameters(elem);
        pro.setInitialContextLoad(elem);
    }
    return elem;
}
Also used : Element(org.talend.core.model.process.Element) IElement(org.talend.core.model.process.IElement) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings)

Aggregations

ImplicitContextSettings (org.talend.core.model.properties.ImplicitContextSettings)11 StatAndLogsSettings (org.talend.core.model.properties.StatAndLogsSettings)9 List (java.util.List)6 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)6 PersistenceException (org.talend.commons.exception.PersistenceException)5 ElementParameterTypeImpl (org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)5 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)4 IElement (org.talend.core.model.process.IElement)2 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)2 TalendFileFactory (org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 EList (org.eclipse.emf.common.util.EList)1 Element (org.talend.core.model.process.Element)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 ComponentSetting (org.talend.core.model.properties.ComponentSetting)1 Document (org.w3c.dom.Document)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1