Search in sources :

Example 1 with UnitShard

use of eu.ggnet.dwoss.uniqueunit.api.UnitShard in project dwoss by gg-net.

the class UnitOverseerBean method internalFind.

private UnitShard internalFind(String refurbishId) {
    L.debug("find({})", refurbishId);
    UniqueUnitEao uuEao = new UniqueUnitEao(uuEm);
    UniqueUnit uu = uuEao.findByIdentifier(Identifier.REFURBISHED_ID, refurbishId);
    String oldRefurbishedOd = null;
    L.debug("find({}) uniqueUnit={}", refurbishId, uu);
    if (uu == null) {
        uu = uuEao.findByRefurbishedIdInHistory(refurbishId);
        if (uu == null) {
            if (!bridgeInstance.isUnsatisfied() && !bridgeInstance.get().isUnitIdentifierAvailable(refurbishId)) {
                return new UnitShard(refurbishId, 0, toHtmlDescription(refurbishId, null, "Nicht Verfügbar", "", "(Auskunft aus Sopo)"), false, null);
            } else {
                return new UnitShard(refurbishId, 0, "<html>SopoNr.:<b>" + refurbishId + "<u> existiert nicht.</u><br /><br /></b></html>", null, null);
            }
        } else {
            oldRefurbishedOd = "(Frühere SopoNr: " + refurbishId + ")";
            refurbishId = uu.getIdentifier(REFURBISHED_ID);
        }
    }
    StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uu.getId());
    L.debug("find({}) stockUnit={}", refurbishId, stockUnit);
    Integer stockId = null;
    if (stockUnit != null && stockUnit.isInStock())
        stockId = stockUnit.getStock().getId();
    if (stockUnit == null) {
        return new UnitShard(refurbishId, uu.getId(), toHtmlDescription(refurbishId, oldRefurbishedOd, "Nicht Verfügbar", "", null), false, null);
    }
    if (stockUnit.getLogicTransaction() != null) {
        return new UnitShard(refurbishId, uu.getId(), toHtmlDescription(refurbishId, oldRefurbishedOd, "Nicht Verfügbar", stockUnit, null), false, stockId);
    }
    // If the Database is clean, the Unit is available, but we make some safty checks here.
    if (new DossierEao(redTapeEm).isUnitBlocked(uu.getId())) {
        L.warn("find({}) Database Error RedTape sanity check", refurbishId);
        return new UnitShard(refurbishId, uu.getId(), toHtmlDescription(refurbishId, oldRefurbishedOd, "Nicht Verfügbar", stockUnit, "(Datenbankfehler, RedTape sanity check!)"), false, stockId);
    }
    // Now we are shure.
    return new UnitShard(refurbishId, uu.getId(), toHtmlDescription(refurbishId, oldRefurbishedOd, "Verfügbar", stockUnit, null), true, stockId);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) UnitShard(eu.ggnet.dwoss.uniqueunit.api.UnitShard) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 2 with UnitShard

use of eu.ggnet.dwoss.uniqueunit.api.UnitShard in project dwoss by gg-net.

the class UnitAvailabillityTryout method main.

public static void main(String[] args) {
    Dl.remote().add(UnitOverseer.class, new UnitOverseer() {

        private Map<String, Tuple2<UnitShard, String>> data = new HashMap<>();

        {
            data.put("1", new Tuple2<>(new UnitShard("1", 1, "SopoNr.: 1", Boolean.TRUE, 1), "Details zu Unit 1"));
            data.put("2", new Tuple2<>(new UnitShard("2", 2, "SopoNr.: 2", Boolean.FALSE, 1), "Details zu Unit 2"));
            data.put("3", new Tuple2<>(new UnitShard("3", 3, "SopoNr.: 3", Boolean.TRUE, 1), "Details zu Unit 3"));
            data.put("4", new Tuple2<>(new UnitShard("4", 4, "SopoNr.: 4", Boolean.FALSE, 1), "Details zu Unit 4"));
            data.put("5", new Tuple2<>(new UnitShard("5", 5, "SopoNr.: 5 exitiert nicht", null, null), "Existiert Nicht"));
            data.put("6", new Tuple2<>(new UnitShard("6", 6, "SopoNr.: 6", Boolean.FALSE, null), "Details zu Unit 6"));
        }

        @Override
        public String toDetailedHtml(String refurbishId, String username) {
            if (!data.containsKey(refurbishId))
                return refurbishId + " existiert nicht";
            return data.get(refurbishId)._2;
        }

        @Override
        public UnitShard find(String refurbishId) {
            if (!data.containsKey(refurbishId))
                return new UnitShard(refurbishId, 0, "SopoNr.: " + refurbishId + " exitiert nicht", null, null);
            return data.get(refurbishId)._1;
        }

        @Override
        public boolean isAvailable(String refurbishId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void lockStockUnit(long dossierId, String refurbishedId) throws IllegalStateException {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Result<List<Position>> createUnitPosition(String refurbishId, long documentId) throws UserInfoException {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public String toDetailedHtml(int uniqueUnitId, String username) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    Ui.exec(() -> {
        UiCore.startSwing(() -> new JLabel("Main Application"));
        Ui.build().swing().show(() -> new UnitAvailabilityViewCask());
    });
}
Also used : UnitAvailabilityViewCask(eu.ggnet.dwoss.redtapext.ui.cap.UnitAvailabilityViewCask) UnitOverseer(eu.ggnet.dwoss.redtapext.ee.UnitOverseer) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) UnitShard(eu.ggnet.dwoss.uniqueunit.api.UnitShard) JLabel(javax.swing.JLabel) Result(eu.ggnet.dwoss.util.interactiveresult.Result) Tuple2(eu.ggnet.dwoss.util.Tuple2) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Example 3 with UnitShard

use of eu.ggnet.dwoss.uniqueunit.api.UnitShard in project dwoss by gg-net.

the class UnitAvailabilityViewCask method resultListMouseClicked.

// </editor-fold>//GEN-END:initComponents
private void resultListMouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_resultListMouseClicked
    if (evt.getClickCount() != 2)
        return;
    UnitShard us = resultList.getSelectedValue();
    if (us == null || us.getAvailable() == null)
        return;
    Ui.exec(() -> {
        Ui.build().id(us.getRefurbishedId()).fx().show(() -> Dl.remote().lookup(UnitOverseer.class).toDetailedHtml(us.getRefurbishedId(), Dl.local().lookup(Guardian.class).getUsername()), () -> new HtmlPane());
    });
}
Also used : UnitShard(eu.ggnet.dwoss.uniqueunit.api.UnitShard) Guardian(eu.ggnet.saft.core.auth.Guardian) HtmlPane(eu.ggnet.dwoss.util.HtmlPane)

Example 4 with UnitShard

use of eu.ggnet.dwoss.uniqueunit.api.UnitShard in project dwoss by gg-net.

the class UnitAvailabilityViewCask method searchActionPerformed.

// GEN-LAST:event_resultListMouseClicked
private void searchActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_searchActionPerformed
    String refurbishedId = searchCommand.getText().trim();
    UnitShard us = Dl.remote().lookup(UnitOverseer.class).find(refurbishedId);
    model.add(0, us);
    searchCommand.setText("");
}
Also used : UnitOverseer(eu.ggnet.dwoss.redtapext.ee.UnitOverseer) UnitShard(eu.ggnet.dwoss.uniqueunit.api.UnitShard)

Example 5 with UnitShard

use of eu.ggnet.dwoss.uniqueunit.api.UnitShard in project dwoss by gg-net.

the class UnitOverseerBean method createUnitPosition.

/**
 * Find a Unit by its refurbished id and returns it.
 * <p/>
 * This method will throw a UserInfoException describing, why the unit is not available.
 * <p/>
 * @param refurbishId The refurbished id of the UniqueUnit
 * @param documentId  the document as reference for tax and more.
 * @return a Unit by its refurbished id or null if nothing is found of the unit is not available.
 * @throws UserInfoException if the refurbishId is not available
 */
@Override
public Result<List<Position>> createUnitPosition(String refurbishId, long documentId) throws UserInfoException {
    UnitShard us = internalFind(refurbishId);
    if (!us.isAvailable())
        throwNotAvailable(refurbishId, us);
    Document doc = new DocumentEao(redTapeEm).findById(documentId);
    UniqueUnit uu = new UniqueUnitEao(uuEm).findByIdentifier(Identifier.REFURBISHED_ID, refurbishId);
    Position p = Position.builder().amount(1).price(0.).serialNumber(uu.getSerial()).refurbishedId(uu.getRefurbishId()).bookingAccount(postLedger.get(PositionType.UNIT, doc.getTaxType()).orElse(null)).type(PositionType.UNIT).tax(doc.getTaxType().getTax()).uniqueUnitId(uu.getId()).uniqueUnitProductId(uu.getProduct().getId()).name(UniqueUnitFormater.toPositionName(uu)).description(UniqueUnitFormater.toDetailedDiscriptionLine(uu)).build();
    // return Result
    if (redTapeHook.isUnsatisfied())
        return new Result(Arrays.asList(p));
    return redTapeHook.get().elaborateUnitPosition(p, documentId);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UnitShard(eu.ggnet.dwoss.uniqueunit.api.UnitShard) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) Result(eu.ggnet.dwoss.util.interactiveresult.Result)

Aggregations

UnitShard (eu.ggnet.dwoss.uniqueunit.api.UnitShard)6 UnitOverseer (eu.ggnet.dwoss.redtapext.ee.UnitOverseer)2 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)2 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)2 Result (eu.ggnet.dwoss.util.interactiveresult.Result)2 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)1 UnitAvailabilityViewCask (eu.ggnet.dwoss.redtapext.ui.cap.UnitAvailabilityViewCask)1 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)1 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)1 HtmlPane (eu.ggnet.dwoss.util.HtmlPane)1 Tuple2 (eu.ggnet.dwoss.util.Tuple2)1 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)1 Guardian (eu.ggnet.saft.core.auth.Guardian)1 JLabel (javax.swing.JLabel)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1