use of org.openstack4j.model.image.v2.Task in project openstack4j by ContainX.
the class ImageV2Tests method createTask.
public void createTask() throws IOException {
respondWith(TASK_JSON);
Map<String, Object> input = new HashMap<>();
input.put("test", "hi");
String type = "import";
Task t = Builders.taskBuilder().type(type).input(input).build();
Task task = osv3().imagesV2().tasks().create(t);
assertNotNull(task);
assertEquals(task.getType(), type);
}
use of org.openstack4j.model.image.v2.Task in project kie-wb-common by kiegroup.
the class TaskConverter method noneTask.
private PropertyWriter noneTask(Node<View<NoneTask>, ?> n) {
Task task = bpmn2.createTask();
task.setId(n.getUUID());
NoneTask definition = n.getContent().getDefinition();
ActivityPropertyWriter p = propertyWriterFactory.of(task);
p.setName(definition.getGeneral().getName().getValue());
p.setBounds(n.getContent().getBounds());
p.setSimulationSet(definition.getSimulationSet());
return p;
}
use of org.openstack4j.model.image.v2.Task in project openstack4j by ContainX.
the class ImageV2Tests method getTask.
public void getTask() throws IOException {
respondWith(TASK_JSON);
String id = "78925244-2951-462d-b979-773a49274d7f";
Task task = osv3().imagesV2().tasks().get(id);
assertNotNull(task);
assertEquals(task.getId(), id);
assertEquals(task.getType(), "import");
}
use of org.openstack4j.model.image.v2.Task in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitTaskAssociations.
public void revisitTaskAssociations(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
List<FlowElement> flowElements = process.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof Task) {
Task t = (Task) fe;
if (t.getDataInputAssociations() != null) {
List<DataInputAssociation> inputList = t.getDataInputAssociations();
if (inputList != null) {
for (DataInputAssociation input : inputList) {
List<ItemAwareElement> sourceRef = input.getSourceRef();
if (sourceRef != null) {
for (ItemAwareElement iae : sourceRef) {
String[] iaeParts = iae.getId().split("\\.");
if (iaeParts.length > 1) {
// FormalExpression dataInputTransformationExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
// dataInputTransformationExpression.setBody(iae.getId());
// input.setTransformation(dataInputTransformationExpression);
// iae.setId(iaeParts[0]);
}
}
}
}
}
}
if (t.getDataOutputAssociations() != null) {
List<DataOutputAssociation> outputList = t.getDataOutputAssociations();
if (outputList != null) {
for (DataOutputAssociation output : outputList) {
ItemAwareElement targetEle = output.getTargetRef();
if (targetEle != null) {
String[] targetEleParts = targetEle.getId().split("\\.");
if (targetEleParts.length > 1) {
// FormalExpression dataOutputTransformationExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
// dataOutputTransformationExpression.setBody(targetEle.getId());
// output.setTransformation(dataOutputTransformationExpression);
// targetEle.setId(targetEleParts[0]);
}
}
}
}
}
if (t.getIoSpecification() != null) {
InputOutputSpecification ios = t.getIoSpecification();
if (ios.getInputSets() == null || ios.getInputSets().size() < 1) {
InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
ios.getInputSets().add(inset);
}
if (ios.getOutputSets() == null) {
if (ios.getOutputSets() == null || ios.getOutputSets().size() < 1) {
OutputSet outset = Bpmn2Factory.eINSTANCE.createOutputSet();
ios.getOutputSets().add(outset);
}
}
}
}
}
}
}
}
use of org.openstack4j.model.image.v2.Task in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitMultiInstanceTasks.
public void revisitMultiInstanceTasks(Definitions def) {
try {
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
List<FlowElement> flowElements = process.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof Task) {
Task task = (Task) fe;
Iterator<FeatureMap.Entry> iter = task.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("mitask")) {
String multiValue = (String) entry.getValue();
String[] multiValueParts = multiValue.split("@");
if (multiValueParts != null && multiValueParts.length == 5) {
String miCollectionInput = (multiValueParts[0].equals(" ") ? "" : multiValueParts[0]);
String miCollectionOutput = (multiValueParts[1].equals(" ") ? "" : multiValueParts[1]);
String miDataInput = (multiValueParts[2].equals(" ") ? "" : multiValueParts[2]);
String miDataOutput = (multiValueParts[3].equals(" ") ? "" : multiValueParts[3]);
String miCompletionCondition = (multiValueParts[4].equals(" ") ? "" : multiValueParts[4]);
MultiInstanceLoopCharacteristics loopCharacteristics = Bpmn2Factory.eINSTANCE.createMultiInstanceLoopCharacteristics();
if (miCollectionInput != null && miCollectionInput.length() > 0) {
List<Property> properties = process.getProperties();
for (Property prop : properties) {
if (prop.getId() != null && prop.getId().equals(miCollectionInput)) {
DataInput miCollectionInputDI = Bpmn2Factory.eINSTANCE.createDataInput();
miCollectionInputDI.setName("miinputCollection");
ItemDefinition miCollectionInputDIItemDefinition = this.getMessageItemDefinition(def.getRootElements(), prop.getId());
miCollectionInputDI.setItemSubjectRef(miCollectionInputDIItemDefinition);
task.getIoSpecification().getDataInputs().add(miCollectionInputDI);
if (task.getIoSpecification().getInputSets() == null || task.getIoSpecification().getInputSets().size() < 1) {
InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
task.getIoSpecification().getInputSets().add(inset);
}
task.getIoSpecification().getInputSets().get(0).getDataInputRefs().add(miCollectionInputDI);
loopCharacteristics.setLoopDataInputRef(miCollectionInputDI);
DataInputAssociation miCollectionInputDataInputAssociation = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
miCollectionInputDataInputAssociation.getSourceRef().add(prop);
miCollectionInputDataInputAssociation.setTargetRef(miCollectionInputDI);
task.getDataInputAssociations().add(miCollectionInputDataInputAssociation);
break;
}
}
}
if (miCollectionOutput != null && miCollectionOutput.length() > 0) {
List<Property> properties = process.getProperties();
for (Property prop : properties) {
if (prop.getId() != null && prop.getId().equals(miCollectionOutput)) {
DataOutput miCollectionOutputDI = Bpmn2Factory.eINSTANCE.createDataOutput();
miCollectionOutputDI.setName("mioutputCollection");
ItemDefinition miCollectionOutputDIItemDefinition = this.getMessageItemDefinition(def.getRootElements(), prop.getId());
miCollectionOutputDI.setItemSubjectRef(miCollectionOutputDIItemDefinition);
task.getIoSpecification().getDataOutputs().add(miCollectionOutputDI);
if (task.getIoSpecification().getOutputSets() == null || task.getIoSpecification().getOutputSets().size() < 1) {
OutputSet outset = Bpmn2Factory.eINSTANCE.createOutputSet();
task.getIoSpecification().getOutputSets().add(outset);
}
task.getIoSpecification().getOutputSets().get(0).getDataOutputRefs().add(miCollectionOutputDI);
loopCharacteristics.setLoopDataOutputRef(miCollectionOutputDI);
DataOutputAssociation miCollectionInputDataOutputAssociation = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
miCollectionInputDataOutputAssociation.setTargetRef(prop);
miCollectionInputDataOutputAssociation.getSourceRef().add(miCollectionOutputDI);
task.getDataOutputAssociations().add(miCollectionInputDataOutputAssociation);
break;
}
}
}
if (miDataInput != null && miDataInput.length() > 0) {
List<DataInput> dins = task.getIoSpecification().getDataInputs();
for (DataInput di : dins) {
if (di.getName().equals(miDataInput)) {
DataInput inputDataItemObj = Bpmn2Factory.eINSTANCE.createDataInput();
inputDataItemObj.setId("miDataInputX");
inputDataItemObj.setItemSubjectRef(di.getItemSubjectRef());
loopCharacteristics.setInputDataItem(inputDataItemObj);
break;
}
}
}
if (miDataOutput != null && miDataOutput.length() > 0) {
List<DataOutput> douts = task.getIoSpecification().getDataOutputs();
for (DataOutput dout : douts) {
if (dout.getName().equals(miDataOutput)) {
DataOutput outputDataItemObj = Bpmn2Factory.eINSTANCE.createDataOutput();
outputDataItemObj.setId("miDataOutputX");
outputDataItemObj.setItemSubjectRef(dout.getItemSubjectRef());
loopCharacteristics.setOutputDataItem(outputDataItemObj);
break;
}
}
}
if (miCompletionCondition != null && !miCompletionCondition.isEmpty()) {
FormalExpression expr = Bpmn2Factory.eINSTANCE.createFormalExpression();
expr.setBody(miCompletionCondition);
loopCharacteristics.setCompletionCondition(expr);
}
task.setLoopCharacteristics(loopCharacteristics);
if (miDataInput != null && miDataInput.length() > 0 && ((MultiInstanceLoopCharacteristics) task.getLoopCharacteristics()).getInputDataItem() != null) {
DataInputAssociation dias = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
dias.getSourceRef().add(((MultiInstanceLoopCharacteristics) task.getLoopCharacteristics()).getInputDataItem());
List<DataInput> dins = task.getIoSpecification().getDataInputs();
for (DataInput di : dins) {
if (di.getName().equals(miDataInput)) {
dias.setTargetRef(di);
task.getDataInputAssociations().add(dias);
break;
}
}
}
if (miDataOutput != null && miDataOutput.length() > 0 && ((MultiInstanceLoopCharacteristics) task.getLoopCharacteristics()).getOutputDataItem() != null) {
DataOutputAssociation dout = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
dout.setTargetRef(((MultiInstanceLoopCharacteristics) task.getLoopCharacteristics()).getOutputDataItem());
List<DataOutput> douts = task.getIoSpecification().getDataOutputs();
for (DataOutput dou : douts) {
if (dou.getName().equals(miDataOutput)) {
dout.getSourceRef().add(dou);
task.getDataOutputAssociations().add(dout);
break;
}
}
}
}
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations