[Mulgara-svn] r1316 - in trunk: jxdata/iTQL/standard_queries src/jar/resolver/java/org/mulgara/resolver

pag at mulgara.org pag at mulgara.org
Wed Oct 15 06:57:55 UTC 2008


Author: pag
Date: 2008-10-14 23:57:54 -0700 (Tue, 14 Oct 2008)
New Revision: 1316

Modified:
   trunk/jxdata/iTQL/standard_queries/queryResult17.txt
   trunk/jxdata/iTQL/standard_queries/queryResult3.txt
   trunk/jxdata/iTQL/standard_queries/test.jxu
   trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java
Log:
Updated references to 'model' to say 'graph' instead. This doesn't extend to public methods yet.

Modified: trunk/jxdata/iTQL/standard_queries/queryResult17.txt
===================================================================
--- trunk/jxdata/iTQL/standard_queries/queryResult17.txt	2008-10-15 03:50:16 UTC (rev 1315)
+++ trunk/jxdata/iTQL/standard_queries/queryResult17.txt	2008-10-15 06:57:54 UTC (rev 1316)
@@ -1,3 +1,3 @@
 ItqlInterpreter error - Could not commit modify
 Caused by: (QueryException) org.mulgara.query.MulgaraTransactionException: Transaction rollback triggered
-Caused by: (QueryException) rmi://localhost/server1#nomodelexistswiththisname is not a Model
+Caused by: (QueryException) rmi://localhost/server1#nographexistswiththisname is not a Graph

Modified: trunk/jxdata/iTQL/standard_queries/queryResult3.txt
===================================================================
--- trunk/jxdata/iTQL/standard_queries/queryResult3.txt	2008-10-15 03:50:16 UTC (rev 1315)
+++ trunk/jxdata/iTQL/standard_queries/queryResult3.txt	2008-10-15 06:57:54 UTC (rev 1316)
@@ -1,4 +1,4 @@
 ItqlInterpreter error - Query failed
 Caused by: (MulgaraTransactionException) Transaction rollback triggered
 Caused by: (QueryException) Error resolving [$pmid http://mulgara.org/mulgara/Document#subject "Birds" $_from] from @server@#badmodel
-Caused by: (QueryException) @server@#badmodel is not a Model
+Caused by: (QueryException) @server@#badmodel is not a Graph

Modified: trunk/jxdata/iTQL/standard_queries/test.jxu
===================================================================
--- trunk/jxdata/iTQL/standard_queries/test.jxu	2008-10-15 03:50:16 UTC (rev 1315)
+++ trunk/jxdata/iTQL/standard_queries/test.jxu	2008-10-15 06:57:54 UTC (rev 1316)
@@ -276,7 +276,7 @@
   <set name="query" value="
     insert &lt;http://test.com/&gt;
       &lt;http://cdls.nstl.gov.cn/cdls2/w3c/2003/Metadata/elements/title&gt;
-      &apos;test2 escape char &lt;&apos; into &lt;rmi://localhost/server1#nomodelexistswiththisname&gt; ; "/>
+      &apos;test2 escape char &lt;&apos; into &lt;rmi://localhost/server1#nographexistswiththisname&gt; ; "/>
 
   <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
   <ifEqual converse="true" file="queryResult17.txt" name="queryResult">
@@ -298,7 +298,7 @@
   <set name="query" value="
     insert &lt;http://test.com/&gt;
       &lt;http://cdls.nstl.gov.cn/cdls2/w3c/2003/Metadata/elements/title&gt;
-      &apos;test2 escape char &lt;&apos; into &lt;@server2@#nomodelexistswiththisname&gt; ; "/>
+      &apos;test2 escape char &lt;&apos; into &lt;@server2@#nographexistswiththisname&gt; ; "/>
 
   <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
   <ifEqual converse="true" file="queryResult19.txt" name="queryResult">

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2008-10-15 03:50:16 UTC (rev 1315)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2008-10-15 06:57:54 UTC (rev 1316)
@@ -92,33 +92,24 @@
     Logger.getLogger(DatabaseOperationContext.class.getName() + "#symbolic");
 
   /**
-   * The models from external resolvers which have been cached as temporary
-   * models.
-   *
-   * Every model in this set can be manipulated by resolvers from the
-   * {@link #temporaryResolverFactory}.
+   * The graphs from external resolvers which have been cached as temporary graphs.
+   * Every graph in this set can be manipulated by resolvers from the {@link #temporaryResolverFactory}.
    */
-  private final Set<LocalNode> cachedModelSet;
+  private final Set<LocalNode> cachedGraphSet;
 
   /**
-   * The models from external resolvers which have been cached as temporary
-   * models and modified.
-   *
-   * Every model in this set can be manipulated by resolvers from the
-   * {@link #temporaryResolverFactory}.
+   * The graphs from external resolvers which have been cached as temporary graphs and modified.
+   * Every graph in this set can be manipulated by resolvers from the {@link #temporaryResolverFactory}.
    */
-  private final Set<LocalNode> changedCachedModelSet;
+  private final Set<LocalNode> changedCachedGraphSet;
 
   /**
-   * A map from {@link URI}s of models to {@link LocalNode}s representing the
-   * localized type of the model.
-   *
-   * This is populated by {@link #findModelTypeURI} and cleared by
-   * clear()
+   * A map from {@link URI}s of graphs to {@link LocalNode}s representing the localized type of the graph.
+   * This is populated by {@link #findGraphTypeURI} and cleared by clear()
    */
-  private final Map<LocalNode,URI> systemModelCacheMap = new WeakHashMap<LocalNode,URI>();
+  private final Map<LocalNode,URI> systemGraphCacheMap = new WeakHashMap<LocalNode,URI>();
 
-  /** Resolver used for accessing the system model (<code>#</code>).  */
+  /** Resolver used for accessing the system graph (<code>#</code>).  */
   protected SystemResolverFactory systemResolverFactory;
   protected SystemResolver systemResolver;
 
@@ -133,7 +124,7 @@
   private final Map<URI,InternalResolverFactory> internalResolverFactoryMap;
   private final DatabaseMetadata   metadata;
   private final List<SecurityAdapter> securityAdapterList;
-  private final URI                temporaryModelTypeURI;
+  private final URI                temporaryGraphTypeURI;
   private final ResolverFactory    temporaryResolverFactory;
   /** Symbolic transformations this instance should apply. */
   private final List<SymbolicTransformation> symbolicTransformationList;
@@ -147,7 +138,7 @@
                            Map<URI,InternalResolverFactory> internalResolverFactoryMap,
                            DatabaseMetadata      metadata,
                            List<SecurityAdapter> securityAdapterList,
-                           URI                   temporaryModelTypeURI,
+                           URI                   temporaryGraphTypeURI,
                            ResolverFactory       temporaryResolverFactory,
                            List<SymbolicTransformation> symbolicTransformationList,
                            SystemResolverFactory systemResolverFactory,
@@ -158,7 +149,7 @@
     assert internalResolverFactoryMap != null;
     assert metadata                   != null;
     assert securityAdapterList        != null;
-    assert temporaryModelTypeURI      != null;
+    assert temporaryGraphTypeURI      != null;
     assert temporaryResolverFactory   != null;
     assert symbolicTransformationList != null;
     assert systemResolverFactory      != null;
@@ -168,14 +159,14 @@
     this.internalResolverFactoryMap = internalResolverFactoryMap;
     this.metadata                   = metadata;
     this.securityAdapterList        = securityAdapterList;
-    this.temporaryModelTypeURI      = temporaryModelTypeURI;
+    this.temporaryGraphTypeURI      = temporaryGraphTypeURI;
     this.temporaryResolverFactory   = temporaryResolverFactory;
     this.symbolicTransformationList = symbolicTransformationList;
     this.isWriting                  = isWriting;
     this.systemResolverFactory      = systemResolverFactory;
 
-    this.cachedModelSet             = new HashSet<LocalNode>();
-    this.changedCachedModelSet      = new HashSet<LocalNode>();
+    this.cachedGraphSet             = new HashSet<LocalNode>();
+    this.changedCachedGraphSet      = new HashSet<LocalNode>();
     this.enlistedResolverMap        = new HashMap<ResolverFactory,Resolver>();
     this.answers                    = new WeakHashMap<TransactionalAnswer,Object>();
   }
@@ -184,105 +175,105 @@
   // Methods implementing OperationContext
   //
 
-  public ResolverFactory findModelResolverFactory(long model) throws QueryException {
+  public ResolverFactory findModelResolverFactory(long graph) throws QueryException {
 
-    if (logger.isDebugEnabled()) logger.debug("Finding resolver factory for model " + model);
+    if (logger.isDebugEnabled()) logger.debug("Finding resolver factory for graph " + graph);
 
-    // See if the model is an internal one, with a model type
+    // See if the graph is an internal one, with a graph type
     try {
-      URI modelTypeURI = findModelTypeURI(model);
-      if (modelTypeURI != null) {
-        // The model had a type recorded in the system model, so it's internal
+      URI graphTypeURI = findGraphTypeURI(graph);
+      if (graphTypeURI != null) {
+        // The graph had a type recorded in the system graph, so it's internal
         if (logger.isDebugEnabled()) {
-          logger.debug("Model " + model + " type is " + modelTypeURI);
+          logger.debug("Graph " + graph + " type is " + graphTypeURI);
         }
-        InternalResolverFactory internalResolverFactory = internalResolverFactoryMap.get(modelTypeURI);
+        InternalResolverFactory internalResolverFactory = internalResolverFactoryMap.get(graphTypeURI);
 
         if (internalResolverFactory == null) {
-          throw new QueryException("Unsupported model type for model " + model);        }
+          throw new QueryException("Unsupported graph type for graph " + graph);        }
 
         return internalResolverFactory;
       } else {
-        // This might be an external model or an aliased internal model.
-        // get the model URI
-        Node modelNode = systemResolver.globalize(model);
-        if (!(modelNode instanceof URIReference)) {
-          throw new QueryException(modelNode.toString() + " is not a valid Model");
+        // This might be an external graph or an aliased internal graph.
+        // get the graph URI
+        Node graphNode = systemResolver.globalize(graph);
+        if (!(graphNode instanceof URIReference)) {
+          throw new QueryException(graphNode.toString() + " is not a valid Graph");
         }
-        URI modelURI = ((URIReference)modelNode).getURI();
+        URI graphURI = ((URIReference)graphNode).getURI();
 
-        // check if this is really a reference to a local model, using a different server name
-        Node aliasedNode = getCanonicalAlias(modelURI);
+        // check if this is really a reference to a local graph, using a different server name
+        Node aliasedNode = getCanonicalAlias(graphURI);
         if (aliasedNode != null) {
-          long aliasedModel = systemResolver.localize(aliasedNode);
-          return findModelResolverFactory(aliasedModel);
+          long aliasedGraph = systemResolver.localize(aliasedNode);
+          return findModelResolverFactory(aliasedGraph);
         }
 
-        // test the model URI against the current server
+        // test the graph URI against the current server
         try {
           if (logger.isDebugEnabled()) {
-            logger.debug("Comparing " + metadata.getURI().toString() + " to " + (new URI(modelURI.getScheme(),
-                    modelURI.getSchemeSpecificPart(), null)).toString());
+            logger.debug("Comparing " + metadata.getURI().toString() + " to " + (new URI(graphURI.getScheme(),
+                    graphURI.getSchemeSpecificPart(), null)).toString());
           }
 
           // Check all the hostname aliases to see if we're attempting to
           // contact the local server.
-          URI tmpModelName = new URI(modelURI.getScheme(),
-              modelURI.getSchemeSpecificPart(), null);
-          String host = tmpModelName.getHost();
+          URI tmpGraphName = new URI(graphURI.getScheme(),
+              graphURI.getSchemeSpecificPart(), null);
+          String host = tmpGraphName.getHost();
 
           // Ensure that the host name can be extracted - in case there's an
           // opaque hostname.
-          if (tmpModelName.isOpaque()) {
-            throw new QueryException("Unknown graph, and no hostname: " + tmpModelName);
+          if (tmpGraphName.isOpaque()) {
+            throw new QueryException("Unknown graph, and no hostname: " + tmpGraphName);
           }
 
           // Do not test for locality if jar or file protocol
-          if (!(modelURI.getScheme().startsWith("file")) &&
-            !(modelURI.getScheme().startsWith("jar"))) {
+          if (!(graphURI.getScheme().startsWith("file")) &&
+            !(graphURI.getScheme().startsWith("jar"))) {
 
             // Check that it's the same host name and server name.
             if ((metadata.getHostnameAliases().contains(host)) &&
-                (metadata.getServerName().equals(metadata.getServerName(modelURI)))) {
+                (metadata.getServerName().equals(metadata.getServerName(graphURI)))) {
               // should be on the current server, but was not found here
-              throw new QueryException(modelNode.toString() + " is not a Model");
+              throw new QueryException(graphNode.toString() + " is not a Graph");
             }
           }
         } catch (URISyntaxException use) {
-          throw new QueryException("Internal error.  Model URI cannot be manipulated.");
+          throw new QueryException("Internal error.  Graph URI cannot be manipulated.");
         }
 
-        // This is not a local model, get the protocol
-        String modelProtocol = findProtocol(model);
+        // This is not a local graph, get the protocol
+        String graphProtocol = findProtocol(graph);
         if (logger.isDebugEnabled()) {
-          logger.debug("Model " + model + " protocol is " + modelProtocol);
+          logger.debug("Graph " + graph + " protocol is " + graphProtocol);
         }
 
         // find the factory for this protocol
-        ResolverFactory resolverFactory = externalResolverFactoryMap.get(modelProtocol);
+        ResolverFactory resolverFactory = externalResolverFactoryMap.get(graphProtocol);
         if (resolverFactory == null) {
           throw new QueryException(
-              "Unsupported protocol for destination model (" +
-              modelProtocol + ", " + model + " : '" + modelProtocol + "')");
+              "Unsupported protocol for destination graph (" +
+              graphProtocol + ", " + graph + " : '" + graphProtocol + "')");
         }
 
-        // For the moment, not applying caching to any external models
+        // For the moment, not applying caching to any external graphs
         // TODO: add a method to ResolverFactory interface to test whether
         //       caching is appropriate for that particular implementation
         if (cachedResolverFactorySet.contains(resolverFactory)) {
           return new CacheResolverFactory(resolverFactory,
                                           temporaryResolverFactory,
-                                          temporaryModelTypeURI,
-                                          cachedModelSet,
-                                          changedCachedModelSet);
+                                          temporaryGraphTypeURI,
+                                          cachedGraphSet,
+                                          changedCachedGraphSet);
         } else {
           return resolverFactory;
         }
       }
     } catch (GlobalizeException eg) {
-      throw new QueryException("Unable to globalize modeltype", eg);
+      throw new QueryException("Unable to globalize graph type", eg);
     } catch (LocalizeException el) {
-      throw new QueryException("Unable to localize model", el);
+      throw new QueryException("Unable to localize graph", el);
     }
   }
 
@@ -292,55 +283,55 @@
    * @return a completely unwrapped resolver factory
    */
   // TODO: Common code with findModelResolverFactory should be consolidated.
-  private ResolverFactory findResolverFactory(long model) throws QueryException {
+  private ResolverFactory findResolverFactory(long graph) throws QueryException {
 
-    if (logger.isDebugEnabled()) logger.debug("Finding raw resolver factory for model " + model);
+    if (logger.isDebugEnabled()) logger.debug("Finding raw resolver factory for graph " + graph);
 
     try {
-      // get the model URI
-      Node modelNode = systemResolver.globalize(model);
-      if (!(modelNode instanceof URIReference)) {
-        throw new QueryException(modelNode.toString() + " is not a valid Model");
+      // get the graph URI
+      Node graphNode = systemResolver.globalize(graph);
+      if (!(graphNode instanceof URIReference)) {
+        throw new QueryException(graphNode.toString() + " is not a valid Graph");
       }
-      URI modelURI = ((URIReference)modelNode).getURI();
+      URI graphURI = ((URIReference)graphNode).getURI();
 
-      // test the model URI against the current server
+      // test the graph URI against the current server
       try {
         if (logger.isDebugEnabled()) {
           logger.debug("Comparing " + metadata.getURI().toString() + " to "
-              + (new URI(modelURI.getScheme(), modelURI.getSchemeSpecificPart(), null)).toString());
+              + (new URI(graphURI.getScheme(), graphURI.getSchemeSpecificPart(), null)).toString());
         }
         if (metadata.getURI().equals(
-            new URI(modelURI.getScheme(), modelURI.getSchemeSpecificPart(), null))) {
+            new URI(graphURI.getScheme(), graphURI.getSchemeSpecificPart(), null))) {
           // should be on the current server, but was not found here
-          throw new QueryException(modelNode.toString() + " is not a Model");
+          throw new QueryException(graphNode.toString() + " is not a Graph");
         }
       } catch (URISyntaxException use) {
-        throw new QueryException("Internal error.  Model URI cannot be manipulated.");
+        throw new QueryException("Internal error.  Graph URI cannot be manipulated.");
       }
 
-      // This is not a local model, get the protocol
-      String modelProtocol = findProtocol(model);
+      // This is not a local graph, get the protocol
+      String graphProtocol = findProtocol(graph);
       if (logger.isDebugEnabled()) {
-        logger.debug("Model " + model + " protocol is " + modelProtocol);
+        logger.debug("Graph " + graph + " protocol is " + graphProtocol);
       }
 
       // find the factory for this protocol
-      ResolverFactory resolverFactory = externalResolverFactoryMap.get(modelProtocol);
+      ResolverFactory resolverFactory = externalResolverFactoryMap.get(graphProtocol);
       if (resolverFactory == null) {
         throw new QueryException(
-            "Unsupported protocol for destination model (" +
-            modelProtocol + ", " + model + " : '" + modelProtocol + "')");
+            "Unsupported protocol for destination graph (" +
+            graphProtocol + ", " + graph + " : '" + graphProtocol + "')");
       }
 
       return resolverFactory;
     } catch (GlobalizeException eg) {
-      throw new QueryException("Unable to globalize modeltype", eg);
+      throw new QueryException("Unable to globalize graph type", eg);
     }
   }
 
-  public ResolverFactory findModelTypeResolverFactory(URI modelTypeURI) throws QueryException {
-    return internalResolverFactoryMap.get(modelTypeURI);
+  public ResolverFactory findModelTypeResolverFactory(URI graphTypeURI) throws QueryException {
+    return internalResolverFactoryMap.get(graphTypeURI);
   }
 
   public List<SecurityAdapter> getSecurityAdapterList() {
@@ -387,54 +378,54 @@
 
 
   /**
-   * Returns the canonical form of the model, leaving the model alone if it is recognised or unknown.
+   * Returns the canonical form of the graph, leaving the graph alone if it is recognised or unknown.
    *
-   * @param model The model to check.
-   * @return The new model node, or the current model if it is already canonical or unknown.
+   * @param graph The graph to check.
+   * @return The new graph node, or the current graph if it is already canonical or unknown.
    */
-  public long getCanonicalModel(long model) {
+  public long getCanonicalModel(long graph) {
     // globalize to a URI
     try {
-      Node modelNode = systemResolver.globalize(model);
-      if (!(modelNode instanceof URIReference)) {
-        logger.warn(modelNode.toString() + " is not a valid Model");
-        return model;
+      Node graphNode = systemResolver.globalize(graph);
+      if (!(graphNode instanceof URIReference)) {
+        logger.warn(graphNode.toString() + " is not a valid Graph");
+        return graph;
       }
-      URI modelURI = ((URIReference)modelNode).getURI();
+      URI graphURI = ((URIReference)graphNode).getURI();
 
-      // check if this is really a reference to a local model, using a different server name
-      Node aliasedNode = getCanonicalAlias(modelURI);
+      // check if this is really a reference to a local graph, using a different server name
+      Node aliasedNode = getCanonicalAlias(graphURI);
       if (aliasedNode != null) {
         return systemResolver.localize(aliasedNode);
       }
     } catch (Exception e) {
-      // unable to get a canonical form, so leave this model alone
+      // unable to get a canonical form, so leave this graph alone
     }
-    // model was not recognised as being on this server, so leave it alone
-    return model;
+    // graph was not recognised as being on this server, so leave it alone
+    return graph;
   }
 
   //
   // Methods required by SymbolicTransformationContext
   //
 
-  public URI mapToModelTypeURI(URI modelURI) throws QueryException {
+  public URI mapToModelTypeURI(URI graphURI) throws QueryException {
     try {
-      if (logger.isDebugEnabled()) logger.debug("Finding modelTypeURI for " + modelURI);
-      long rawModel = systemResolver.localize(new URIReferenceImpl(modelURI));
-      long canModel = getCanonicalModel(rawModel);
+      if (logger.isDebugEnabled()) logger.debug("Finding graphTypeURI for " + graphURI);
+      long rawGraph = systemResolver.localize(new URIReferenceImpl(graphURI));
+      long canGraph = getCanonicalModel(rawGraph);
 
-      URI modelTypeURI = findModelTypeURI(canModel);
+      URI graphTypeURI = findGraphTypeURI(canGraph);
 
       if (logger.isInfoEnabled()) {
-        logger.info("Mapped " + modelURI + " via " + rawModel + ":" + canModel + " to ModelTypeURI: " + modelTypeURI);
+        logger.info("Mapped " + graphURI + " via " + rawGraph + ":" + canGraph + " to GraphTypeURI: " + graphTypeURI);
       }
 
-      return modelTypeURI;
+      return graphTypeURI;
     } catch (GlobalizeException eg) {
-      throw new QueryException("Failed to map model to modelType", eg);
+      throw new QueryException("Failed to map graph to graphType", eg);
     } catch (LocalizeException el) {
-      throw new QueryException("Failed to map model to modelType", el);
+      throw new QueryException("Failed to map graph to graphType", el);
     }
   }
 
@@ -443,63 +434,62 @@
   //
 
   /**
-   * Find the type of a model.
+   * Find the type of a graph.
    *
-   * @param model  the local node of a model
-   * @return the local node representing the type of the <var>model</var>, or
-   *   {@link NodePool#NONE} if the <var>model</var> isn't stored within the
+   * @param graph  the local node of a graph
+   * @return the local node representing the type of the <var>graph</var>, or
+   *   {@link NodePool#NONE} if the <var>graph</var> isn't stored within the
    *   system
-   * @throws QueryException if the model type can't be determined
+   * @throws QueryException if the graph type can't be determined
    */
-  private URI findModelTypeURI(long model) throws QueryException, GlobalizeException {
-    // If model is a query-node, model cannot exist in the system model so return null.
-    if (model < 0) return null;
+  private URI findGraphTypeURI(long graph) throws QueryException, GlobalizeException {
+    // If graph is a query-node, graph cannot exist in the system graph so return null.
+    if (graph < 0) return null;
 
-    // Check our cached version of the system model
-    LocalNode modelLocalNode = new LocalNode(model);
-    URI modelTypeURI = systemModelCacheMap.get(modelLocalNode);
-    if (modelTypeURI != null) {
-      return modelTypeURI;
+    // Check our cached version of the system graph
+    LocalNode graphLocalNode = new LocalNode(graph);
+    URI graphTypeURI = systemGraphCacheMap.get(graphLocalNode);
+    if (graphTypeURI != null) {
+      return graphTypeURI;
     }
 
-    // Query the system model for the type of the model
-    Variable modelTypeVariable = new Variable("modelType");
-    Constraint modelConstraint =
-      new ConstraintImpl(new LocalNode(model),
+    // Query the system graph for the type of the graph
+    Variable graphTypeVariable = new Variable("graphType");
+    Constraint graphConstraint =
+      new ConstraintImpl(new LocalNode(graph),
                          new LocalNode(metadata.getRdfTypeNode()),
-                         modelTypeVariable,
+                         graphTypeVariable,
                          new LocalNode(metadata.getSystemModelNode()));
-    Resolution resolution = systemResolver.resolve(modelConstraint);
+    Resolution resolution = systemResolver.resolve(graphConstraint);
     assert resolution != null;
 
-    // Check the solution and extract the model type (if any) from it
+    // Check the solution and extract the graph type (if any) from it
     try {
       resolution.beforeFirst();
       if (resolution.next()) {
-        long modelType = resolution.getColumnValue(
-            resolution.getColumnIndex(modelTypeVariable));
+        long graphType = resolution.getColumnValue(
+            resolution.getColumnIndex(graphTypeVariable));
 
         if (resolution.next()) {
-          throw new QueryException("Model " + model +
-              " has more than one type!");
+          throw new QueryException("Graph " + graph + " has more than one type!");
         }
-        Node modelNode = systemResolver.globalize(modelType);
-        assert modelNode instanceof URIReferenceImpl;
-        modelTypeURI = ((URIReferenceImpl) modelNode).getURI();
-        systemModelCacheMap.put(modelLocalNode, modelTypeURI);
+        Node graphNode = systemResolver.globalize(graphType);
+        assert graphNode instanceof URIReferenceImpl;
+        graphTypeURI = ((URIReferenceImpl) graphNode).getURI();
+        systemGraphCacheMap.put(graphLocalNode, graphTypeURI);
 
-        return modelTypeURI;
+        return graphTypeURI;
       } else {
         return null;
       }
     } catch (TuplesException e) {
-      throw new QueryException("Unable to determine model type of " + model, e);
+      throw new QueryException("Unable to determine graph type of " + graph, e);
     } finally {
       if ( resolution != null ) {
         try {
           resolution.close();
         } catch (TuplesException e) {
-          logger.warn("Unable to close find model type resolution to model " + model, e);
+          logger.warn("Unable to close find graph type resolution to graph " + graph, e);
         }
       }
     }
@@ -519,7 +509,7 @@
         throw new QueryException(node + " is not a URI reference");
       }
       if (logger.isDebugEnabled()) {
-        logger.debug("Model URI for model " + n + " is " + node);
+        logger.debug("Graph URI for graph " + n + " is " + node);
       }
       // Return the protocol
       return ((URIReference) node).getURI().getScheme();
@@ -529,19 +519,19 @@
   }
 
   /**
-   * Check if the given model actually refers to a model on the local server.
+   * Check if the given graph actually refers to a graph on the local server.
    *
-   * @param modelURI The URI of the model being searched for.
-   * @return The Node for the local model, or <code>null</code> if not found.
-   * @throws QueryException When the model URI cannot be manipulated.
+   * @param graphURI The URI of the graph being searched for.
+   * @return The Node for the local graph, or <code>null</code> if not found.
+   * @throws QueryException When the graph URI cannot be manipulated.
    */
-  private Node getCanonicalAlias(URI modelURI) throws QueryException {
+  private Node getCanonicalAlias(URI graphURI) throws QueryException {
     if (logger.isDebugEnabled()) {
-      logger.debug("Checking for an alias on: " + modelURI);
+      logger.debug("Checking for an alias on: " + graphURI);
     }
 
     // extract the host name
-    String host = modelURI.getHost();
+    String host = graphURI.getHost();
     if (host == null) {
       return null;
     }
@@ -563,7 +553,7 @@
         metadata.getHostnameAliases().contains(addr.getCanonicalHostName()) ||
         metadata.getHostnameAliases().contains(addr.getHostAddress())) {
       // change the host name to one that is recognised
-      return getLocalURI(modelURI);
+      return getLocalURI(graphURI);
     }
 
     // not found, so return nothing
@@ -579,16 +569,16 @@
    * @throws QueryException When the uri cannot be manipulated.
    */
   private Node getLocalURI(URI uri) throws QueryException {
-    // use the system model to find the local host name
+    // use the system graph to find the local host name
     String newHost = metadata.getSystemModelURI().getHost();
     // update the URI
     try {
-      URI newModelURI = new URI(uri.getScheme(), newHost, uri.getPath(), uri.getFragment());
-      logger.debug("Changing model URI from " + uri + " to " + newModelURI);
+      URI newGraphURI = new URI(uri.getScheme(), newHost, uri.getPath(), uri.getFragment());
+      logger.debug("Changing graph URI from " + uri + " to " + newGraphURI);
 
-      return new URIReferenceImpl(newModelURI);
+      return new URIReferenceImpl(newGraphURI);
     } catch (URISyntaxException e) {
-      throw new QueryException("Internal error.  Model URI cannot be manipulated.");
+      throw new QueryException("Internal error.  Graph URI cannot be manipulated.");
     }
   }
 
@@ -617,23 +607,23 @@
       throw new IllegalArgumentException("Null \"constraint\" parameter");
     }
 
-    ConstraintElement modelElem = constraint.getModel();
-    if (modelElem instanceof Variable) {
-      return resolveVariableModel(constraint);
-    } else if (modelElem instanceof LocalNode) {
-      long model = ((LocalNode) modelElem).getValue();
-      long realModel = getCanonicalModel(model);
+    ConstraintElement graphElem = constraint.getModel();
+    if (graphElem instanceof Variable) {
+      return resolveVariableGraph(constraint);
+    } else if (graphElem instanceof LocalNode) {
+      long graph = ((LocalNode) graphElem).getValue();
+      long realGraph = getCanonicalModel(graph);
 
       // Make sure security adapters are satisfied
       for (SecurityAdapter securityAdapter: securityAdapterList) {
 
         // Lie to the user
-        if (!securityAdapter.canSeeModel(realModel, systemResolver)) {
+        if (!securityAdapter.canSeeModel(realGraph, systemResolver)) {
           try {
-            throw new QueryException("No such model " + systemResolver.globalize(realModel));
+            throw new QueryException("No such graph " + systemResolver.globalize(realGraph));
           } catch (GlobalizeException e) {
-            logger.warn("Unable to globalize model " + realModel);
-            throw new QueryException("No such model");
+            logger.warn("Unable to globalize graph " + realGraph);
+            throw new QueryException("No such graph");
           }
         }
       }
@@ -641,50 +631,48 @@
       for (SecurityAdapter securityAdapter: securityAdapterList) {
 
         // Tell a different lie to the user
-        if (!securityAdapter.canResolve(realModel, systemResolver)) {
+        if (!securityAdapter.canResolve(realGraph, systemResolver)) {
           return TuplesOperations.empty();
         }
       }
 
-      // if the model was changed then update the constraint
-      if (model != realModel) {
-        constraint = ConstraintOperations.rewriteConstraintModel(new LocalNode(realModel), constraint);
+      // if the graph was changed then update the constraint
+      if (graph != realGraph) {
+        constraint = ConstraintOperations.rewriteConstraintModel(new LocalNode(realGraph), constraint);
       }
 
       // Evaluate the constraint
-      Tuples result = obtainResolver(findModelResolverFactory(realModel)).resolve(constraint);
+      Tuples result = obtainResolver(findModelResolverFactory(realGraph)).resolve(constraint);
       assert result != null;
 
       return result;
     } else {
-      throw new QueryException("Non-localized model in resolve: " + modelElem);
+      throw new QueryException("Non-localized graph in resolve: " + graphElem);
     }
   }
 
   /**
-  * Resolve a {@link Constraint} in the case where the model isn't fixed.
+  * Resolve a {@link Constraint} in the case where the graph isn't fixed.
   *
   * This is mostly relevant in the case where the <code>in</code> clause takes
-  * a variable parameter.  It's tricky to resolve because external models may
+  * a variable parameter.  It's tricky to resolve because external graphs may
   * be accessible to the system, but aren't known to it unless they're named.
-  * The policy we take is to only consider internal models.
+  * The policy we take is to only consider internal graphs.
   *
-  * @param constraint  a constraint with a {@link Variable}-valued model
+  * @param constraint  a constraint with a {@link Variable}-valued graph
   *   element, never <code>null</code>
   * @return the solutions to the <var>constraint</var> occurring in all
-  *   internal models, never <code>null</code>
+  *   internal graphs, never <code>null</code>
   * @throws QueryException if the solution can't be evaluated
   */
-  private Tuples resolveVariableModel(Constraint constraint)
-    throws QueryException
-  {
+  private Tuples resolveVariableGraph(Constraint constraint) throws QueryException {
     assert constraint != null;
     assert constraint.getElement(3) instanceof Variable;
 
     Tuples tuples = TuplesOperations.empty();
 
     // This is the alternate code we'd use if we were to consult external
-    // models as well as internal models during the resolution of variable IN
+    // graphs as well as internal graphs during the resolution of variable IN
     // clauses:
     //
     //Iterator i = resolverFactoryList.iterator();
@@ -754,36 +742,36 @@
     }
   }
 
-  protected void doModify(URI modelURI, Statements statements, boolean insert) throws Throwable {
-    long model = systemResolver.localize(new URIReferenceImpl(modelURI));
-    model = getCanonicalModel(model);
+  protected void doModify(URI graphURI, Statements statements, boolean insert) throws Throwable {
+    long graph = systemResolver.localize(new URIReferenceImpl(graphURI));
+    graph = getCanonicalModel(graph);
 
     // Make sure security adapters are satisfied
     for (SecurityAdapter securityAdapter: securityAdapterList) {
 
       // Lie to the user
-      if (!securityAdapter.canSeeModel(model, systemResolver)) {
-        throw new QueryException("No such model " + modelURI);
+      if (!securityAdapter.canSeeModel(graph, systemResolver)) {
+        throw new QueryException("No such graph " + graphURI);
       }
 
       // Tell the truth to the user
-      if (!securityAdapter.canModifyModel(model, systemResolver)) {
-        throw new QueryException("You aren't allowed to modify " + modelURI);
+      if (!securityAdapter.canModifyModel(graph, systemResolver)) {
+        throw new QueryException("You aren't allowed to modify " + graphURI);
       }
     }
 
-    // Obtain a resolver for the destination model type
-    Resolver resolver = obtainResolver(findModelResolverFactory(model));
+    // Obtain a resolver for the destination graph type
+    Resolver resolver = obtainResolver(findModelResolverFactory(graph));
     assert resolver != null;
 
     if (logger.isDebugEnabled()) {
-      logger.debug("Modifying " + modelURI + " using " + resolver);
+      logger.debug("Modifying " + graphURI + " using " + resolver);
     }
 
-    resolver.modifyModel(model, statements, insert);
+    resolver.modifyModel(graph, statements, insert);
 
     if (logger.isDebugEnabled()) {
-      logger.debug("Modified " + modelURI);
+      logger.debug("Modified " + graphURI);
     }
   }
 
@@ -868,7 +856,7 @@
         clearCache();
       } finally {
         systemResolver = null;
-        systemModelCacheMap.clear();
+        systemGraphCacheMap.clear();
         enlistedResolverMap.clear();
         if (error != null) {
           throw new QueryException("Error force-closing answers", error);
@@ -883,48 +871,47 @@
 
 
   /**
-   * Clear the cache of temporary models.
+   * Clear the cache of temporary graphs.
    */
   private void clearCache() {
-    // Clear the temporary models
-    if (!cachedModelSet.isEmpty()) {
+    // Clear the temporary graphs
+    if (!cachedGraphSet.isEmpty()) {
       try {
         Resolver temporaryResolver =
           temporaryResolverFactory.newResolver(true, systemResolver, systemResolver);
-        for (Iterator<LocalNode> i = cachedModelSet.iterator(); i.hasNext();) {
-          LocalNode modelLocalNode = i.next();
-          long model = modelLocalNode.getValue();
+        for (Iterator<LocalNode> i = cachedGraphSet.iterator(); i.hasNext();) {
+          LocalNode graphLocalNode = i.next();
+          long graph = graphLocalNode.getValue();
 
-          if (changedCachedModelSet.contains(modelLocalNode)) {
-            // Write back the modifications to the original model
+          if (changedCachedGraphSet.contains(graphLocalNode)) {
+            // Write back the modifications to the original graph
             try {
               Resolver resolver =
-                findResolverFactory(model).newResolver(true, systemResolver, systemResolver);
+                findResolverFactory(graph).newResolver(true, systemResolver, systemResolver);
               Variable s = new Variable("s");
               Variable p = new Variable("p");
               Variable o = new Variable("o");
-              resolver.modifyModel(model,
+              resolver.modifyModel(graph,
                 new TuplesWrapperStatements(temporaryResolver.resolve(
-                    new ConstraintImpl(s, p, o, modelLocalNode)), s, p, o),
+                    new ConstraintImpl(s, p, o, graphLocalNode)), s, p, o),
                 true  // insert the content
               );
             } catch (Exception e) {
-              logger.error("Failed to write back cached model " + model +
-                           " after transaction", e);
+              logger.error("Failed to write back cached graph " + graph + " after transaction", e);
             }
-            changedCachedModelSet.remove(modelLocalNode);
+            changedCachedGraphSet.remove(graphLocalNode);
           }
 
-          // Remove the cached model
+          // Remove the cached graph
           try {
-            temporaryResolver.removeModel(model);
+            temporaryResolver.removeModel(graph);
           } catch (Exception e) {
-            logger.error("Failed to clear cached model " + model + " after transaction", e);
+            logger.error("Failed to clear cached graph " + graph + " after transaction", e);
           }
           i.remove();
         }
       } catch (Exception e) {
-        logger.error("Failed to clear cached models after transaction", e);
+        logger.error("Failed to clear cached graphs after transaction", e);
       }
     }
   }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java	2008-10-15 03:50:16 UTC (rev 1315)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java	2008-10-15 06:57:54 UTC (rev 1316)
@@ -57,16 +57,16 @@
 
   /**
    * Find a {@link ResolverFactory} capable of generating a {#link Resolver} to
-   * manipulate a specified model.
+   * manipulate a specified graph.
    *
-   * @param model  any model
+   * @param graph  any graph
    * @return  a {@link ResolverFactory} capable of generating
-   *   {@link Resolver}s which can manipulate the <var>model</var>, never
+   *   {@link Resolver}s which can manipulate the <var>graph</var>, never
    *   <code>null</code>
    * @throws QueryException if the <var>model</var> isn't a supported type or
    *   protocol
    */
-  public ResolverFactory findModelResolverFactory(long model)
+  public ResolverFactory findModelResolverFactory(long graph)
     throws QueryException;
 
   /**




More information about the Mulgara-svn mailing list