当前位置: 首页>>代码示例>>Java>>正文


Java DelegateExecution类代码示例

本文整理汇总了Java中org.camunda.bpm.engine.delegate.DelegateExecution的典型用法代码示例。如果您正苦于以下问题:Java DelegateExecution类的具体用法?Java DelegateExecution怎么用?Java DelegateExecution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DelegateExecution类属于org.camunda.bpm.engine.delegate包,在下文中一共展示了DelegateExecution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {
  final String decisionTable = DMN_TABLE.getValue(execution);
  final BusinessData businessData = new BusinessData(BUSINESS_DATA.getValue(execution));

  log.info("\n-----\n" +
    "evaluateDmn\n\n" +
    "table: {}\n" +
    "data: {}\n" +
    "-----\n", decisionTable, businessData.toVariables());

  final CandidateGroup candidateGroup = Try.of(() -> transactionWrapper.requireNewTransaction(evaluateDecisionTable).apply(decisionTable, businessData))
    .onFailure(e -> log.warn("could not evaluate candidateGroup, {}", e.getMessage()))
    .getOrElse(CandidateGroup.empty());

  CANDIDATE_GROUP.setValue(execution, candidateGroup.getName());
}
 
开发者ID:holisticon,项目名称:holunda,代码行数:18,代码来源:EvaluateDmnDelegate.java

示例2: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {

    String message = getMessageName(execution);
    notNull(message, () -> new BadArgument("message"));

    RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();

    MessageCorrelationBuilder correlation = runtimeService.createMessageCorrelation(message);

    if (variableName != null) {
        correlation.setVariable(variableName, variableValue);
    }

    if (correlateName != null) {
        correlation.processInstanceVariableEquals(correlateName, correlateValue);
    }

    correlation.correlateWithResult();
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:21,代码来源:SimpleMessageThrowDelegate.java

示例3: notify

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void notify(DelegateExecution execution) throws Exception {
  List<String> risks = new ArrayList<String>();
  Set<String> riskAssessments = new HashSet<String>();
  
  //DmnDecisionOutput vs DmnDecisionResult
  @SuppressWarnings("unchecked")
  List<Map<String, Object>> resultList = (List<Map<String, Object>>) execution.getVariable("riskAssessmentResult");
  for (Map<String, Object> result : resultList) {
    risks.add((String)result.get("risk"));
    if (result.get("riskAssessment")!=null) {
      riskAssessments.add(((String)result.get("riskAssessment")).toLowerCase());
    }
  }

  String riskAssessment = "green";
  if (riskAssessments.contains("red")) {
    riskAssessment = "red";
  } else if (riskAssessments.contains("yellow")) {
    riskAssessment = "yellow";
  }
  execution.setVariable("riskAssessment", riskAssessment);
}
 
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:24,代码来源:MapDmnResult.java

示例4: persistOrder

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
public void persistOrder(DelegateExecution delegateExecution) {
  // Create new order instance
  OrderEntity orderEntity = new OrderEntity();

  // Get all process variables
  Map<String, Object> variables = delegateExecution.getVariables();

  // Set order attributes
  orderEntity.setCustomer((String) variables.get("customer"));
  orderEntity.setAddress((String) variables.get("address"));
  orderEntity.setPizza((String) variables.get("pizza"));

  // Persist order instance and flush. After the flush the
  // id of the order instance is set.
  entityManager.persist(orderEntity);
  entityManager.flush();

  // Remove no longer needed process variables
  delegateExecution.removeVariables(variables.keySet());

  // Add newly created order id as process variable
  delegateExecution.setVariable("orderId", orderEntity.getId());
}
 
开发者ID:derursm,项目名称:bvis,代码行数:24,代码来源:OrderBusinessLogic.java

示例5: testExecutionListener

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Deployment
public void testExecutionListener() {
  final AtomicInteger eventCount = new AtomicInteger();
  
  EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
    public ExecutionListener getExecutionListener() {
      // this process application returns an execution listener
      return new ExecutionListener() {
        public void notify(DelegateExecution execution) throws Exception {
            eventCount.incrementAndGet();
        }
      };
    }
  };

  // register app so that it is notified about events
  managementService.registerProcessApplication(deploymentId, processApplication.getReference());

  // start process instance
  runtimeService.startProcessInstanceByKey("startToEnd");

  // 7 events received
  assertEquals(7, eventCount.get());
 }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:25,代码来源:ProcessApplicationEventListenerTest.java

示例6: getMessageName

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
/**
 * Retrieves the name of message from BPMN diagram
 *
 * @param execution Execution
 * @return Message name
 * @throws UnsupportedOperationException If the element where this delegate is used is not a message event or the message is not specified
 */
protected String getMessageName(DelegateExecution execution) {
    FlowElement element = execution.getBpmnModelElementInstance();
    if (element instanceof Event) {
        MessageEventDefinition definition = (MessageEventDefinition) element
                .getUniqueChildElementByType(MessageEventDefinition.class);

        if (definition != null) {
            Message message = definition.getMessage();

            if (message != null) {
                return message.getName();
            }
        }

        throw new UnsupportedOperationException("Message must by specified in BPMN diagram.");
    } else {
        throw new UnsupportedOperationException("Only message events are supported with this delegate.");
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:27,代码来源:MessageThrowDelegate.java

示例7: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {

    String message = getMessageName(execution);
    notNull(message, () -> new BadArgument("message"));

    RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();

    MessageCorrelationBuilder correlation = runtimeService.createMessageCorrelation(message);

    if (variables != null) {
        correlation.setVariables((Map<String, Object>) variables.getValue(execution));
    }

    if (correlateName != null) {
        correlation.processInstanceVariableEquals((String) correlateName.getValue(execution), correlateValue.getValue(execution));
    }

    correlation.correlateWithResult();
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:21,代码来源:MapMessageThrowDelegate.java

示例8: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(final DelegateExecution execution) throws Exception {
  final String dmnTable = DMN_TABLE.getValue(execution);
  final String businessKey = BUSINESS_KEY.getValue(execution);

  Set<String> requiredKeys = getInputParameters.apply(dmnTable);
  BusinessData businessData = businessDataService.loadBusinessData(new BusinessKey(businessKey), requiredKeys);

  log.info("\n-----\n loadRequiredData\n" +
    "table: {}\n" +
    "businessKey: {}\n" +
    "requiredKeys: {}\n" +
    "data: {}\n" +
    "-----\n", dmnTable, businessKey, requiredKeys, businessData);


  BUSINESS_DATA.setValue(execution, businessData.getData());
}
 
开发者ID:holisticon,项目名称:holunda,代码行数:19,代码来源:LoadRequiredDataDelegate.java

示例9: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@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
}
 
开发者ID:flowing,项目名称:flowing-retail,代码行数:18,代码来源:EmitEventAdapter.java

示例10: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
public void execute(DelegateExecution ctx) throws Exception {
  CreateChargeRequest request = new CreateChargeRequest();
  request.amount = (int) ctx.getVariable("remainingAmount");

  CreateChargeResponse response = rest.postForObject( //
      stripeChargeUrl, //
      request, //
      CreateChargeResponse.class);   
  
  // TODO Add error scenarios to StripeFake and then raise "Error_CreditCardError" here
  if (response.errorCode!=null) {
    ctx.setVariable("errorCode", response.errorCode);
    throw new BpmnError("Error_PaymentError");
  }

  ctx.setVariable("paymentTransactionId", response.transactionId);
}
 
开发者ID:flowing,项目名称:flowing-retail,代码行数:18,代码来源:ChargeCreditCardAdapter.java

示例11: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution context) throws Exception {
  Order order = orderRepository.getOrder( //
      (String)context.getVariable("orderId")); 
  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()))); 
}
 
开发者ID:flowing,项目名称:flowing-retail,代码行数:17,代码来源:ShipGoodsAdapter.java

示例12: notify

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void notify(DelegateExecution execution) throws Exception {

    LOGGER.info("Timer fired at " + new Date() + " in Scope " + execution.getId());

    // fetch the BPMN model ID of the timer event
    String timerEventId = execution.getCurrentActivityId();

    // get the task this timer event is attached to
    Job timerJob = execution.getProcessEngineServices().getManagementService().createJobQuery()
            .activityId(timerEventId).singleResult();
    Task task = execution.getProcessEngineServices().getTaskService().createTaskQuery()
            .executionId(timerJob.getExecutionId()).singleResult();

    if (task.getFollowUpDate() != null && task.getFollowUpDate().before(new Date())) {
        LOGGER.info("the follow up date (" + task.getFollowUpDate()
                + ") of the User Task was reached");
        execution.getProcessEngineServices().getRuntimeService().setVariableLocal(
                task.getExecutionId(), "demoTaskBoundaryEvent.followUpDateReached", true);
    }

    // set a trigger marker variable on the local task scope
    execution.getProcessEngineServices().getRuntimeService()
            .setVariableLocal(task.getExecutionId(), "demoTaskBoundaryEvent.fired", true);

}
 
开发者ID:FrVaBe,项目名称:camunda,代码行数:27,代码来源:DemoTaskBoundaryTimerListener.java

示例13: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {

    String processInstanceId = execution.getProcessInstanceId();

    System.out.println("Entering FindOwnProcessTask.execute (processInstanceId="
            + processInstanceId + ")");

    ProcessInstanceQuery query = execution.getProcessEngineServices().getRuntimeService()
            .createProcessInstanceQuery().processInstanceId(processInstanceId);
    ProcessInstance pi = query.singleResult();

    if (pi == null) {
        System.out
                .println("WARN - No process instance with id " + processInstanceId + " found!");
    } else {
        System.out.println("Hello World!");
    }

    System.out.println(
            "Exiting FindOwnProcessTask.execute (processInstanceId=" + processInstanceId + ")");

}
 
开发者ID:FrVaBe,项目名称:camunda,代码行数:24,代码来源:FindOwnProcessTask.java

示例14: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {

    String processInstanceId = execution.getProcessInstanceId();

    System.out.println(
            "Entering HelloWorldTask.execute (processInstanceId=" + processInstanceId + ")");

    ProcessInstanceQuery query =
            runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId);
    ProcessInstance pi = query.singleResult();

    if (pi == null) {
        System.out
                .println("WARN - No process instance with id " + processInstanceId + " found!");
    } else {
        System.out.println("Hello World!");
    }

    System.out.println(
            "Exiting HelloWorldTask.execute (processInstanceId=" + processInstanceId + ")");

}
 
开发者ID:FrVaBe,项目名称:camunda,代码行数:24,代码来源:HelloWorldTask.java

示例15: execute

import org.camunda.bpm.engine.delegate.DelegateExecution; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {
    final String topicValue = getTopic(execution);

    if (topicValue == null) {
        LOGGER.error("Not throwing any event in {}. Could not determine topic.", execution.getCurrentActivityName());
        // TODO Should we throw an exception here?
        return;
    }
    final Object messageValue = getMessagePayload(execution);

    if (messageValue == null) {
        LOGGER.error("Not throwing any event in {}. " + "Designated message payload for topic {} could not be found.", execution.getCurrentActivityName(),
                topicValue);
        // TODO Should we throw an exception here?
        return;
    }
    sender.sendMessage(topicValue, messageValue.toString());
    LOGGER.info("Throwing event topic {} with value {}", topicValue, messageValue);

}
 
开发者ID:zambrovski,项目名称:mqtt-camunda-bpm,代码行数:22,代码来源:MqttThrowingEvent.java


注:本文中的org.camunda.bpm.engine.delegate.DelegateExecution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。