Search in sources :

Example 1 with BrandContractorCount

use of eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount in project dwoss by gg-net.

the class UniqueUnitReporterOperation method buildSumModel.

private List<Object[]> buildSumModel(Step step, NavigableSet<TradeName> usedManufacturers, NavigableMap<Date, BrandContractorCount> revenue) {
    List<Object[]> rows = new ArrayList<>();
    for (Entry<Date, BrandContractorCount> e : revenue.entrySet()) {
        BrandContractorCount r = e.getValue();
        Object[] row = new Object[usedManufacturers.size() + 2];
        row[0] = step.format(e.getKey());
        int count = 1;
        for (TradeName manufacturer : usedManufacturers) {
            row[count] = r.countByManufacturer(manufacturer);
            count++;
        }
        row[count] = r.count();
        rows.add(row);
    }
    return rows;
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) BrandContractorCount(eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount)

Example 2 with BrandContractorCount

use of eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount in project dwoss by gg-net.

the class UniqueUnitReporterOperation method unitInputAsXls.

@Override
public FileJacket unitInputAsXls(Date start, Date end, Step step) {
    String name = "Aufnahmemengereport";
    SubMonitor m = monitorFactory.newSubMonitor(name);
    m.start();
    UniqueUnitEao eao = new UniqueUnitEao(em);
    NavigableSet<TradeName> usedManufacturers = eao.findUsedManufactuers();
    NavigableMap<Date, BrandContractorCount> revenue = eao.countByInputDateContractor(start, end, step);
    STable template = new STable();
    template.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
    template.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
    template.add(new STableColumn(step.name(), 12));
    for (TradeName manufacturer : usedManufacturers) {
        template.add(new STableColumn(manufacturer.getName(), 15, new CFormat(RIGHT)));
    }
    template.add(new STableColumn("Summe", 18, new CFormat(RIGHT)));
    STable all = new STable(template);
    all.setModel(new STableModelList(buildSumModel(step, usedManufacturers, revenue)));
    CCalcDocument cdoc = new TempCalcDocument(name);
    cdoc.add(new CSheet("Input_All", all));
    for (TradeName contractor : contractors.all()) {
        STable simple = new STable(template);
        simple.setModel(new STableModelList(buildContractorModel(step, contractor, usedManufacturers, revenue)));
        cdoc.add(new CSheet("Input_" + contractor, simple));
    }
    FileJacket result = new FileJacket(name, ".xls", new JExcelLucidCalcWriter().write(cdoc));
    m.finish();
    return result;
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) BrandContractorCount(eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount) JExcelLucidCalcWriter(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter)

Example 3 with BrandContractorCount

use of eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount 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();
}
Also used : BrandContractorCount(eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) LocalDate(java.time.LocalDate)

Example 4 with BrandContractorCount

use of eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount in project dwoss by gg-net.

the class UniqueUnitReporterOperation method buildContractorModel.

private List<Object[]> buildContractorModel(Step step, TradeName contractor, NavigableSet<TradeName> usedManufacturers, NavigableMap<Date, BrandContractorCount> revenue) {
    List<Object[]> rows = new ArrayList<>();
    for (Entry<Date, BrandContractorCount> e : revenue.entrySet()) {
        BrandContractorCount r = e.getValue();
        Object[] row = new Object[usedManufacturers.size() + 2];
        row[0] = step.format(e.getKey());
        int count = 1;
        for (TradeName manufacturer : usedManufacturers) {
            row[count] = r.countByContractorManufacturer(contractor, manufacturer);
            count++;
        }
        row[count] = r.countByContractor(contractor);
        rows.add(row);
    }
    return rows;
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) BrandContractorCount(eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount)

Aggregations

BrandContractorCount (eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount)4 TradeName (eu.ggnet.dwoss.rules.TradeName)3 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)2 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 FileJacket (eu.ggnet.dwoss.util.FileJacket)1 JExcelLucidCalcWriter (eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter)1 LocalDate (java.time.LocalDate)1