-
Notifications
You must be signed in to change notification settings - Fork 468
/
RetrievePaymentAdapter.java
37 lines (29 loc) · 1.17 KB
/
RetrievePaymentAdapter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.flowing.retail.order.flow;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import io.flowing.retail.order.domain.Order;
import io.flowing.retail.order.messages.Message;
import io.flowing.retail.order.messages.MessageSender;
import io.flowing.retail.order.persistence.OrderRepository;
@Component
public class RetrievePaymentAdapter implements JavaDelegate {
@Autowired
private MessageSender messageSender;
@Autowired
private OrderRepository orderRepository;
@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())));
}
}