clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject svn commit: r1516993 [1/2] - in /clerezza/trunk/rdf.core/src: main/java/org/apache/clerezza/rdf/core/sparql/ main/java/org/apache/clerezza/rdf/core/sparql/query/ main/java/org/apache/clerezza/rdf/core/sparql/query/impl/ main/javacc/org/apache/clerezza/...
Date Fri, 23 Aug 2013 19:29:06 GMT
Author: hasan
Date: Fri Aug 23 19:29:05 2013
New Revision: 1516993

URL: http://svn.apache.org/r1516993
Log:
CLEREZZA-761: Added parsing of GroupGraphPattern, SubSelect, WhereClause, SolutionModifier, ValuesClause, and InlineData in SPARQL 1.1 PreParser

Added:
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java
      - copied, changed from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java
      - copied, changed from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java
      - copied, changed from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java
      - copied, changed from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java
      - copied, changed from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java
      - copied, changed from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java
      - copied, changed from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java
      - copied, changed from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java
      - copied, changed from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java
Modified:
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java
    clerezza/trunk/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj
    clerezza/trunk/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java

Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java?rev=1516993&r1=1516992&r2=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java Fri Aug 23 19:29:05 2013
@@ -20,10 +20,17 @@ package org.apache.clerezza.rdf.core.spa
 
 import java.io.StringReader;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.TcProvider;
+import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.DataSet;
+import org.apache.clerezza.rdf.core.sparql.query.GraphGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.MinusGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.Query;
 import org.apache.clerezza.rdf.core.sparql.query.SparqlUnit;
 import org.apache.clerezza.rdf.core.sparql.update.Update;
@@ -64,6 +71,7 @@ public class SparqlPreParser {
         JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString));
         SparqlUnit sparqlUnit;
         sparqlUnit = parser.parse();
+        boolean referringVariableNamedGraph = false;
         if (sparqlUnit.isQuery()) {
             Query q = sparqlUnit.getQuery();
             DataSet dataSet = q.getDataSet();
@@ -73,14 +81,84 @@ public class SparqlPreParser {
             } else {
                 referredGraphs = new HashSet<UriRef>();
             }
+            GroupGraphPattern queryPattern = q.getQueryPattern();
+            Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns();
+            for (GraphPattern graphPattern : graphPatterns) {
+            }
+//            referringVariableNamedGraph = q.referringVariableNamedGraph();
+            referringVariableNamedGraph = referringVariableNamedGraph(q);
         } else {
             Update u = sparqlUnit.getUpdate();
             referredGraphs = u.getReferredGraphs(defaultGraph, tcProvider);
         }
         if (referredGraphs.isEmpty()) {
-            return null;
-//            referredGraphs.add(defaultGraph);
+            if (referringVariableNamedGraph) {
+                return null;
+            }
+            referredGraphs.add(defaultGraph);
         }
         return referredGraphs;
     }
+
+    private boolean referringVariableNamedGraph(Query query) {
+        GroupGraphPattern queryPattern = query.getQueryPattern();
+        Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns();
+        return referringVariableNamedGraph(graphPatterns);
+    }
+
+    private boolean referringVariableNamedGraph(Set<GraphPattern> graphPatterns) {
+        boolean referringVariableNamedGraph = false;
+        for (GraphPattern graphPattern : graphPatterns) {
+            if (referringVariableNamedGraph(graphPattern)) {
+                referringVariableNamedGraph = true;
+                break;
+            }
+        }
+        return referringVariableNamedGraph;
+    }
+
+    private boolean referringVariableNamedGraph(GraphPattern graphPattern) {
+        if (graphPattern instanceof GraphGraphPattern) {
+            return ((GraphGraphPattern) graphPattern).getGraph().isVariable();
+        }
+        if (graphPattern instanceof AlternativeGraphPattern) {
+            List<GroupGraphPattern> alternativeGraphPatterns =
+                    ((AlternativeGraphPattern) graphPattern).getAlternativeGraphPatterns();
+            boolean referringVariableNamedGraph = false;
+            for (GroupGraphPattern groupGraphPattern : alternativeGraphPatterns) {
+                if (referringVariableNamedGraph(groupGraphPattern)) {
+                    referringVariableNamedGraph = true;
+                    break;
+                }
+            }
+            return referringVariableNamedGraph;
+        }
+        if (graphPattern instanceof OptionalGraphPattern) {
+            GraphPattern mainGraphPattern = ((OptionalGraphPattern) graphPattern).getMainGraphPattern();
+            if (referringVariableNamedGraph(mainGraphPattern)) {
+                return true;
+            }
+            GroupGraphPattern optionalGraphPattern = ((OptionalGraphPattern) graphPattern).getOptionalGraphPattern();
+            return referringVariableNamedGraph(optionalGraphPattern);
+        }
+        if (graphPattern instanceof MinusGraphPattern) {
+            GraphPattern minuendGraphPattern = ((MinusGraphPattern) graphPattern).getMinuendGraphPattern();
+            if (referringVariableNamedGraph(minuendGraphPattern)) {
+                return true;
+            }
+            GroupGraphPattern subtrahendGraphPattern = ((MinusGraphPattern) graphPattern).getSubtrahendGraphPattern();
+            return referringVariableNamedGraph(subtrahendGraphPattern);
+        }
+        if (graphPattern instanceof GroupGraphPattern) {
+            GroupGraphPattern groupGraphPattern = (GroupGraphPattern) graphPattern;
+            if (groupGraphPattern.isSubSelect()) {
+                Query query = ((GroupGraphPattern) graphPattern).getSubSelect();
+                return referringVariableNamedGraph(query);
+            } else {
+                Set<GraphPattern> graphPatterns = ((GroupGraphPattern) graphPattern).getGraphPatterns();
+                return referringVariableNamedGraph(graphPatterns);
+            }
+        }
+        return false;
+    }
 }

Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java?rev=1516993&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java Fri Aug 23 19:29:05 2013
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.clerezza.rdf.core.sparql.query;
+
+/**
+ *
+ * @author hasan
+ */
+public class BinaryPropertyPathOperation implements PropertyPathExpression {
+    private String operator;
+    private PropertyPathExpression lhsOperand;
+    private PropertyPathExpression rhsOperand;
+
+    public BinaryPropertyPathOperation(String operator, PropertyPathExpression lhsOperand, PropertyPathExpression rhsOperand) {
+        this.operator = operator;
+        this.lhsOperand = lhsOperand;
+        this.rhsOperand = rhsOperand;
+    }
+
+    public PropertyPathExpression getLhsOperand() {
+        return lhsOperand;
+    }
+
+    public PropertyPathExpression getRhsOperand() {
+        return rhsOperand;
+    }
+
+}

Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java?rev=1516993&r1=1516992&r2=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java Fri Aug 23 19:29:05 2013
@@ -20,7 +20,7 @@ package org.apache.clerezza.rdf.core.spa
 
 /**
  * This is the generic interface for all types of graph patterns:
- * {@link BasicGraphPattern}, {@link GroupGraphPattern},
+ * {@link BasicGraphPattern}, {@link PathSupportedBasicGraphPattern}, {@link GroupGraphPattern},
  * {@link GraphGraphPattern}, {@link AlternativeGraphPattern}, and
  * {@link OptionalGraphPattern}
  *

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java (from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java&r1=1510871&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -19,27 +19,22 @@
 package org.apache.clerezza.rdf.core.sparql.query;
 
 /**
- * Specifying an optional graph pattern implies the existence of a main graph
- * pattern.
- * The main graph pattern is an empty group pattern if it is not specified.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#optionals">
- * SPARQL Query Language: 6 Including Optional Values</a>
  * 
  * @author hasan
  */
-public interface OptionalGraphPattern extends GraphPattern {
+public interface MinusGraphPattern extends GraphPattern {
 
     /**
      *
      * @return
-     *        the main graph pattern to match
+     *        the minuend graph pattern to match
      */
-    public GraphPattern getMainGraphPattern();
+    public GraphPattern getMinuendGraphPattern();
 
     /**
      *
      * @return
-     *        the optional graph pattern to match
+     *        the subtrahend graph pattern to match
      */
-    public GroupGraphPattern getOptionalGraphPattern();
+    public GroupGraphPattern getSubtrahendGraphPattern();
 }

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java (from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java&r1=1505585&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -21,18 +21,23 @@ package org.apache.clerezza.rdf.core.spa
 import java.util.Set;
 
 /**
- * Defines a basic graph pattern.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#BasicGraphPatterns">
- * SPARQL Query Language: 5.1 Basic Graph Patterns</a>
+ * Defines a basic graph pattern that supports property path expressions.
+ * A {@link PathSupportedBasicGraphPattern} is a set of {@link PropertyPathPattern}s.
+ * A {@link PropertyPathPattern} is a generalization of a {@link TriplePattern} to include
+ * a {@link PropertyPathExpression} in the property position.
+ * Therefore, a {@link PathSupportedBasicGraphPattern} can be seen as a generalization of a {@link BasicGraphPattern}
+ * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlBasicGraphPatterns">
+ * SPARQL 1.1 Query Language: 18.1.6 Basic Graph Patterns</a>
+ * and <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlPropertyPaths">
+ * SPARQL 1.1 Query Language: 18.1.7 Property Path Patterns</a>
  *
  * @author hasan
  */
-public interface BasicGraphPattern extends GraphPattern {
+public interface PathSupportedBasicGraphPattern extends GraphPattern {
 
     /**
      *
-     * @return a set of all triple patterns to match.
+     * @return a set of all property path patterns to match.
      */
-    public Set<TriplePattern> getTriplePatterns();
-
+    public Set<PropertyPathPattern> getPropertyPathPatterns();
 }

Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java?rev=1516993&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java Fri Aug 23 19:29:05 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.clerezza.rdf.core.sparql.query;
+
+import org.apache.clerezza.rdf.core.UriRef;
+
+/**
+ *
+ * @author hasan
+ */
+public class PredicatePath implements PropertyPathExpression {
+    private UriRef predicatePath;
+
+    public PredicatePath(UriRef predicatePath) {
+        this.predicatePath = predicatePath;
+    }
+
+    public UriRef getPredicatePath() {
+        return predicatePath;
+    }
+
+}

Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java?rev=1516993&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java Fri Aug 23 19:29:05 2013
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.clerezza.rdf.core.sparql.query;
+
+/**
+ * This interface models property path expressions.
+ * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#propertypaths">
+ * SPARQL 1.1 Query Language: 9 Property Paths</a>
+ * 
+ * @author hasan
+ */
+public interface PropertyPathExpression {
+}

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java (from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java&r1=1505585&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java Fri Aug 23 19:29:05 2013
@@ -18,50 +18,48 @@
  */
 package org.apache.clerezza.rdf.core.sparql.query;
 
-import org.apache.clerezza.rdf.core.Resource;
-
 /**
- * Wraps either a {@link Resource} or a {@link Variable}
+ * Wraps either a {@link PropertyPathExpression} or a {@link Variable}
  *
  * @author hasan
  */
-public class ResourceOrVariable {
+public class PropertyPathExpressionOrVariable {
 
-    private final Resource resource;
+    private final PropertyPathExpression propertyPathExpression;
     private final Variable variable;
 
-    public ResourceOrVariable(Resource resource) {
-        if (resource == null) {
-            throw new IllegalArgumentException("Invalid resource: null");
+    public PropertyPathExpressionOrVariable(PropertyPathExpression propertyPathExpression) {
+        if (propertyPathExpression == null) {
+            throw new IllegalArgumentException("Invalid propertyPathExpression: null");
         }
-        this.resource = resource;
+        this.propertyPathExpression = propertyPathExpression;
         variable = null;
     }
 
-    public ResourceOrVariable(Variable variable) {
+    public PropertyPathExpressionOrVariable(Variable variable) {
         if (variable == null) {
             throw new IllegalArgumentException("Invalid variable: null");
         }
         this.variable = variable;
-        resource = null;
+        propertyPathExpression = null;
     }
 
     /**
      *
      * @return
-     *        true if it is a {@link Variable}, false if it is a {@link Resource}
+     *        true if it is a {@link Variable}, false if it is a {@link PropertyPathExpression}
      */
     public boolean isVariable() {
-        return resource == null;
+        return propertyPathExpression == null;
     }
 
     /**
      * 
      * @return
-     *        the wrapped Resource if it is a Resource, null otherwise
+     *        the wrapped PropertyPathExpression if it is a PropertyPathExpression, null otherwise
      */
-    public Resource getResource() {
-        return resource;
+    public PropertyPathExpression getPropertyPathExpression() {
+        return propertyPathExpression;
     }
     
     /**
@@ -78,10 +76,10 @@ public class ResourceOrVariable {
         if (obj == null) {
             return false;
         }
-        if (!(obj instanceof ResourceOrVariable)) {
+        if (!(obj instanceof PropertyPathExpressionOrVariable)) {
             return false;
         }
-        final ResourceOrVariable other = (ResourceOrVariable) obj;
+        final PropertyPathExpressionOrVariable other = (PropertyPathExpressionOrVariable) obj;
         if (this.isVariable() != other.isVariable()) {
             return false;
         }
@@ -90,7 +88,7 @@ public class ResourceOrVariable {
                 return false;
             }
         } else {
-            if (!this.getResource().equals(other.getResource())) {
+            if (!this.getPropertyPathExpression().equals(other.getPropertyPathExpression())) {
                 return false;
             }
         }
@@ -100,7 +98,7 @@ public class ResourceOrVariable {
     @Override
     public int hashCode() {
         return (isVariable()
-                ? 13 * getVariable().hashCode() + 7
-                : 13 * getResource().hashCode() + 7);
+                ? 13 * getVariable().hashCode() + 17
+                : 13 * getPropertyPathExpression().hashCode() + 17);
     }
 }

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java (from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java&r1=1505585&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java Fri Aug 23 19:29:05 2013
@@ -19,13 +19,15 @@
 package org.apache.clerezza.rdf.core.sparql.query;
 
 /**
- * Defines a triple pattern consisting of a subject, a predicate, and an object.
+ * Defines a property path pattern consisting of a subject, a property path expression, and an object.
  * The subject and object are of type {@link ResourceOrVariable}, whereas
- * the predicate is of type {@link UriRefOrVariable}.
+ * the predicate is of type {@link PropertyPathExpressionOrVariable}.
+ * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlPropertyPaths">
+ * SPARQL 1.1 Query Language: 18.1.7 Property Path Patterns</a>
  *
  * @author hasan
  */
-public interface TriplePattern {
+public interface PropertyPathPattern {
 
     /**
      * @return the subject
@@ -33,9 +35,9 @@ public interface TriplePattern {
     public ResourceOrVariable getSubject();
 
     /**
-     * @return the predicate
+     * @return the property path expression
      */
-    public UriRefOrVariable getPredicate();
+    public PropertyPathExpressionOrVariable getPropertyPathExpression();
 
     /**
      * @return the object

Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java?rev=1516993&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java Fri Aug 23 19:29:05 2013
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.clerezza.rdf.core.sparql.query;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A property set is intended to store only predicate paths and inverse predicate paths.
+ *
+ * @author hasan
+ */
+public class PropertySet implements PropertyPathExpression {
+    private Set<PropertyPathExpression> propertySet = new HashSet<PropertyPathExpression>();
+
+    /**
+     * 
+     * @param propertyPathExpression expected value is a predicate path or an inverse predicate path
+     */
+    public void addElement(PropertyPathExpression propertyPathExpression) {
+        this.propertySet.add(propertyPathExpression);
+    }
+
+    public Set<PropertyPathExpression> getPropertySet() {
+        return propertySet;
+    }
+
+}

Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java?rev=1516993&r1=1516992&r2=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java Fri Aug 23 19:29:05 2013
@@ -22,15 +22,22 @@ import java.util.List;
 
 /**
  * <p>This interface represents a SPARQL query which contains a specification
- * of solution modifiers: ORDER BY, OFFSET, and LIMIT.</p>
+ * of solution modifiers: GROUP BY, HAVING, ORDER BY, OFFSET, and LIMIT.</p>
  *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#solutionModifiers">
- * SPARQL Query Language: 9 Solution Sequences and Modifiers</a>
+ * @see <a href="http://www.w3.org/TR/sparql11-query/#aggregates">
+ * SPARQL 1.1 Query Language: 11 Aggregates</a>
+ * and
+ * @see <a href="http://www.w3.org/TR/sparql11-query/#solutionModifiers">
+ * SPARQL 1.1 Query Language: 15 Solution Sequences and Modifiers</a>
  *
  * @author hasan
  */
 public interface QueryWithSolutionModifier extends Query {
 
+    public List<Expression> getGroupConditions();
+
+    public List<Expression> getHavingConditions();
+
     /**
      * <p>Gets the list of required ordering conditions in decreasing ordering
      * priority.</p>

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java (from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java&r1=1510871&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -19,20 +19,19 @@
 package org.apache.clerezza.rdf.core.sparql.query;
 
 /**
- * Defines a graph graph pattern.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#queryDataset">
- * SPARQL Query Language: 8.3 Querying the Dataset</a>
+ * Defines a service graph pattern.
+ * @see <a href="http://www.w3.org/TR/sparql11-federated-query/">
+ * SPARQL 1.1 Federated Query</a>
  *
  * @author hasan
  */
-public interface GraphGraphPattern extends GraphPattern {
+public interface ServiceGraphPattern extends GraphPattern {
 
     /**
      *
-     * @return a {@link UriRefOrVariable} which specifies the graph
-     *        against which the pattern should match.
+     * @return a {@link UriRefOrVariable} which specifies the service endpoint.
      */
-    public UriRefOrVariable getGraph();
+    public UriRefOrVariable getService();
 
     /**
      * 

Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java?rev=1516993&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java Fri Aug 23 19:29:05 2013
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.clerezza.rdf.core.sparql.query;
+
+/**
+ *
+ * @author hasan
+ */
+public class UnaryPropertyPathOperation implements PropertyPathExpression {
+    private String operator;
+    private PropertyPathExpression operand;
+
+    public UnaryPropertyPathOperation(String operator, PropertyPathExpression operand) {
+        this.operator = operator;
+        this.operand = operand;
+    }
+
+    public PropertyPathExpression getOperand() {
+        return operand;
+    }
+}

Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java?rev=1516993&r1=1516992&r2=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -22,10 +22,12 @@ import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
+import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.Expression;
 import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.PathSupportedBasicGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern;
 import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
 import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
 
@@ -39,6 +41,7 @@ public class SimpleGroupGraphPattern imp
 	private List<Expression> constraints = new ArrayList<Expression>();
 	private List<GraphPattern> graphPatterns = new ArrayList<GraphPattern>();
     private SelectQuery subSelect = null;
+    private boolean lastBasicGraphPatternIsComplete = true;
 
     @Override
     public boolean isSubSelect() {
@@ -72,7 +75,9 @@ public class SimpleGroupGraphPattern imp
 	 */
 	public void addGraphPattern(GraphPattern graphPattern) {
         subSelect = null;
-		graphPatterns.add(graphPattern);
+        graphPatterns.add(graphPattern);
+        lastBasicGraphPatternIsComplete =
+                !(graphPattern instanceof BasicGraphPattern || graphPattern instanceof PathSupportedBasicGraphPattern);
 	}
 
 	/**
@@ -86,6 +91,36 @@ public class SimpleGroupGraphPattern imp
 		constraints.add(constraint);
 	}
 
+    public void endLastBasicGraphPattern() {
+        lastBasicGraphPatternIsComplete = true;
+    }
+
+    /**
+	 * If the last {@link GraphPattern} added to the group is not a 
+	 * {@link SimplePathSupportedBasicGraphPattern}, then creates one containing the 
+	 * specified {@link PropertyPathPattern}s and adds it to the group.
+	 * Otherwise, adds the specified {@link PropertyPathPattern}s to the last
+	 * added {@link SimplePathSupportedBasicGraphPattern} in the group.
+	 * 
+	 * @param propertyPathPatterns
+	 *		a set of {@link PropertyPathPattern}s to be added into a 
+	 *		{@link SimplePathSupportedBasicGraphPattern} of the group.
+	 */
+	public void addPropertyPathPatterns(Set<PropertyPathPattern> propertyPathPatterns) {
+        subSelect = null;
+        if (lastBasicGraphPatternIsComplete) {
+            graphPatterns.add(new SimplePathSupportedBasicGraphPattern(propertyPathPatterns));
+            lastBasicGraphPatternIsComplete = false;
+        } else {
+            GraphPattern prevGraphPattern;
+        	int size = graphPatterns.size();
+			prevGraphPattern = graphPatterns.get(size-1);
+            if (prevGraphPattern instanceof SimplePathSupportedBasicGraphPattern) {
+                ((SimplePathSupportedBasicGraphPattern) prevGraphPattern).addPropertyPathPatterns(propertyPathPatterns);
+            }
+        }
+	}
+
 	/**
 	 * If the last {@link GraphPattern} added to the group is not a 
 	 * {@link SimpleBasicGraphPattern}, then creates one containing the 
@@ -101,7 +136,7 @@ public class SimpleGroupGraphPattern imp
         subSelect = null;
         GraphPattern prevGraphPattern;
 		int size = graphPatterns.size();
-		if (size > 0) {
+		if (!lastBasicGraphPatternIsComplete && (size > 0)) {
 			prevGraphPattern = graphPatterns.get(size-1);
 			if (prevGraphPattern instanceof SimpleBasicGraphPattern) {
 				((SimpleBasicGraphPattern) prevGraphPattern)
@@ -110,6 +145,7 @@ public class SimpleGroupGraphPattern imp
 			}
 		}
 		graphPatterns.add(new SimpleBasicGraphPattern(triplePatterns));
+        lastBasicGraphPatternIsComplete = false;
 	}
 
 	/**
@@ -131,5 +167,17 @@ public class SimpleGroupGraphPattern imp
 			prevGraphPattern = graphPatterns.remove(size-1);
 		}
 		graphPatterns.add(new SimpleOptionalGraphPattern(prevGraphPattern, optional));
+        lastBasicGraphPatternIsComplete = true;
+	}
+
+    public void addMinusGraphPattern(GroupGraphPattern subtrahend) {
+        subSelect = null;
+		GraphPattern prevGraphPattern = null;
+		int size = graphPatterns.size();
+		if (size > 0) {
+			prevGraphPattern = graphPatterns.remove(size-1);
+		}
+		graphPatterns.add(new SimpleMinusGraphPattern(prevGraphPattern, subtrahend));
+        lastBasicGraphPatternIsComplete = true;
 	}
 }

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java (from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java&r1=1510871&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -20,49 +20,48 @@ package org.apache.clerezza.rdf.core.spa
 
 import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.MinusGraphPattern;
 
 /**
- * This class implements {@link OptionalGraphPattern}.
+ * This class implements {@link MinusGraphPattern}.
  *
  * @author hasan
  */
-public class SimpleOptionalGraphPattern implements OptionalGraphPattern {
+public class SimpleMinusGraphPattern implements MinusGraphPattern {
 
-    private GraphPattern mainGraphPattern;
-    private GroupGraphPattern optionalGraphPattern;
+    private GraphPattern minuendGraphPattern;
+    private GroupGraphPattern subtrahendGraphPattern;
 
     /**
-     * Constructs an {@link OptionalGraphPattern} out of a {@link GraphPattern}
-     * as the main graph pattern and a {@link GroupGraphPattern} as the 
-     * optional pattern.
+     * Constructs a {@link MinusGraphPattern} out of a {@link GraphPattern}
+     * as the minuend graph pattern and a {@link GroupGraphPattern} as the 
+     * subtrahend pattern.
      * 
-     * @param mainGraphPattern
-     *        a {@link GraphPattern} specifying the main pattern.
-     * @param optionalGraphPattern
-     *        a {@link GroupGraphPattern} specifying the optional pattern.
+     * @param minuendGraphPattern
+     *        a {@link GraphPattern} specifying the minuend pattern.
+     * @param subtrahendGraphPattern
+     *        a {@link GroupGraphPattern} specifying the subtrahend pattern.
      */
-    public SimpleOptionalGraphPattern(GraphPattern mainGraphPattern,
-            GroupGraphPattern optionalGraphPattern) {
-        if (optionalGraphPattern == null) {
-            throw new IllegalArgumentException("Optional graph pattern may not be null");
+    public SimpleMinusGraphPattern(GraphPattern minuendGraphPattern, GroupGraphPattern subtrahendGraphPattern) {
+        if (subtrahendGraphPattern == null) {
+            throw new IllegalArgumentException("Subtrahend graph pattern may not be null");
         }
-        if (mainGraphPattern == null) {
-            this.mainGraphPattern = new SimpleGroupGraphPattern();
+        if (minuendGraphPattern == null) {
+            this.minuendGraphPattern = new SimpleGroupGraphPattern();
         } else {
-            this.mainGraphPattern = mainGraphPattern;
+            this.minuendGraphPattern = minuendGraphPattern;
         }
-        this.optionalGraphPattern = optionalGraphPattern;
+        this.subtrahendGraphPattern = subtrahendGraphPattern;
     }
 
     @Override
-    public GraphPattern getMainGraphPattern() {
-        return mainGraphPattern;
+    public GraphPattern getMinuendGraphPattern() {
+        return minuendGraphPattern;
     }
 
     @Override
-    public GroupGraphPattern getOptionalGraphPattern() {
-        return optionalGraphPattern;
+    public GroupGraphPattern getSubtrahendGraphPattern() {
+        return subtrahendGraphPattern;
     }
 
 }

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java (from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java&r1=1505585&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -20,29 +20,29 @@ package org.apache.clerezza.rdf.core.spa
 
 import java.util.LinkedHashSet;
 import java.util.Set;
-import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
+import org.apache.clerezza.rdf.core.sparql.query.PathSupportedBasicGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern;
 
 /**
  *
  * @author hasan
  */
-public class SimpleBasicGraphPattern implements BasicGraphPattern {
+public class SimplePathSupportedBasicGraphPattern implements PathSupportedBasicGraphPattern {
 
-    private Set<TriplePattern> triplePatterns;
+    private Set<PropertyPathPattern> propertyPathPatterns;
 
-    public SimpleBasicGraphPattern(Set<TriplePattern> triplePatterns) {
-        this.triplePatterns = (triplePatterns == null)
-                ? new LinkedHashSet<TriplePattern>()
-                : triplePatterns;
+    public SimplePathSupportedBasicGraphPattern(Set<PropertyPathPattern> propertyPathPatterns) {
+        this.propertyPathPatterns = (propertyPathPatterns == null)
+                ? new LinkedHashSet<PropertyPathPattern>()
+                : propertyPathPatterns;
     }
 
     @Override
-    public Set<TriplePattern> getTriplePatterns() {
-        return triplePatterns;
+    public Set<PropertyPathPattern> getPropertyPathPatterns() {
+        return propertyPathPatterns;
     }
 
-    public void addTriplePatterns(Set<TriplePattern> triplePatterns) {
-        this.triplePatterns.addAll(triplePatterns);
+    public void addPropertyPathPatterns(Set<PropertyPathPattern> propertyPathPatterns) {
+        this.propertyPathPatterns.addAll(propertyPathPatterns);
     }
 }

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java (from r1505585, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java&r1=1505585&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java Fri Aug 23 19:29:05 2013
@@ -20,76 +20,76 @@ package org.apache.clerezza.rdf.core.spa
 
 import org.apache.clerezza.rdf.core.NonLiteral;
 import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.sparql.query.PropertyPathExpression;
+import org.apache.clerezza.rdf.core.sparql.query.PropertyPathExpressionOrVariable;
+import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern;
 import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
 import org.apache.clerezza.rdf.core.sparql.query.Variable;
 
 /**
  *
  * @author hasan
  */
-public class SimpleTriplePattern implements TriplePattern {
+public class SimplePropertyPathPattern implements PropertyPathPattern {
 
     private ResourceOrVariable subject;
-    private UriRefOrVariable predicate;
+    private PropertyPathExpressionOrVariable propertyPathExpression;
     private ResourceOrVariable object;
 
-    public SimpleTriplePattern(ResourceOrVariable subject,
-            UriRefOrVariable predicate,
+    public SimplePropertyPathPattern(ResourceOrVariable subject,
+            PropertyPathExpressionOrVariable propertyPathExpression,
             ResourceOrVariable object) {
         if (subject == null) {
             throw new IllegalArgumentException("Invalid subject: null");
         }
-        if (predicate == null) {
-            throw new IllegalArgumentException("Invalid predicate: null");
+        if (propertyPathExpression == null) {
+            throw new IllegalArgumentException("Invalid property path expression: null");
         }
         if (object == null) {
             throw new IllegalArgumentException("Invalid object: null");
         }
         this.subject = subject;
-        this.predicate = predicate;
+        this.propertyPathExpression = propertyPathExpression;
         this.object = object;
     }
 
-    public SimpleTriplePattern(Variable subject, Variable predicate, Variable object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(Variable subject, Variable propertyPathExpression, Variable object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(NonLiteral subject, Variable predicate, Variable object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(NonLiteral subject, Variable propertyPathExpression, Variable object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(Variable subject, UriRef predicate, Variable object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(Variable subject, Variable propertyPathExpression, Resource object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(NonLiteral subject, UriRef predicate, Variable object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(NonLiteral subject, Variable propertyPathExpression, Resource object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(Variable subject, Variable predicate, Resource object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(Variable subject, PropertyPathExpression propertyPathExpression, Variable object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(NonLiteral subject, Variable predicate, Resource object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(NonLiteral subject, PropertyPathExpression propertyPathExpression, Variable object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(Variable subject, UriRef predicate, Resource object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(Variable subject, PropertyPathExpression propertyPathExpression, Resource object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
-    public SimpleTriplePattern(NonLiteral subject, UriRef predicate, Resource object) {
-        this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
+    public SimplePropertyPathPattern(NonLiteral subject, PropertyPathExpression propertyPathExpression, Resource object) {
+        this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
                 new ResourceOrVariable(object));
     }
 
@@ -99,8 +99,8 @@ public class SimpleTriplePattern impleme
     }
 
     @Override
-    public UriRefOrVariable getPredicate() {
-        return predicate;
+    public PropertyPathExpressionOrVariable getPropertyPathExpression() {
+        return propertyPathExpression;
     }
 
     @Override
@@ -113,14 +113,14 @@ public class SimpleTriplePattern impleme
         if (obj == null) {
             return false;
         }
-        if (!(obj instanceof TriplePattern)) {
+        if (!(obj instanceof PropertyPathPattern)) {
             return false;
         }
-        final TriplePattern other = (TriplePattern) obj;
+        final PropertyPathPattern other = (PropertyPathPattern) obj;
         if (!this.subject.equals(other.getSubject())) {
             return false;
         }
-        if (!this.predicate.equals(other.getPredicate())) {
+        if (!this.propertyPathExpression.equals(other.getPropertyPathExpression())) {
             return false;
         }
         if (!this.object.equals(other.getObject())) {
@@ -131,6 +131,6 @@ public class SimpleTriplePattern impleme
 
     @Override
     public int hashCode() {
-        return (subject.hashCode() >> 1) ^ subject.hashCode() ^ (subject.hashCode() << 1);
+        return (subject.hashCode() >> 1) ^ propertyPathExpression.hashCode() ^ (object.hashCode() << 1);
     }
 }

Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java?rev=1516993&r1=1516992&r2=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java Fri Aug 23 19:29:05 2013
@@ -20,6 +20,7 @@ package org.apache.clerezza.rdf.core.spa
 
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.clerezza.rdf.core.sparql.query.Expression;
 import org.apache.clerezza.rdf.core.sparql.query.OrderCondition;
 import org.apache.clerezza.rdf.core.sparql.query.QueryWithSolutionModifier;
 
@@ -30,6 +31,8 @@ import org.apache.clerezza.rdf.core.spar
 public abstract class SimpleQueryWithSolutionModifier extends SimpleQuery
         implements QueryWithSolutionModifier {
 
+    private List<Expression> groupConditions = new ArrayList<Expression>();
+    private List<Expression> havingConditions = new ArrayList<Expression>();
     private List<OrderCondition> orderConditions = new ArrayList<OrderCondition>();
 
     /**
@@ -43,6 +46,16 @@ public abstract class SimpleQueryWithSol
     private int limit = -1;
 
     @Override
+    public List<Expression> getGroupConditions() {
+        return groupConditions;
+    }
+
+    @Override
+    public List<Expression> getHavingConditions() {
+        return havingConditions;
+    }
+
+    @Override
     public List<OrderCondition> getOrderConditions() {
         return orderConditions;
     }
@@ -57,6 +70,14 @@ public abstract class SimpleQueryWithSol
         return limit;
     }
 
+    public void addGroupCondition(Expression groupCondition) {
+        groupConditions.add(groupCondition);
+    }
+
+    public void addHavingCondition(Expression havingCondition) {
+        havingConditions.add(havingCondition);
+    }
+
     public void addOrderCondition(OrderCondition orderCondition) {
         orderConditions.add(orderCondition);
     }

Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java (from r1510871, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java&r1=1510871&r2=1516993&rev=1516993&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java Fri Aug 23 19:29:05 2013
@@ -18,38 +18,49 @@
  */
 package org.apache.clerezza.rdf.core.sparql.query.impl;
 
-import org.apache.clerezza.rdf.core.sparql.query.GraphGraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.ServiceGraphPattern;
 import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
 
 /**
  *
  * @author hasan
  */
-public class SimpleGraphGraphPattern implements GraphGraphPattern {
+public class SimpleServiceGraphPattern implements ServiceGraphPattern {
 
-    private UriRefOrVariable graph;
+    private UriRefOrVariable service;
     private GroupGraphPattern groupGraphPattern;
+    private boolean silent;
 
-    public SimpleGraphGraphPattern(UriRefOrVariable graph,
+    public SimpleServiceGraphPattern(UriRefOrVariable service,
             GroupGraphPattern groupGraphPattern) {
-        if (graph == null) {
-            throw new IllegalArgumentException("Graph may not be null");
+        if (service == null) {
+            throw new IllegalArgumentException("Service endpoint may not be null");
         }
         if (groupGraphPattern == null) {
             throw new IllegalArgumentException("Group Graph Pattern may not be null");
         }
-        this.graph = graph;
+        this.service = service;
         this.groupGraphPattern = groupGraphPattern;
+        this.silent = false;
     }
 
     @Override
-    public UriRefOrVariable getGraph() {
-        return graph;
+    public UriRefOrVariable getService() {
+        return service;
     }
 
     @Override
     public GroupGraphPattern getGroupGraphPattern() {
         return groupGraphPattern;
     }
+
+    public void setSilent(boolean silent) {
+        this.silent = silent;
+    }
+
+    public boolean isSilent() {
+        return silent;
+    }
+
 }



Mime
View raw message