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;
}
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;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ParametersType in project tdi-studio-se by Talend.
the class ResetVMArgumentMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
ParametersType parameters = processType.getParameters();
if (parameters == null) {
return ExecutionResult.NOTHING_TO_DO;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
EList listParamType = parameters.getElementParameter();
for (int j = 0; j < listParamType.size(); j++) {
ElementParameterType pType = (ElementParameterType) listParamType.get(j);
if (pType.getName().equals("JOB_RUN_VM_ARGUMENTS")) {
//$NON-NLS-1$
String value = pType.getValue().trim();
if (value != null && value.length() > 0 && !isJson(value)) {
try {
JSONObject root = new JSONObject();
JSONArray args = new JSONArray();
//$NON-NLS-1$
String[] vms = value.split(" ");
for (String vm : vms) {
args.put(vm);
}
//$NON-NLS-1$
root.put("JOB_RUN_VM_ARGUMENTS", args);
pType.setValue(root.toString());
factory.save(item, true);
break;
} catch (JSONException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ParametersType in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method isStatUseProjectSetting.
protected boolean isStatUseProjectSetting(IRepositoryViewObject object) {
Property property = object.getProperty();
ProcessItem pItem = (ProcessItem) property.getItem();
ParametersType pType = pItem.getProcess().getParameters();
String statB = ElementParameter2ParameterType.getParameterValue(pType, getParameterName().getName());
return Boolean.parseBoolean(statB);
}
use of org.talend.designer.core.model.utils.emf.talendfile.ParametersType in project tdi-studio-se by Talend.
the class EncryptPasswordInProjectSettingsMigrationTask 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$
try {
if (encryptValueIfNeeded(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$
try {
if (encryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
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;
}
Aggregations