diff --git a/src/board/Board.java b/src/board/Board.java index 5773103..71a7710 100644 --- a/src/board/Board.java +++ b/src/board/Board.java @@ -1,6 +1,7 @@ package board; import com.hp.hpl.jena.query.*; +import com.hp.hpl.jena.shared.*; import com.hp.hpl.jena.rdf.model.*; import java.util.*; @@ -11,27 +12,16 @@ */ public interface Board { /** - * Registers the pattern with the given client. Patterns are matched - * when a client posts an update, regardless whether it is a sensor or - * a regular client. There is no order enforced by this interface for - * matching the patterns. One client may only register one pattern; - * if a client has already registered a pattern, it is overwritten. - * @param pattern A SPARQL query. - * @param client The associated client. + * Adds a client to the list of registered clients. * @see Client#postUpdate */ - public void registerClientPattern (String pattern, Client client); + public void registerClient (Client client); /** - * Drops the client from the registered pattern list. If the client - * hasn't registered a pattern nothing happens. - * @param pattern A SPARQL query. Has to be the same (though doesn't - * have to share the identity) as during registration. - * @param client The associated client (in case more than one client - * registered the pattern). + * Removes a client from the list of registered clients. * @see #registerClientPattern */ - public void unregisterClientPattern (String pattern, Client client); + public void unregisterClient (Client client); /** * Merges the given values with the world model. @@ -66,4 +56,6 @@ public interface Board { * @param klass The type information for the example object. */ public List matching (Model test, Resource marker, MateClass klass); + + public PrefixMapping getDefaultPrefixMapping (); } diff --git a/src/board/Whiteboard.java b/src/board/Whiteboard.java index bb30a74..811b7ff 100644 --- a/src/board/Whiteboard.java +++ b/src/board/Whiteboard.java @@ -19,6 +19,7 @@ import com.hp.hpl.jena.sparql.modify.request.*; import com.hp.hpl.jena.vocabulary.RDF; +import com.hp.hpl.jena.vocabulary.RDFS; import com.hp.hpl.jena.vocabulary.XSD; import com.hp.hpl.jena.vocabulary.OWL; @@ -143,10 +144,12 @@ public Whiteboard (Options options) throws FileNotFoundException { public void reset (Options options) throws FileNotFoundException { prefixes = PrefixMapping.Factory.create (); prefixes.setNsPrefix ("rdf", RDF.getURI ()); + prefixes.setNsPrefix ("rdfs", RDFS.getURI ()); prefixes.setNsPrefix ("xsd", XSD.getURI ()); prefixes.setNsPrefix ("owl", OWL.getURI ()); prefixes.setNsPrefix ("mate", Mate.prefix); prefixes.setNsPrefix ("sensors", Sensors.prefix); + prefixes.setNsPrefix ("legacy", Legacy.prefix); ModelFactory.setDefaultModelPrefixes (prefixes); worldModel = ModelFactory.createDefaultModel (); @@ -234,6 +237,7 @@ else if (string.equals ("none")) /* Set up the ModelD2RQ using a mapping file */ legacyModel = new ModelD2RQ ("file:d2rq.n3"); + legacyModel.setNsPrefixes (worldModel); try { runWebServer (); @@ -360,6 +364,8 @@ private void runWebServer () throws Exception { context.addServlet (new ServletHolder (new ModelServlet (worldModel)), "/world/*"); context.addServlet (new ServletHolder (new ModelServlet (sensorValues)), "/sensors/*"); context.addServlet (new ServletHolder (new ModelServlet (historyValues)), "/history/*"); + context.addServlet (new ServletHolder (new ModelServlet (legacyModel)), "/legacy/*"); + context.addServlet (new ServletHolder (new QueryServlet (this)), "/query/*"); server.start (); @@ -405,14 +411,6 @@ private GraphStore getPrivateStore (Client client) { return result; } - public void registerClientPattern (String pattern, Client client) { - - } - - public void unregisterClientPattern (String pattern, Client client) { - - } - /** * Checks whether a model is consistent with respect to the given * ontology. @@ -918,6 +916,10 @@ public QueryExecution query (String query) { return query (QueryFactory.create (query)); } + public PrefixMapping getDefaultPrefixMapping () { + return prefixes; + } + public static String writeToString (Model model) { return writeToString (model, "N3"); }