Search in sources :

Example 1 with Task

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);
}
Also used : Task(org.openstack4j.model.image.v2.Task) HashMap(java.util.HashMap)

Example 2 with Task

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;
}
Also used : BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) Task(org.eclipse.bpmn2.Task) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BaseTask(org.kie.workbench.common.stunner.bpmn.definition.BaseTask) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) ActivityPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ActivityPropertyWriter) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask)

Example 3 with Task

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");
}
Also used : Task(org.openstack4j.model.image.v2.Task)

Example 4 with Task

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);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : OutputSet(org.eclipse.bpmn2.OutputSet) ServiceTask(org.eclipse.bpmn2.ServiceTask) ReceiveTask(org.eclipse.bpmn2.ReceiveTask) SendTask(org.eclipse.bpmn2.SendTask) GlobalTask(org.eclipse.bpmn2.GlobalTask) BusinessRuleTask(org.eclipse.bpmn2.BusinessRuleTask) Task(org.eclipse.bpmn2.Task) ScriptTask(org.eclipse.bpmn2.ScriptTask) UserTask(org.eclipse.bpmn2.UserTask) InputOutputSpecification(org.eclipse.bpmn2.InputOutputSpecification) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) InputSet(org.eclipse.bpmn2.InputSet) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation)

Example 5 with Task

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();
    }
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ServiceTask(org.eclipse.bpmn2.ServiceTask) ReceiveTask(org.eclipse.bpmn2.ReceiveTask) SendTask(org.eclipse.bpmn2.SendTask) GlobalTask(org.eclipse.bpmn2.GlobalTask) BusinessRuleTask(org.eclipse.bpmn2.BusinessRuleTask) Task(org.eclipse.bpmn2.Task) ScriptTask(org.eclipse.bpmn2.ScriptTask) UserTask(org.eclipse.bpmn2.UserTask) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) Property(org.eclipse.bpmn2.Property) OutputSet(org.eclipse.bpmn2.OutputSet) FormalExpression(org.eclipse.bpmn2.FormalExpression) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) DataInput(org.eclipse.bpmn2.DataInput) InputSet(org.eclipse.bpmn2.InputSet) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation)

Aggregations

Task (org.eclipse.bpmn2.Task)5 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)4 BusinessRuleTask (org.eclipse.bpmn2.BusinessRuleTask)4 FlowElement (org.eclipse.bpmn2.FlowElement)4 GlobalTask (org.eclipse.bpmn2.GlobalTask)4 Process (org.eclipse.bpmn2.Process)4 ReceiveTask (org.eclipse.bpmn2.ReceiveTask)4 RootElement (org.eclipse.bpmn2.RootElement)4 ScriptTask (org.eclipse.bpmn2.ScriptTask)4 SendTask (org.eclipse.bpmn2.SendTask)4 ServiceTask (org.eclipse.bpmn2.ServiceTask)4 SubProcess (org.eclipse.bpmn2.SubProcess)4 UserTask (org.eclipse.bpmn2.UserTask)4 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)3 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)3 InputSet (org.eclipse.bpmn2.InputSet)3 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)3 OutputSet (org.eclipse.bpmn2.OutputSet)3 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)3 Task (org.openstack4j.model.image.v2.Task)3