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