use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class SchedulerFrontend method validateUpdatedVariables.
private boolean validateUpdatedVariables(Map<String, String> updatedVariables, List<JobVariable> inputVariables) throws JobValidationException {
DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>(updatedVariables);
validatorServiceProvider.validateVariables(inputVariables, serializableUpdatedVariables, this, this);
return true;
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method getTaskLauncherInitializerWithWorkflowVariableAndForkEnvironment.
private TaskLauncherInitializer getTaskLauncherInitializerWithWorkflowVariableAndForkEnvironment() {
// Create and setup task launcher initializer
TaskLauncherInitializer taskLauncherInitializer = createTaskLauncherInitializer();
Map<String, JobVariable> variablesToPut = new HashMap<>();
variablesToPut.put(testVariable1Key, new JobVariable(testVariable1Key, testVariable1Value));
taskLauncherInitializer.setJobVariables(variablesToPut);
return taskLauncherInitializer;
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class StaxJobFactory method createJob.
/**
* Start parsing and creating the job.
*
* @throws JobCreationException if an error occurred during job creation process.
*/
private Job createJob(XMLStreamReader cursorRoot, Map<String, String> replacementVariables, Map<String, String> replacementGenericInfos, Map<String, ArrayList<String>> dependencies, String jobContent) throws JobCreationException {
String current = null;
GlobalVariablesData globalVariablesData = getConfiguredGlobalVariablesData(jobContent);
// start parsing
try {
int eventType;
Job job = null;
while (cursorRoot.hasNext()) {
eventType = cursorRoot.next();
if (eventType == XMLEvent.START_ELEMENT) {
current = cursorRoot.getLocalName();
if (XMLTags.JOB.matches(current)) {
// first tag of the job.
job = createAndFillJob(cursorRoot, replacementVariables, replacementGenericInfos, jobContent, globalVariablesData);
} else if (XMLTags.TASK.matches(current)) {
// once here, the job instance has been created
fillJobWithTasks(cursorRoot, job, dependencies, globalVariablesData);
} else if (XMLTags.METADATA_VISUALIZATION.matches(current) && job != null) {
// Add workflow visualization's embedded html
job.setVisualization(getJobVisualization(cursorRoot));
// Metadata is the last element to parse
break;
}
}
}
if (job != null) {
resolveCleaningScripts((TaskFlowJob) job, job.getVariablesAsReplacementMap());
}
Map<String, JobVariable> globalVariables = new LinkedHashMap<>();
for (String globalVariable : globalVariablesData.getVariables().keySet()) {
globalVariables.put(globalVariable, job.getVariables().get(globalVariable));
}
job.setGlobalVariables(globalVariables);
Map<String, String> globalGenericInfoMap = new LinkedHashMap<>();
for (String globalGenericInfo : globalVariablesData.getGenericInformation().keySet()) {
globalGenericInfoMap.put(globalGenericInfo, job.getGenericInformation().get(globalGenericInfo));
}
job.setGlobalGenericInformation(globalGenericInfoMap);
return job;
} catch (JobCreationException jce) {
if (XMLTags.TASK.matches(current)) {
jce.pushTag(XMLTags.TASK_FLOW.getXMLName());
}
throw jce;
} catch (Exception e) {
throw new JobCreationException(current, null, e);
}
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class StaxJobFactory method fillUpdatedVariables.
private void fillUpdatedVariables(JobValidationException e, TaskFlowJob job) {
HashMap<String, String> updatedVariables = new HashMap<>();
HashMap<String, String> updatedModels = new HashMap<>();
HashMap<String, String> updatedDescriptions = new HashMap<>();
HashMap<String, String> updatedGroups = new HashMap<>();
HashMap<String, Boolean> updatedAdvanced = new HashMap<>();
HashMap<String, Boolean> updatedHidden = new HashMap<>();
for (JobVariable jobVariable : job.getVariables().values()) {
updatedVariables.put(jobVariable.getName(), jobVariable.getValue());
updatedModels.put(jobVariable.getName(), jobVariable.getModel());
updatedDescriptions.put(jobVariable.getName(), jobVariable.getDescription());
updatedGroups.put(jobVariable.getName(), jobVariable.getGroup());
updatedAdvanced.put(jobVariable.getName(), jobVariable.isAdvanced());
updatedHidden.put(jobVariable.getName(), jobVariable.isHidden());
}
for (Task task : job.getTasks()) {
for (TaskVariable taskVariable : task.getVariables().values()) {
updatedVariables.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getValue());
updatedModels.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getModel());
updatedDescriptions.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getDescription());
updatedGroups.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getGroup());
updatedAdvanced.put(task.getName() + ":" + taskVariable.getName(), taskVariable.isAdvanced());
updatedHidden.put(task.getName() + ":" + taskVariable.getName(), taskVariable.isHidden());
}
}
e.setUpdatedVariables(updatedVariables);
e.setUpdatedModels(updatedModels);
e.setUpdatedDescriptions(updatedDescriptions);
e.setUpdatedGroups(updatedGroups);
e.setUpdatedAdvanced(updatedAdvanced);
e.setUpdatedHidden(updatedHidden);
}
use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.
the class ModelValidatorContext method updateJobVariablesWithContext.
/**
* updates the given job variables with the current context
*/
public void updateJobVariablesWithContext(List<JobVariable> jobVariables) {
for (JobVariable jobVariable : jobVariables) {
jobVariable.setValue(spELVariables.getVariables().get(jobVariable.getName()).toString());
jobVariable.setModel(spELVariables.getModels().get(jobVariable.getName()));
String groupName = jobVariable.getGroup();
if (!Strings.isNullOrEmpty(groupName)) {
Boolean hiddenGroupStatus = spELVariables.getHiddenGroups().get(groupName);
if (hiddenGroupStatus != null) {
jobVariable.setHidden(hiddenGroupStatus);
}
}
Boolean hiddenVariableStatus = spELVariables.getHiddenVariables().get(jobVariable.getName());
if (hiddenVariableStatus != null) {
jobVariable.setHidden(hiddenVariableStatus);
}
}
}
Aggregations