[MOBY-guts] biomoby commit
Gary Schlitz
gss at pub.open-bio.org
Wed Jul 21 22:01:19 UTC 2004
gss
Wed Jul 21 18:01:19 EDT 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets
In directory pub.open-bio.org:/tmp/cvs-serv12905/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets
Modified Files:
KeywordSearchServlet.java BaseServlet.java
Added Files:
ProviderEngagementServlet.java
Log Message:
Many changes prior to BOSC
moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets ProviderEngagementServlet.java,NONE,1.1 KeywordSearchServlet.java,1.1,1.2 BaseServlet.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets/KeywordSearchServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets/KeywordSearchServlet.java 2004/07/15 20:27:17 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets/KeywordSearchServlet.java 2004/07/21 22:01:19 1.2
@@ -1,10 +1,11 @@
package org.smoby.ref.servlets;
import java.io.*;
-
+import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.servlet.http.HttpServletResponse;
+import org.smoby.graph.*;
+import org.smoby.ref.tools.*;
public class KeywordSearchServlet extends BaseServlet
{
@@ -12,37 +13,121 @@
throws ServletException, IOException
{
PrintStream out = new PrintStream(response.getOutputStream());
+
+ List provider = getKeywords("provider", request);
+ List accepts = getKeywords("accepts", request);
+ List returns = getKeywords("returns", request);
+
startHTML(response, out);
+ if ((provider == null) && (accepts == null) && (returns == null))
+ {
+ showResultCount(-1, out);
+ }
+ else
+ {
+ KeywordQuery q = new KeywordQuery(provider, accepts, returns);
+
+ List matching = q.findMatchingProviders();
+
+ showResultCount(matching.size(), out);
+
+ for (Iterator it = matching.iterator(); it.hasNext();)
+ {
+ MOBYProvider p = (MOBYProvider) it.next();
+ showProvider(p, out);
+ }
+ }
finishHTML(response, out);
}
- private void startHTML(HttpServletResponse response, PrintStream out)
+ private List getKeywords(String paramName, HttpServletRequest request)
{
- response.setContentType("text/html");
- out.println("<html>");
- out.println("<head>");
- out.println("<title>Semantic MOBY search results</title>");
- out.println("</head>");
- out.println("<h2>");
- out.println("<span style=\"color: rgb(51, 204, 0);\"><i>Semantic</i>");
- out.println("<span style=\"color: blue\">M<span style=\"color: red\">" +
- "O<span style=\"color: blue\">B<span style=\"color: red\">Y");
- out.println("</h2>");
+ List keywords = new ArrayList();
+
+ String value = request.getParameter(paramName);
+ if (value == null) return keywords;
+
+ value = value.trim();
+
+ if (value.length() == 0) return keywords;
+
+ StreamTokenizer st = new StreamTokenizer(new StringReader(value));
+ st.wordChars('*', '*');
+ st.wordChars('%', '%');
+ try
+ {
+ while (st.nextToken() != StreamTokenizer.TT_EOF)
+ {
+ if (st.sval != null)
+ {
+ String val = st.sval.toLowerCase().trim().replace('*', '%');
+ keywords.add(val);
+ }
+ }
+ } catch (IOException e) {}
+
+ return keywords;
}
private void showResultCount(int count, PrintStream out)
{
- if (count < 1) {
- out.println("<b>No matches</b>");
+ out.println("<table border=\"0\" width=\"100%\">");
+ out.println("<tr>");
+ out.println("<td style=\"background-color:#e5ecf9\">");
+
+ if (count < 0) {
+ out.println("No keywords were entered, so no search was performed.");
+ } else if (count < 1) {
+ out.println("No matching providers were found. <i>Note that");
+ out.println("very few providers have yet been defined.</i>");
} else {
- out.println("<b>" + count + " results found:</b>");
+ out.println(count + " matching provider" +
+ (count > 1 ? "s" : "") + " found");
}
+ out.println("</td>");
+ out.println("</tr>");
+ out.println("</table>");
+ out.println("<br>");
}
- private void finishHTML(HttpServletResponse response, PrintStream out)
+ private void showProvider(MOBYProvider provider, PrintStream out)
{
- response.setContentType("text/html");
- out.println("<html>");
+ String uri = provider.getResource().getURI();
+ String name = provider.getName();
+ String description = provider.getOneLineDescription();
+ String moreInfo = provider.getMoreInfoURI();
+
+ out.println("<b>");
+ out.print("<a href=\"");
+ out.print("http://www.semanticmoby.org/engage-provider?provider-url=");
+ out.print(uri);
+ out.print("\">");
+ if ((name != null) && (name.trim().length() > 0)) {
+ out.println(name);
+ } else {
+ out.println(uri);
+ }
+ out.print("</a>");
+ out.println("</b>");
+ out.print("<a href=\"");
+ out.print(uri);
+ out.print("\">");
+ out.print("<img border=\"0\" src=\"images/rdf-logo.png\" alt=\"Definition\">");
+ out.print("</a>");
+ out.println("<br>");
+
+ if ((description != null) && (description.trim().length() > 0)) {
+ out.println(description);
+ } else {
+ out.println("No description is available for this provider.");
+ }
+ out.println("<br>");
+
+ if ((moreInfo != null) && (moreInfo.trim().length() > 0)) {
+ out.println("For more information see <a href=\"" + moreInfo +
+ "\">" + moreInfo + "</a>");
+ }
+ out.println("<br>");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets/BaseServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets/BaseServlet.java 2004/07/15 20:27:17 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/servlets/BaseServlet.java 2004/07/21 22:01:19 1.2
@@ -5,6 +5,7 @@
import javax.servlet.*;
import javax.servlet.http.*;
+
import org.smoby.ref.tools.*;
import org.smoby.servlet.*;
import org.apache.log4j.*;
@@ -48,4 +49,32 @@
}
}
}
+
+ protected void startHTML(HttpServletResponse response, PrintStream out)
+ {
+ response.setContentType("text/html");
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<title>Semantic MOBY search results</title>");
+ out.println("</head>");
+ out.println("<center>");
+ out.println("<h1>");
+ out.println("<font face=\"serif\">");
+ out.println("<span style=\"color: rgb(51, 204, 0);\"><i>Semantic</i>");
+ out.println("<span style=\"color: blue\">M<span style=\"color: red\">" +
+ "O<span style=\"color: blue\">B<span style=\"color: red\">Y" +
+ "<span style=\"color: black\">");
+ out.println("</font>");
+ out.println("</h1>");
+ out.println("</center>");
+ out.println("<body>");
+ out.println("<font face=\"sans-serif\">");
+ }
+
+ protected void finishHTML(HttpServletResponse response, PrintStream out)
+ {
+ out.println("</font>");
+ out.println("</body>");
+ out.println("</html>");
+ }
}
\ No newline at end of file
More information about the MOBY-guts
mailing list