Search in sources :

Example 1 with CREATE_TRANSACTION_FOR_SINGLE_UNIT

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());
}
Also used : StockTransactionProcessor(eu.ggnet.dwoss.stock.ee.StockTransactionProcessor) DescriptiveConsumer(eu.ggnet.saft.core.ops.DescriptiveConsumer) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) Ui(eu.ggnet.saft.Ui) Collectors(java.util.stream.Collectors) Dl(eu.ggnet.saft.Dl) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) Guardian(eu.ggnet.saft.core.auth.Guardian) List(java.util.List) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) DescriptiveConsumerFactory(eu.ggnet.saft.core.ops.DescriptiveConsumerFactory) CREATE_TRANSACTION_FOR_SINGLE_UNIT(eu.ggnet.dwoss.rights.api.AtomicRight.CREATE_TRANSACTION_FOR_SINGLE_UNIT) Collections(java.util.Collections) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) Guardian(eu.ggnet.saft.core.auth.Guardian) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Aggregations

ReplyUtil (eu.ggnet.dwoss.common.ReplyUtil)1 CREATE_TRANSACTION_FOR_SINGLE_UNIT (eu.ggnet.dwoss.rights.api.AtomicRight.CREATE_TRANSACTION_FOR_SINGLE_UNIT)1 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)1 StockTransactionProcessor (eu.ggnet.dwoss.stock.ee.StockTransactionProcessor)1 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)1 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)1 PicoUnit (eu.ggnet.dwoss.uniqueunit.api.PicoUnit)1 Dl (eu.ggnet.saft.Dl)1 Ui (eu.ggnet.saft.Ui)1 Guardian (eu.ggnet.saft.core.auth.Guardian)1 DescriptiveConsumer (eu.ggnet.saft.core.ops.DescriptiveConsumer)1 DescriptiveConsumerFactory (eu.ggnet.saft.core.ops.DescriptiveConsumerFactory)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1