本文整理汇总了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());
}
示例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();
}
示例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);
}
示例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());
}
示例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());
}
示例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.");
}
}
示例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();
}
示例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());
}
示例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
}
示例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);
}
示例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())));
}
示例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);
}
示例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 + ")");
}
示例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 + ")");
}
示例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);
}