Search in sources :

Example 16 with TaskVariable

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);
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 17 with TaskVariable

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);
        }
    }
}
Also used : TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable)

Example 18 with TaskVariable

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);
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) HashMap(java.util.HashMap) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 19 with TaskVariable

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;
}
Also used : HashMap(java.util.HashMap) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer)

Example 20 with TaskVariable

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);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) IOException(java.io.IOException)

Aggregations

TaskVariable (org.ow2.proactive.scheduler.common.task.TaskVariable)19 HashMap (java.util.HashMap)10 Task (org.ow2.proactive.scheduler.common.task.Task)9 LinkedHashMap (java.util.LinkedHashMap)6 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)6 FileNotFoundException (java.io.FileNotFoundException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 Test (org.junit.Test)4 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)4 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)4 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)4 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 IOException (java.io.IOException)3 Map (java.util.Map)3 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)3 LRUMap (org.apache.commons.collections4.map.LRUMap)2 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)2 GlobalVariablesParserTest (org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesParserTest)2