use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class AuditReporterOperation method onRollIn.
/**
* Returns an audit report of units which are input between the dates.
* <p/>
* @return an audit report of units which are input between the dates.
*/
@Override
public FileJacket onRollIn() {
SubMonitor m = monitorFactory.newSubMonitor("AuditReport", 100);
m.message("loading UniqueUnits");
m.start();
List<StockTransaction> rollInTransactions = new StockTransactionEao(stocks.getEntityManager()).findByTypeAndStatus(StockTransactionType.ROLL_IN, StockTransactionStatusType.PREPARED);
List<Integer> uuIds = toUniqueUnitIds(rollInTransactions);
List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uus.getEntityManager()).findByIds(uuIds);
m.worked(5, "preparing Document");
List<Object[]> rows = new ArrayList<>();
for (UniqueUnit uu : uniqueUnits) {
rows.add(new Object[] { uu.getRefurbishId(), uu.getProduct().getGroup().getNote(), uu.getProduct().getPartNo(), uu.getSerial(), ProductFormater.toName(uu.getProduct()), uu.getContractor(), UniqueUnitFormater.toSingleLineAccessories(uu), UniqueUnitFormater.toSingleLineComment(uu), UniqueUnitFormater.toSingleLineInternalComment(uu), uu.getCondition().getNote(), uu.getShipmentLabel(), uu.getProduct().getDescription(), "" });
}
CSheet sheet = new CSheet("Audit");
STable table = new STable();
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("SopoNr", 7)).add(new STableColumn("Warengruppe", 13)).add(new STableColumn("ArtikelNr", 15)).add(new STableColumn("Seriennummer", 27));
table.add(new STableColumn("Name", 30)).add(new STableColumn("Lieferant", 12)).add(new STableColumn("Zubehör", 50)).add(new STableColumn("Bemerkung", 50));
table.add(new STableColumn("Interne Bemerkung", 30)).add(new STableColumn("Zustand", 12)).add(new STableColumn("Shipment", 12)).add(new STableColumn("Beschreibung", 50));
table.setModel(new STableModelList(rows));
sheet.addBelow(table);
CCalcDocument document = new TempCalcDocument();
document.add(sheet);
FileJacket fj = new FileJacket("Audit", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document));
m.finish();
return fj;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class AuditReporterOperation method byRange.
/**
* Returns an audit report of units which are on a roll in transaction, but not yet rolled in.
* <p/>
* @return an audit report of units which are on a roll in transaction, but not yet rolled in.
*/
@Override
public FileJacket byRange(Date start, Date end) {
SubMonitor m = monitorFactory.newSubMonitor("AuditReport", 100);
m.message("loading UniqueUnits");
m.start();
List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uus.getEntityManager()).findBetweenInputDates(start, end);
m.worked(5, "preparing Document");
List<Object[]> rows = new ArrayList<>();
for (UniqueUnit uu : uniqueUnits) {
rows.add(new Object[] { uu.getRefurbishId(), uu.getProduct().getGroup().getNote(), uu.getProduct().getPartNo(), uu.getSerial(), ProductFormater.toName(uu.getProduct()), uu.getContractor(), UniqueUnitFormater.toSingleLineAccessories(uu), UniqueUnitFormater.toSingleLineComment(uu), UniqueUnitFormater.toSingleLineInternalComment(uu), uu.getCondition().getNote(), uu.getShipmentLabel(), uu.getProduct().getDescription(), "" });
}
CSheet sheet = new CSheet("Audit");
STable table = new STable();
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("SopoNr", 7)).add(new STableColumn("Warengruppe", 13)).add(new STableColumn("ArtikelNr", 15)).add(new STableColumn("Seriennummer", 27));
table.add(new STableColumn("Name", 30)).add(new STableColumn("Lieferant", 12)).add(new STableColumn("Zubehör", 50)).add(new STableColumn("Bemerkung", 50));
table.add(new STableColumn("Interne Bemerkung", 30)).add(new STableColumn("Zustand", 12)).add(new STableColumn("Shipment", 12)).add(new STableColumn("Beschreibung", 50));
table.setModel(new STableModelList(rows));
sheet.addBelow(table);
CCalcDocument document = new TempCalcDocument();
document.add(sheet);
FileJacket fj = new FileJacket("Audit", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document));
m.finish();
return fj;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class ExporterOperation method load.
/**
* Loads exactly one Unit as PriceEngineResult.
*
* @param refurbishId the unitid
* @return The PriceEngineResult or Null if Id not found
* @throws UserInfoException if the unitId is not a Number
*/
@Override
public PriceEngineResult load(String refurbishId) throws UserInfoException {
UniqueUnit uu = new UniqueUnitEao(uuEm).findByIdentifier(Identifier.REFURBISHED_ID, refurbishId);
PriceEngineResult per = new PriceEngineResult(uu);
per.setRetailerPrice(uu.getPrice(PriceType.RETAILER));
per.setCustomerPrice(uu.getPrice(PriceType.CUSTOMER));
return per;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class UniqueUnitEaoFindsIT method testFinds.
/**
* Multiple tests on find.
*
* @throws Exception
*/
@Test
public void testFinds() throws Exception {
Product p = new Product(ProductGroup.MONITOR, TradeName.FUJITSU, PARTNO_1, "The Notebook");
UniqueUnitEao eao = new UniqueUnitEao(em);
UniqueUnit unit1 = new UniqueUnit();
unit1.setMfgDate(new Date());
unit1.setIdentifier(SERIAL, "ROFFFLAASSS");
unit1.setIdentifier(REFURBISHED_ID, "22223");
unit1.setContractor(TradeName.ONESELF);
unit1.setCondition(Condition.AS_NEW);
unit1.setProduct(p);
UniqueUnit unit2 = new UniqueUnit();
unit2.setIdentifier(SERIAL, "FASREAGFSGSWE");
unit2.setIdentifier(REFURBISHED_ID, "54422");
unit2.setContractor(TradeName.ONESELF);
unit2.setCondition(Condition.AS_NEW);
unit2.setProduct(p);
UniqueUnit unit3 = new UniqueUnit();
unit3.setIdentifier(SERIAL, "FHASKHFUAERHFAGTQ5");
unit3.setIdentifier(REFURBISHED_ID, "33323");
unit3.setContractor(TradeName.ONESELF);
unit3.setCondition(Condition.AS_NEW);
unit3.setProduct(p);
UniqueUnit unit4 = new UniqueUnit();
unit4.setIdentifier(SERIAL, "GFSKLFDIACVHDAIERQ");
unit4.setIdentifier(REFURBISHED_ID, "54142");
unit4.setContractor(TradeName.ONESELF);
unit4.setCondition(Condition.AS_NEW);
unit4.setProduct(p);
UniqueUnit unit5 = new UniqueUnit();
unit5.setIdentifier(SERIAL, "FDALOIFUOWE");
unit5.setIdentifier(REFURBISHED_ID, "29471");
unit5.setContractor(TradeName.ONESELF);
unit5.setCondition(Condition.AS_NEW);
unit5.setProduct(p);
Set<ConstraintViolation<UniqueUnit>> validate = Validation.buildDefaultValidatorFactory().getValidator().validate(unit1);
assertTrue(ConstraintViolationFormater.toMultiLine(new HashSet<>(validate), true), validate.isEmpty());
utx.begin();
em.joinTransaction();
em.persist(p);
em.persist(unit1);
em.persist(unit2);
em.persist(unit3);
em.persist(unit4);
em.persist(unit5);
utx.commit();
utx.begin();
em.joinTransaction();
assertThat(eao.findByIdentifier(REFURBISHED_ID, "22223").getId()).as("Id of Unit1 via findByIdentifier 22223").isEqualTo(unit1.getId());
assertThat(eao.findByIdentifier(REFURBISHED_ID, "54422").getId()).as("Id of Unit2 via findByIdentifier 54422").isEqualTo(unit2.getId());
assertThat(eao.findByPartialIdentifier(REFURBISHED_ID, "54*")).as("Result of 54* should contation unit2 and unit4").contains(unit2, unit4);
assertThat(eao.findByPartialIdentifier(REFURBISHED_ID, "*22*")).as("Result of *22* should contation unit1 and unit2").contains(unit1, unit2);
assertThat(eao.countFind("*5*")).as("Counting *5*").isEqualTo(3);
assertThat(eao.find("*5*")).as("Find of *5*").contains(unit2, unit3, unit4);
utx.commit();
SearchProvider search = null;
for (Iterator<SearchProvider> iterator = searchProviders.iterator(); iterator.hasNext(); ) {
SearchProvider next = iterator.next();
if (next.getSource() == UNIQUE_UNIT)
search = next;
}
assertThat(search.estimateMaxResults(new SearchRequest("*5*"))).as("Counting via Searchprovider *5*").isEqualTo(3);
assertThat(search.search(new SearchRequest("*5*"), 0, 1000)).as("Find of *5*").extracting(ShortSearchResult::getKey).contains(new GlobalKey(GlobalKey.Component.UNIQUE_UNIT, unit2.getId()), new GlobalKey(GlobalKey.Component.UNIQUE_UNIT, unit3.getId()), new GlobalKey(GlobalKey.Component.UNIQUE_UNIT, unit4.getId()));
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class UniqueUnitEaoIT method testFindIdentifier.
@Test
public void testFindIdentifier() throws Exception {
utx.begin();
em.joinTransaction();
UniqueUnitEao unitEao = new UniqueUnitEao(em);
assertNotNull(unitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, REFURBISHID_62325));
assertNull(unitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, "65475"));
assertEquals(unit_62325, unitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, REFURBISHID_62325));
utx.commit();
}
Aggregations