org.camunda.bpm.model.bpmn.instance.ServiceTask Java Examples
The following examples show how to use
org.camunda.bpm.model.bpmn.instance.ServiceTask.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceTaskBpmnModelExecutionContextTest.java From camunda-bpm-platform with Apache License 2.0 | 7 votes |
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()); }
Example #2
Source File: CompensateEventOrderTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); }
Example #3
Source File: BpmnProcessModelCustomizer.java From wecube-platform with Apache License 2.0 | 5 votes |
protected void enhanceServiceTasks(BpmnModelInstance procModelInstance) { Collection<ServiceTask> serviceTasks = procModelInstance.getModelElementsByType(ServiceTask.class); for (ServiceTask serviceTask : serviceTasks) { log.debug("validate service task, {} {}", serviceTask.getId(), serviceTask.getName()); String delegateExpression = serviceTask.getCamundaDelegateExpression(); if (StringUtils.isBlank(delegateExpression)) { log.debug("delegate expression is blank, {} {}", serviceTask.getId(), serviceTask.getName()); delegateExpression = "${srvBean}"; serviceTask.setCamundaDelegateExpression(delegateExpression); } } }
Example #4
Source File: AbstractServiceTaskHandleDelegate.java From wecube-platform with Apache License 2.0 | 4 votes |
private ServiceInvocationEvent serviceInvocationEvent(DelegateExecution execution, ProcessDefinition procDef) { ServiceInvocationEventImpl event = new ServiceInvocationEventImpl(); event.setDefinitionId(execution.getProcessDefinitionId()); event.setDefinitionVersion(procDef.getVersion()); event.setDefinitionKey(procDef.getKey()); // event.setExecutionId(execution.getId()); event.setBusinessKey(execution.getProcessBusinessKey()); event.setInstanceId(execution.getProcessInstanceId()); event.setEventSourceId(execution.getCurrentActivityId()); event.setEventSourceName(execution.getCurrentActivityName()); event.setEventType(ServiceInvocationEvent.EventType.SERVICE_INVOCATION); ServiceTask serviceTask = execution.getBpmnModelInstance() .getModelElementById(execution.getCurrentActivityId()); List<EventBasedGateway> eventBaseGateways = serviceTask.getSucceedingNodes() .filterByType(EventBasedGateway.class).list(); EventBasedGateway eventBaseGateway = null; if (!eventBaseGateways.isEmpty()) { eventBaseGateway = eventBaseGateways.get(0); } IntermediateCatchEvent intermediateCatchEvent = null; if (eventBaseGateway != null) { List<IntermediateCatchEvent> intermediateCatchEvents = eventBaseGateway.getSucceedingNodes() .filterByType(IntermediateCatchEvent.class).list(); for (IntermediateCatchEvent ice : intermediateCatchEvents) { getLogger().debug("IntermediateCatchEvent:{} {}", ice.getId(), ice.getName()); Collection<EventDefinition> eventDefinitions = ice.getEventDefinitions(); for (EventDefinition ed : eventDefinitions) { getLogger().debug("EventDefinition: {} {}", ed.getId(), ed.getElementType().getTypeName()); if ("signalEventDefinition".equals(ed.getElementType().getTypeName())) { intermediateCatchEvent = ice; break; } } if (intermediateCatchEvent != null) { break; } } } if (intermediateCatchEvent != null) { event.setExecutionId(intermediateCatchEvent.getId()); } List<String> allowedOptions = tryCalAllowedOptions(execution); if (allowedOptions != null) { for (String option : allowedOptions) { event.addAllowedOption(option); } } return event; }
Example #5
Source File: ServiceTaskImpl.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
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(); }
Example #6
Source File: AbstractServiceTaskBuilder.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
protected AbstractServiceTaskBuilder(BpmnModelInstance modelInstance, ServiceTask element, Class<?> selfType) { super(modelInstance, element, selfType); }
Example #7
Source File: ServiceTaskBuilder.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
public ServiceTaskBuilder(BpmnModelInstance modelInstance, ServiceTask element) { super(modelInstance, element, ServiceTaskBuilder.class); }
Example #8
Source File: ServiceTaskImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
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(); }
Example #9
Source File: AbstractServiceTaskBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected AbstractServiceTaskBuilder(BpmnModelInstance modelInstance, ServiceTask element, Class<?> selfType) { super(modelInstance, element, selfType); }
Example #10
Source File: ServiceTaskBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public ServiceTaskBuilder(BpmnModelInstance modelInstance, ServiceTask element) { super(modelInstance, element, ServiceTaskBuilder.class); }
Example #11
Source File: ModelExecutionContextServiceTask.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void execute(DelegateExecution execution) throws Exception { modelInstance = execution.getBpmnModelInstance(); serviceTask = (ServiceTask) execution.getBpmnModelElementInstance(); }
Example #12
Source File: JavaDelegateProcessEngineServicesAccessTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected Task createModelAccessTask(BpmnModelInstance modelInstance, Class<?> delegateClass) { ServiceTask serviceTask = modelInstance.newInstance(ServiceTask.class); serviceTask.setId("serviceTask"); serviceTask.setCamundaClass(delegateClass.getName()); return serviceTask; }