// Generate the html for a given Type and a given parameter (for example: collection id) public static String GenerateHTML( Context context, Type type, String param, String contextPath, String beginY, String endY) throws SQLException { // Pickup the metadata_field_id for a given element and a qualifier (from the // metadatafieldregistry) int autId = Item.returnId(context, "contributor", "author"); int citId = Item.returnId(context, "identifier", "citation"); int titleId = Item.returnId(context, "title", ""); int dateId = Item.returnId(context, "date", "issued"); int typeId = Item.returnId(context, "type", ""); boolean stop = false; String typ = ""; // Get a vector with the IDs of the requested items List<Integer> ids = GetIds(context, dateId, type, param, beginY, endY); // actual HTML string String result = ""; int currentYear = 0; // Construct the html string for (int i = 0; i < ids.size(); ++i) { String auth = ""; // pickup the metadata from the DB List<String> authors = Item.latestAdditionsText(context, ids.get(i), autId, 0); List<String> citations = Item.latestAdditionsText(context, ids.get(i), citId); List<String> titles = Item.latestAdditionsText(context, ids.get(i), titleId); List<String> dates = Item.latestAdditionsText(context, ids.get(i), dateId); List<String> types = Item.latestAdditionsText(context, ids.get(i), typeId); int year = getYear(dates.get(0)); // incase this items year differs from the last one, display a new year header if (year != currentYear) { currentYear = year; if (year != 0) { result += "</ul>"; } result += "<h2 class=\"dateItem\" style=\"cursor: pointer;\" onclick=\"Effect.toggle('" + year + "', 'blind')\">" + year + "</h2><ul id=\"" + year + "\">"; } // incase this items type differs from the last one, display a new type header if (!typ.equals(types.get(0))) { typ = types.get(0); result += "<li><h3>" + typ + "</h3></li>"; } // display all authors for (int j = 0; j < authors.size() && !stop; ++j) { if (j < (authors.size() - 1)) { auth += "<a href=\"" + contextPath + "/browse?type=author&value=" + Item.latestAdditionsText(context, ids.get(i), "contributor", "author").get(0) + "\">" + Item.latestAdditionsText(context, ids.get(i), "contributor", "author").get(0) + "</a>; "; } else if (authors.get(j) == null) { stop = false; } else { auth += "<a href=\"" + contextPath + "/browse?type=author&value=" + Item.latestAdditionsText(context, ids.get(i), "contributor", "author").get(0) + "\">" + Item.latestAdditionsText(context, ids.get(i), "contributor", "author").get(0) + "</a> "; } } // display the other important metadata result += "<ul class=\"collectionListItem\"><li class=\"metadataFieldValue\" style=\"list-style-type: none;\">" + auth + " (" + year + ") <em>" + "<a href=\"" + contextPath + "/handle/" + Item.getHandleMod(context, ids.get(i)) + "\"/>" + titles.get(0) + "</a><br/>" + "</em>" + citations.get(0) + "</li></ul>"; } // close the year tag! if (currentYear != 0) { result += "</ul>"; } return result; }