use of eu.ggnet.dwoss.core.common.values.SalesChannel 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) {
L.info("rollIn(transactions.ids={}) starting", detachtedTransactions.stream().map(StockTransaction::getId).collect(Collectors.toList()));
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.applyDefaultChannelOnRollIn()) {
SalesChannel channel = stockUnit.getStock().getPrimaryChannel();
channelChanger.fire(new SalesChannelChange.Builder().uniqueUnitId(stockUnit.getUniqueUnitId()).newChannel(channel).build());
history.fire(UnitHistory.create(stockUnit.getUniqueUnitId(), "Rolled in " + stockUnit.getStock().getName() + " with " + channel.description, arranger));
} else {
history.fire(UnitHistory.create(stockUnit.getUniqueUnitId(), "Rolled in " + stockUnit.getStock().getName(), arranger));
}
}
m.finish();
return stockUnits.stream().map(x -> x.getId()).collect(Collectors.toList());
}
Aggregations