use of org.ow2.proactive.scheduler.common.task.TaskVariable 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.task.TaskVariable in project scheduling by ow2-proactive.
the class ModelValidatorContext method updateTaskWithContext.
/**
* updates the given task with the current context
*/
public void updateTaskWithContext(Task task) {
for (TaskVariable taskVariable : task.getVariables().values()) {
taskVariable.setValue(spELVariables.getVariables().get(taskVariable.getName()).toString());
taskVariable.setModel(spELVariables.getModels().get(taskVariable.getName()));
String groupName = taskVariable.getGroup();
if (!Strings.isNullOrEmpty(groupName)) {
Boolean hiddenGroupStatus = spELVariables.getHiddenGroups().get(groupName);
if (hiddenGroupStatus != null) {
taskVariable.setHidden(hiddenGroupStatus);
}
}
Boolean hiddenVariableStatus = spELVariables.getHiddenVariables().get(taskVariable.getName());
if (hiddenVariableStatus != null) {
taskVariable.setHidden(hiddenVariableStatus);
}
}
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class ValidationUtil method fillUpdatedVariables.
private static void fillUpdatedVariables(TaskFlowJob job, JobValidationData data) {
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());
}
}
data.setUpdatedVariables(updatedVariables);
data.setUpdatedModels(updatedModels);
data.setUpdatedDescriptions(updatedDescriptions);
data.setUpdatedGroups(updatedGroups);
data.setUpdatedAdvanced(updatedAdvanced);
data.setUpdatedHidden(updatedHidden);
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method getTaskLauncherInitializerWithWorkflowVariables.
private TaskLauncherInitializer getTaskLauncherInitializerWithWorkflowVariables() {
// 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);
Map<String, TaskVariable> variablesToPut2 = new HashMap<>();
variablesToPut2.put(testVariable2Key, new TaskVariable(testVariable2Key, testVariable2Value, null, false));
taskLauncherInitializer.setTaskVariables(variablesToPut2);
return taskLauncherInitializer;
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class TaskContextVariableExtractor method getScopeVariables.
/**
* Return all variables in scope of a given taskContext.
*
* @param taskContext task context container.
* @return Map containing all variables resolved.
*/
public Map<String, Serializable> getScopeVariables(TaskContext taskContext) {
Map<String, Serializable> variables = new HashMap<>();
Map<String, Serializable> inherited = new HashMap<>();
Map<String, Serializable> dictionary = new HashMap<>();
try {
inherited.putAll(extractJobVariables(taskContext));
inherited.putAll(extractInheritedVariables(taskContext));
inherited.putAll(extractSystemVariables(taskContext, ""));
for (TaskVariable taskVariable : taskContext.getInitializer().getTaskVariables().values()) {
if (!taskVariable.isJobInherited()) {
// add non inherited variables
variables.put(taskVariable.getName(), taskVariable.getValue());
} else if (!inherited.containsKey(taskVariable.getName())) {
// but if the variable is inherited
// replace by the inherited value if exists
variables.put(taskVariable.getName(), taskVariable.getValue());
}
}
dictionary = extractAllVariables(taskContext, null, "");
} catch (IOException | ClassNotFoundException e) {
logger.error(ERROR_READING_VARIABLES, e);
}
return VariableSubstitutor.resolveVariables(variables, dictionary);
}
Aggregations