Package org.apache.syncope.core.persistence.beans

Examples of org.apache.syncope.core.persistence.beans.Report


    }

    @Override
    public void execute(final JobExecutionContext context) throws JobExecutionException {

        Report report = reportDAO.find(reportId);
        if (report == null) {
            throw new JobExecutionException("Report " + reportId + " not found");
        }

        // 1. create execution
        ReportExec execution = new ReportExec();
        execution.setStatus(ReportExecStatus.STARTED);
        execution.setStartDate(new Date());
        execution.setReport(report);
        execution = reportExecDAO.save(execution);

        report.addExec(execution);
        report = reportDAO.save(report);

        // 2. define a SAX handler for generating result as XML
        TransformerHandler handler;

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ZipOutputStream zos = new ZipOutputStream(baos);
        zos.setLevel(Deflater.BEST_COMPRESSION);
        try {
            SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            handler = transformerFactory.newTransformerHandler();
            Transformer serializer = handler.getTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");

            // a single ZipEntry in the ZipOutputStream
            zos.putNextEntry(new ZipEntry(report.getName()));

            // streaming SAX handler in a compressed byte array stream
            handler.setResult(new StreamResult(zos));
        } catch (Exception e) {
            throw new JobExecutionException("While configuring for SAX generation", e, true);
        }

        execution.setStatus(ReportExecStatus.RUNNING);
        execution = reportExecDAO.save(execution);

        ConfigurableListableBeanFactory beanFactory =
                ApplicationContextManager.getApplicationContext().getBeanFactory();

        // 3. actual report execution
        StringBuilder reportExecutionMessage = new StringBuilder();
        StringWriter exceptionWriter = new StringWriter();
        try {
            // report header
            handler.startDocument();
            AttributesImpl atts = new AttributesImpl();
            atts.addAttribute("", "", ATTR_NAME, XSD_STRING, report.getName());
            handler.startElement("", "", ELEMENT_REPORT, atts);

            // iterate over reportlet instances defined for this report
            for (ReportletConf reportletConf : report.getReportletConfs()) {
                Class<Reportlet> reportletClass =
                        dataBinder.findReportletClassHavingConfClass(reportletConf.getClass());
                if (reportletClass != null) {
                    Reportlet autowired = (Reportlet) beanFactory.createBean(reportletClass,
                            AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
View Full Code Here


            }

            Long reportId = JobInstanceLoader.getReportIdFromJobName(bundle.getJobDetail().getName());
            if (reportId != null) {
                ReportDAO reportDAO = ctx.getBean(ReportDAO.class);
                Report report = reportDAO.find(reportId);

                JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
                jobInstanceLoader.registerJob(report);
            }
        }
View Full Code Here

    @Autowired
    private ReportExecDAO reportExecDAO;

    @Test
    public void find() {
        Report report = reportDAO.find(1L);
        assertNotNull(report);

        assertNotNull(report.getExecs());
        assertFalse(report.getExecs().isEmpty());
        assertEquals(1, report.getExecs().size());
    }
View Full Code Here

        assertEquals(1, report.getExecs().size());
    }

    @Test(expected = EntityExistsException.class)
    public void saveWithExistingName() {
        Report report = reportDAO.find(1L);
        assertNotNull(report);

        String name = report.getName();

        report = new Report();
        report.setName(name);

        reportDAO.save(report);
        reportDAO.flush();
    }
View Full Code Here

        reportDAO.flush();
    }

    @Test
    public void save() {
        Report report = reportDAO.find(1L);
        assertNotNull(report);
        assertEquals(1, report.getExecs().size());

        ReportExec reportExec = new ReportExec();
        reportExec.setReport(report);
        reportExec.setStartDate(new Date());
        reportExec.setEndDate(new Date());
        reportExec.setStatus(ReportExecStatus.SUCCESS);

        report.addExec(reportExec);

        reportExec = reportExecDAO.save(reportExec);
        assertNotNull(reportExec);
        assertNotNull(reportExec.getId());

        reportExecDAO.flush();

        report = reportDAO.find(1L);
        assertNotNull(report);
        assertEquals(2, report.getExecs().size());
    }
View Full Code Here

        reportExecDAO.flush();

        assertNull(reportExecDAO.find(1L));

        Report report = reportDAO.find(1L);
        assertEquals(report.getExecs().size(), executionNumber - 1);
    }
View Full Code Here

        return entityManager.merge(report);
    }

    @Override
    public void delete(final Long id) {
        Report report = find(id);
        if (report == null) {
            return;
        }

        delete(report);
View Full Code Here

    @Autowired
    private ReportDAO reportDAO;

    @Test
    public void find() {
        Report report = reportDAO.find(1L);
        assertNotNull(report);

        report = reportDAO.find(10L);
        assertNull(report);
    }
View Full Code Here

    @Test
    public void save() {
        int beforeCount = reportDAO.count();

        Report report = new Report();
        report.setName("new report");
        report.addReportletConf(new UserReportletConf("first"));
        report.addReportletConf(new UserReportletConf("second"));

        report = reportDAO.save(report);
        assertNotNull(report);
        assertNotNull(report.getId());

        int afterCount = reportDAO.count();
        assertEquals(afterCount, beforeCount + 1);
    }
View Full Code Here

        assertEquals(afterCount, beforeCount + 1);
    }

    @Test
    public void delete() {
        Report report = reportDAO.find(1L);
        assertNotNull(report);

        reportDAO.delete(1L);

        report = reportDAO.find(1L);
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.Report

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.