You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by ha...@apache.org on 2013/03/25 06:05:11 UTC
svn commit: r1460522 [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/java/org/apache/clerezza/rd...
Author: hasan
Date: Mon Mar 25 05:05:11 2013
New Revision: 1460522
URL: http://svn.apache.org/r1460522
Log:
CLEREZZA-761: Added initial implementation of SparqlPreParser
Added:
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java
- copied, changed from r1460424, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphManagementOperation.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphUpdateOperation.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleGraphUpdateOperation.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java
clerezza/trunk/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj
- copied, changed from r1454966, clerezza/trunk/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedQueryParser.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/StringQuerySerializer.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java
clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.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/SimpleQuery.java
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java (from r1460424, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java&r1=1460424&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java Mon Mar 25 05:05:11 2013
@@ -19,54 +19,47 @@
package org.apache.clerezza.rdf.core.sparql;
import java.io.StringReader;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.sparql.query.DataSet;
+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;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
/**
- * This class implements an OSGi service to provide a method to parse a
- * SPARQL query and generate a {@link Query} object.
+ * This class implements an OSGi service to provide a method to obtain referred Graphs in a SPARQL Query or Update.
*
* @author hasan
*/
@Component
-@Service(QueryParser.class)
-public class QueryParser {
-
- private static volatile QueryParser instance;
- public QueryParser() {
- QueryParser.instance = this;
- }
+@Service(SparqlPreParser.class)
+public class SparqlPreParser {
- /**
- * Returns an instance of this class.
- * This method is provided due to backward compatibility.
- */
- public static QueryParser getInstance() {
- if (instance == null) {
- synchronized (QueryParser.class) {
- if (instance == null) {
- new QueryParser();
- }
+ public Set<UriRef> getReferredGraphs(String queryString, UriRef defaultGraph) throws ParseException {
+ Set<UriRef> referredGraphs = null;
+ JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString));
+ SparqlUnit sparqlUnit;
+ sparqlUnit = parser.parse();
+ if (sparqlUnit.isQuery()) {
+ Query q = sparqlUnit.getQuery();
+ DataSet dataSet = q.getDataSet();
+ if (dataSet != null) {
+ referredGraphs = dataSet.getDefaultGraphs();
+ referredGraphs.addAll(dataSet.getNamedGraphs());
+ } else {
+ referredGraphs = new HashSet<UriRef>();
}
+ } else {
+ Update u = sparqlUnit.getUpdate();
+ referredGraphs = u.getReferredGraphs();
}
- return instance;
- }
-
- /**
- * Parses a SPARQL query string into a {@link Query} object.
- *
- * @param queryString
- * SPARQL query string
- * @return
- * {@link Query} object corresponding to the specified query string
- *
- * @throws org.apache.clerezza.rdf.core.sparql.ParseException
- */
- public Query parse(final String queryString) throws ParseException {
- JavaCCGeneratedQueryParser parser = new JavaCCGeneratedQueryParser(
- new StringReader(queryString));
- return parser.parse();
+ if (referredGraphs.isEmpty()) {
+ referredGraphs.add(defaultGraph);
+ }
+ return referredGraphs;
}
}
Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java?rev=1460522&r1=1460521&r2=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java Mon Mar 25 05:05:11 2013
@@ -19,9 +19,9 @@
package org.apache.clerezza.rdf.core.sparql;
import org.apache.clerezza.rdf.core.sparql.query.AskQuery;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
+import org.apache.clerezza.rdf.core.sparql.query.Query;
import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
/**
Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java?rev=1460522&r1=1460521&r2=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java Mon Mar 25 05:05:11 2013
@@ -30,16 +30,32 @@ import java.util.Set;
*/
public interface GroupGraphPattern extends GraphPattern {
- /**
- *
- * @return a set of all patterns, ANDed together.
- */
- public Set<GraphPattern> getGraphPatterns();
+ /**
+ *
+ * @return
+ * true if it wraps a {@link SelectQuery}, false otherwise.
+ */
+ public boolean isSubSelect();
- /**
- * @return
- * a list of filter expressions for all patterns in the group if any,
- * otherwise an empty list is returned.
- */
- public List<Expression> getFilter();
+ /**
+ *
+ * @return
+ * the wrapped subselect if it wraps a {@link SelectQuery}, null otherwise.
+ */
+ public SelectQuery getSubSelect();
+
+ /**
+ *
+ * @return
+ * null if it wraps a {@link SelectQuery}, otherwise
+ * a set of all patterns, ANDed together.
+ */
+ public Set<GraphPattern> getGraphPatterns();
+
+ /**
+ * @return
+ * null if it wraps a {@link SelectQuery}, otherwise
+ * a list of filter expressions for all patterns in the group if any.
+ */
+ public List<Expression> getFilter();
}
Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java?rev=1460522&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java Mon Mar 25 05:05:11 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.List;
+import org.apache.clerezza.rdf.core.Resource;
+
+/**
+ *
+ * @author hasan
+ */
+public interface InlineData extends GraphPattern {
+ public List<Variable> getVariables();
+ public List<List<Resource>> getValues();
+}
Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java?rev=1460522&r1=1460521&r2=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java Mon Mar 25 05:05:11 2013
@@ -47,6 +47,8 @@ public interface Query {
* If the WHERE clause is not specified, null is returned.
*/
public GroupGraphPattern getQueryPattern();
+
+ public InlineData getInlineData();
/**
*
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java Mon Mar 25 05:05:11 2013
@@ -18,19 +18,20 @@
*/
package org.apache.clerezza.rdf.core.sparql.query;
+import java.util.List;
+
/**
- * Defines an operation with two operands: a left hand side and a right hand side
- * operand.
+ * Defines an operation with two operands: a left hand side and a right hand side operand
+ * where the right hand side operand is a list.
*
* @author hasan
*/
-public class BinaryOperation extends AbstractOperation {
+public class RhsListBinaryOperation extends AbstractOperation {
private Expression lhsOperand;
- private Expression rhsOperand;
+ private List<Expression> rhsOperand;
- public BinaryOperation(String operator,
- Expression lhsOperand, Expression rhsOperand) {
+ public RhsListBinaryOperation(String operator, Expression lhsOperand, List<Expression> rhsOperand) {
super(operator);
this.lhsOperand = lhsOperand;
this.rhsOperand = rhsOperand;
@@ -40,7 +41,7 @@ public class BinaryOperation extends Abs
return lhsOperand;
}
- public Expression getRhsOperand() {
+ public List<Expression> getRhsOperand() {
return rhsOperand;
}
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java Mon Mar 25 05:05:11 2013
@@ -18,40 +18,34 @@
*/
package org.apache.clerezza.rdf.core.sparql.query;
+import org.apache.clerezza.rdf.core.sparql.update.Update;
+
/**
- * <p>This interface represents a SPARQL query.</p>
- * <p>There are four types of SPARQL queries: {@link SelectQuery},
- * {@link ConstructQuery}, {@link DescribeQuery}, and {@link AskQuery}.</p>
+ * <p>This interface represents a SPARQL Query or Update.</p>
*
* @author hasan
*/
-public interface Query {
+public interface SparqlUnit {
- /**
- * <p>Gets {@link DataSet} containing the specification of the default
- * graph and named graphs, if any.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#specifyingDataset">
- * SPARQL Query Language: 8.2 Specifying RDF Datasets</a>
+ /**
+ *
* @return
- * null if no data set is specified, indicating the use of
- * system default graph. Otherwise a {@link DataSet} object is returned.
- */
- public DataSet getDataSet();
-
- /**
- * <p>Gets the query pattern of the WHERE clause for the query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#GraphPattern">
- * SPARQL Query Language: 5 Graph Patterns</a>
+ * true if it is a {@link Query}, false if it is an {@link Update}
+ */
+ public boolean isQuery();
+
+ /**
+ *
* @return
- * the {@link GroupGraphPattern} of the WHERE clause for this query.
- * If the WHERE clause is not specified, null is returned.
- */
- public GroupGraphPattern getQueryPattern();
-
- /**
- *
- * @return A valid String representation of the query.
- */
- @Override
- public abstract String toString();
+ * the wrapped Query if it is a {@link Query}, null otherwise
+ */
+ public Query getQuery();
+
+ /**
+ *
+ * @return
+ * the wrapped Update if it is an {@link Update}, null otherwise
+ */
+ public Update getUpdate();
+
}
Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java?rev=1460522&r1=1460521&r2=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java Mon Mar 25 05:05:11 2013
@@ -28,45 +28,59 @@ import java.util.UUID;
*/
public class Variable implements Expression {
- private String name;
+ private String name;
+ private Expression boundExpression;
- public Variable() {
- this.name = UUID.randomUUID().toString();
- }
-
- /**
- * Creates a variable with the specified name
- *
- * @param name
- */
- public Variable(String name) {
- if (name == null) {
- throw new IllegalArgumentException("name may not be null");
- }
- this.name = name;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Variable other = (Variable) obj;
- return name.equals(other.name);
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
+ public Variable() {
+ this.name = UUID.randomUUID().toString();
+ }
+
+ /**
+ * Creates a variable with the specified name
+ *
+ * @param name
+ */
+ public Variable(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("name may not be null");
+ }
+ this.name = name;
+ }
+
+ public Variable(String name, Expression boundExpression) {
+ this.name = name;
+ this.boundExpression = boundExpression;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ public Expression getBoundExpression() {
+ return boundExpression;
+ }
+
+ public void setBoundExpression(Expression boundExpression) {
+ this.boundExpression = boundExpression;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Variable other = (Variable) obj;
+ return name.equals(other.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
}
Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java?rev=1460522&r1=1460521&r2=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java Mon Mar 25 05:05:11 2013
@@ -24,7 +24,7 @@ import org.apache.clerezza.rdf.core.spar
*
* @author hasan
*/
-public class SimpleAskQuery extends SimpleQuery implements AskQuery {
+public class SimpleAskQuery extends SimpleQueryWithSolutionModifier implements AskQuery {
@Override
public String toString() {
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=1460522&r1=1460521&r2=1460522&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 Mon Mar 25 05:05:11 2013
@@ -26,6 +26,7 @@ import org.apache.clerezza.rdf.core.spar
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.SelectQuery;
import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
/**
@@ -35,82 +36,100 @@ import org.apache.clerezza.rdf.core.spar
*/
public class SimpleGroupGraphPattern implements GroupGraphPattern {
- private List<Expression> constraints = new ArrayList<Expression>();
- private List<GraphPattern> graphPatterns = new ArrayList<GraphPattern>();
+ private List<Expression> constraints = new ArrayList<Expression>();
+ private List<GraphPattern> graphPatterns = new ArrayList<GraphPattern>();
+ private SelectQuery subSelect = null;
@Override
- public Set<GraphPattern> getGraphPatterns() {
- return new LinkedHashSet(graphPatterns);
+ public boolean isSubSelect() {
+ return subSelect != null;
}
@Override
- public List<Expression> getFilter() {
- return constraints;
+ public SelectQuery getSubSelect() {
+ return subSelect;
}
- /**
- * Adds a {@link GraphPattern} to the group.
- *
- * @param graphPattern
- * the GraphPattern to be added.
- */
- public void addGraphPattern(GraphPattern graphPattern) {
- graphPatterns.add(graphPattern);
- }
+ @Override
+ public Set<GraphPattern> getGraphPatterns() {
+ return subSelect == null ? new LinkedHashSet(graphPatterns) : null;
+ }
+
+ @Override
+ public List<Expression> getFilter() {
+ return subSelect == null ? constraints : null;
+ }
- /**
- * Adds a constraint to the {@link GroupGraphPattern}.
- *
- * @param constraint
- * an {@link Expression} as the constraint to be added.
- */
- public void addConstraint(Expression constraint) {
- constraints.add(constraint);
+ public void setSubSelect(SelectQuery subSelect) {
+ this.subSelect = subSelect;
}
/**
- * If the last {@link GraphPattern} added to the group is not a
- * {@link SimpleBasicGraphPattern}, then creates one containing the
- * specified {@link TriplePattern}s and adds it to the group.
- * Otherwise, adds the specified {@link TriplePattern}s to the last
- * added {@link SimpleBasicGraphPattern} in the group.
- *
- * @param triplePatterns
- * a set of {@link TriplePattern}s to be added into a
- * {@link SimpleBasicGraphPattern} of the group.
- */
- public void addTriplePatterns(Set<TriplePattern> triplePatterns) {
+ * Adds a {@link GraphPattern} to the group.
+ *
+ * @param graphPattern
+ * the GraphPattern to be added.
+ */
+ public void addGraphPattern(GraphPattern graphPattern) {
+ subSelect = null;
+ graphPatterns.add(graphPattern);
+ }
+
+ /**
+ * Adds a constraint to the {@link GroupGraphPattern}.
+ *
+ * @param constraint
+ * an {@link Expression} as the constraint to be added.
+ */
+ public void addConstraint(Expression constraint) {
+ subSelect = null;
+ constraints.add(constraint);
+ }
+
+ /**
+ * If the last {@link GraphPattern} added to the group is not a
+ * {@link SimpleBasicGraphPattern}, then creates one containing the
+ * specified {@link TriplePattern}s and adds it to the group.
+ * Otherwise, adds the specified {@link TriplePattern}s to the last
+ * added {@link SimpleBasicGraphPattern} in the group.
+ *
+ * @param triplePatterns
+ * a set of {@link TriplePattern}s to be added into a
+ * {@link SimpleBasicGraphPattern} of the group.
+ */
+ public void addTriplePatterns(Set<TriplePattern> triplePatterns) {
+ subSelect = null;
GraphPattern prevGraphPattern;
- int size = graphPatterns.size();
- if (size > 0) {
- prevGraphPattern = graphPatterns.get(size-1);
- if (prevGraphPattern instanceof SimpleBasicGraphPattern) {
- ((SimpleBasicGraphPattern) prevGraphPattern)
- .addTriplePatterns(triplePatterns);
- return;
- }
- }
- graphPatterns.add(new SimpleBasicGraphPattern(triplePatterns));
- }
-
- /**
- * Adds an {@link OptionalGraphPattern} to the group consisting of
- * a main graph pattern and the specified {@link GroupGraphPattern} as
- * the optional pattern.
- * The main graph pattern is taken from the last added {@link GraphPattern}
- * in the group, if it exists. Otherwise, the main graph pattern is null.
- *
- * @param optional
- * a {@link GroupGraphPattern} as the optional pattern of
- * an {@link OptionalGraphPattern}.
- */
- public void addOptionalGraphPattern(GroupGraphPattern optional) {
-
- GraphPattern prevGraphPattern = null;
- int size = graphPatterns.size();
- if (size > 0) {
- prevGraphPattern = graphPatterns.remove(size-1);
- }
- graphPatterns.add(new SimpleOptionalGraphPattern(prevGraphPattern, optional));
- }
+ int size = graphPatterns.size();
+ if (size > 0) {
+ prevGraphPattern = graphPatterns.get(size-1);
+ if (prevGraphPattern instanceof SimpleBasicGraphPattern) {
+ ((SimpleBasicGraphPattern) prevGraphPattern)
+ .addTriplePatterns(triplePatterns);
+ return;
+ }
+ }
+ graphPatterns.add(new SimpleBasicGraphPattern(triplePatterns));
+ }
+
+ /**
+ * Adds an {@link OptionalGraphPattern} to the group consisting of
+ * a main graph pattern and the specified {@link GroupGraphPattern} as
+ * the optional pattern.
+ * The main graph pattern is taken from the last added {@link GraphPattern}
+ * in the group, if it exists. Otherwise, the main graph pattern is null.
+ *
+ * @param optional
+ * a {@link GroupGraphPattern} as the optional pattern of
+ * an {@link OptionalGraphPattern}.
+ */
+ public void addOptionalGraphPattern(GroupGraphPattern optional) {
+ subSelect = null;
+ GraphPattern prevGraphPattern = null;
+ int size = graphPatterns.size();
+ if (size > 0) {
+ prevGraphPattern = graphPatterns.remove(size-1);
+ }
+ graphPatterns.add(new SimpleOptionalGraphPattern(prevGraphPattern, optional));
+ }
}
Added: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java?rev=1460522&view=auto
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java (added)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java Mon Mar 25 05:05:11 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.sparql.query.InlineData;
+import org.apache.clerezza.rdf.core.sparql.query.Variable;
+
+/**
+ *
+ * @author hasan
+ */
+public class SimpleInlineData implements InlineData {
+
+ private List<Variable> variables = new ArrayList<Variable>();
+ private List<List<Resource>> values = new ArrayList<List<Resource>>();
+
+ @Override
+ public List<Variable> getVariables() {
+ return variables;
+ }
+
+ @Override
+ public List<List<Resource>> getValues() {
+ return values;
+ }
+
+ public void addVariable(Variable variable) {
+ variables.add(variable);
+ }
+
+ public void addValues(List<Resource> values) {
+ this.values.add(values);
+ }
+}
Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java?rev=1460522&r1=1460521&r2=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java Mon Mar 25 05:05:11 2013
@@ -21,6 +21,7 @@ package org.apache.clerezza.rdf.core.spa
import org.apache.clerezza.rdf.core.UriRef;
import org.apache.clerezza.rdf.core.sparql.query.DataSet;
import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
+import org.apache.clerezza.rdf.core.sparql.query.InlineData;
import org.apache.clerezza.rdf.core.sparql.query.Query;
/**
@@ -28,37 +29,47 @@ import org.apache.clerezza.rdf.core.spar
* @author hasan
*/
public abstract class SimpleQuery implements Query {
- private SimpleDataSet dataSet = null;
- private GroupGraphPattern queryPattern = null;
-
- @Override
- public DataSet getDataSet() {
- return dataSet;
+ private SimpleDataSet dataSet = null;
+ private GroupGraphPattern queryPattern = null;
+ private InlineData inlineData = null;
+
+ @Override
+ public DataSet getDataSet() {
+ return dataSet;
+ }
+
+ @Override
+ public GroupGraphPattern getQueryPattern() {
+ return queryPattern;
}
@Override
- public GroupGraphPattern getQueryPattern() {
- return queryPattern;
+ public InlineData getInlineData() {
+ return inlineData;
}
public void addDefaultGraph(UriRef defaultGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addDefaultGraph(defaultGraph);
- }
-
- public void addNamedGraph(UriRef namedGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addNamedGraph(namedGraph);
- }
+ if (dataSet == null) {
+ dataSet = new SimpleDataSet();
+ }
+ dataSet.addDefaultGraph(defaultGraph);
+ }
+
+ public void addNamedGraph(UriRef namedGraph) {
+ if (dataSet == null) {
+ dataSet = new SimpleDataSet();
+ }
+ dataSet.addNamedGraph(namedGraph);
+ }
+
+ public void setQueryPattern(GroupGraphPattern queryPattern) {
+ this.queryPattern = queryPattern;
+ }
- public void setQueryPattern(GroupGraphPattern queryPattern) {
- this.queryPattern = queryPattern;
+ public void setInlineData(InlineData inlineData) {
+ this.inlineData = inlineData;
}
@Override
- public abstract String toString();
+ public abstract String toString();
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java Mon Mar 25 05:05:11 2013
@@ -18,47 +18,48 @@
*/
package org.apache.clerezza.rdf.core.sparql.query.impl;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
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;
/**
*
* @author hasan
*/
-public abstract class SimpleQuery implements Query {
- private SimpleDataSet dataSet = null;
- private GroupGraphPattern queryPattern = null;
-
- @Override
- public DataSet getDataSet() {
- return dataSet;
- }
+public class SimpleSparqlUnit implements SparqlUnit {
- @Override
- public GroupGraphPattern getQueryPattern() {
- return queryPattern;
- }
+ private final Query query;
+ private final Update update;
- public void addDefaultGraph(UriRef defaultGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
+ public SimpleSparqlUnit(Query query) {
+ if (query == null) {
+ throw new IllegalArgumentException("Invalid query: null");
}
- dataSet.addDefaultGraph(defaultGraph);
+ this.query = query;
+ update = null;
}
- public void addNamedGraph(UriRef namedGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
+ public SimpleSparqlUnit(Update update) {
+ if (update == null) {
+ throw new IllegalArgumentException("Invalid update: null");
}
- dataSet.addNamedGraph(namedGraph);
+ this.update = update;
+ query = null;
}
- public void setQueryPattern(GroupGraphPattern queryPattern) {
- this.queryPattern = queryPattern;
- }
- @Override
- public abstract String toString();
+ @Override
+ public boolean isQuery() {
+ return update == null;
+ }
+
+ @Override
+ public Query getQuery() {
+ return query;
+ }
+
+ @Override
+ public Update getUpdate() {
+ return update;
+ }
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphManagementOperation.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphManagementOperation.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphManagementOperation.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphManagementOperation.java Mon Mar 25 05:05:11 2013
@@ -16,26 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.sparql.query;
+package org.apache.clerezza.rdf.core.sparql.update;
/**
- * Defines an operation in an {@link Expression}. An operation has an operator
- * and one or more operands.
+ * SPARQL Graph Management Operation
*
* @author hasan
*/
-public abstract class AbstractOperation implements Expression {
- private String operator;
-
- public AbstractOperation(String operator) {
- this.operator = operator;
- }
-
- /**
- * A string representation of the operator
- * @return The operator as a string
- */
- public String getOperatorString() {
- return operator;
- }
+public interface GraphManagementOperation extends UpdateOperation {
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphUpdateOperation.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphUpdateOperation.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphUpdateOperation.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/GraphUpdateOperation.java Mon Mar 25 05:05:11 2013
@@ -16,26 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.sparql.query;
+package org.apache.clerezza.rdf.core.sparql.update;
+
+import java.util.Set;
+import org.apache.clerezza.rdf.core.UriRef;
/**
- * Defines an operation in an {@link Expression}. An operation has an operator
- * and one or more operands.
+ * SPARQL Graph Update Operation
*
* @author hasan
*/
-public abstract class AbstractOperation implements Expression {
- private String operator;
+public interface GraphUpdateOperation extends UpdateOperation {
- public AbstractOperation(String operator) {
- this.operator = operator;
- }
+ public Set<UriRef> getGraphs();
- /**
- * A string representation of the operator
- * @return The operator as a string
- */
- public String getOperatorString() {
- return operator;
- }
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java Mon Mar 25 05:05:11 2013
@@ -16,41 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.sparql.query;
+package org.apache.clerezza.rdf.core.sparql.update;
+
+import java.util.Set;
+import org.apache.clerezza.rdf.core.UriRef;
/**
- * <p>This interface represents a SPARQL query.</p>
- * <p>There are four types of SPARQL queries: {@link SelectQuery},
- * {@link ConstructQuery}, {@link DescribeQuery}, and {@link AskQuery}.</p>
+ * <p>This interface represents a SPARQL Update.</p>
*
* @author hasan
*/
-public interface Query {
+public interface Update {
/**
- * <p>Gets {@link DataSet} containing the specification of the default
- * graph and named graphs, if any.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#specifyingDataset">
- * SPARQL Query Language: 8.2 Specifying RDF Datasets</a>
- * @return
- * null if no data set is specified, indicating the use of
- * system default graph. Otherwise a {@link DataSet} object is returned.
- */
- public DataSet getDataSet();
-
- /**
- * <p>Gets the query pattern of the WHERE clause for the query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#GraphPattern">
- * SPARQL Query Language: 5 Graph Patterns</a>
+ *
* @return
- * the {@link GroupGraphPattern} of the WHERE clause for this query.
- * If the WHERE clause is not specified, null is returned.
+ * a set of graphs referred in the {@link Update}
*/
- public GroupGraphPattern getQueryPattern();
+ public Set<UriRef> getReferredGraphs();
- /**
+ /**
*
- * @return A valid String representation of the query.
+ * @return A valid String representation of the {@link Update}.
*/
@Override
public abstract String toString();
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java Mon Mar 25 05:05:11 2013
@@ -16,26 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.sparql.query;
+package org.apache.clerezza.rdf.core.sparql.update;
/**
- * Defines an operation in an {@link Expression}. An operation has an operator
- * and one or more operands.
+ * SPARQL Update Operation
*
* @author hasan
*/
-public abstract class AbstractOperation implements Expression {
- private String operator;
-
- public AbstractOperation(String operator) {
- this.operator = operator;
- }
-
- /**
- * A string representation of the operator
- * @return The operator as a string
- */
- public String getOperatorString() {
- return operator;
- }
+public interface UpdateOperation {
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleGraphUpdateOperation.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleGraphUpdateOperation.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleGraphUpdateOperation.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleGraphUpdateOperation.java Mon Mar 25 05:05:11 2013
@@ -16,49 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.sparql.query.impl;
+package org.apache.clerezza.rdf.core.sparql.update.impl;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
+import org.apache.clerezza.rdf.core.sparql.update.GraphUpdateOperation;
/**
*
* @author hasan
*/
-public abstract class SimpleQuery implements Query {
- private SimpleDataSet dataSet = null;
- private GroupGraphPattern queryPattern = null;
+public abstract class SimpleGraphUpdateOperation implements GraphUpdateOperation {
+ private Set<UriRef> graphs = new HashSet<UriRef>();
- @Override
- public DataSet getDataSet() {
- return dataSet;
- }
-
- @Override
- public GroupGraphPattern getQueryPattern() {
- return queryPattern;
- }
-
- public void addDefaultGraph(UriRef defaultGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addDefaultGraph(defaultGraph);
- }
-
- public void addNamedGraph(UriRef namedGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addNamedGraph(namedGraph);
- }
-
- public void setQueryPattern(GroupGraphPattern queryPattern) {
- this.queryPattern = queryPattern;
- }
-
- @Override
- public abstract String toString();
+ @Override
+ public Set<UriRef> getGraphs() {
+ return graphs;
+ }
}
Copied: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java (from r1454966, clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java?p2=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java&p1=clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java&r1=1454966&r2=1460522&rev=1460522&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java (original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java Mon Mar 25 05:05:11 2013
@@ -16,49 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.sparql.query.impl;
+package org.apache.clerezza.rdf.core.sparql.update.impl;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
+import org.apache.clerezza.rdf.core.sparql.update.Update;
/**
*
* @author hasan
*/
-public abstract class SimpleQuery implements Query {
- private SimpleDataSet dataSet = null;
- private GroupGraphPattern queryPattern = null;
+public abstract class SimpleUpdate implements Update {
+ private Set<UriRef> referredGraphs = new HashSet<UriRef>();
- @Override
- public DataSet getDataSet() {
- return dataSet;
+ void addReferredGraph(UriRef referredGraph) {
+ referredGraphs.add(referredGraph);
}
- @Override
- public GroupGraphPattern getQueryPattern() {
- return queryPattern;
- }
-
- public void addDefaultGraph(UriRef defaultGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addDefaultGraph(defaultGraph);
- }
-
- public void addNamedGraph(UriRef namedGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addNamedGraph(namedGraph);
- }
-
- public void setQueryPattern(GroupGraphPattern queryPattern) {
- this.queryPattern = queryPattern;
- }
-
- @Override
- public abstract String toString();
}