Search in sources :

Example 41 with UniqueUnitEao

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;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ArrayList(java.util.ArrayList) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) StockTransactionEao(eu.ggnet.dwoss.stock.ee.eao.StockTransactionEao) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 42 with UniqueUnitEao

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;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ArrayList(java.util.ArrayList) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder)

Example 43 with UniqueUnitEao

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;
}
Also used : PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 44 with UniqueUnitEao

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()));
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) ConstraintViolation(javax.validation.ConstraintViolation) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) Test(org.junit.Test)

Example 45 with UniqueUnitEao

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();
}
Also used : UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Aggregations

UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)49 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)38 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)21 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)19 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)17 FileJacket (eu.ggnet.dwoss.util.FileJacket)10 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)9 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)6 File (java.io.File)6 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)5 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)5 CFormat (eu.ggnet.lucidcalc.CFormat)5 CSheet (eu.ggnet.lucidcalc.CSheet)5 STable (eu.ggnet.lucidcalc.STable)5 STableColumn (eu.ggnet.lucidcalc.STableColumn)5 STableModelList (eu.ggnet.lucidcalc.STableModelList)5 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)5 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)4 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)4