use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class UniqueUnitEaoIT method testCount.
@Test
// TODO: The query behind the eao fails in hsqld but works in mysql. Can't test it for now.
@Ignore
public void testCount() throws Exception {
utx.begin();
em.joinTransaction();
UniqueUnitEao unitEao = new UniqueUnitEao(em);
NavigableMap<Date, BrandContractorCount> counted = unitEao.countByInputDateContractor(BEFORE, AFTER, WEEK);
for (Entry<Date, BrandContractorCount> e : counted.entrySet()) {
LoggerFactory.getLogger(UniqueUnitEaoIT.class).info("TestCount: k={}, v={}", e.getKey(), e.getValue());
}
utx.commit();
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class UniqueUnitEaoIT method testFindByProductPartNo.
@Test
public void testFindByProductPartNo() throws Exception {
utx.begin();
em.joinTransaction();
UniqueUnitEao unitEao = new UniqueUnitEao(em);
List<UniqueUnit> uus = unitEao.findByProductPartNo(PARTNO_1);
assertFalse(uus.isEmpty());
assertEquals(2, uus.size());
utx.commit();
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class UniqueUnitEaoIT method testFindIdentifiers.
@Test
public void testFindIdentifiers() throws Exception {
utx.begin();
em.joinTransaction();
UniqueUnitEao unitEao = new UniqueUnitEao(em);
assertEquals(2, unitEao.findByIdentifiers(REFURBISHED_ID, new TreeSet<>(Arrays.asList("99999", "99998"))).size());
assertTrue(unitEao.findByIdentifiers(REFURBISHED_ID, Arrays.asList(REFURBISHID_62325)).contains(unit_62325));
utx.commit();
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class RedTapeUpdateRepaymentWorkflow method rollInMissingStockUnits.
/**
* If referenced Units are not in Stock, roll them in and append them to the instance variable (stockUnits).
*
* @return the list of rolled in StockUnits
*/
List<StockUnit> rollInMissingStockUnits(String dossierIdentifier, Collection<Position> positions, int destinationId) {
List<UniqueUnit> uniqueUnits = new ArrayList<>();
StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uniqueUnitEm);
for (Position position : positions) {
if (stockUnitEao.findByUniqueUnitId(position.getUniqueUnitId()) == null) {
uniqueUnits.add(uniqueUnitEao.findById(position.getUniqueUnitId()));
}
}
if (uniqueUnits.isEmpty())
return Collections.EMPTY_LIST;
StockTransactionEmo transactionEmo = new StockTransactionEmo(stockEm);
StockTransaction rollInTransaction = transactionEmo.requestRollInPrepared(destinationId, arranger, "RollIn durch Gutschrift " + dossierIdentifier);
for (UniqueUnit uu : uniqueUnits) {
StockUnit stockUnit = new StockUnit(uu.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID), uu.getProduct().getName(), uu.getId());
rollInTransaction.addUnit(stockUnit);
stockEm.persist(stockUnit);
}
List<StockUnit> rolledInUnits = transactionEmo.completeRollIn(arranger, Arrays.asList(rollInTransaction));
L.info("Missing Units rolled In: {}", toIds(rolledInUnits));
return rolledInUnits;
}
Aggregations