[Mulgara-svn] r814 - branches/mgr-61-sparql/src/jar/resolver/java/org/mulgara/resolver
pag at mulgara.org
pag at mulgara.org
Tue Apr 22 17:31:04 UTC 2008
Author: pag
Date: 2008-04-22 10:31:03 -0700 (Tue, 22 Apr 2008)
New Revision: 814
Modified:
branches/mgr-61-sparql/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
Log:
Added a new resolve() method to handle the new ModelVariable model expression
Modified: branches/mgr-61-sparql/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
===================================================================
--- branches/mgr-61-sparql/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java 2008-04-22 17:29:54 UTC (rev 813)
+++ branches/mgr-61-sparql/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java 2008-04-22 17:31:03 UTC (rev 814)
@@ -51,26 +51,19 @@
// Third party packages
import org.apache.log4j.Logger;
import org.jrdf.graph.Node;
-import org.jrdf.graph.URIReference;
// Local packages
import org.mulgara.query.*;
import org.mulgara.query.rdf.BlankNodeImpl;
import org.mulgara.query.rdf.LiteralImpl;
import org.mulgara.query.rdf.URIReferenceImpl;
-import org.mulgara.resolver.spi.ConstraintBindingHandler;
-import org.mulgara.resolver.spi.ConstraintLocalization;
-import org.mulgara.resolver.spi.ConstraintModelRewrite;
-import org.mulgara.resolver.spi.ConstraintResolutionHandler;
import org.mulgara.resolver.spi.GlobalizeException;
import org.mulgara.resolver.spi.LocalizeException;
-import org.mulgara.resolver.spi.ModelResolutionHandler;
import org.mulgara.resolver.spi.QueryEvaluationContext;
import org.mulgara.resolver.spi.ResolverSession;
import org.mulgara.store.tuples.RestrictPredicateFactory;
import org.mulgara.store.tuples.Tuples;
import org.mulgara.store.tuples.TuplesOperations;
-import org.mulgara.util.NVPair;
/**
* Localized version of a global {@link Query}.
@@ -204,6 +197,38 @@
}
+ /**
+ * Resolve the variable leaf node of the <code>FROM</code> and
+ * <code>WHERE</code> clause product.
+ * @param modelVariable the <code>FROM<code> clause to resolve, never <code>null</codE>
+ * @param constraint the <code>WHERE</code> clause to resolve, which must
+ * have a {@link Variable#FROM} as its fourth element, and never be <code>null</code>
+ * @throws QueryException if resolution can't be obtained
+ */
+ public Tuples resolve(ModelVariable modelVariable, Constraint constraint) throws QueryException
+ {
+ assert modelVariable != null || !constraint.getModel().equals(Variable.FROM);
+ assert constraint != null;
+
+ // Delegate constraint resolution back to the database session
+ try {
+ Constraint localized = ConstraintOperations.localize(this, constraint);
+
+ if (localized.getModel().equals(Variable.FROM)) {
+ localized = ConstraintOperations.rewriteConstraintModel(modelVariable.getVariable(), localized);
+ }
+
+ return operationContext.resolve(localized);
+
+ } catch (LocalizeException e) {
+ throw new QueryException("Unable to resolve FROM " + modelVariable + " WHERE " + constraint, e);
+ } catch (QueryException eq) {
+ throw new QueryException("Error resolving " + constraint + " from " + modelVariable, eq);
+ } catch (Exception e) {
+ throw new QueryException("Unexpected error resolving " + constraint + " from " + modelVariable, e);
+ }
+ }
+
public Tuples resolve(ModelExpression modelExpression, ConstraintExpression constraintExpression) throws QueryException {
return ConstraintOperations.resolveConstraintExpression(this, modelExpression, constraintExpression);
}
More information about the Mulgara-svn
mailing list