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

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


        registerJob(getJobName(report), jobInstance, report.getCronExpression());
    }

    @Transactional(readOnly = true)
    public void registerReportJob(final Long reportId) throws SchedulerException, ParseException {
        Report report = reportDAO.find(reportId);
        if (report == null) {
            throw new NotFoundException("Report " + reportId);
        } else {
            registerJob(report);
        }
View Full Code Here


    }

    @SuppressWarnings("rawtypes")
    @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 tFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            handler = tFactory.newTransformerHandler();
            Transformer serializer = handler.getTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, SyncopeConstants.DEFAULT_ENCODING);
            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);

        // 3. actual report execution
        StringBuilder reportExecutionMessage = new StringBuilder();
        StringWriter exceptionWriter = new StringWriter();
        try {
            // report header
            handler.startDocument();
            AttributesImpl atts = new AttributesImpl();
            atts.addAttribute("", "", ReportXMLConst.ATTR_NAME, ReportXMLConst.XSD_STRING, report.getName());
            handler.startElement("", "", ReportXMLConst.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) ApplicationContextProvider.getBeanFactory().
                            createBean(reportletClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
View Full Code Here

    @Autowired
    private ReportDataBinder binder;

    @PreAuthorize("hasRole('REPORT_CREATE')")
    public ReportTO create(final ReportTO reportTO) {
        Report report = new Report();
        binder.getReport(report, reportTO);
        report = reportDAO.save(report);

        try {
            jobInstanceLoader.registerJob(report);
        } catch (Exception e) {
            LOG.error("While registering quartz job for report " + report.getId(), e);

            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
            sce.getElements().add(e.getMessage());
            throw sce;
        }
View Full Code Here

        return binder.getReportTO(report);
    }

    @PreAuthorize("hasRole('REPORT_UPDATE')")
    public ReportTO update(final ReportTO reportTO) {
        Report report = reportDAO.find(reportTO.getId());
        if (report == null) {
            throw new NotFoundException("Report " + reportTO.getId());
        }

        binder.getReport(report, reportTO);
        report = reportDAO.save(report);

        try {
            jobInstanceLoader.registerJob(report);
        } catch (Exception e) {
            LOG.error("While registering quartz job for report " + report.getId(), e);

            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
            sce.getElements().add(e.getMessage());
            throw sce;
        }
View Full Code Here

        return reportletConfClasses;
    }

    @PreAuthorize("hasRole('REPORT_READ')")
    public ReportTO read(final Long reportId) {
        Report report = reportDAO.find(reportId);
        if (report == null) {
            throw new NotFoundException("Report " + reportId);
        }
        return binder.getReportTO(report);
    }
View Full Code Here

        return reportExec;
    }

    @PreAuthorize("hasRole('REPORT_EXECUTE')")
    public ReportExecTO execute(final Long reportId) {
        Report report = reportDAO.find(reportId);
        if (report == null) {
            throw new NotFoundException("Report " + reportId);
        }

        try {
View Full Code Here

        return result;
    }

    @PreAuthorize("hasRole('REPORT_DELETE')")
    public ReportTO delete(final Long reportId) {
        Report report = reportDAO.find(reportId);
        if (report == null) {
            throw new NotFoundException("Report " + reportId);
        }

        ReportTO deletedReport = binder.getReportTO(report);
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

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.