Ejemplo n.º 1
0
  @Override
  public void add(final I_C_Order order) {
    Loggables.get().addLog("@Created@ " + order.getDocumentNo());

    orderGeneratedNotifier.notify(order, defaultNotificationRecipientId);

    countOrders.incrementAndGet();
  }
Ejemplo n.º 2
0
/**
 * Default {@link IOrdersCollector} implementation which is:
 *
 * <ul>
 *   <li>counts generated orders: {@link #getCountOrders()}
 *   <li>notifies on event bus that an order was generated
 * </ul>
 *
 * @author metas-dev <*****@*****.**>
 */
public class OrdersCollector implements IOrdersCollector {
  public static final OrdersCollector newInstance() {
    return new OrdersCollector();
  }

  private final AtomicInteger countOrders = new AtomicInteger(0);

  private static final String MSG_Event_Generated = "Event_ProcurementPurchaseOrderGenerated";
  private final DocumentEventBus<I_C_Order> orderGeneratedNotifier =
      DocumentEventBus.<I_C_Order>builder()
          .setLogger(ProcurementConstants.getLogger(OrdersCollector.class))
          .setTopic(ProcurementConstants.EVENTBUS_TOPIC_PurchaseOrderGenerated)
          .setEventAD_Message(MSG_Event_Generated)
          .setEventAD_MessageParamsExtractor(
              new Function<I_C_Order, Object[]>() {
                @Override
                public Object[] apply(final I_C_Order document) {
                  final I_C_BPartner bpartner = document.getC_BPartner();
                  final String bpValue = bpartner.getValue();
                  final String bpName = bpartner.getName();
                  return new Object[] {TableRecordReference.of(document), bpValue, bpName};
                }
              })
          .build();

  private int defaultNotificationRecipientId = -1;

  private OrdersCollector() {
    super();
    orderGeneratedNotifier.queueEventsUntilCurrentTrxCommit();
  }

  public void setDefaultNotificationRecipientId(final int defaultNotificationRecipientId) {
    this.defaultNotificationRecipientId = defaultNotificationRecipientId;
  }

  @Override
  public void add(final I_C_Order order) {
    Loggables.get().addLog("@Created@ " + order.getDocumentNo());

    orderGeneratedNotifier.notify(order, defaultNotificationRecipientId);

    countOrders.incrementAndGet();
  }

  public int getCountOrders() {
    return countOrders.get();
  }
}
Ejemplo n.º 3
0
 private OrdersCollector() {
   super();
   orderGeneratedNotifier.queueEventsUntilCurrentTrxCommit();
 }