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);
}
}
}
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());
}
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;
}
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;
}
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;
}
Aggregations