Exemple #1
0
  private int writeHTML(PrintWriter out, int level, ReportData rd) throws ReportException {

    /* no ReportData */
    if (rd == null) {
      return 0;
    }

    /* simple report */
    if (!rd.isSingleDeviceOnly() || (rd.getDeviceCount() <= 1)) {
      return this._writeHTML(out, level, rd, -1);
    }

    /* multiple per-device reports */
    ReportDeviceList rdl = rd.getReportDeviceList();
    java.util.List<ReportDeviceList.DeviceHolder> dhList = rdl.getDeviceHolderList(true);
    rdl.clear();
    int rcdCount = 0;
    int devCount = dhList.size();
    for (int i = 0; i < devCount; i++) {
      if (i > 0) {
        out.print("<br>\n");
      }
      rdl.setDevice(null, dhList.get(i));
      rcdCount += this._writeHTML(out, level, rd, i);
    }
    return rcdCount;
  }
Exemple #2
0
  private int _writeXML(PrintWriter out, int level, ReportData rd, boolean urlOnly)
      throws ReportException {
    boolean isSoapRequest = rd.isSoapRequest();
    RequestProperties reqState = rd.getRequestProperties();
    PrivateLabel privLabel = rd.getPrivateLabel();
    I18N i18n = privLabel.getI18N(ReportTable.class);
    String PFX1 = XMLTools.PREFIX(isSoapRequest, level * ReportTable.INDENT);
    String PFX2 = XMLTools.PREFIX(isSoapRequest, (level + 1) * ReportTable.INDENT);

    /* begin */
    out.print(PFX1);
    out.print(
        XMLTools.startTAG(
            isSoapRequest,
            "Report", // TAG_Report
            XMLTools.ATTR("name", rd.getReportName())
                + // ATTR_name
                XMLTools.ATTR("type", rd.getReportType()), // ATTR_type
            false,
            true));

    /* constraints */
    ReportConstraints rc = rd.getReportConstraints();
    String dtFmt = DateTime.DEFAULT_DATE_FORMAT + "," + DateTime.DEFAULT_TIME_FORMAT;
    TimeZone tzone = rd.getTimeZone();
    String tzStr = rd.getTimeZoneString();
    long tmBeg = rc.getTimeStart();
    long tmEnd = rc.getTimeEnd();
    DateTime dtStr = new DateTime(tmBeg, tzone);
    DateTime dtEnd = new DateTime(tmEnd, tzone);

    /* Account */
    out.print(PFX2);
    out.print(XMLTools.startTAG(isSoapRequest, "Account", "", false, false)); // TAG_Account
    out.print(XmlFilter(isSoapRequest, rd.getAccountID()));
    out.print(XMLTools.endTAG(isSoapRequest, "Account", true)); // TAG_Account

    /* TimeFrom */
    out.print(PFX2);
    out.print(
        XMLTools.startTAG(
            isSoapRequest,
            "TimeFrom", // TAG_TimeFrom
            XMLTools.ATTR("timestamp", String.valueOf(tmBeg))
                + // ATTR_timestamp
                XMLTools.ATTR("timezone", tzStr), // ATTR_timezone
            false,
            false));
    out.print((tmBeg > 0L) ? XmlFilter(isSoapRequest, dtStr.format(dtFmt)) : "");
    out.print(XMLTools.endTAG(isSoapRequest, "TimeFrom", true)); // TAG_TimeFrom

    /* TimeTo */
    out.print(PFX2);
    out.print(
        XMLTools.startTAG(
            isSoapRequest,
            "TimeTo", // TAG_TimeTo
            XMLTools.ATTR("timestamp", String.valueOf(tmEnd))
                + // ATTR_timestamp
                XMLTools.ATTR("timezone", tzStr), // ATTR_timezone
            false,
            false));
    out.print((tmEnd > 0L) ? XmlFilter(isSoapRequest, dtEnd.format(dtFmt)) : "");
    out.print(XMLTools.endTAG(isSoapRequest, "TimeTo", true)); // TAG_TimeTo

    /* ValidGPSRequired */
    out.print(PFX2);
    out.print(
        XMLTools.startTAG(
            isSoapRequest, "ValidGPSRequired", "", false, false)); // TAG_ValidGPSRequired
    out.print(XmlFilter(isSoapRequest, rc.getValidGPSRequired()));
    out.print(XMLTools.endTAG(isSoapRequest, "ValidGPSRequired", true)); // TAG_ValidGPSRequired

    /* SelectionLimit */
    out.print(PFX2);
    out.print(
        XMLTools.startTAG(
            isSoapRequest,
            "SelectionLimit", // TAG_SelectionLimit
            XMLTools.ATTR("type", rc.getSelectionLimitType()),
            false,
            false));
    out.print(XmlFilter(isSoapRequest, rc.getSelectionLimit()));
    out.print(XMLTools.endTAG(isSoapRequest, "SelectionLimit", true)); // TAG_SelectionLimit

    /* Ascending */
    out.print(PFX2);
    out.print(XMLTools.startTAG(isSoapRequest, "Ascending", "", false, false)); // TAG_Ascending
    out.print(XmlFilter(isSoapRequest, rc.getOrderAscending()));
    out.print(XMLTools.endTAG(isSoapRequest, "Ascending", true)); // TAG_Ascending

    /* ReportLimit */
    out.print(PFX2);
    out.print(XMLTools.startTAG(isSoapRequest, "ReportLimit", "", false, false)); // TAG_ReportLimit
    out.print(XmlFilter(isSoapRequest, rc.getReportLimit()));
    out.print(XMLTools.endTAG(isSoapRequest, "ReportLimit", true)); // TAG_ReportLimit

    /* Where */
    if (rc.hasWhere()) {
      out.print(PFX2);
      out.print(XMLTools.startTAG(isSoapRequest, "Where", "", false, false)); // TAG_Where
      out.print(XmlFilter(isSoapRequest, rc.getWhere()));
      out.print(XMLTools.endTAG(isSoapRequest, "Where", true)); // TAG_Where
    }

    /* RuleSelector */
    if (rc.hasRuleSelector()) {
      out.print(PFX2);
      out.print(
          XMLTools.startTAG(isSoapRequest, "RuleSelector", "", false, false)); // TAG_RuleSelector
      out.print(XmlFilter(isSoapRequest, rc.getRuleSelector()));
      out.print(XMLTools.endTAG(isSoapRequest, "RuleSelector", true)); // TAG_RuleSelector
    }

    /* Title */
    out.print(PFX2);
    out.print(XMLTools.startTAG(isSoapRequest, "Title", "", false, false)); // TAG_Title
    out.print(XmlFilter(isSoapRequest, rd.getReportTitle()));
    out.print(XMLTools.endTAG(isSoapRequest, "Title", true)); // TAG_Title

    /* Subtitle */
    out.print(PFX2);
    out.print(XMLTools.startTAG(isSoapRequest, "Subtitle", "", false, false)); // TAG_Subtitle
    out.print(XmlFilter(isSoapRequest, rd.getReportSubtitle()));
    out.print(XMLTools.endTAG(isSoapRequest, "Subtitle", true)); // TAG_Subtitle

    /* URL */
    if (urlOnly) {
      // Web-URL only
      HttpServletRequest request = reqState.getHttpServletRequest();
      ReportDeviceList devList = rd.getReportDeviceList();
      String deviceID = devList.isDeviceGroup() ? null : devList.getFirstDeviceID();
      String groupID = devList.isDeviceGroup() ? devList.getDeviceGroupID() : null;
      String baseURL =
          privLabel.hasDefaultBaseURL()
              ? privLabel.getDefaultBaseURL()
              : ((request != null) ? request.getRequestURL().toString() : "");
      URIArg rptURL =
          ReportURL.createReportURL(
              baseURL,
              false,
              rd.getAccountID(),
              rd.getUserID(),
              "",
              deviceID,
              groupID,
              rc.getTimeStart(),
              rc.getTimeEnd(),
              rd.getTimeZoneString(),
              rd.getReportName(),
              rc.getReportLimit(),
              rc.getSelectionLimitType().toString(),
              ReportPresentation.FORMAT_HTML);
      out.print(PFX2);
      out.print(XMLTools.startTAG(isSoapRequest, "URL", "", false, false)); // TAG_URL
      out.print(XmlFilter(isSoapRequest, rptURL.toString()));
      out.print(XMLTools.endTAG(isSoapRequest, "URL", true)); // TAG_URL
    } else {
      // Report header/body
      this.rptHeader.writeXML(out, level + 1, rd);
      this.rptBody.writeXML(out, level + 1, rd);
    }

    /* Partial */
    out.print(PFX2);
    out.print(XMLTools.startTAG(isSoapRequest, "Partial", "", false, false)); // TAG_Partial
    out.print(XmlFilter(isSoapRequest, this.rptBody.isPartial()));
    out.print(XMLTools.endTAG(isSoapRequest, "Partial", true)); // TAG_Partial

    /* end of report */
    out.print(PFX1);
    out.print(XMLTools.endTAG(isSoapRequest, "Report", true)); // TAG_Report
    return this.rptBody.getRecordCount();
  }