use of eu.ggnet.dwoss.rights.api.AtomicRight.CREATE_TRANSACTION_FOR_SINGLE_UNIT in project dwoss by gg-net.
the class ConsumerFactoryOfStockTransactions method of.
@Override
public List<DescriptiveConsumer<PicoUnit>> of(PicoUnit t) {
StockAgent stockAgent = Dl.remote().lookup(StockAgent.class);
StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(t.uniqueUnitId);
if (su == null || su.isInTransaction())
return Collections.EMPTY_LIST;
Guardian guardian = Dl.local().lookup(Guardian.class);
if (!guardian.hasRight(CREATE_TRANSACTION_FOR_SINGLE_UNIT))
return Collections.EMPTY_LIST;
return stockAgent.findAll(Stock.class).stream().filter(s -> !s.equals(su.getStock())).map(destination -> {
return new DescriptiveConsumer<>("Umfuhr von " + su.getStock().getName() + " nach " + destination.getName(), (PicoUnit t1) -> {
Ui.exec(() -> {
Ui.build().dialog().eval(() -> new CreateQuestionModel(su, destination, "Umfuhr direkt durch Nutzer erzeugt"), () -> new CreateQuestionView()).opt().map(v -> ReplyUtil.wrap(() -> Dl.remote().lookup(StockTransactionProcessor.class).perpareTransfer(v.stockUnits, v.destination.getId(), Dl.local().lookup(Guardian.class).getUsername(), v.comment))).filter(Ui.failure()::handle).ifPresent(u -> Ui.build().alert("Umfuhr angelegt"));
});
});
}).collect(Collectors.toList());
}
Aggregations