use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class ValidationUtil method fillUpdatedVariables.
private void fillUpdatedVariables(TaskFlowJob job, JobValidationData data) {
HashMap<String, String> updatedVariables = new HashMap<>();
for (JobVariable jobVariable : job.getVariables().values()) {
updatedVariables.put(jobVariable.getName(), jobVariable.getValue());
}
for (Task task : job.getTasks()) {
for (TaskVariable taskVariable : task.getVariables().values()) {
updatedVariables.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getValue());
}
}
data.setUpdatedVariables(updatedVariables);
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class StaxJobFactory method createTaskVariables.
/**
* Create a map of variables from XML variables.
* Leave the method with the cursor at the end of 'ELEMENT_VARIABLES' tag
*
* @param cursorVariables the streamReader with the cursor on the 'ELEMENT_VARIABLES' tag.
* @return the map in which the variables were added.
* @throws JobCreationException
*/
private Map<String, TaskVariable> createTaskVariables(XMLStreamReader cursorVariables, Map<String, String> variables) throws JobCreationException {
Map<String, TaskVariable> variablesMap = new HashMap<>();
try {
int eventType;
while (cursorVariables.hasNext()) {
eventType = cursorVariables.next();
if (eventType == XMLEvent.START_ELEMENT && XMLTags.VARIABLE.matches(cursorVariables.getLocalName())) {
TaskVariable taskVariable = getTaskVariable(cursorVariables, variables);
variablesMap.put(taskVariable.getName(), taskVariable);
} else if (eventType == XMLEvent.END_ELEMENT && XMLTags.VARIABLES.matches(cursorVariables.getLocalName())) {
return variablesMap;
}
}
} catch (JobCreationException jce) {
jce.pushTag(cursorVariables.getLocalName());
throw jce;
} catch (Exception e) {
String attrtmp = null;
if (cursorVariables.isStartElement() && cursorVariables.getAttributeCount() == 1) {
attrtmp = cursorVariables.getAttributeLocalName(0);
}
throw new JobCreationException(cursorVariables.getLocalName(), attrtmp, e);
}
return variablesMap;
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProvider method validateJob.
@Override
public TaskFlowJob validateJob(TaskFlowJob job) throws JobValidationException {
ModelValidatorContext context = new ModelValidatorContext(job);
for (JobVariable jobVariable : job.getVariables().values()) {
checkVariableFormat(null, jobVariable, context);
context.updateJobWithContext(job);
}
for (Task task : job.getTasks()) {
context = new ModelValidatorContext(task);
for (TaskVariable taskVariable : task.getVariables().values()) {
checkVariableFormat(task, taskVariable, context);
context.updateTaskWithContext(task);
}
}
return job;
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProvider method validateJob.
@Override
public TaskFlowJob validateJob(TaskFlowJob job, Scheduler scheduler, SchedulerSpaceInterface space, String sessionId) throws JobValidationException {
ModelValidatorContext context = new ModelValidatorContext(job, scheduler, space, sessionId);
for (JobVariable jobVariable : job.getVariables().values()) {
checkVariableFormat(null, jobVariable, context);
context.updateJobWithContext(job);
}
for (Task task : job.getTasks()) {
context = new ModelValidatorContext(task, scheduler, space, sessionId);
for (TaskVariable taskVariable : task.getVariables().values()) {
checkVariableFormat(task, taskVariable, context);
context.updateTaskWithContext(task);
}
}
return job;
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class Attribute method createTaskVariablesElement.
/**
* Creates the task variables element
*/
private Element createTaskVariablesElement(Document doc, Map<String, TaskVariable> variables) {
if (variables == null) {
return null;
}
Element variablesE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.VARIABLES.getXMLName());
for (TaskVariable variable : variables.values()) {
List<Attribute> varAttributes = new ArrayList<>();
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_NAME.getXMLName(), variable.getName()));
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_VALUE.getXMLName(), variable.getValue()));
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_MODEL.getXMLName(), variable.getModel()));
if (variable.getDescription() != null) {
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_DESCRIPTION.getXMLName(), variable.getDescription()));
}
if (variable.getGroup() != null) {
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_GROUP.getXMLName(), variable.getGroup()));
}
if (variable.isAdvanced()) {
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_ADVANCED.getXMLName(), String.valueOf(variable.isAdvanced())));
}
if (variable.isHidden()) {
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_HIDDEN.getXMLName(), String.valueOf(variable.isHidden())));
}
varAttributes.add(new Attribute(XMLAttributes.VARIABLE_JOB_INHERITED.getXMLName(), String.valueOf(variable.isJobInherited())));
Element variableE = createElement(doc, XMLTags.VARIABLE.getXMLName(), null, varAttributes.toArray(new Attribute[0]));
variablesE.appendChild(variableE);
}
return variablesE;
}
Aggregations