Package com.serotonin.m2m2.reports.vo

Examples of com.serotonin.m2m2.reports.vo.ReportInstance


    @Override
    public View handleRequest(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model)
            throws Exception {
        int instanceId = Integer.parseInt(request.getParameter("instanceId"));
        ReportDao reportDao = new ReportDao();
        ReportInstance instance = reportDao.getReportInstance(instanceId);

        User user = Common.getUser(request);
        ReportCommon.ensureReportInstancePermission(user, instance);

        ReportChartCreator creator = new ReportChartCreator(ControllerUtils.getTranslations(request),
View Full Code Here


        // User is ok. Continue...
        ReportWorkItem item = new ReportWorkItem();

        // Create the database record in process.
        item.reportConfig = report;
        ReportInstance reportInstance = new ReportInstance(report);

        item.user = user;
        item.reportDao = new ReportDao();
        item.reportDao.saveReportInstance(reportInstance);

        // Start the report work item out of process.
        item.reportInstance = reportInstance;
        Common.backgroundProcessing.addWorkItem(item);

        LOG.debug("Queued report with id " + report.getId() + ", instance id " + reportInstance.getId());
    }
View Full Code Here

   
    class ReportInstanceRowMapper implements RowMapper<ReportInstance> {
        @Override
        public ReportInstance mapRow(ResultSet rs, int rowNum) throws SQLException {
            int i = 0;
            ReportInstance ri = new ReportInstance();
            ri.setId(rs.getInt(++i));
            ri.setUserId(rs.getInt(++i));
            ri.setReportId(rs.getInt(++i));
            ri.setName(rs.getString(++i));
            ri.setTemplateFile(rs.getString(++i));
            ri.setIncludeEvents(rs.getInt(++i));
            ri.setIncludeUserComments(charToBool(rs.getString(++i)));
            ri.setReportStartTime(rs.getLong(++i));
            ri.setReportEndTime(rs.getLong(++i));
            ri.setRunStartTime(rs.getLong(++i));
            ri.setRunEndTime(rs.getLong(++i));
            ri.setRecordCount(rs.getInt(++i));
            ri.setPreventPurge(charToBool(rs.getString(++i)));
            ri.setXidMap((Map<String, String>)SerializationHelper.readObjectInContext(rs.getBlob(++i).getBinaryStream()));
            return ri;
        }
View Full Code Here

        for (int id : dataPointIds) {
            DataPointVO dp = dataPointDao.getDataPoint(id);
            if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
                continue;

            ReportPointVO rp = new ReportPointVO();
            rp.setPointId(dp.getId());
            rp.setPointKey("p" + dp.getId());
            rp.setColour(dp.getChartColour());
            rp.setConsolidatedChart(true);
            rp.setPlotType(dp.getPlotType());
            report.getPoints().add(rp);
        }

        return report;
    }
View Full Code Here

        return response;
    }

    @DwrPermission(user = true)
    public ReportVO getReport(int id, boolean copy) {
        ReportVO report;
        if (id == Common.NEW_ID) {
            report = new ReportVO();
            report.setXid(new ReportDao().generateUniqueXid());
            report.setName(translate("common.newName"));
        }
        else {
            report = new ReportDao().getReport(id);

            if (copy) {
                report.setId(Common.NEW_ID);
                report.setName(TranslatableMessage.translate(getTranslations(), "common.copyPrefix", report.getName()));
            }

            ReportCommon.ensureReportPermission(Common.getUser(), report);
        }
        return report;
View Full Code Here

        if (response.getHasMessages())
            return response;

        User user = Common.getUser();
        ReportDao reportDao = new ReportDao();
        ReportVO report;
        if (id == Common.NEW_ID) {
            report = new ReportVO();
            report.setUserId(user.getId());
        }
        else
            report = reportDao.getReport(id);
       
        ReportCommon.ensureReportPermission(user, report);

        // Update the new values.
        report.setXid(xid);
        report.setName(name);
        report.setPoints(points);
        report.setTemplate(template);
        report.setIncludeEvents(includeEvents);
        report.setIncludeUserComments(includeUserComments);
        report.setDateRangeType(dateRangeType);
        report.setRelativeDateType(relativeDateType);
        report.setPreviousPeriodCount(previousPeriodCount);
        report.setPreviousPeriodType(previousPeriodType);
        report.setPastPeriodCount(pastPeriodCount);
        report.setPastPeriodType(pastPeriodType);
        report.setFromNone(fromNone);
        report.setFromYear(fromYear);
        report.setFromMonth(fromMonth);
        report.setFromDay(fromDay);
        report.setFromHour(fromHour);
        report.setFromMinute(fromMinute);
        report.setToNone(toNone);
        report.setToYear(toYear);
        report.setToMonth(toMonth);
        report.setToDay(toDay);
        report.setToHour(toHour);
        report.setToMinute(toMinute);
        report.setSchedule(schedule);
        report.setSchedulePeriod(schedulePeriod);
        report.setRunDelayMinutes(runDelayMinutes);
        report.setScheduleCron(scheduleCron);
        report.setEmail(email);
        report.setIncludeData(includeData);
        report.setZipData(zipData);
        report.setRecipients(recipients);

        // Save the report
        reportDao.saveReport(report);

        // Conditionally schedule the report.
        ReportJob.scheduleReportJob(report);

        // Send back the report id in case this was new.
        response.addData("reportId", report.getId());
        response.addData("report", report);
        return response;
    }
View Full Code Here

        // Basic validation
        //TODO Replace with vo.validate()
        validateData(response, name, points, dateRangeType, relativeDateType, previousPeriodCount, pastPeriodCount);

        if (!response.getHasMessages()) {
            ReportVO report = new ReportVO();
            report.setXid(xid);
            report.setName(name);
            report.setUserId(Common.getUser().getId());
            report.setPoints(points);
            report.setTemplate(template);
            report.setIncludeEvents(includeEvents);
            report.setIncludeUserComments(includeUserComments);
            report.setDateRangeType(dateRangeType);
            report.setRelativeDateType(relativeDateType);
            report.setPreviousPeriodCount(previousPeriodCount);
            report.setPreviousPeriodType(previousPeriodType);
            report.setPastPeriodCount(pastPeriodCount);
            report.setPastPeriodType(pastPeriodType);
            report.setFromNone(fromNone);
            report.setFromYear(fromYear);
            report.setFromMonth(fromMonth);
            report.setFromDay(fromDay);
            report.setFromHour(fromHour);
            report.setFromMinute(fromMinute);
            report.setToNone(toNone);
            report.setToYear(toYear);
            report.setToMonth(toMonth);
            report.setToDay(toDay);
            report.setToHour(toHour);
            report.setToMinute(toMinute);
            report.setSchedule(false); //Never allow schedule when running from UI
            report.setEmail(email);
            report.setIncludeData(includeData);
            report.setZipData(zipData);
            report.setRecipients(recipients);

            ReportWorkItem.queueReport(report);
        }

        return response;
View Full Code Here

    @DwrPermission(user = true)
    public void deleteReport(int id) {
        ReportDao reportDao = new ReportDao();

        ReportVO report = reportDao.getReport(id);
        if (report != null) {
            ReportCommon.ensureReportPermission(Common.getUser(), report);
            ReportJob.unscheduleReportJob(report);
            reportDao.deleteReport(id);
        }
View Full Code Here

        new ReportDao().setReportInstancePreventPurge(instanceId, value, Common.getUser());
    }

    @DwrPermission(user = true)
    public ReportVO createReportFromWatchlist(String name, int[] dataPointIds) {
        ReportVO report = new ReportVO();
        User user = Common.getUser();

        report.setName(new TranslatableMessage("common.copyPrefix", name).translate(getTranslations()));
        report.setXid(Common.generateXid("REP_"));
        DataPointDao dataPointDao = new DataPointDao();
        for (int id : dataPointIds) {
            DataPointVO dp = dataPointDao.getDataPoint(id);
            if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
                continue;

            ReportPointVO rp = new ReportPointVO();
            rp.setPointId(dp.getId());
            rp.setPointKey("p" + dp.getId());
            rp.setColour(dp.getChartColour());
            rp.setConsolidatedChart(true);
            rp.setPlotType(dp.getPlotType());
            report.getPoints().add(rp);
        }

        return report;
    }
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) {
    User user = Common.getUser(request);
    if(user != null) {
      ReportDao dao = new ReportDao();
      ReportVO report = null;
      int id = getIntRequestParameter(request, "reportId", -1);
      if(id != -1)
        report = dao.getReport(id);
      String xid = request.getParameter("reportXid");
      if(xid != null)
        report = dao.getReport(xid);
      if(report != null && (user.getId() == report.getUserId() || user.isAdmin())) {
        ReportJob.scheduleReportJob(report);
        try {
          response.getWriter().write("Report " + report.getName() + " scheduled");
        } catch(Exception e) {
          response.setStatus(500);
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.reports.vo.ReportInstance

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.