Java Code Examples for org.camunda.bpm.engine.delegate.DelegateExecution#getProcessBusinessKey()

The following examples show how to use org.camunda.bpm.engine.delegate.DelegateExecution#getProcessBusinessKey() . 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: AbstractServiceNodeStartListener.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void logServiceNodeStart(DelegateExecution execution) {
    String nodeId = execution.getCurrentActivityId();
    String procInstanceBizKey = execution.getProcessBusinessKey();

    ServiceNodeStatusRepository serviceNodeStatusRepository = SpringApplicationContextUtil
            .getBean(ServiceNodeStatusRepository.class);

    ServiceNodeStatusEntity entity = serviceNodeStatusRepository
            .findOneByProcInstanceBizKeyAndNodeId(procInstanceBizKey, nodeId);

    if (entity == null) {
        getLogger().warn("{} is null for procInstanceBizKey={},nodeId={}", ServiceNodeStatusEntity.class.getSimpleName(),
                procInstanceBizKey, nodeId);
        throw new IllegalStateException("service node status entity doesnt exist");
    }
    
    Date currTime = new Date();
    entity.setUpdatedBy(WorkflowConstants.DEFAULT_USER);
    entity.setUpdatedTime(currTime);
    entity.setStatus(TraceStatus.InProgress);
    entity.setStartTime(currTime);
    
    serviceNodeStatusRepository.saveAndFlush(entity);
    
}
 
Example 2
Source File: AbstractServiceNodeEndListener.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void logServiceNodeEnd(DelegateExecution execution) {
    String nodeId = execution.getCurrentActivityId();
    String procInstanceBizKey = execution.getProcessBusinessKey();

    ServiceNodeStatusRepository serviceNodeStatusRepository = SpringApplicationContextUtil
            .getBean(ServiceNodeStatusRepository.class);

    ServiceNodeStatusEntity entity = serviceNodeStatusRepository
            .findOneByProcInstanceBizKeyAndNodeId(procInstanceBizKey, nodeId);

    if (entity == null) {
        getLogger().warn("{} is null for procInstanceBizKey={},nodeId={}", ServiceNodeStatusEntity.class.getSimpleName(),
                procInstanceBizKey, nodeId);
        throw new IllegalStateException("service node status entity doesnt exist");
    }
    
    Date currTime = new Date();
    entity.setUpdatedBy(WorkflowConstants.DEFAULT_USER);
    entity.setUpdatedTime(currTime);
    entity.setStatus(TraceStatus.Completed);
    entity.setEndTime(currTime);
    
    serviceNodeStatusRepository.saveAndFlush(entity);
    
}
 
Example 3
Source File: ShipGoodsAdapter.java    From flowing-retail with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution context) throws Exception {
  Order order = orderRepository.findById( //
      (String)context.getVariable("orderId")).get(); 
  String pickId = (String)context.getVariable("pickId"); // TODO read from step before!
  String traceId = context.getProcessBusinessKey();

  messageSender.send(new Message<ShipGoodsCommandPayload>( //
          "ShipGoodsCommand", //
          traceId, //
          new ShipGoodsCommandPayload() //
            .setRefId(order.getId())
            .setPickId(pickId) //
            .setRecipientName(order.getCustomer().getName()) //
            .setRecipientAddress(order.getCustomer().getAddress()))); 
}
 
Example 4
Source File: EmitEventAdapter.java    From flowing-retail with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution context) throws Exception {
  String traceId = context.getProcessBusinessKey();

  String eventNameString = null;
  if (eventName!=null && eventName.getValue(context)!=null) {
    eventNameString = (String) eventName.getValue(context);
  } else {
    // if not configured we use the element id from the flow definition as default
    eventNameString = context.getCurrentActivityId();
  }
  
  messageSender.send(new Message<String>( //
      eventNameString, //
      traceId, //
      null)); // no payload at the moment
}
 
Example 5
Source File: DelegateEvent.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static DelegateEvent fromExecution(DelegateExecution delegateExecution) {
  DelegateEvent event = new DelegateEvent();

  event.activityInstanceId = delegateExecution.getActivityInstanceId();
  event.businessKey = delegateExecution.getBusinessKey();
  event.currentActivityId = delegateExecution.getCurrentActivityId();
  event.currentActivityName = delegateExecution.getCurrentActivityName();
  event.currentTransitionId = delegateExecution.getCurrentTransitionId();
  event.eventName = delegateExecution.getEventName();
  event.id = delegateExecution.getId();
  event.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId();
  event.parentId = delegateExecution.getParentId();
  event.processBusinessKey = delegateExecution.getProcessBusinessKey();
  event.processDefinitionId = delegateExecution.getProcessDefinitionId();
  event.processInstanceId = delegateExecution.getProcessInstanceId();
  event.tenantId = delegateExecution.getTenantId();
  event.variableScopeKey = delegateExecution.getVariableScopeKey();

  return event;
}
 
Example 6
Source File: AbstractServiceTaskHandleDelegate.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void logServiceNodeExecution(DelegateExecution execution) {
    String activityId = execution.getCurrentActivityId();
    if (activityId == null) {
        return;
    }

    String nodeId = activityId;
    if (activityId.startsWith(WorkflowConstants.PREFIX_SRV_BEAN_SERVICETASK)) {
        nodeId = activityId.substring(WorkflowConstants.PREFIX_SRV_BEAN_SERVICETASK.length());
    }

    String procInstanceBizKey = execution.getProcessBusinessKey();

    ServiceNodeStatusRepository repository = SpringApplicationContextUtil
            .getBean(ServiceNodeStatusRepository.class);

    ServiceNodeStatusEntity entity = repository.findOneByProcInstanceBizKeyAndNodeId(procInstanceBizKey, nodeId);

    if (entity != null) {
        entity.setTryTimes(entity.getTryTimes() + 1);
        entity.setStatus(TraceStatus.InProgress);
        entity.setUpdatedTime(new Date());
        entity.setUpdatedBy(WorkflowConstants.DEFAULT_USER);
        repository.save(entity);
    }

}
 
Example 7
Source File: AbstractServiceExceptionHandleDelegate.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void logServiceNodeException(DelegateExecution execution, TraceStatus traceStatus, String idPrefix) {
    String activityId = execution.getCurrentActivityId();
    if (activityId == null) {
        return;
    }

    if (!activityId.startsWith(idPrefix)) {
        return;
    }

    String nodeId = activityId.substring(idPrefix.length());
    String procInstanceBizKey = execution.getProcessBusinessKey();

    ServiceNodeStatusRepository repository = SpringApplicationContextUtil
            .getBean(ServiceNodeStatusRepository.class);

    ServiceNodeStatusEntity entity = repository.findOneByProcInstanceBizKeyAndNodeId(procInstanceBizKey, nodeId);

    if (entity == null) {
        getLogger().warn("{} doesnt exist for procInstanceBizKey={},nodeId={}",
                ServiceNodeStatusEntity.class.getSimpleName(), procInstanceBizKey, nodeId);
        throw new IllegalStateException("Entity doesnt exist");
    }

    entity.setUpdatedBy(WorkflowConstants.DEFAULT_USER);
    entity.setUpdatedTime(new Date());
    entity.setStatus(traceStatus);

    repository.save(entity);
}
 
Example 8
Source File: OrderCompletedAdapter.java    From flowing-retail with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution context) throws Exception {
  String orderId = (String)context.getVariable("orderId"); 
  String traceId = context.getProcessBusinessKey();

  messageSender.send( //
      new Message<OrderCompletedEventPayload>( //
          "OrderCompletedEvent", //
          traceId, //
          new OrderCompletedEventPayload() //
            .setOrderId(orderId)));
}
 
Example 9
Source File: RetrievePaymentAdapter.java    From flowing-retail with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution context) throws Exception {
  Order order = orderRepository.findById( //
      (String)context.getVariable("orderId")).get(); 
  String traceId = context.getProcessBusinessKey(); 
  
  messageSender.send( //
      new Message<RetrievePaymentCommandPayload>( //
          "RetrievePaymentCommand", //
          traceId, //
          new RetrievePaymentCommandPayload() //
            .setRefId(order.getId()) //
            .setAmount(order.getTotalSum())));
}
 
Example 10
Source File: FetchGoodsAdapter.java    From flowing-retail with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution context) throws Exception {
  Order order = orderRepository.findById( //
      (String)context.getVariable("orderId")).get(); 
  String traceId = context.getProcessBusinessKey();

  // publish
  messageSender.send(new Message<FetchGoodsCommandPayload>( //
          "FetchGoodsCommand", //
          traceId, //
          new FetchGoodsCommandPayload() //
            .setRefId(order.getId()) //
            .setItems(order.getItems())));
}
 
Example 11
Source File: PaymentReceivedAdapter.java    From flowing-retail with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution context) throws Exception {
  String refId = (String) context.getVariable("refId");
  String correlationId = (String) context.getVariable("correlationId");
  String traceId = context.getProcessBusinessKey();

  messageSender.send( //
      new Message<PaymentReceivedEventPayload>( //
          "PaymentReceivedEvent", //
          traceId, //
          new PaymentReceivedEventPayload() //
              .setRefId(refId))
  		.setCorrelationid(correlationId));
}
 
Example 12
Source File: ExecutionEvent.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
public ExecutionEvent(DelegateExecution delegateExecution) {
  this.activityInstanceId = delegateExecution.getActivityInstanceId();
  this.businessKey = delegateExecution.getBusinessKey();
  this.currentActivityId = delegateExecution.getCurrentActivityId();
  this.currentActivityName = delegateExecution.getCurrentActivityName();
  this.currentTransitionId = delegateExecution.getCurrentTransitionId();
  this.eventName = delegateExecution.getEventName();
  this.id = delegateExecution.getId();
  this.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId();
  this.parentId = delegateExecution.getParentId();
  this.processBusinessKey = delegateExecution.getProcessBusinessKey();
  this.processDefinitionId = delegateExecution.getProcessDefinitionId();
  this.processInstanceId = delegateExecution.getProcessInstanceId();
  this.tenantId = delegateExecution.getTenantId();
}
 
Example 13
Source File: ExecutionEvent.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ExecutionEvent(DelegateExecution delegateExecution) {
  this.activityInstanceId = delegateExecution.getActivityInstanceId();
  this.businessKey = delegateExecution.getBusinessKey();
  this.currentActivityId = delegateExecution.getCurrentActivityId();
  this.currentActivityName = delegateExecution.getCurrentActivityName();
  this.currentTransitionId = delegateExecution.getCurrentTransitionId();
  this.eventName = delegateExecution.getEventName();
  this.id = delegateExecution.getId();
  this.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId();
  this.parentId = delegateExecution.getParentId();
  this.processBusinessKey = delegateExecution.getProcessBusinessKey();
  this.processDefinitionId = delegateExecution.getProcessDefinitionId();
  this.processInstanceId = delegateExecution.getProcessInstanceId();
  this.tenantId = delegateExecution.getTenantId();
}