use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class SalesListingProducerOperation method generateXlsListings.
/**
* Generates XLS files for units in a specific sales channel.
* The lists are seperated by brand.
* <p>
* @param channel the saleschannel
* @return XLS files for units in a specific sales channel.
*/
private Map<TradeName, Collection<FileJacket>> generateXlsListings(SalesChannel channel) {
SubMonitor m = monitorFactory.newSubMonitor("Listen für " + channel.getName() + " erstellen", 100);
m.start();
List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransactionAndPresentStock();
List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
Map<TradeName, List<UniqueUnit>> units = uniqueUnits.stream().collect(Collectors.groupingBy(uu -> uu.getProduct().getTradeName()));
m.worked(2, "prüfe und filtere Geräte");
Map<TradeName, Collection<FileJacket>> files = new HashMap<>();
for (TradeName k : units.keySet()) {
List<UniqueUnit> uus = units.get(k);
Collections.sort(uus, new UniqueUnitComparator());
List<Object[]> rows = new ArrayList<>();
for (UniqueUnit get : uus) {
UniqueUnit uu = get;
Product p = uu.getProduct();
// Cases to filter out.
if (uu.getSalesChannel() != channel)
continue;
if (!uu.hasPrice((channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER)))
continue;
Object[] row = { uu.getRefurbishId(), p.getPartNo(), p.getGroup().getNote(), p.getTradeName().getName(), p.getName(), p.getDescription(), uu.getWarranty().getName(), uu.getWarrentyValid(), UniqueUnitFormater.toSingleLineAccessories(uu), uu.getCondition().getNote(), UniqueUnitFormater.toSingleLineComment(uu), uu.getPrice(PriceType.RETAILER), uu.getPrice(PriceType.CUSTOMER), (!uu.hasPrice(PriceType.CUSTOMER) ? null : TwoDigits.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.DEFAULT_TAX.getTax(), 0)) };
rows.add(row);
}
if (rows.isEmpty())
continue;
m.worked(5, "creating File, Geräte: " + rows.size());
STable unitTable = new STable();
unitTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
unitTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
unitTable.setRowHeight(1000);
unitTable.add(new STableColumn("SopoNr", 12));
unitTable.add(new STableColumn("ArtikelNr", 15));
unitTable.add(new STableColumn("Warengruppe", 18));
unitTable.add(new STableColumn("Hersteller", 15));
unitTable.add(new STableColumn("Bezeichnung", 30));
unitTable.add(new STableColumn("Beschreibung", 60, LFT));
unitTable.add(new STableColumn("Garantie", 18, LFT));
unitTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
unitTable.add(new STableColumn("Zubehör", 30, LFT));
unitTable.add(new STableColumn("optische Bewertung", 25));
unitTable.add(new STableColumn("Bemerkung", 50, LFT));
unitTable.add(new STableColumn("Händler", 15, EURO));
unitTable.add(new STableColumn("Endkunde", 15, EURO));
unitTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
unitTable.setModel(new STableModelList(rows));
CCalcDocument cdoc = new TempCalcDocument();
cdoc.add(new CSheet("Sonderposten", unitTable));
files.put(k, Arrays.asList(new FileJacket(k.getName() + " Liste", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc))));
}
m.finish();
return files;
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class SubMonitorUnitTest method testConvert2.
@Test
public void testConvert2() {
JUnitMonitor m = new JUnitMonitor(1000);
SubMonitor sm = SubMonitor.convert(m, 100);
sm.start();
m.testRemaining(1000, 1);
sm.worked(50);
m.testRemaining(500, 1);
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class MonitorFactorySupportBean method doSomething.
public void doSomething() {
LoggerFactory.getLogger(MonitorFactorySupportBean.class).info("doSomething called");
SubMonitor m = monitorFactory.newSubMonitor("The Test Progress", 100);
for (int i = 0; i < 100; i++) {
m.worked(1, "Done: " + i);
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
}
}
m.finish();
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class ReportLineGeneratorOperation method makeReportLines.
public void makeReportLines(int amount) {
SubMonitor m = monitorFactory.newSubMonitor("Erzeuge " + amount + " ReportLines", amount);
m.start();
for (int i = 0; i < amount; i++) {
reportEm.persist(generator.makeReportLine());
m.worked(1);
}
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class SageExporterEngine method execute.
public void execute(IMonitor monitor) {
SubMonitor m = SubMonitor.convert(monitor, "Create GS-Office XML Data", customerInvoices.size() + 10);
RowData rowData = generateGSRowData(monitor);
m.message("writting Output");
try {
JAXBContext context = JAXBContext.newInstance(RowData.class);
Marshaller ms = context.createMarshaller();
ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
ms.setProperty(Marshaller.JAXB_ENCODING, "ISO-8859-1");
ms.marshal(rowData, output);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
m.finish();
}
Aggregations