/** * ** Encodes this DBRecordKey into XML ** @param sb The StringBuffer to which the DBRecord XML is * writen ** @param indent The number of spaces to indent ** @param sequence An optional record * sequence number ** @param soapXML True for SOAP XML ** @return The StringBuffer */ public StringBuffer toXML(StringBuffer sb, int indent, int sequence, boolean soapXML) { if (sb == null) { sb = new StringBuffer(); } String prefix = StringTools.replicateString(" ", indent); DBRecordKey<gDBR> recKey = this; String tableName = recKey.getTableName(); DBField fld[] = recKey.getKeyFields(); // KEY fields DBFieldValues fldVals = recKey.getFieldValues(); String PFX1 = XMLTools.PREFIX(soapXML, indent); sb.append(PFX1); sb.append( XMLTools.startTAG( soapXML, DBFactory.TAG_RecordKey, XMLTools.ATTR(DBFactory.ATTR_table, tableName) + ((sequence > 0) ? XMLTools.ATTR(DBFactory.ATTR_sequence, sequence) : ""), false, true)); DBFactory.writeXML_DBFields(sb, 2 * indent, fld, fldVals, soapXML); sb.append(PFX1); sb.append(XMLTools.endTAG(soapXML, DBFactory.TAG_RecordKey, true)); return sb; }
/** ** Encodes this DBRecordKey into XML for "GTSRequest' purposes */ private StringBuffer toRequestXML(StringBuffer sb, int indent) { boolean isSoapReq = false; if (sb == null) { sb = new StringBuffer(); } DBRecordKey<gDBR> recKey = this; String tableName = recKey.getTableName(); DBField fld[] = recKey.getKeyFields(); // KEY fields DBFieldValues fldVals = recKey.getFieldValues(); String PFX1 = XMLTools.PREFIX(isSoapReq, indent); sb.append(PFX1); sb.append( XMLTools.startTAG( isSoapReq, DBFactory.TAG_Record, XMLTools.ATTR(DBFactory.ATTR_table, tableName), false, true)); DBFactory.writeXML_DBFields(sb, 2 * indent, fld, fldVals, isSoapReq); sb.append(PFX1); sb.append(XMLTools.endTAG(isSoapReq, DBFactory.TAG_Record, true)); return sb; }
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(); }