use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class ImportImageIdsAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Optional<File> inFile = Ui.fileChooser().open().opt();
if (!inFile.isPresent())
return;
Ui.build().dialog().eval(() -> new Alert(CONFIRMATION, "ImageIds aus der Datei:" + inFile.get().getPath() + " importieren ?")).opt().filter(b -> b == OK).map(b -> TikaUtil.isExcel(inFile.get())).filter(Ui.failure()::handle).map(Reply::getPayload).map(f -> Ui.progress().call(() -> Dl.remote().lookup(ImageIdHandler.class).importMissing(new FileJacket("in", ".xls", f)))).filter(Ui.failure()::handle).isPresent();
});
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class RedTapeTryout method main.
public static void main(String[] args) {
Dl.local().add(RemoteLookup.class, new RemoteLookup() {
@Override
public <T> boolean contains(Class<T> clazz) {
return false;
}
@Override
public <T> T lookup(Class<T> clazz) {
return null;
}
});
Dl.remote().add(RedTapeAgent.class, new RedTapeAgentStub());
Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
Dl.remote().add(UniversalSearcher.class, new UniversalSearcherStub());
Dl.remote().add(CustomerService.class, new CustomerServiceStub());
Dl.remote().add(DocumentSupporter.class, new DocumentSupporter() {
@Override
public void mail(Document document, DocumentViewType jtype) throws UserInfoException, RuntimeException {
System.out.println("Mailing " + document);
}
@Override
public JasperPrint render(Document document, DocumentViewType viewType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Dossier briefed(Document detached, String arranger) {
detached.add(Document.Flag.CUSTOMER_BRIEFED);
detached.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
return detached.getDossier();
}
@Override
public FileJacket toXls(String identifier) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.local().add(Guardian.class, new AbstractGuardian() {
@Override
public void login(String user, char[] pass) throws AuthenticationException {
setRights(new Operator(user, 1, Arrays.asList(AtomicRight.values())));
}
});
Dl.remote().add(StockAgent.class, null);
Dl.remote().add(UniqueUnitAgent.class, null);
// Dl.remote().add(LegacyRemoteBridge.class, null);
Dl.remote().add(ShippingCostService.class, null);
Mandators mandatorSupporterMock = mock(Mandators.class);
when(mandatorSupporterMock.loadSalesdata()).thenReturn(new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, Arrays.asList(SalesChannel.CUSTOMER, SalesChannel.RETAILER), null));
Dl.remote().add(Mandators.class, mandatorSupporterMock);
CustomerUpi ccos = mock(CustomerUpi.class);
when(ccos.createCustomer(any())).thenReturn(0L);
when(ccos.updateCustomer(any(), anyLong())).thenReturn(true);
Dl.local().add(CustomerUpi.class, ccos);
UiCore.startSwing(() -> new JLabel("Main Applikation"));
Ui.exec(() -> {
Ui.build().swing().show(() -> RedTapeController.build().getView());
});
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class DebitorsReporterOperation method toXls.
/**
* Creates the Report
*
* @param monitor
* @return a ByteArray represeting the content of an xls file.
*/
@Override
public FileJacket toXls(Date start, Date end) {
SubMonitor m = monitorFactory.newSubMonitor("DebitorenReport", 25);
m.message("loading Dossiers");
DocumentEao documentEao = new DocumentEao(redTapeEm);
List<Document> documents = new ArrayList<>();
documents.addAll(documentEao.findDocumentsBetweenDates(start, end, DocumentType.INVOICE));
m.worked(10, "preparing Data");
List<Object[]> rows = new ArrayList<>();
for (Document document : documents) {
UiCustomer c = customerService.asUiCustomer(document.getDossier().getCustomerId());
rows.add(new Object[] { c.getId(), document.getDossier().getIdentifier(), c.getCompany(), c.toNameLine(), document.getDossier().getCrucialDirective().getName(), document.getDossier().getComment(), document.getActual(), document.getIdentifier(), document.getPrice(), document.toAfterTaxPrice(), document.getDossier().getPaymentMethod().getNote() });
}
m.worked(10, "building Report");
STable table = new STable();
table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("Kid", 8, new CFormat(RIGHT))).add(new STableColumn("AiD", 10, new CFormat(RIGHT))).add(new STableColumn("Firma", 20));
table.add(new STableColumn("Nachname", 20)).add(new STableColumn("Letzer Status", 20));
table.add(new STableColumn("Bemerkung", 10)).add(new STableColumn("Datum", 10, new CFormat(RIGHT, SHORT_DATE)));
table.add(new STableColumn("RE_Nr", 10, new CFormat(RIGHT))).add(new STableColumn("Netto", 15, new CFormat(RIGHT, CURRENCY_EURO))).add(new STableColumn("Brutto", 10, new CFormat(RIGHT, CURRENCY_EURO)));
table.add(new STableColumn("ZahlungsModalität", 10, new CFormat(RIGHT)));
table.setModel(new STableModelList(rows));
CCalcDocument cdoc = new TempCalcDocument("Debitoren_");
cdoc.add(new CSheet("DebitorenReport", table));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
FileJacket result = new FileJacket("Debitoren", ".xls", file);
m.finish();
return result;
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class ImportPriceManagementLogicTest method testFromXls.
@Test
public void testFromXls() throws UserInfoException {
PriceCoreOperation core = mock(PriceCoreOperation.class);
ImporterOperation importer = new ImporterOperation(core, new ProgressProducerForTests());
FileJacket jacket = new FileJacket("Sample", "xls", new File("target/test-classes/ImportPriceManagementLogicSamples.xls"));
importer.fromXls(jacket, "testuser");
List<PriceEngineResult> expected = new ArrayList<>();
expected.add(new PriceEngineResult("1", "A", 1.0, 1.0, 0, 1, 0));
expected.add(new PriceEngineResult("2", "A", 2.0, 2.0, 1, 0, 0));
expected.add(new PriceEngineResult("3", "B", 3.0, 3.0, 0, -1, 0));
expected.add(new PriceEngineResult("4", "B", 4.0, 4.0, 1, 0, 0));
expected.add(new PriceEngineResult("5", "C", 5.0, 5.0, 0, 0, 1));
verify(core).store(eq(expected), eq("ImportPriceManagementOperation.fromXls()"), anyString(), any(IMonitor.class));
}
use of eu.ggnet.dwoss.util.FileJacket 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;
}
Aggregations