Package com.serotonin.m2m2.reports.vo

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


*/
abstract public class ViewTagSupport extends TagSupport {
    private static final long serialVersionUID = -1;

    protected JspView getJspView() throws JspException {
        JspView view = JspViewsCommon.getJspView((HttpServletRequest) pageContext.getRequest());
        if (view == null)
            throw new JspException("No JSP view in session. Use the init tag before defining points");
        return view;
    }
View Full Code Here


*/
public class ReportsDwr extends ModuleDwr {
    @DwrPermission(user = true)
    public ProcessResult init() {
        ProcessResult response = new ProcessResult();
        ReportDao reportDao = new ReportDao();
        User user = Common.getUser();

        response.addData("points", getReadablePoints());
        response.addData("mailingLists", new MailingListDao().getMailingLists());
        response.addData("users", new UserDao().getUsers());
        if(user.isAdmin()) {
          response.addData("reports", reportDao.getReports());
          response.addData("instances", getReportInstances(user));
      }
        else {
          response.addData("reports", reportDao.getReports(user.getId()));
          response.addData("instances", getReportInstances(user));
      }
        response.addData("templates", getTemplateList());

        return response;
View Full Code Here

    @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()));
            }
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.
View Full Code Here

        return response;
    }

    @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

    }

    @DwrPermission(user = true)
    public List<ReportInstance> deleteReportInstance(int instanceId) {
        User user = Common.getUser();
        ReportDao reportDao = new ReportDao();
        reportDao.deleteReportInstance(instanceId, user.getId());
        return getReportInstances(user);
    }
View Full Code Here

     */
    private List<ReportInstance> getReportInstances(User user) {
      //Allow Admin access to all report instances
      List<ReportInstance> result;
      if(user.isAdmin())
        result = new ReportDao().getReportInstances();
      else
        result = new ReportDao().getReportInstances(user.getId());
        Translations translations = getTranslations();
        UserDao userDao = new UserDao();
        for (ReportInstance i : result){
            i.setTranslations(translations);
            User reportUser = userDao.getUser(i.getUserId());
View Full Code Here

        return result;
    }

    @DwrPermission(user = true)
    public void setPreventPurge(int instanceId, boolean value) {
        new ReportDao().setReportInstancePreventPurge(instanceId, value, Common.getUser());
    }
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) {
View Full Code Here

    protected void execute(HttpServletRequest request, HttpServletResponse response, int content) throws IOException {
        // Get the report instance id
        int instanceId = Integer.parseInt(request.getParameter("instanceId"));

        // Get the report instance
        ReportDao reportDao = new ReportDao();
        ReportInstance instance = reportDao.getReportInstance(instanceId);

        // Ensure the user is allowed access.
        ReportCommon.ensureReportInstancePermission(Common.getUser(request), instance);

        // Stream the content.
        response.setContentType("text/csv");

        Translations translations = Common.getTranslations();
        if (content == CONTENT_REPORT) {
            ExportCsvStreamer creator = new ExportCsvStreamer(response.getWriter(), translations);
            if(Common.databaseProxy.getNoSQLProxy() == null)
              reportDao.reportInstanceDataSQL(instanceId, creator);
            else
              reportDao.reportInstanceDataNoSQL(instanceId, creator);
        }
        else if (content == CONTENT_EVENTS)
            new EventCsvStreamer(response.getWriter(), reportDao.getReportInstanceEvents(instanceId), translations);
        else if (content == CONTENT_COMMENTS)
            new UserCommentCsvStreamer(response.getWriter(), reportDao.getReportInstanceUserComments(instanceId),
                    translations);
    }
View Full Code Here

TOP

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

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.