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);
}
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();
}
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);
}
}
Aggregations