@Override public void executeAction(final ConsignmentProcessModel process) { LOG.info("Process: " + process.getCode() + " in step " + getClass()); try { // simulate different ending times Thread.sleep((long) (Math.random() * 2000)); } catch (final InterruptedException e) { // can't help it } process.setDone(true); save(process); LOG.info("Process: " + process.getCode() + " wrote DONE marker"); getBusinessProcessService() .triggerEvent( process.getParentProcess().getCode() + "_" + KaslyjyFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_END_EVENT_NAME); LOG.info( "Process: " + process.getCode() + " fired event " + KaslyjyFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_END_EVENT_NAME); }
@Override public void executeAction(final ConsignmentProcessModel process) { getProcess2WarehouseAdapter().prepareConsignment(process.getConsignment()); process.setWaitingForConsignment(true); getModelService().save(process); LOG.info("Setting waitForConsignment to true"); }
@Override protected LanguageModel getEmailLanguage(final ConsignmentProcessModel consignmentProcessModel) { if (consignmentProcessModel.getConsignment().getOrder() instanceof OrderModel) { return ((OrderModel) consignmentProcessModel.getConsignment().getOrder()).getLanguage(); } return null; }
@Override public void init( final ConsignmentProcessModel consignmentProcessModel, final EmailPageModel emailPageModel) { super.init(consignmentProcessModel, emailPageModel); orderCode = consignmentProcessModel.getConsignment().getOrder().getCode(); orderGuid = consignmentProcessModel.getConsignment().getOrder().getGuid(); consignmentData = getConsignmentConverter().convert(consignmentProcessModel.getConsignment()); guest = CustomerType.GUEST.equals(getCustomer(consignmentProcessModel).getType()); }
@Override public void receiveConsignmentStatus( final ConsignmentModel consignment, final WarehouseConsignmentStatus status) { for (final ConsignmentProcessModel process : consignment.getConsignmentProcesses()) { final WarehouseConsignmentState state = getStatusMap().get(status); if (state == null) { throw new RuntimeException("No mapping for WarehouseConsignmentStatus: " + status); } process.setWarehouseConsignmentState(state); getModelService().save(process); getBusinessProcessService() .triggerEvent( process.getCode() + "_" + OctcommonFulfilmentProcessConstants.WAIT_FOR_WAREHOUSE); } }
@Override protected void onSiteEvent(final SendReadyForPickupMessageEvent sendReadyForPickupMessageEvent) { final ConsignmentModel consignmentModel = sendReadyForPickupMessageEvent.getProcess().getConsignment(); final ConsignmentProcessModel consignmentProcessModel = getBusinessProcessService() .createProcess( "telcoSendReadyForPickupEmailProcess-" + consignmentModel.getCode() + "-" + System.currentTimeMillis(), "telcoSendReadyForPickupEmailProcess"); consignmentProcessModel.setConsignment(consignmentModel); getModelService().save(consignmentProcessModel); getBusinessProcessService().startProcess(consignmentProcessModel); }
@Override public void executeAction(final ConsignmentProcessModel process) { getEventService().publishEvent(getEvent(process)); if (LOG.isInfoEnabled()) { LOG.info("Process: " + process.getCode() + " in step " + getClass()); } }
@Override public String execute(final ConsignmentProcessModel process) { final ConsignmentModel consignment = process.getConsignment(); if (consignment != null) { consignment.setStatus(ConsignmentStatus.PICKUP_COMPLETE); getModelService().save(consignment); return Transition.OK.toString(); } LOG.error("Process has no consignment"); return Transition.ERROR.toString(); }
@Override public void executeAction(final OrderProcessModel process) throws Exception { if (LOG.isInfoEnabled()) { LOG.info("Process: " + process.getCode() + " in step " + getClass()); } // find the order's entries that are not already allocated to consignments final List<AbstractOrderEntryModel> entriesToSplit = new ArrayList<AbstractOrderEntryModel>(); for (final AbstractOrderEntryModel entry : process.getOrder().getEntries()) { if (entry.getConsignmentEntries() == null || entry.getConsignmentEntries().isEmpty()) { entriesToSplit.add(entry); } } final List<ConsignmentModel> consignments = getOrderSplittingService().splitOrderForConsignment(process.getOrder(), entriesToSplit); if (LOG.isDebugEnabled()) { LOG.debug("Splitting order into " + consignments.size() + " consignments."); } final BusinessProcessService businessProcessService = getBusinessProcessService(); int index = 0; for (final ConsignmentModel consignment : consignments) { final ConsignmentProcessModel subProcess = businessProcessService.<ConsignmentProcessModel>createProcess( process.getCode() + "_" + (++index), MitreFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_NAME); subProcess.setParentProcess(process); subProcess.setConsignment(consignment); save(subProcess); businessProcessService.startProcess(subProcess); } setOrderStatus(process.getOrder(), OrderStatus.ORDER_SPLIT); }
@Override public String execute(final ConsignmentProcessModel process) { final ConsignmentModel consignment = process.getConsignment(); if (consignment != null) { try { // Check if the Order is Cancelled if (OrderStatus.CANCELLED.equals(consignment.getOrder().getStatus()) || OrderStatus.CANCELLING.equals(consignment.getOrder().getStatus())) { return Transition.CANCEL.toString(); } else { getProcess2WarehouseAdapter().shipConsignment(process.getConsignment()); if (consignment.getDeliveryMode() instanceof PickUpDeliveryModeModel) { return Transition.PICKUP.toString(); } else { return Transition.DELIVERY.toString(); } } } catch (final Exception e) { return Transition.ERROR.toString(); } } return Transition.ERROR.toString(); }
@Override protected CustomerModel getCustomer(final ConsignmentProcessModel consignmentProcessModel) { return (CustomerModel) consignmentProcessModel.getConsignment().getOrder().getUser(); }
@Override protected BaseSiteModel getSite(final ConsignmentProcessModel consignmentProcessModel) { return consignmentProcessModel.getConsignment().getOrder().getSite(); }