Search in sources :

Example 6 with LogicTransactionEmo

use of eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo in project dwoss by gg-net.

the class UnitOverseerBean method lockStockUnit.

/**
 * Find an available StockUnit and locks it by add to a LogicTransaction via DossierId.
 * <p/>
 * If no unit is found a LayerEightException is thrown.
 * <p/>
 * @param dossierId     The Dossiers ID
 * @param refurbishedId The refurbished id for the Unique Unit search
 * @throws IllegalStateException if the refurbishId is not available
 */
@Override
public void lockStockUnit(long dossierId, String refurbishedId) throws IllegalStateException {
    if (!internalFind(refurbishedId).isAvailable())
        throw new IllegalStateException("Trying to lock refusbishId " + refurbishedId + ", but it is not available!");
    UniqueUnit uu = new UniqueUnitEao(uuEm).findByIdentifier(Identifier.REFURBISHED_ID, refurbishedId);
    StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uu.getId());
    LogicTransaction lt = new LogicTransactionEmo(stockEm).request(dossierId);
    lt.add(stockUnit);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 7 with LogicTransactionEmo

use of eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo in project dwoss by gg-net.

the class LogicTransactionEmoIT method testRequest.

@Test
public void testRequest() throws Exception {
    L.info("starting test request");
    LogicTransactionEmo ltEmo = new LogicTransactionEmo(em);
    utx.begin();
    em.joinTransaction();
    LogicTransaction lt1 = new LogicTransaction();
    lt1.setDossierId(1);
    LogicTransaction lt2 = ltEmo.request(2);
    em.persist(lt1);
    assertNotNull(lt1);
    assertNotNull(lt2);
    utx.commit();
}
Also used : LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Test(org.junit.Test)

Example 8 with LogicTransactionEmo

use of eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo in project dwoss by gg-net.

the class RedTapeWorkflow method equilibrateOrRemoveLogicTransaction.

/**
 * Equilibrates the LogicTransaction to the Document and added History to all UniqueUnits.
 * <p>
 * @param document
 * @param remove   if true everything is removed.
 * @return
 */
protected void equilibrateOrRemoveLogicTransaction(Document document, boolean remove) {
    LogicTransactionEmo ltEmo = new LogicTransactionEmo(stockEm);
    EquilibrationResult equilibrate = ltEmo.equilibrate(document.getDossier().getId(), remove ? new ArrayList<>() : document.getPositionsUniqueUnitIds());
    if (equilibrate == null)
        return;
    L.debug("Equilibrated Stock LogicTransaction: {}", equilibrate);
    for (Integer uuid : equilibrate.getAdded()) {
        uniqueUnitEm.find(UniqueUnit.class, uuid).addHistory("Added to Dossier " + document.getDossier().getIdentifier() + " of Customer " + document.getDossier().getCustomerId() + " by " + arranger);
    }
    for (Integer uuid : equilibrate.getRemoved()) {
        uniqueUnitEm.find(UniqueUnit.class, uuid).addHistory("Removed from Dossier " + document.getDossier().getIdentifier() + " of Customer " + document.getDossier().getCustomerId() + " by " + arranger);
    }
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) EquilibrationResult(eu.ggnet.dwoss.stock.ee.emo.EquilibrationResult) LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) ArrayList(java.util.ArrayList)

Aggregations

LogicTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo)8 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)3 DossierEmo (eu.ggnet.dwoss.redtape.ee.emo.DossierEmo)2 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)2 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)2 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)2 Test (org.junit.Test)2 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)1 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)1 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)1 CustomerDocument (eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)1 LogicTransactionEao (eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao)1 EquilibrationResult (eu.ggnet.dwoss.stock.ee.emo.EquilibrationResult)1 StockTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo)1 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)1 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)1 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)1 ArrayList (java.util.ArrayList)1