[Mulgara-svn] r1398 - in trunk/src/jar: query/java/org/mulgara/query server/java/org/mulgara/server util/java/org/mulgara/util/functional web/java/org/mulgara/webquery web/resources

pag at mulgara.org pag at mulgara.org
Thu Dec 4 23:38:29 UTC 2008


Author: pag
Date: 2008-12-04 15:38:27 -0800 (Thu, 04 Dec 2008)
New Revision: 1398

Added:
   trunk/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java
   trunk/src/jar/web/resources/tutorial.html
   trunk/src/jar/web/resources/tutorial_head.html
Modified:
   trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java
   trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java
   trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java
   trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java
   trunk/src/jar/query/java/org/mulgara/query/ModelResource.java
   trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java
   trunk/src/jar/server/java/org/mulgara/server/HttpServices.java
   trunk/src/jar/util/java/org/mulgara/util/functional/C.java
   trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
   trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
   trunk/src/jar/web/resources/template.html
   trunk/src/jar/web/resources/template_head.html
Log:
Updated WebUI with a couple of cosmetic enhancements.
 * No longer require a ; at the end of a TQL query. This addresses #157
 * If the default graph is blank, then update it with the last queried graph
 * A separate servlet for the tutorial. This gets the tutorial out of the way
   for this majority of users as they're not using it.



Modified: trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -70,6 +70,13 @@
   public Set<URI> getDatabaseURIs();
 
   /**
+   * Calculate the graphs involved in this expression.
+   *
+   * @return a set containing the {@link URI}s of the graphs
+   */
+  public Set<URI> getGraphURIs();
+
+  /**
    * Clones sets of models in the rhs and lhs objects.
    */
   public Object clone();

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -70,6 +70,7 @@
   /**
    * Logger. This is named after the class.
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(ModelLiteral.class);
 
   /**
@@ -121,10 +122,15 @@
   /**
    * @return an empty {@link Set}
    */
-  @SuppressWarnings("unchecked")
   public Set<URI> getDatabaseURIs() {
+    return Collections.emptySet();
+  }
 
-    return (Set<URI>)Collections.EMPTY_SET;
+  /**
+   * @return an empty {@link Set}
+   */
+  public Set<URI> getGraphURIs() {
+    return Collections.emptySet();
   }
 
   //

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -120,6 +120,20 @@
     return databaseURIs;
   }
 
+  /**
+   * Calculate the graphs involved in this expression.
+   *
+   * @return a set containing the {@link URI}s of the graphs
+   */
+  public Set<URI> getGraphURIs() {
+    
+    Set<URI> graphURIs = new HashSet<URI>();
+    graphURIs.addAll(lhs.getGraphURIs());
+    graphURIs.addAll(rhs.getGraphURIs());
+
+    return graphURIs;
+  }
+
   //
   // Additional API
   //

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -62,9 +62,8 @@
    */
   static final long serialVersionUID = 8660358035003409731L;
 
-  /**
-   * Logger.
-   */
+  /** Logger. */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(ModelPartition.class);
 
   //

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelResource.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelResource.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelResource.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -34,8 +34,6 @@
 // Third party packages
 import org.apache.log4j.Logger;
 
-// Local packages
-import org.mulgara.query.rdf.URIReferenceImpl;
 
 /**
  * A leaf expression containing the {@link URL} of an RDF model.
@@ -65,15 +63,11 @@
    */
   static final long serialVersionUID = -5673467065206144337L;
 
-  /**
-   * Logger. This is named after the class.
-   */
-  private final static Logger logger =
-      Logger.getLogger(ModelResource.class.getName());
+  /** Logger. This is named after the class. */
+  @SuppressWarnings("unused")
+  private final static Logger logger = Logger.getLogger(ModelResource.class.getName());
 
-  /**
-   * The {@link URI} of the RDF model.
-   */
+  /** The {@link URI} of the RDF model. */
   private URI uri;
 
   //
@@ -132,6 +126,11 @@
 
   }
 
+  /** @see org.mulgara.query.ModelExpression#getGraphURIs() */
+  public Set<URI> getGraphURIs() {
+    return Collections.singleton(uri);
+  }
+
   //
   // API methods
   //
@@ -216,4 +215,5 @@
       throw new RuntimeException("ModelResource not cloneable");
     }
   }
+
 }

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelVariable.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -62,11 +62,18 @@
    * Gets a set of database URIs to operate against.
    * @return We don't know what is in the variable, so return the empty {@link Set}
    */
-  @SuppressWarnings("unchecked")
   public Set<URI> getDatabaseURIs() {
-    return (Set<URI>)Collections.EMPTY_SET;
+    return Collections.emptySet();
   }
 
+  /**
+   * Gets a set of graph URIs this represents.
+   * @return We don't know what is in the variable, so return the empty {@link Set}
+   */
+  public Set<URI> getGraphURIs() {
+    return Collections.emptySet();
+  }
+
   //
   // API methods
   //

Modified: trunk/src/jar/server/java/org/mulgara/server/HttpServices.java
===================================================================
--- trunk/src/jar/server/java/org/mulgara/server/HttpServices.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/server/java/org/mulgara/server/HttpServices.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -79,6 +79,9 @@
   /** The Web Query path. */
   private final static String WEBQUERY_PATH = "webui";
 
+  /** The Web Tutorial path. */
+  private final static String WEBTUTORIAL_PATH = "tutorial";
+
   /** The sparql path. */
   private final static String SPARQL_PATH = "sparql";
 
@@ -220,8 +223,11 @@
       return addWebServicesWebAppContext(s);
     } });
     starters.add(new ContextStarter() { public Service fn(Server s) throws IOException {
-      return addWebQueryContext(s);
+      return addWebQueryContext(s, "User Interface", "org.mulgara.webquery.QueryServlet", WEBQUERY_PATH);
     } });
+    starters.add(new ContextStarter() { public Service fn(Server s) throws IOException {
+      return addWebQueryContext(s, "User Tutorial", "org.mulgara.webquery.TutorialServlet", WEBTUTORIAL_PATH);
+    } });
     // expect to get the following from a config file
     // TODO: create a decent configuration object, instead of just handing out a Server
     starters.add(new ContextStarter() { public Service fn(Server s) throws IOException {
@@ -305,22 +311,22 @@
 
 
   /**
-   * Creates the Mulgara Semantic Store Query Tool (webui).
+   * Creates and registers a web servlet.
    * @throws IOException if the servlet cannot talk to the network.
    */
-  private Service addWebQueryContext(Server server) throws IOException {
-    if (logger.isDebugEnabled()) logger.debug("Adding WebQuery servlet context");
+  private Service addWebQueryContext(Server server, String name, String servletClass, String servletPath) throws IOException {
+    if (logger.isDebugEnabled()) logger.debug("Adding Web servlet context: " + name);
 
-    // create the web query context
+    // create the web context
     try {
       AbstractServer serverMBean = (AbstractServer)hostServer.getServerMBean();
       String rmiName = hostServer.getServerName();
-      Servlet servlet = (Servlet)Reflect.newInstance(Class.forName("org.mulgara.webquery.QueryServlet"), hostName, rmiName, serverMBean);
-      String webPath = "/" + WEBQUERY_PATH;
+      Servlet servlet = (Servlet)Reflect.newInstance(Class.forName(servletClass), hostName, rmiName, serverMBean);
+      String webPath = "/" + servletPath;
       new org.mortbay.jetty.servlet.Context(server, webPath, SESSIONS).addServlet(new ServletHolder(servlet), "/*");
-      return new Service("User Interface", webPath);
+      return new Service(name, webPath);
     } catch (ClassNotFoundException e) {
-      throw new IllegalStateException("Not configured to use the requested Query servlet");
+      throw new IllegalStateException("Not configured to use the requested servlet: " + name + "(" + servletClass + ")");
     }
   }
 

Modified: trunk/src/jar/util/java/org/mulgara/util/functional/C.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/functional/C.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/util/java/org/mulgara/util/functional/C.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -181,4 +181,28 @@
     return arg.isEmpty() ? null : arg.get(arg.size() - 1);
   }
 
+  /**
+   * Returns the first item from a Collection. This is a simple wrapper for {@link LinkedList#getFirst()}
+   * @param <T1> The element type.
+   * @param arg The list.
+   * @return The first element in the list.
+   * @throws NoSuchElementException If the list is empty.
+   */
+  public static <T1> T1 first(LinkedList<T1> arg) throws NoSuchElementException {
+    return arg.getFirst();
+  }
+
+  /**
+   * Returns the first item from an Iterable.
+   * @param <T1> The element type.
+   * @param arg The iterable collection.
+   * @return The first element in the collection.
+   * @throws NoSuchElementException If the collection is empty.
+   */
+  public static <T1> T1 first(Collection<T1> arg) throws NoSuchElementException {
+    if (arg instanceof LinkedList) return ((LinkedList<T1>)arg).getFirst();
+    if (arg.isEmpty()) throw new NoSuchElementException("Empty Collection");
+    return arg.iterator().next();
+  }
+
 }

Modified: trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java
===================================================================
--- trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/web/java/org/mulgara/webquery/QueryResponsePage.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -79,6 +79,12 @@
   /** The structure for sending the page back to the client. */
   HttpServletResponse response;
 
+  /** The absolute file path of the template header, with the root set to the resource directory. */
+  final String templateHeadFile;
+
+  /** The absolute file path of the template footer, with the root set to the resource directory. */
+  final String templateTailFile;
+
   /** A map of tags to the values that should replace them. */
   Map<String,String> tagMap;
 
@@ -105,10 +111,12 @@
    * @param tagMap A map of tags to the values that should replace them
    */
   @SuppressWarnings("unchecked")
-  public QueryResponsePage(HttpServletRequest req, HttpServletResponse resp, Map<String,String> tagMap) {
+  public QueryResponsePage(HttpServletRequest req, HttpServletResponse resp, Map<String,String> tagMap, String headFile, String tailFile) {
     this.request = req;
     this.response = resp;
     this.tagMap = tagMap;
+    this.templateHeadFile = headFile;
+    this.templateTailFile = tailFile;
     this.unfinishedResults = (Map<Answer,Pair<Long,Command>>)req.getSession().getAttribute(UNFINISHED_RESULTS);
   }
 
@@ -140,7 +148,7 @@
     response.setHeader("pragma", "no-cache");
     PrintWriter output = getOutput();
     // write the head of the page
-    new ResourceTextFile(TEMPLATE_HEAD, tagMap).sendTo(output);
+    new ResourceTextFile(templateHeadFile, tagMap).sendTo(output);
 
     // summarise the results first
     writeResultSummary(time, results.size());
@@ -154,7 +162,7 @@
     if (r.hasNext()) response.sendError(SC_INTERNAL_SERVER_ERROR, "Internal error: results do not match queries.");
 
     // write the tail of the page
-    new ResourceTextFile(TEMPLATE_TAIL).sendTo(output);
+    new ResourceTextFile(templateTailFile).sendTo(output);
 
     output.close();
   }

Modified: trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
===================================================================
--- trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/web/java/org/mulgara/webquery/QueryServlet.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.HashMap;
@@ -36,8 +37,10 @@
 import org.mulgara.connection.SessionConnection;
 import org.mulgara.itql.TqlInterpreter;
 import org.mulgara.parser.Interpreter;
+import org.mulgara.parser.MulgaraLexerException;
 import org.mulgara.parser.MulgaraParserException;
 import org.mulgara.query.Answer;
+import org.mulgara.query.Query;
 import org.mulgara.query.QueryException;
 import org.mulgara.query.TuplesException;
 import org.mulgara.query.operation.Command;
@@ -90,12 +93,12 @@
   private final AbstractServer server;
 
   /** The default graph URI to use. */
-  private final String defaultGraphUri;
+  private String defaultGraphUri;
 
   /** Session factory for accessing the database. */
   private SessionFactory cachedSessionFactory;
 
-  /** The path down to the TEMPLATE resource. */
+  /** The path down to the template resource. */
   private String templatePath;
 
   /** The path prefix for resources. */
@@ -114,8 +117,8 @@
     this.servername = servername;
     this.cachedSessionFactory = null;
     this.server = server;
-    URL path = getClass().getClassLoader().getResource(ResourceFile.RESOURCES + TEMPLATE);
-    if (path == null) throw new IOException("Resource not found: " + ResourceFile.RESOURCES + TEMPLATE);
+    URL path = getClass().getClassLoader().getResource(ResourceFile.RESOURCES + getTemplateFile());
+    if (path == null) throw new IOException("Resource not found: " + ResourceFile.RESOURCES + getTemplateFile());
     templatePath = path.toString();
     resourcePath = templatePath.split("!")[0];
     defaultGraphUri = "rmi://" + hostname + "/" + servername + "#sampledata";
@@ -189,7 +192,7 @@
    */
   private void outputStandardTemplate(HttpServletResponse resp) throws IOException {
     PrintWriter out = resp.getWriter();
-    new ResourceTextFile(TEMPLATE, getTemplateTags()).sendTo(out);
+    new ResourceTextFile(getTemplateFile(), getTemplateTags()).sendTo(out);
     out.close();
   }
 
@@ -235,11 +238,19 @@
       return;
     }
 
+    // Use the first graph mentioned as the future default
+    for (Command c: cmds) {
+      if (c instanceof Query) {
+        updateDefaultGraph(c);
+        break;
+      }
+    }
+
     // Get the tags to use in the page template
     Map<String,String> templateTags = getTemplateTagMap();
     templateTags.put(GRAPH_TAG, defaultGraph(graphUri));
     // Generate the page
-    QueryResponsePage page = new QueryResponsePage(req, resp, templateTags);
+    QueryResponsePage page = new QueryResponsePage(req, resp, templateTags, getTemplateHeaderFile(), getTemplateTailFile());
     page.writeResults(time, cmds, results);
   }
 
@@ -276,7 +287,7 @@
     templateTags.put(GRAPH_TAG, defaultGraph(req.getParameter(GRAPH_ARG)));
     
     // Generate the page
-    QueryResponsePage page = new QueryResponsePage(req, resp, templateTags);
+    QueryResponsePage page = new QueryResponsePage(req, resp, templateTags, getTemplateHeaderFile(), getTemplateTailFile());
     page.writeResult(unfinishedResults.get(remaining).second(), remaining);
   }
 
@@ -417,6 +428,16 @@
 
 
   /**
+   * Updates the default graph URI to one found in a Query.
+   * @param cmd A Command that contains a query.
+   */
+  private void updateDefaultGraph(Command cmd) {
+    assert cmd instanceof Query;
+    Set<URI> graphs = ((Query)cmd).getModelExpression().getGraphURIs();
+    if (!graphs.isEmpty()) defaultGraphUri = C.first(graphs).toString();
+  }
+
+  /**
    * Creates the default graph name for the sample data.
    * @param The graph name that the user has already set.
    * @return The default graph name to use when no graph has been set.
@@ -480,7 +501,7 @@
       factory = new Fn<Interpreter>(){ public Interpreter fn(){ return new SparqlInterpreter(); }};
       attr = SPARQL_INTERPRETER;
     } else {
-      factory = new Fn<Interpreter>(){ public Interpreter fn() { return new TqlInterpreter(); }};
+      factory = new Fn<Interpreter>(){ public Interpreter fn() { return new TerminatingTqlInterpreter(); }};
       attr = TQL_INTERPRETER;
     }
     return new RegInterpreter(factory, attr);
@@ -523,16 +544,44 @@
 
 
   /**
+   * Get the name of the file to be used for the template.
+   * @return The absolute file path, with a root set at the resource directory.
+   */
+  protected String getTemplateFile() {
+    return TEMPLATE;
+  }
+
+
+  /**
+   * Get the name of the file to be used for the header template.
+   * @return The absolute file path, with a root set at the resource directory.
+   */
+  protected String getTemplateHeaderFile() {
+    return TEMPLATE_HEAD;
+  }
+
+
+  /**
+   * Get the name of the file to be used for the footer template.
+   * @return The absolute file path, with a root set at the resource directory.
+   */
+  protected String getTemplateTailFile() {
+    return TEMPLATE_TAIL;
+  }
+
+
+  /**
    * Returns the filename extension for a given path.
    * @param path The path to get the extension for.
    * @return The extension, including the . character. If there is no extension, then an empty string.
    */
-  private String getExtension(String path) {
+  private static String getExtension(String path) {
     int dot = path.lastIndexOf('.');
     if (dot < 0) return "";
     return path.substring(dot);
   }
 
+
   /**
    * Registerable Interpreter. This contains a factory for an interpreter, plus the name it should
    * be registered under.
@@ -560,4 +609,26 @@
       return regString;
     }
   }
+
+
+  /**
+   * Extension of TQL interpreter that will automatically terminate any
+   * commands that are not already terminated.
+   */
+  private static class TerminatingTqlInterpreter extends TqlInterpreter {
+
+    /** The terminating character. */
+    private static final String TERMINATOR = ";";
+
+    /**
+     * Calls TqlInterpreter#parseCommands(String) with a guaranteed termination of ";".
+     * @see TqlInterpreter#parseCommands(String)
+     */
+    public List<Command> parseCommands(String command) throws MulgaraParserException, MulgaraLexerException, IOException {
+      command = command.trim();
+      if (!command.endsWith(TERMINATOR)) command += TERMINATOR;
+      return super.parseCommands(command);
+    }
+  }
+
 }

Added: trunk/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java
===================================================================
--- trunk/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java	                        (rev 0)
+++ trunk/src/jar/web/java/org/mulgara/webquery/TutorialServlet.java	2008-12-04 23:38:27 UTC (rev 1398)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2008 Fedora Commons, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.mulgara.webquery;
+
+import java.io.IOException;
+
+import org.mulgara.server.AbstractServer;
+
+/**
+ * A tutorial Web UI for the server. This is almost the same as the standard
+ * WebUI, but includes a series of selectable commands.
+ *
+ * @created Dec 4, 2008
+ * @author Paul Gearon
+ */
+public class TutorialServlet extends QueryServlet {
+
+  /** Generated serialization ID. */
+  private static final long serialVersionUID = 1959974464706199835L;
+
+  /** The name of the template HTML file. */
+  public static final String TUTORIAL = "/tutorial.html";
+  
+  /** The name of the HTML file containing the head of a result. */
+  public static final String TUTORIAL_HEAD = "/tutorial_head.html";
+  
+  /** The name of the HTML file containing the tail of a result. Same as the standard template. */
+  public static final String TUTORIAL_TAIL = "/template_tail.html";
+  
+  /**
+   * Creates the tutorial servlet.
+   * @param hostname
+   * @param servername
+   * @param server
+   * @throws IOException
+   */
+  public TutorialServlet(String hostname, String servername, AbstractServer server) throws IOException {
+    super(hostname, servername, server);
+  }
+
+
+  /**
+   * Provide a description for the servlet.
+   * @see javax.servlet.GenericServlet#getServletInfo()
+   */
+  public String getServletInfo() {
+    return "Mulgara Query Tutorial";
+  }
+
+
+  /**
+   * Get the name of the file to be used for the tutorial template.
+   * @return The absolute file path, with a root set at the resource directory.
+   */
+  protected String getTemplateFile() {
+    return TUTORIAL;
+  }
+
+
+  /**
+   * Get the name of the file to be used for the tutorial header template.
+   * @return The absolute file path, with a root set at the resource directory.
+   */
+  protected String getTemplateHeaderFile() {
+    return TUTORIAL_HEAD;
+  }
+
+
+  /**
+   * Get the name of the file to be used for the tutorial footer template.
+   * @return The absolute file path, with a root set at the resource directory.
+   */
+  protected String getTemplateTailFile() {
+    return TUTORIAL_TAIL;
+  }
+
+}

Modified: trunk/src/jar/web/resources/template.html
===================================================================
--- trunk/src/jar/web/resources/template.html	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/web/resources/template.html	2008-12-04 23:38:27 UTC (rev 1398)
@@ -9,23 +9,6 @@
   <link href="styles/ui.css" rel="stylesheet" type="text/css" />
   <script language="JavaScript" type="text/javascript">
   <!--
-  // Put the selected example query into the query text area. The graph
-  // name is also inserted in to the query.
-  function setQuery() {
-    // Must have a Graph URI
-    if (document.QueryForm.GraphURI.value == '') {
-      alert('Please enter a Graph URI and then select the query again');
-      document.QueryForm.GraphURI.focus;
-      return;
-    }
-    var index = document.QueryForm.ExampleQuery.selectedIndex;
-    var exampleText = document.QueryForm.ExampleQuery[index].value;
-    var graphURI= document.QueryForm.GraphURI.value;
-    // Add the graph name
-    var queryString = exampleText.replace(/-graph-/gi, graphURI);
-    document.QueryForm.QueryText.value = queryString;
-  }
-
   // Validate the form and submit it if all is OK
   function validateAndSubmit() {
     // Is there a query?
@@ -58,25 +41,9 @@
               <table class="queryTable" summary="Enter a query">
                 <tr>
                   <td><strong>Graph URI:</strong> </td>
-                  <td><input name="GraphURI" size="60" type="text" value="rmi://@@hostname@@/@@servername@@#sampledata"> </td>
+                  <td><input name="GraphURI" size="60" type="text" value=""> </td>
                 </tr>
                 <tr>
-                  <td><strong>Example Queries:</strong> </td>
-                  <td>
-                    <select name="ExampleQuery" onchange="javascript:setQuery()">
-                      <option selected value="">Select a query..</option>
-                      <option value="create &lt;-graph-&gt;;">Step 1. Create a graph</option>
-                      <option value="load &lt;@@jarurl@@!/data/w3c-news.rss&gt; into &lt;-graph-&gt;;">Step 2. Load RSS data into the graph</option>
-                      <option value="select $subject $predicate $object from &lt;-graph-&gt; where $subject $predicate $object;">Step 3. List everything in the graph</option>
-                      <option value="select $title $link $description from &lt;-graph-&gt; where $article &lt;http://purl.org/rss/1.0/title&gt; $title and $article &lt;http://purl.org/rss/1.0/link&gt; $link and $article &lt;http://purl.org/rss/1.0/description&gt; $description;">Step 4. List the news articles</option>
-                      <option value="create &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 5. Create a standalone RDF schema graph</option>
-                      <option value="load &lt;@@jarurl@@!/data/rss-1.0.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/dc.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/rdfs.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 6. Load in the referenced schemas</option>
-                      <option value="select $rdfSubject $rdfProperty $value from &lt;-graph-&gt; or &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt; where $rdfSubject $rdfProperty $value and $rdfProperty &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#Property&gt; and $rdfProperty &lt;http://www.w3.org/2000/01/rdf-schema#isDefinedBy&gt; &lt;http://purl.org/rss/1.0/&gt;;">Step 7. List the RSS properties using both graphs</option>
-                      <option value="drop &lt;-graph-&gt;; drop &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 8. Drop the graphs</option>
-                    </select>
-                  </td>
-                </tr>
-                <tr>
                   <td><strong>Query Text:</strong> </td>
                   <td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
                 </tr>

Modified: trunk/src/jar/web/resources/template_head.html
===================================================================
--- trunk/src/jar/web/resources/template_head.html	2008-12-03 09:26:08 UTC (rev 1397)
+++ trunk/src/jar/web/resources/template_head.html	2008-12-04 23:38:27 UTC (rev 1398)
@@ -9,23 +9,6 @@
   <link href="styles/ui.css" rel="stylesheet" type="text/css" />
   <script language="JavaScript" type="text/javascript">
   <!--
-  // Put the selected example query into the query text area. The graph
-  // name is also inserted in to the query.
-  function setQuery() {
-    // Must have a Graph URI
-    if (document.QueryForm.GraphURI.value == '') {
-      alert('Please enter a Graph URI and then select the query again');
-      document.QueryForm.GraphURI.focus;
-      return;
-    }
-    var index = document.QueryForm.ExampleQuery.selectedIndex;
-    var exampleText = document.QueryForm.ExampleQuery[index].value;
-    var graphURI= document.QueryForm.GraphURI.value;
-    // Add the graph name
-    var queryString = exampleText.replace(/-graph-/gi, graphURI);
-    document.QueryForm.QueryText.value = queryString;
-  }
-
   // Validate the form and submit it if all is OK
   function validateAndSubmit() {
     // Is there a query?
@@ -61,22 +44,6 @@
                   <td><input name="GraphURI" size="60" type="text" value="@@graph@@"> </td>
                 </tr>
                 <tr>
-                  <td><strong>Example Queries:</strong> </td>
-                  <td>
-                    <select name="ExampleQuery" onchange="javascript:setQuery()">
-                      <option selected value="">Select a query..</option>
-                      <option value="create &lt;-graph-&gt;;">Step 1. Create a graph</option>
-                      <option value="load &lt;@@jarurl@@!/data/w3c-news.rss&gt; into &lt;-graph-&gt;;">Step 2. Load RSS data into the graph</option>
-                      <option value="select $subject $predicate $object from &lt;-graph-&gt; where $subject $predicate $object;">Step 3. List everything in the graph</option>
-                      <option value="select $title $link $description from &lt;-graph-&gt; where $article &lt;http://purl.org/rss/1.0/title&gt; $title and $article &lt;http://purl.org/rss/1.0/link&gt; $link and $article &lt;http://purl.org/rss/1.0/description&gt; $description;">Step 4. List the news articles</option>
-                      <option value="create &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 5. Create a standalone RDF schema graph</option>
-                      <option value="load &lt;@@jarurl@@!/data/rss-1.0.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/dc.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/rdfs.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 6. Load in the referenced schemas</option>
-                      <option value="select $rdfSubject $rdfProperty $value from &lt;-graph-&gt; or &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt; where $rdfSubject $rdfProperty $value and $rdfProperty &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#Property&gt; and $rdfProperty &lt;http://www.w3.org/2000/01/rdf-schema#isDefinedBy&gt; &lt;http://purl.org/rss/1.0/&gt;;">Step 7. List the RSS properties using both graphs</option>
-                      <option value="drop &lt;-graph-&gt;; drop &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 8. Drop the graphs</option>
-                    </select>
-                  </td>
-                </tr>
-                <tr>
                   <td><strong>Query Text:</strong> </td>
                   <td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
                 </tr>

Added: trunk/src/jar/web/resources/tutorial.html
===================================================================
--- trunk/src/jar/web/resources/tutorial.html	                        (rev 0)
+++ trunk/src/jar/web/resources/tutorial.html	2008-12-04 23:38:27 UTC (rev 1398)
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+@@debug@@
+-->
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+  <title>Mulgara Tutorial</title>
+  <link href="styles/ui.css" rel="stylesheet" type="text/css" />
+  <script language="JavaScript" type="text/javascript">
+  <!--
+  // Put the selected example query into the query text area. The graph
+  // name is also inserted in to the query.
+  function setQuery() {
+    // Must have a Graph URI
+    if (document.QueryForm.GraphURI.value == '') {
+      alert('Please enter a Graph URI and then select the query again');
+      document.QueryForm.GraphURI.focus;
+      return;
+    }
+    var index = document.QueryForm.ExampleQuery.selectedIndex;
+    var exampleText = document.QueryForm.ExampleQuery[index].value;
+    var graphURI= document.QueryForm.GraphURI.value;
+    // Add the graph name
+    var queryString = exampleText.replace(/-graph-/gi, graphURI);
+    document.QueryForm.QueryText.value = queryString;
+  }
+
+  // Validate the form and submit it if all is OK
+  function validateAndSubmit() {
+    // Is there a query?
+    if (document.QueryForm.QueryText.value == null ||
+        document.QueryForm.QueryText.value == "") {
+      alert('Please enter a query');
+      document.QueryForm.QueryText.focus();
+      return false;
+    } else {
+      // Submit the form
+      document.QueryForm.submit();
+      return true;
+    }
+  }
+  //-->
+  </script>
+</head>
+<body>
+  <div id="wrapper">
+    <div id="header">
+      <div id="logo">
+        <a href="http://mulgara.org/"><img src="images/logo.jpg" alt="Mulgara - Semantic Store" border="0" /></a>
+      </div>
+    </div>
+    <div id="content">
+      <table class="formatTable" summary="">
+        <tr>
+          <td>
+            <form action="@@execute@@" method="post" name="QueryForm">
+              <table class="queryTable" summary="Enter a query">
+                <tr>
+                  <td><strong>Graph URI:</strong> </td>
+                  <td><input name="GraphURI" size="60" type="text" value="rmi://@@hostname@@/@@servername@@#sampledata"> </td>
+                </tr>
+                <tr>
+                  <td><strong>Example Queries:</strong> </td>
+                  <td>
+                    <select name="ExampleQuery" onchange="javascript:setQuery()">
+                      <option selected value="">Select a query..</option>
+                      <option value="create &lt;-graph-&gt;;">Step 1. Create a graph</option>
+                      <option value="load &lt;@@jarurl@@!/data/w3c-news.rss&gt; into &lt;-graph-&gt;;">Step 2. Load RSS data into the graph</option>
+                      <option value="select $subject $predicate $object from &lt;-graph-&gt; where $subject $predicate $object;">Step 3. List everything in the graph</option>
+                      <option value="select $title $link $description from &lt;-graph-&gt; where $article &lt;http://purl.org/rss/1.0/title&gt; $title and $article &lt;http://purl.org/rss/1.0/link&gt; $link and $article &lt;http://purl.org/rss/1.0/description&gt; $description;">Step 4. List the news articles</option>
+                      <option value="create &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 5. Create a standalone RDF schema graph</option>
+                      <option value="load &lt;@@jarurl@@!/data/rss-1.0.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/dc.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/rdfs.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 6. Load in the referenced schemas</option>
+                      <option value="select $rdfSubject $rdfProperty $value from &lt;-graph-&gt; or &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt; where $rdfSubject $rdfProperty $value and $rdfProperty &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#Property&gt; and $rdfProperty &lt;http://www.w3.org/2000/01/rdf-schema#isDefinedBy&gt; &lt;http://purl.org/rss/1.0/&gt;;">Step 7. List the RSS properties using both graphs</option>
+                      <option value="drop &lt;-graph-&gt;; drop &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 8. Drop the graphs</option>
+                    </select>
+                  </td>
+                </tr>
+                <tr>
+                  <td><strong>Query Text:</strong> </td>
+                  <td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
+                </tr>
+                <tr>
+                  <td>&nbsp;</td>
+                  <td align="left">
+                    <input type="button" value="Submit Query" onclick="validateAndSubmit()">
+                    <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';">
+                  </td>
+                </tr>
+              </table>
+            </form>
+          </td>
+        </tr>
+      </table>
+    </div>
+  </div>
+</body>
+</html>

Added: trunk/src/jar/web/resources/tutorial_head.html
===================================================================
--- trunk/src/jar/web/resources/tutorial_head.html	                        (rev 0)
+++ trunk/src/jar/web/resources/tutorial_head.html	2008-12-04 23:38:27 UTC (rev 1398)
@@ -0,0 +1,96 @@
+<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+@@debug@@
+-->
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+  <title>Mulgara Tutorial</title>
+  <link href="styles/ui.css" rel="stylesheet" type="text/css" />
+  <script language="JavaScript" type="text/javascript">
+  <!--
+  // Put the selected example query into the query text area. The graph
+  // name is also inserted in to the query.
+  function setQuery() {
+    // Must have a Graph URI
+    if (document.QueryForm.GraphURI.value == '') {
+      alert('Please enter a Graph URI and then select the query again');
+      document.QueryForm.GraphURI.focus;
+      return;
+    }
+    var index = document.QueryForm.ExampleQuery.selectedIndex;
+    var exampleText = document.QueryForm.ExampleQuery[index].value;
+    var graphURI= document.QueryForm.GraphURI.value;
+    // Add the graph name
+    var queryString = exampleText.replace(/-graph-/gi, graphURI);
+    document.QueryForm.QueryText.value = queryString;
+  }
+
+  // Validate the form and submit it if all is OK
+  function validateAndSubmit() {
+    // Is there a query?
+    if (document.QueryForm.QueryText.value == null ||
+        document.QueryForm.QueryText.value == "") {
+      alert('Please enter a query');
+      document.QueryForm.QueryText.focus();
+      return false;
+    } else {
+      // Submit the form
+      document.QueryForm.submit();
+      return true;
+    }
+  }
+  //-->
+  </script>
+</head>
+<body>
+  <div id="wrapper">
+    <div id="header">
+      <div id="logo">
+        <a href="http://mulgara.org/"><img src="images/logo.jpg" alt="Mulgara - Semantic Store" border="0" /></a>
+      </div>
+    </div>
+    <div id="content">
+      <table class="formatTable" summary="">
+        <tr>
+          <td>
+            <form action="@@execute@@.html" method="post" name="QueryForm">
+              <table class="queryTable" summary="Enter a query">
+                <tr>
+                  <td><strong>Graph URI:</strong> </td>
+                  <td><input name="GraphURI" size="60" type="text" value="@@graph@@"> </td>
+                </tr>
+                <tr>
+                  <td><strong>Example Queries:</strong> </td>
+                  <td>
+                    <select name="ExampleQuery" onchange="javascript:setQuery()">
+                      <option selected value="">Select a query..</option>
+                      <option value="create &lt;-graph-&gt;;">Step 1. Create a graph</option>
+                      <option value="load &lt;@@jarurl@@!/data/w3c-news.rss&gt; into &lt;-graph-&gt;;">Step 2. Load RSS data into the graph</option>
+                      <option value="select $subject $predicate $object from &lt;-graph-&gt; where $subject $predicate $object;">Step 3. List everything in the graph</option>
+                      <option value="select $title $link $description from &lt;-graph-&gt; where $article &lt;http://purl.org/rss/1.0/title&gt; $title and $article &lt;http://purl.org/rss/1.0/link&gt; $link and $article &lt;http://purl.org/rss/1.0/description&gt; $description;">Step 4. List the news articles</option>
+                      <option value="create &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 5. Create a standalone RDF schema graph</option>
+                      <option value="load &lt;@@jarurl@@!/data/rss-1.0.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/dc.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;; load &lt;@@jarurl@@!/data/rdfs.rdfs&gt; into &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 6. Load in the referenced schemas</option>
+                      <option value="select $rdfSubject $rdfProperty $value from &lt;-graph-&gt; or &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt; where $rdfSubject $rdfProperty $value and $rdfProperty &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#Property&gt; and $rdfProperty &lt;http://www.w3.org/2000/01/rdf-schema#isDefinedBy&gt; &lt;http://purl.org/rss/1.0/&gt;;">Step 7. List the RSS properties using both graphs</option>
+                      <option value="drop &lt;-graph-&gt;; drop &lt;rmi://@@hostname@@/@@servername@@#rdfs&gt;;">Step 8. Drop the graphs</option>
+                    </select>
+                  </td>
+                </tr>
+                <tr>
+                  <td><strong>Query Text:</strong> </td>
+                  <td><textarea cols="80" name="QueryText" rows="10"></textarea> </td>
+                </tr>
+                <tr>
+                  <td>&nbsp;</td>
+                  <td align="left">
+                    <input type="button" value="Submit Query" onclick="validateAndSubmit()">
+                    <input type="button" value="Clear Query" onclick="javascript:document.QueryForm.QueryText.value='';">
+                  </td>
+                </tr>
+              </table>
+            </form>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <table class="allResultsTable" border="0" cellpadding="5" width="100%">




More information about the Mulgara-svn mailing list