<%-- displayTopic.jsp ---------------- Display the products for this topic. Includes files: none Created by zaz@sri.com. Last modified by zaz@sri.com, 8/29/06. --%> <%@ page import="java.sql.*" %> <% // Connect to database Class.forName("org.gjt.mm.mysql.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/nlts2", "nlts2_webview", "nlts2"); %> <% // Get the topic nick name String topicNickname = request.getParameter("topic"); String topicName = null, topicID = null; boolean isDisability = false; String query = "SELECT * FROM WebTopics WHERE WebTopicNickname=\"" + topicNickname + "\""; ResultSet rs = con.createStatement().executeQuery(query); if (rs != null && rs.next()) { topicName = rs.getString("WebTopicName"); topicID = rs.getString("WebTopicID"); if (rs.getInt("IsDisability") == 1) isDisability = true; } // Get Overviews query = "SELECT ReportPubNick, ReportName"; query += " FROM Products, ProductsToWebTopics, Reports"; query += " WHERE ProductsToWebTopics.ProductID=Products.ProductID"; query += " AND Products.ReportID=Reports.ReportID"; query += " AND ProductsToWebTopics.WebTopicID=\"" + topicID + "\""; query += " AND ProductType=\"Chapter\" AND IsOverview=\"1\""; query += " ORDER BY ReportPubNick DESC, ChapterNum"; ResultSet overviewRS = con.createStatement().executeQuery(query); // Get chapters query = "SELECT ChapterNum, ProductName, ReportPubNick, ReportName"; query += " FROM Products, ProductsToWebTopics, Reports"; query += " WHERE ProductsToWebTopics.ProductID=Products.ProductID"; query += " AND Products.ReportID=Reports.ReportID"; query += " AND ProductsToWebTopics.WebTopicID=\"" + topicID + "\""; query += " AND ProductType=\"Chapter\" AND IsOverview=\"0\""; query += " ORDER BY ReportPubNick DESC, ChapterNum"; ResultSet chapterRS = con.createStatement().executeQuery(query); // Get other product types query = "SELECT ProductName, ProductType, ProductPubNick"; query += " FROM Products, ProductsToWebTopics"; query += " WHERE ProductsToWebTopics.ProductID=Products.ProductID"; query += " AND ProductsToWebTopics.WebTopicID=\"" + topicID + "\""; query += " AND ProductType!=\"Chapter\""; query += " ORDER BY ProductType, ProductName"; ResultSet productRS = con.createStatement().executeQuery(query); %>

Reports & Products: By Topic

<%= topicName %>

<% if (isDisability) { %>

All full reports include information about youth with this disability and, in addition, the following reports and products contain information specifically on youth with <%= topicName %>:

<% } else { %>

The following reports and products contain information on <%= topicName %>:

<% } %> <% boolean foundProduct = false; // Open list or print there are none if (overviewRS != null && overviewRS.next()) { foundProduct = true; %>

Overview

    <% } // List overviews overviewRS.beforeFirst(); while (overviewRS != null && overviewRS.next()) { String rptPubNick = overviewRS.getString("ReportPubNick"); String path = "reports/" + rptPubNick + "/"; %>
  • "><%= overviewRS.getString("ReportName") %>
  • <% // Close list, if necessary if (overviewRS.isLast()) { %>
<% } } // Open list or print there are none if (chapterRS != null && chapterRS.next()) { foundProduct = true; %>

Chapter

    <% } // List chapters chapterRS.beforeFirst(); while (chapterRS != null && chapterRS.next()) { String rptPubNick = chapterRS.getString("ReportPubNick"); String chapterNum = chapterRS.getString("ChapterNum"); String filename = "nlts2_report_" + rptPubNick + "_ch" + chapterNum + ".pdf"; String path = "reports/" + rptPubNick + "/"; %>
  • <%= chapterRS.getString("ProductName") %>, Chapter <%= chapterRS.getString("ChapterNum") %> of the report, "><%= chapterRS.getString("ReportName") %>
  • <% // Close list, if necessary if (chapterRS.isLast()) { %>
<% } } // Print other products String lastType = null; // NDP 6/2/2010 changed "if" to a "while". while (productRS != null && productRS.next()) { // Print heading foundProduct = true; String curType = productRS.getString("ProductType"); if (!curType.equals(lastType)) { if(!productRS.isFirst()) { // NDP 6/2/2010 if this is NOT the first "other product" // but it is also of a type not equal to the lastType, // then we've switched types, and now must close out our previous ul tag. %> <% } %>

<%= curType %>

    <% lastType = curType; } // Print product String path = null; if (curType.equals("Data Brief")) { path = "data_briefs/"; } else if (curType.equals("Fact Sheet")) { path = "fact_sheets/"; } String filename = productRS.getString("ProductPubNick") + ".html"; %>
  • <%= productRS.getString("ProductName") %>
  • <% // Close list if (productRS.isLast()) { %>
<% } } if (!foundProduct) { %>

No reports or products were found for this topic.

<% } %>
<% // Close connection con.close(); %>