Search in sources :

Example 1 with ReportParameter

use of eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter in project dwoss by gg-net.

the class SimpleReportLineTryout method main.

public static void main(String[] args) {
    ReportAgent rastub = new ReportAgent() {

        List<eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine> all = Arrays.asList(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ACER).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.DELL).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(10).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.HP).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(23).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.AMAZON).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.EMACHINES).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.FUJITSU).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ONESELF).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.LENOVO).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.FUJITSU).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.SAMSUNG).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.SAMSUNG).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.AMAZON).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ALSO).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build());

        @Override
        public <T> List<T> findAll(Class<T> entityClass) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class))
                return (List<T>) all;
            return Collections.EMPTY_LIST;
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class)) {
                if (start > all.size())
                    return Collections.EMPTY_LIST;
                if (start < 0)
                    start = 0;
                if (amount + start > all.size())
                    amount = all.size() - start;
                return (List<T>) all.subList(start, amount + start);
            }
            return Collections.EMPTY_LIST;
        }

        @Override
        public List<eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine> findSimple(SearchParameter search, int firstResult, int maxResults) {
            return findAll(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class, firstResult, maxResults);
        }

        @Override
        public long count(SearchParameter search) {
            return all.size();
        }

        @Override
        public <T> long count(Class<T> entityClass) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class))
                return all.size();
            return 0;
        }

        // <editor-fold defaultstate="collapsed" desc="Unused Methods">
        @Override
        public Report store(Report report, Collection<Storeable> storeables) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findAllReportLinesReverse(int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Set<ReportLine> attachDanglingComplaints(TradeName type, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> find(SearchParameter search, int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult findReportResult(long reportId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findReportLinesByDocumentType(DocumentType type, Date from, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public boolean updateReportLineComment(int optLock, long reportId, String comment) {
            System.out.println("Line = " + reportId + " adding comment " + comment);
            return true;
        }

        @Override
        public Reply<String> updateReportName(Report.OptimisticKey key, String name) {
            System.out.println("Report = " + key + " changing name = " + name);
            return Reply.success(name);
        }
    };
    Dl.remote().add(ReportAgent.class, rastub);
    Ui.exec(() -> {
        UiCore.startSwing(() -> new JLabel("Main Applikation"));
        Ui.build().fx().show(() -> {
            RawReportView srl = new RawReportView();
            srl.load(new SearchParameter());
            return srl;
        });
    });
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) Report(eu.ggnet.dwoss.report.ee.entity.Report) RawReportView(eu.ggnet.dwoss.report.ui.RawReportView) JLabel(javax.swing.JLabel) LockModeType(javax.persistence.LockModeType)

Example 2 with ReportParameter

use of eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter in project dwoss by gg-net.

the class SelectExistingReportViewTryout method main.

public static void main(String[] args) {
    ReportAgent rastub = new ReportAgent() {

        private int counter = 0;

        // <editor-fold defaultstate="collapsed" desc="Unused Methods">
        @Override
        public List<SimpleReportLine> findSimple(SearchParameter search, int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> find(SearchParameter search, int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public long count(SearchParameter search) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findReportLinesByDocumentType(DocumentType type, Date from, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Report store(Report report, Collection<Storeable> storeables) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult findReportResult(long reportId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findAllReportLinesReverse(int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Set<ReportLine> attachDanglingComplaints(TradeName type, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> long count(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public boolean updateReportLineComment(int optLock, long reportId, String comment) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        // </editor-fold>
        @Override
        public Reply<String> updateReportName(Report.OptimisticKey key, String name) {
            System.out.println("Report Name updated with " + name + " calles");
            counter++;
            if ((counter % 2) != 0) {
                System.out.println("Counter=" + counter + " simulating Error");
                return Reply.failure("Counter=" + counter + " simulating Error");
            } else {
                System.out.println("Counter=" + counter + " simulating Success");
                return Reply.success(name);
            }
        }
    };
    Dl.remote().add(ReportAgent.class, rastub);
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    final Date today = new Date();
    final Date enddate = new Date();
    final Date startdate = new Date();
    final Set<TradeName> trades = new HashSet<>();
    trades.add(TradeName.HP);
    trades.add(TradeName.ACER);
    // build some sample Reports
    List<Report> allReports = new ArrayList();
    for (int i = 0; i < 8; i++) {
        for (TradeName traden : trades) {
            startdate.setYear(62 + i);
            long sum = today.getTime() + startdate.getTime();
            Date sumDate = new Date(sum);
            String name = "Report: " + i + "-" + traden + "-" + sumDate.toString();
            Report e = new Report(name, traden, sumDate, enddate);
            allReports.add(e);
        }
    }
    Ui.exec(() -> {
        Ui.build().fx().show(() -> allReports, () -> new SelectExistingReportView());
    });
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) SelectExistingReportView(eu.ggnet.dwoss.report.ui.cap.support.SelectExistingReportView) TradeName(eu.ggnet.dwoss.rules.TradeName) Report(eu.ggnet.dwoss.report.ee.entity.Report) DocumentType(eu.ggnet.dwoss.rules.DocumentType) JLabel(javax.swing.JLabel) LockModeType(javax.persistence.LockModeType)

Example 3 with ReportParameter

use of eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter in project dwoss by gg-net.

the class XlsExporter method toFullXls.

public static File toFullXls(ViewReportResult report) {
    STable template = new STable();
    template.setTableFormat(new CFormat("Verdana", 10, new CBorder(Color.BLACK, CBorder.LineStyle.THIN)));
    template.setHeadlineFormat(new CFormat(BOLD, Color.BLACK, Color.YELLOW, CENTER, MIDDLE));
    template.add(new STableColumn("Datum", 10, new CFormat(SHORT_DATE)));
    template.add(new STableColumn("SopoNr", 10));
    template.add(new STableColumn("ArtikelNr", 15));
    template.add(new STableColumn("Bezeichnung", 40));
    template.add(new STableColumn("Seriennummer", 32));
    template.add(new STableColumn("CP", 15, EURO));
    template.add(new STableColumn("VK", 15, EURO));
    template.add(new STableColumn("%CP", 12, new CFormat(RIGHT, PERCENT_FLOAT)).setAction(SUtil.getSelfRow()));
    template.add(new STableColumn("EK", 15, EURO));
    template.add(new STableColumn("Marge", 12, new CFormat(RIGHT, CURRENCY_EURO)).setAction(SUtil.getSelfRow()));
    template.add(new STableColumn("%Marge", 12, new CFormat(RIGHT, PERCENT_FLOAT)));
    template.add(new STableColumn("MFGDate", 10, new CFormat(SHORT_DATE)));
    template.add(new STableColumn("CID", 12));
    template.add(new STableColumn("Firma", 35));
    template.add(new STableColumn("Name", 30));
    template.add(new STableColumn("Postionstype", 15));
    template.add(new STableColumn("DocumenType", 15));
    template.add(new STableColumn("Workflow", 15));
    template.add(new STableColumn("Bemerkung", 30));
    ReportParameter parameter = report.getParameter();
    CSheet sheet = new CSheet(parameter.getReportName());
    for (Type type : report.getLines().keySet()) {
        sheet.addBelow(new SBlock(type.name(), new CFormat(BOLD), true));
        STable table = new STable(template);
        table.setModel(new STableModelList<>(toLucidModel(report.getLines().get(type))));
        sheet.addBelow(table);
        SResult summary = createSummary(table, parameter.getStart(), parameter.getEnd());
        sheet.addBelow(4, 1, summary.block);
    }
    // Construct to create a summary for multivple tables.
    // 
    // SBlock summary = new SBlock();
    // summary.setFormat(new CFormat(BOLD, Color.BLACK, Color.YELLOW, RIGHT, new CBorder(Color.BLACK)));
    // SCell sum1 = new SCell(new SFormula(newSummary.sum1, "+", oldSummary.sum1), EURO);
    // SCell sum2 = new SCell(new SFormula(newSummary.sum2, "+", oldSummary.sum2), EURO);
    // summary.add("Summe", new CFormat(Color.BLUE, Color.WHITE, LEFT),
    // sum1,
    // sum2,
    // new SFormula(sum2, "/", sum1), new CFormat(PERCENT_FLOAT),
    // new SFormula(newSummary.sum3, "+", oldSummary.sum3), EURO,
    // new SFormula(newSummary.sum4, "+", oldSummary.sum4), EURO);
    // 
    CCalcDocument doc = new TempCalcDocument(parameter.getReportName() + "_");
    doc.add(sheet);
    LucidCalcWriter writer = LucidCalc.createWriter(LucidCalc.Backend.XLS);
    return writer.write(doc);
}
Also used : ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) Type(eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult.Type)

Aggregations

ReportParameter (eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter)3 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)2 SearchParameter (eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter)2 Report (eu.ggnet.dwoss.report.ee.entity.Report)2 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)2 LockModeType (javax.persistence.LockModeType)2 JLabel (javax.swing.JLabel)2 Type (eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult.Type)1 SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)1 RawReportView (eu.ggnet.dwoss.report.ui.RawReportView)1 SelectExistingReportView (eu.ggnet.dwoss.report.ui.cap.support.SelectExistingReportView)1 DocumentType (eu.ggnet.dwoss.rules.DocumentType)1 TradeName (eu.ggnet.dwoss.rules.TradeName)1