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;
}
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;
}
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;
}
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();
}
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);
}
}
}
Aggregations