Search in sources :

Example 36 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao 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)

Example 37 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.

the class UniversalSearcherOperation method searchUnits.

/**
 * Returns a List of short descriptions of Units in Html.
 * Ensure to add the html start/end tags manually
 * <p/>
 * @param search a search string.
 * @return a List of short descriptions of Units in Html.
 */
// Used in Misc. Unversal Search
@Override
public List<Tuple2<Long, String>> searchUnits(String search) {
    List<UniqueUnit> uus = new UniqueUnitEao(uuEm).find(search);
    List<Tuple2<Long, String>> result = new ArrayList<>(uus.size());
    Set<Long> uurefurbishIds = new HashSet<>();
    for (UniqueUnit uu : uus) {
        // TODO: WARNING, if we start using letters in refurbhisIds, the search will not show any results.
        try {
            long sopoNr = Long.parseLong(uu.getRefurbishId());
            uurefurbishIds.add(sopoNr);
            result.add(new Tuple2(sopoNr, UniqueUnitFormater.toSimpleHtml(uu)));
        } catch (NumberFormatException e) {
            continue;
        }
    }
    if (bridgeInstance.isUnsatisfied())
        return result;
    for (LegacyUnit unit : bridgeInstance.get().findUnit(search)) {
        try {
            if (uurefurbishIds.contains(Long.parseLong(unit.getUnitIdentifier())))
                continue;
            String re = "<b>" + unit.getUnitIdentifier() + "</b> - ";
            re += unit.getSerial() + "<br />";
            re += unit.getManufacturerPartNo() + "<br />";
            re += "Status: <i>Nicht verfügbar (Legacy System:" + bridgeInstance.get().localName() + ")</i><br />";
            result.add(new Tuple2<>(Long.parseLong(unit.getUnitIdentifier()), re));
        } catch (NumberFormatException e) {
        // Ignore
        }
    }
    return result;
}
Also used : LegacyUnit(eu.ggnet.dwoss.redtape.ee.api.LegacyUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Tuple2(eu.ggnet.dwoss.util.Tuple2)

Example 38 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.

the class UnitProcessorOperation method validateReceipt.

private void validateReceipt(UniqueUnit receiptUnit) throws IllegalArgumentException {
    if (receiptUnit.getId() > 0)
        throw new IllegalArgumentException("UniqueUnit has already been persisted " + receiptUnit);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    UniqueUnit uniqueUnit = uniqueUnitEao.findByIdentifier(Identifier.REFURBISHED_ID, receiptUnit.getIdentifier(Identifier.REFURBISHED_ID));
    if (uniqueUnit != null)
        throw new IllegalArgumentException("Unit with refurbishedId=" + receiptUnit.getRefurbishId() + " exists.\n- Supplied Unit:" + receiptUnit + "\n- Database Unit:" + uniqueUnit);
    StockUnit stockUnit = new StockUnitEao(stockEm).findByRefurbishId(receiptUnit.getRefurbishId());
    if (stockUnit != null)
        throw new IllegalArgumentException(stockUnit + " exists");
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 39 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.

the class UnitSupporterOperation method findRefurbishIdBySerial.

@Override
public String findRefurbishIdBySerial(String serial) {
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.SERIAL, serial);
    if (uu != null)
        return uu.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID);
    return null;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 40 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.

the class UnitSupporterOperation method isRefurbishIdAvailable.

/**
 * Returns true if supplied refurbishId is available, meaning not jet in the database.
 *
 * @param refurbishId the refubishedId
 * @return true if available.
 */
@Override
public boolean isRefurbishIdAvailable(String refurbishId) {
    UniqueUnit uniqueUnit = new UniqueUnitEao(uuEm).findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
    if (uniqueUnit != null)
        return false;
    if (bridgeInstance.isUnsatisfied())
        return true;
    LegacyLocalBridge bridge = bridgeInstance.get();
    L.info("Using LegacyBridge ({})", bridge.localName());
    return bridge.isUnitIdentifierAvailable(refurbishId);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) LegacyLocalBridge(eu.ggnet.dwoss.redtape.ee.api.LegacyLocalBridge) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Aggregations

UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)49 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)38 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)21 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)19 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)17 FileJacket (eu.ggnet.dwoss.util.FileJacket)10 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)9 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)6 File (java.io.File)6 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)5 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)5 CFormat (eu.ggnet.lucidcalc.CFormat)5 CSheet (eu.ggnet.lucidcalc.CSheet)5 STable (eu.ggnet.lucidcalc.STable)5 STableColumn (eu.ggnet.lucidcalc.STableColumn)5 STableModelList (eu.ggnet.lucidcalc.STableModelList)5 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)5 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)4 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)4