Search in sources :

Example 1 with ServiceTask

use of org.camunda.bpm.model.bpmn.instance.ServiceTask in project camunda-bpm-platform by camunda.

the class CompensateEventOrderTest method addServiceTaskCompensationHandler.

private void addServiceTaskCompensationHandler(BpmnModelInstance modelInstance, String boundaryEventId, String compensationHandlerId) {
    BoundaryEvent boundaryEvent = modelInstance.getModelElementById(boundaryEventId);
    BaseElement scope = (BaseElement) boundaryEvent.getParentElement();
    ServiceTask compensationHandler = modelInstance.newInstance(ServiceTask.class);
    compensationHandler.setId(compensationHandlerId);
    compensationHandler.setForCompensation(true);
    compensationHandler.setCamundaClass(IncreaseCurrentTimeServiceTask.class.getName());
    scope.addChildElement(compensationHandler);
    Association association = modelInstance.newInstance(Association.class);
    association.setAssociationDirection(AssociationDirection.One);
    association.setSource(boundaryEvent);
    association.setTarget(compensationHandler);
    scope.addChildElement(association);
}
Also used : BaseElement(org.camunda.bpm.model.bpmn.instance.BaseElement) ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) IncreaseCurrentTimeServiceTask(org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask) Association(org.camunda.bpm.model.bpmn.instance.Association) BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) IncreaseCurrentTimeServiceTask(org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask)

Example 2 with ServiceTask

use of org.camunda.bpm.model.bpmn.instance.ServiceTask in project camunda-bpmn-model by camunda.

the class ServiceTaskImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(ServiceTask.class, BPMN_ELEMENT_SERVICE_TASK).namespaceUri(BPMN20_NS).extendsType(Task.class).instanceProvider(new ModelTypeInstanceProvider<ServiceTask>() {

        public ServiceTask newInstance(ModelTypeInstanceContext instanceContext) {
            return new ServiceTaskImpl(instanceContext);
        }
    });
    implementationAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_IMPLEMENTATION).defaultValue("##WebService").build();
    operationRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_OPERATION_REF).qNameAttributeReference(Operation.class).build();
    /**
     * camunda extensions
     */
    camundaClassAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CLASS).namespace(CAMUNDA_NS).build();
    camundaDelegateExpressionAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_DELEGATE_EXPRESSION).namespace(CAMUNDA_NS).build();
    camundaExpressionAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_EXPRESSION).namespace(CAMUNDA_NS).build();
    camundaResultVariableAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_RESULT_VARIABLE).namespace(CAMUNDA_NS).build();
    camundaTopicAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_TOPIC).namespace(CAMUNDA_NS).build();
    camundaTypeAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_TYPE).namespace(CAMUNDA_NS).build();
    camundaTaskPriorityAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_TASK_PRIORITY).namespace(CAMUNDA_NS).build();
    typeBuilder.build();
}
Also used : ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) Task(org.camunda.bpm.model.bpmn.instance.Task) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 3 with ServiceTask

use of org.camunda.bpm.model.bpmn.instance.ServiceTask in project camunda-bpm-platform by camunda.

the class JavaDelegateProcessEngineServicesAccessTest method createModelAccessTask.

protected Task createModelAccessTask(BpmnModelInstance modelInstance, Class<?> delegateClass) {
    ServiceTask serviceTask = modelInstance.newInstance(ServiceTask.class);
    serviceTask.setId("serviceTask");
    serviceTask.setCamundaClass(delegateClass.getName());
    return serviceTask;
}
Also used : ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask)

Example 4 with ServiceTask

use of org.camunda.bpm.model.bpmn.instance.ServiceTask in project camunda-bpm-platform by camunda.

the class ServiceTaskBpmnModelExecutionContextTest method testJavaDelegateModelExecutionContext.

public void testJavaDelegateModelExecutionContext() {
    deploy();
    runtimeService.startProcessInstanceByKey(PROCESS_ID);
    BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance;
    assertNotNull(modelInstance);
    Model model = modelInstance.getModel();
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class));
    assertEquals(2, events.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class));
    assertEquals(1, tasks.size());
    Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
    assertEquals(PROCESS_ID, process.getId());
    assertTrue(process.isExecutable());
    ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask;
    assertNotNull(serviceTask);
    assertEquals(ModelExecutionContextServiceTask.class.getName(), serviceTask.getCamundaClass());
}
Also used : ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) Task(org.camunda.bpm.model.bpmn.instance.Task) ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Model(org.camunda.bpm.model.xml.Model) Event(org.camunda.bpm.model.bpmn.instance.Event) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Aggregations

ServiceTask (org.camunda.bpm.model.bpmn.instance.ServiceTask)4 Task (org.camunda.bpm.model.bpmn.instance.Task)2 IncreaseCurrentTimeServiceTask (org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask)1 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)1 Association (org.camunda.bpm.model.bpmn.instance.Association)1 BaseElement (org.camunda.bpm.model.bpmn.instance.BaseElement)1 BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)1 Event (org.camunda.bpm.model.bpmn.instance.Event)1 Process (org.camunda.bpm.model.bpmn.instance.Process)1 Model (org.camunda.bpm.model.xml.Model)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1