use of eu.ggnet.dwoss.event.SalesChannelChange in project dwoss by gg-net.
the class StockTransactionProcessorOperation method rollIn.
/**
* Rolls all StockTransaction in, completing them and setting the Stock.
*
* @param detachtedTransactions the transactions
* @param arranger the arranger
*/
@Override
public List<Integer> rollIn(List<StockTransaction> detachtedTransactions, String arranger) {
SubMonitor m = monitorFactory.newSubMonitor("RollIn", detachtedTransactions.size() * 2);
StockTransactionEao stockTransactionEao = new StockTransactionEao(stockEm);
StockTransactionEmo stockTransactionEmo = new StockTransactionEmo(stockEm);
List<StockTransaction> transactions = new ArrayList<>();
m.message("loading Transactions");
for (StockTransaction detachedTransaction : detachtedTransactions) {
transactions.add(stockTransactionEao.findById(detachedTransaction.getId()));
m.worked(1);
}
m.setWorkRemaining(3);
m.message("rolling in");
List<StockUnit> stockUnits = stockTransactionEmo.completeRollIn(arranger, transactions);
m.worked(2, "adding History");
for (StockUnit stockUnit : stockUnits) {
if (mandator.isApplyDefaultChannelOnRollIn()) {
SalesChannel channel = stockUnit.getStock().getPrimaryChannel();
channelChanger.fire(new SalesChannelChange(stockUnit.getUniqueUnitId(), channel));
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Rolled in " + stockUnit.getStock().getName() + " with " + channel.getName(), arranger));
} else {
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Rolled in " + stockUnit.getStock().getName(), arranger));
}
}
m.finish();
return stockUnits.stream().map(x -> x.getId()).collect(Collectors.toList());
}
Aggregations