Search in sources :

Example 11 with StockUnitEao

use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.

the class UnitProcessorOperation method transfer.

/**
 * Transfers a UniqueUnits StockUnit to the supplied Stock.
 * <p>
 * <ul>
 * <li>Validate, if a StockUnit for the UniqueUnit exists, and this StockUnit is in Stock</li>
 * <li>Transfer StockUnit via {@link StockTransactionType#EXTERNAL_TRANSFER}</li>
 * <li>Update the SopoUnit</li>
 * </ul>
 * <p/>
 * @param uniqueUnit the uniqueUnit
 * @param stockId    the stockId
 * @param arranger
 * @return
 */
// TODO: Use StockTransactionEmo.resquestExternalTransfer and completeExternalTransfer
@Override
public UniqueUnit transfer(UniqueUnit uniqueUnit, int stockId, String arranger) {
    StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
    if (stockUnit == null)
        throw new IllegalArgumentException("No StockUnit for " + uniqueUnit);
    if (stockUnit.isInTransaction())
        throw new IllegalArgumentException(stockUnit + " is on Transaction");
    Stock destination = new DefaultEao<>(Stock.class, stockEm).findById(stockId);
    StockTransaction st = new StockTransaction(StockTransactionType.EXTERNAL_TRANSFER);
    StockTransactionStatus status = new StockTransactionStatus(StockTransactionStatusType.COMPLETED, new Date());
    status.addParticipation(new StockTransactionParticipation(StockTransactionParticipationType.ARRANGER, arranger));
    st.addStatus(status);
    st.setSource(stockUnit.getStock());
    st.setDestination(destination);
    st.addPosition(new StockTransactionPosition(stockUnit));
    stockEm.persist(st);
    stockUnit.setPosition(null);
    new StockLocationDiscoverer(stockEm).discoverAndSetLocation(stockUnit, destination);
    uniqueUnit = new UniqueUnitEao(uuEm).findById(uniqueUnit.getId());
    uniqueUnit.addHistory("External Stock change from " + stockUnit.getStock() + " to " + destination + " by " + arranger);
    uniqueUnit.fetchEager();
    return uniqueUnit;
}
Also used : StockTransactionParticipation(eu.ggnet.dwoss.stock.ee.entity.StockTransactionParticipation) StockLocationDiscoverer(eu.ggnet.dwoss.stock.ee.emo.StockLocationDiscoverer) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) StockTransactionPosition(eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 12 with StockUnitEao

use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.

the class RedTapeWorkerOperation method toDetailedHtml.

/**
 * Create a HTML formated String representing the detailed information from a {@link Dossier}.
 * <p/>
 * @param dossierId The Dossier
 * @return a HTML formated String representing the detailed information from a {@link Dossier}.
 */
@Override
public String toDetailedHtml(long dossierId) {
    Dossier dos = redTapeEm.find(Dossier.class, dossierId);
    if (dos == null)
        return "<strong>No Dossier with Id: " + dossierId + " found</strong>";
    String detailedHtmlCustomer = customerService.asHtmlHighDetailed(dos.getCustomerId());
    String stockInfo = "StockUnits:<ul>";
    for (StockUnit stockUnit : new StockUnitEao(stockEm).findByUniqueUnitIds(dos.getRelevantUniqueUnitIds())) stockInfo += "<li>" + stockUnit + "</li>";
    stockInfo += "</ul>";
    return "<html>" + detailedHtmlCustomer + "<br />" + DossierFormater.toHtmlDetailed(dos) + "<br />" + stockInfo + "</html>";
}
Also used : StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 13 with StockUnitEao

use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao 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 14 with StockUnitEao

use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.

the class UnitOverseerBean method throwNotAvailable.

/**
 * Build and throw an exception for a not available unit.
 * <p>
 * @param refurbishId the refurbished id of the unit
 * @param us          the unit shard
 * @throws UserInfoException
 */
private void throwNotAvailable(String refurbishId, UnitShard us) throws UserInfoException {
    // <- auch in di auslagerung...
    if (us.getAvailable() == null)
        throw new UserInfoException("SopoNr " + refurbishId + " existiert nicht");
    StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(us.getUniqueUnitId());
    if (stockUnit != null && stockUnit.getLogicTransaction() != null) {
        Dossier dos = new DossierEao(redTapeEm).findById(stockUnit.getLogicTransaction().getDossierId());
        if (dos == null)
            throw new UserInfoException("SopoNr " + refurbishId + " is on a LogicTransaction, but there is no Dossier, inform Team Software");
        UiCustomer customer = customerService.asUiCustomer(dos.getCustomerId());
        if (customer == null)
            throw new UserInfoException("SopoNr " + refurbishId + " is on Dossier " + dos.getIdentifier() + ", but Customer " + dos.getCustomerId() + " does not exist.");
        throw new UserInfoException("SopoNr " + refurbishId + " ist schon vergeben" + "\nKID = " + customer.getId() + "\nKunde = " + customer.toTitleNameLine() + "\n\nVorgang = " + dos.getIdentifier());
    }
}
Also used : StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer)

Example 15 with StockUnitEao

use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.

the class UnitSupporterOperation method isSerialAvailable.

@Override
public boolean isSerialAvailable(String serial) {
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.SERIAL, serial);
    if (uu != null) {
        StockUnit stockUnit = stockUnitEao.findByUniqueUnitId(uu.getId());
        if (stockUnit != null) {
            return false;
        }
    }
    return true;
}
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)

Aggregations

StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)29 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)25 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)19 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)16 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)9 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)6 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)6 StockTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo)5 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)5 LogicTransactionEao (eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao)4 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)4 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)4 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)3 ProductSpecEao (eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao)3 FileJacket (eu.ggnet.dwoss.util.FileJacket)3 Test (org.junit.Test)3 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)2 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)2 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)2 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)2