Search in sources :

Example 36 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class ModelValidatorContext method updateJobWithContext.

/**
 * updates the given job with the current context
 */
public void updateJobWithContext(TaskFlowJob job) {
    for (JobVariable jobVariable : job.getVariables().values()) {
        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);
        }
    }
}
Also used : JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 37 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class TestStaxJobFactory method testJobCreationAttributeOrderDefinitionVariableXmlElement.

@Test
public void testJobCreationAttributeOrderDefinitionVariableXmlElement() throws URISyntaxException, JobCreationException {
    GlobalVariablesParser.setConfigurationPath(GlobalVariablesParserTest.class.getResource("/org/ow2/proactive/scheduler/common/job/factories/globalvariables/global_variables_default.xml").toExternalForm());
    GlobalVariablesParser.getInstance().reloadFilters();
    Job job = factory.createJob(jobDescriptorAttrDefVariableXmlElement);
    Map<String, JobVariable> jobVariables = job.getVariables();
    assertEquals(2, jobVariables.size());
    JobVariable jobVariable = jobVariables.get("name1");
    assertNotNull(jobVariable);
    assertEquals("name1", jobVariable.getName());
    assertEquals("value1", jobVariable.getValue());
    assertEquals("model1", jobVariable.getModel());
    jobVariable = jobVariables.get("name2");
    assertNotNull(jobVariable);
    assertEquals("name2", jobVariable.getName());
    assertEquals("value2", jobVariable.getValue());
    assertEquals("model2", jobVariable.getModel());
}
Also used : Job(org.ow2.proactive.scheduler.common.job.Job) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) GlobalVariablesParserTest(org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesParserTest) Test(org.junit.Test)

Example 38 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class DefaultModelJobValidatorServiceProviderTest method createJobWithJobModelVariable.

private TaskFlowJob createJobWithJobModelVariable(String value, String model) throws UserException {
    TaskFlowJob job = new TaskFlowJob();
    JobVariable jobVariable = new JobVariable("VAR", value, model);
    job.setVariables(Collections.singletonMap(jobVariable.getName(), jobVariable));
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 39 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class DefaultModelJobValidatorServiceProviderTest method createJobWithSpelJobModelVariablesKO.

private TaskFlowJob createJobWithSpelJobModelVariablesKO() throws UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setVariables(ImmutableMap.of("var1", new JobVariable("var1", "value1", SPEL_LEFT + "#value == 'value1' ? (variables['var2'] == '' ? (variables['var2'] = 'toto1') instanceof T(String) : true) : false" + SPEL_RIGHT), "var2", new JobVariable("var2", "", SPEL_LEFT + "#value == 'toto2'" + SPEL_RIGHT)));
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 40 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class DefaultModelJobValidatorServiceProviderTest method createJobWithSpelJobModelVariablesOK.

private TaskFlowJob createJobWithSpelJobModelVariablesOK() throws UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setVariables(ImmutableMap.of("var1", new JobVariable("var1", "value1", SPEL_LEFT + "#value == 'value1' ? (variables['var2'] == '' ? (variables['var2'] = 'toto1') instanceof T(String) : true) : false" + SPEL_RIGHT), "var2", new JobVariable("var2", "", SPEL_LEFT + "#value == 'toto1'" + SPEL_RIGHT)));
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Aggregations

JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)51 Test (org.junit.Test)19 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)17 HashMap (java.util.HashMap)15 LinkedHashMap (java.util.LinkedHashMap)9 Job (org.ow2.proactive.scheduler.common.job.Job)8 JobId (org.ow2.proactive.scheduler.common.job.JobId)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)7 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)6 Task (org.ow2.proactive.scheduler.common.task.Task)6 TaskVariable (org.ow2.proactive.scheduler.common.task.TaskVariable)6 IOException (java.io.IOException)5 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)5 SimpleScript (org.ow2.proactive.scripting.SimpleScript)5 TaskScript (org.ow2.proactive.scripting.TaskScript)5 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)4 SimpleJob (functionaltests.jobs.SimpleJob)4 FileNotFoundException (java.io.FileNotFoundException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)4