Creating the JSP report viewer logic

The logic for a JSP report viewer is contained in a JSP that is called by the Data Management Portal. A typical implementation of a JSP report uses a Java™ helper class called TMSDataHelper to query the TADDM API. The results of the query are objects that can be manipulated using Java methods. For more information about the TADDM API and model, consult the SDK documentation in $COLLATION_HOME/sdk/doc.

The following example is a simple JSP report viewer implementation. Copy the following contents into a new file, $COLLATION_HOME/deploy-tomcat/reports.war/WEB-INF/view/custom.jsp if you use TADDM 7.3.0, or $COLLATION_HOME/apps/reports.war/WEB-INF/view/custom.jsp if you use TADDM 7.3.0.1, and later, and make the file readable and executable by the user that runs the TADDM server.

The following example shows the appServers.xsl style sheet used to transform the appServers.xml file generated by the shell script. The report displays application server names and their product versions. Copy the contents into a new file, $COLLATION_HOME/sdk/bin/appServers.xsl and make the file readable by the user that runs the TADDM server.
<%@ page language="java" %>
<%@ page import="com.collation.cdm.common.util.TMSDataHelper" %>
<%@ page import="java.lang.StringBuffer" %>
<%@ page import="com.collation.cdm.reports.util.ReportsParser" %>
<%@ page import="com.collation.cdm.common.util.TMSReportingTransformer" %>
<%@ page import="com.collation.platform.model.AttributeNotSetException" %>
<%@ page import="com.collation.platform.model.ModelObject" %>
<%@ page import="com.collation.platform.model.topology.sys.ComputerSystem" %>
<%@ page import="com.collation.platform.model.topology.process.BusinessProcess" %>
<%@ page import="com.collation.platform.model.topology.process.Activity" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.collation.platform.util.Props" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.collation.cdm.common.messages.CdmLocalizedMessages"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%
java.util.Locale locale = 
com.collation.cdm.common.util.CDMUtil.checkLocale(request.getLocale());
    if (null == session.getAttribute(org.apache.struts.Globals.LOCALE_KEY)) {
session.setAttribute(org.apache.struts.Globals.LOCALE_KEY, locale);
    }
%>
<%
//TMSDataHelper is a utility class for running MQL queries against the DB
TMSDataHelper tms = new TMSDataHelper(locale);

//Perform a query for all ComputerSystems
ModelObject dataIn[] = tms.doModelObjectQuery("SELECT * FROM ComputerSystem",null);

  //Build an HTML report based on the API output
  StringBuffer output = new StringBuffer();
  output.append("<p>");
  output.append("<table border=\"1\">");
                int c = 0;
                int s = dataIn.length;
                while (cs) {
                        ComputerSystem tmo = (ComputerSystem)dataIn[c];
                        String csName = null;
                        String csLabel = null;
                        if (tmo.hasName()) {
                                try {
                                        csName = tmo.getName();
                                } catch (AttributeNotSetException e) {
                                        csName = "unknown";
                                }
                        }
                        if (tmo.hasSignature()) {
                                try {
                                        csLabel = tmo.getSignature();
                                } catch (AttributeNotSetException e) {
                                        csLabel = "";
                                }
                        }
                        output.append("<tr><td colspan=\"2\" bgcolor=\"#9999FF\">");
                        output.append("ComputerSystem" + "<br>");
                        output.append(" Name: " + csName + "<br>");
                        output.append("</td><td>");
                        output.append("Signature: " + csLabel);
                        output.append("</td></tr>");
                        c++;
                }
output.append("</table>");
String bpstring = output.toString();
%>
<html>
<body>
<h1>Sample JSP Report/h1>
<%=bpstring%>
</body>
</html>