http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java deleted file mode 100644 index 354f5b0..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.HashSet; -import java.util.Set; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.sparql.query.DataSet; - -/** - * - * @author hasan - */ -public class SimpleDataSet implements DataSet { - private Set<IRI> defaultGraphs = new HashSet<IRI>(); - private Set<IRI> namedGraphs = new HashSet<IRI>(); - - @Override - public Set<IRI> getDefaultGraphs() { - return defaultGraphs; - } - - @Override - public Set<IRI> getNamedGraphs() { - return namedGraphs; - } - - public void addDefaultGraph(IRI defaultGraph) { - defaultGraphs.add(defaultGraph); - } - - public void addNamedGraph(IRI namedGraph) { - namedGraphs.add(namedGraph); - } -}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java deleted file mode 100644 index 9faba61..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.sparql.query.DescribeQuery; -import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable; - -/** - * - * @author hasan - */ -public class SimpleDescribeQuery extends SimpleQueryWithSolutionModifier - implements DescribeQuery { - - private boolean describeAll; - private List<ResourceOrVariable> resourcesToDescribe = - new ArrayList<ResourceOrVariable>(); - - @Override - public boolean isDescribeAll() { - return describeAll; - } - - @Override - public List<ResourceOrVariable> getResourcesToDescribe() { - return resourcesToDescribe; - } - - public void setDescribeAll() { - assert resourcesToDescribe.isEmpty(); - describeAll = true; - } - - public void addResourceToDescribe(ResourceOrVariable node) { - resourcesToDescribe.add(node); - } - - @Override - public String toString() { - return (new SimpleStringQuerySerializer()).serialize(this); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java deleted file mode 100644 index 45badaa..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 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.UriRefOrVariable; - -/** - * - * @author hasan - */ -public class SimpleGraphGraphPattern implements GraphGraphPattern { - - private UriRefOrVariable ImmutableGraph; - private GroupGraphPattern groupGraphPattern; - - public SimpleGraphGraphPattern(UriRefOrVariable ImmutableGraph, - GroupGraphPattern groupGraphPattern) { - if (ImmutableGraph == null) { - throw new IllegalArgumentException("ImmutableGraph may not be null"); - } - if (groupGraphPattern == null) { - throw new IllegalArgumentException("Group ImmutableGraph Pattern may not be null"); - } - this.ImmutableGraph = ImmutableGraph; - this.groupGraphPattern = groupGraphPattern; - } - - @Override - public UriRefOrVariable getGraph() { - return ImmutableGraph; - } - - @Override - public GroupGraphPattern getGroupGraphPattern() { - return groupGraphPattern; - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java deleted file mode 100644 index cd893d2..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern; -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.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.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; -import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable; - -/** - * This class implements {@link GroupGraphPattern}. - * - * @author hasan - */ -public class SimpleGroupGraphPattern implements GroupGraphPattern { - - 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() { - return subSelect != null; - } - - @Override - public SelectQuery getSubSelect() { - return subSelect; - } - - @Override - public Set<GraphPattern> getGraphPatterns() { - return subSelect == null ? new LinkedHashSet(graphPatterns) : null; - } - - @Override - public List<Expression> getFilter() { - return subSelect == null ? constraints : null; - } - - public void setSubSelect(SelectQuery subSelect) { - this.subSelect = subSelect; - } - - /** - * Adds a {@link GraphPattern} to the group. - * - * @param graphPattern - * the GraphPattern to be added. - */ - public void addGraphPattern(GraphPattern graphPattern) { - subSelect = null; - graphPatterns.add(graphPattern); - lastBasicGraphPatternIsComplete = - !(graphPattern instanceof BasicGraphPattern || graphPattern instanceof PathSupportedBasicGraphPattern); - } - - /** - * 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); - } - - 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 - * 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 (!lastBasicGraphPatternIsComplete && (size > 0)) { - prevGraphPattern = graphPatterns.get(size-1); - if (prevGraphPattern instanceof SimpleBasicGraphPattern) { - ((SimpleBasicGraphPattern) prevGraphPattern) - .addTriplePatterns(triplePatterns); - return; - } - } - graphPatterns.add(new SimpleBasicGraphPattern(triplePatterns)); - lastBasicGraphPatternIsComplete = false; - } - - /** - * Adds an {@link OptionalGraphPattern} to the group consisting of - * a main ImmutableGraph pattern and the specified {@link GroupGraphPattern} as - * the optional pattern. - * The main ImmutableGraph pattern is taken from the last added {@link GraphPattern} - * in the group, if it exists. Otherwise, the main ImmutableGraph 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)); - 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; - } - - @Override - public Set<IRI> getReferredGraphs() { - Set<IRI> referredGraphs = new HashSet<IRI>(); - if (subSelect != null) { - GroupGraphPattern queryPattern = subSelect.getQueryPattern(); - referredGraphs.addAll(queryPattern.getReferredGraphs()); - } else { - for (GraphPattern graphPattern : graphPatterns) { - referredGraphs.addAll(getReferredGraphs(graphPattern)); - } - } - return referredGraphs; - } - - private Set<IRI> getReferredGraphs(GraphPattern graphPattern) { - Set<IRI> referredGraphs = new HashSet<IRI>(); - if (graphPattern instanceof GraphGraphPattern) { - GraphGraphPattern graphGraphPattern = (GraphGraphPattern) graphPattern; - UriRefOrVariable ImmutableGraph = graphGraphPattern.getGraph(); - if (!ImmutableGraph.isVariable()) { - referredGraphs.add(ImmutableGraph.getResource()); - } - referredGraphs.addAll(graphGraphPattern.getGroupGraphPattern().getReferredGraphs()); - } else if (graphPattern instanceof AlternativeGraphPattern) { - List<GroupGraphPattern> alternativeGraphPatterns = - ((AlternativeGraphPattern) graphPattern).getAlternativeGraphPatterns(); - for (GroupGraphPattern groupGraphPattern : alternativeGraphPatterns) { - referredGraphs.addAll(groupGraphPattern.getReferredGraphs()); - } - } else if (graphPattern instanceof OptionalGraphPattern) { - GraphPattern mainGraphPattern = ((OptionalGraphPattern) graphPattern).getMainGraphPattern(); - referredGraphs.addAll(getReferredGraphs(mainGraphPattern)); - GroupGraphPattern optionalGraphPattern = ((OptionalGraphPattern) graphPattern).getOptionalGraphPattern(); - referredGraphs.addAll(optionalGraphPattern.getReferredGraphs()); - } else if (graphPattern instanceof MinusGraphPattern) { - GraphPattern minuendGraphPattern = ((MinusGraphPattern) graphPattern).getMinuendGraphPattern(); - referredGraphs.addAll(getReferredGraphs(minuendGraphPattern)); - GroupGraphPattern subtrahendGraphPattern = ((MinusGraphPattern) graphPattern).getSubtrahendGraphPattern(); - referredGraphs.addAll(subtrahendGraphPattern.getReferredGraphs()); - } else if (graphPattern instanceof GroupGraphPattern) { - GroupGraphPattern groupGraphPattern = (GroupGraphPattern) graphPattern; - referredGraphs.addAll(groupGraphPattern.getReferredGraphs()); - } - return referredGraphs; - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java deleted file mode 100644 index 3b49f02..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.commons.rdf.RDFTerm; -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<RDFTerm>> values = new ArrayList<List<RDFTerm>>(); - - @Override - public List<Variable> getVariables() { - return variables; - } - - @Override - public List<List<RDFTerm>> getValues() { - return values; - } - - public void addVariable(Variable variable) { - variables.add(variable); - } - - public void addValues(List<RDFTerm> values) { - this.values.add(values); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java deleted file mode 100644 index 951b9ec..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 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; - -/** - * This class implements {@link MinusGraphPattern}. - * - * @author hasan - */ -public class SimpleMinusGraphPattern implements MinusGraphPattern { - - private GraphPattern minuendGraphPattern; - private GroupGraphPattern subtrahendGraphPattern; - - /** - * Constructs a {@link MinusGraphPattern} out of a {@link GraphPattern} - * as the minuend ImmutableGraph pattern and a {@link GroupGraphPattern} as the - * subtrahend pattern. - * - * @param minuendGraphPattern - * a {@link GraphPattern} specifying the minuend pattern. - * @param subtrahendGraphPattern - * a {@link GroupGraphPattern} specifying the subtrahend pattern. - */ - public SimpleMinusGraphPattern(GraphPattern minuendGraphPattern, GroupGraphPattern subtrahendGraphPattern) { - if (subtrahendGraphPattern == null) { - throw new IllegalArgumentException("Subtrahend ImmutableGraph pattern may not be null"); - } - if (minuendGraphPattern == null) { - this.minuendGraphPattern = new SimpleGroupGraphPattern(); - } else { - this.minuendGraphPattern = minuendGraphPattern; - } - this.subtrahendGraphPattern = subtrahendGraphPattern; - } - - @Override - public GraphPattern getMinuendGraphPattern() { - return minuendGraphPattern; - } - - @Override - public GroupGraphPattern getSubtrahendGraphPattern() { - return subtrahendGraphPattern; - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java deleted file mode 100644 index 64abd73..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 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; - -/** - * This class implements {@link OptionalGraphPattern}. - * - * @author hasan - */ -public class SimpleOptionalGraphPattern implements OptionalGraphPattern { - - private GraphPattern mainGraphPattern; - private GroupGraphPattern optionalGraphPattern; - - /** - * Constructs an {@link OptionalGraphPattern} out of a {@link GraphPattern} - * as the main ImmutableGraph pattern and a {@link GroupGraphPattern} as the - * optional pattern. - * - * @param mainGraphPattern - * a {@link GraphPattern} specifying the main pattern. - * @param optionalGraphPattern - * a {@link GroupGraphPattern} specifying the optional pattern. - */ - public SimpleOptionalGraphPattern(GraphPattern mainGraphPattern, - GroupGraphPattern optionalGraphPattern) { - if (optionalGraphPattern == null) { - throw new IllegalArgumentException("Optional ImmutableGraph pattern may not be null"); - } - if (mainGraphPattern == null) { - this.mainGraphPattern = new SimpleGroupGraphPattern(); - } else { - this.mainGraphPattern = mainGraphPattern; - } - this.optionalGraphPattern = optionalGraphPattern; - } - - @Override - public GraphPattern getMainGraphPattern() { - return mainGraphPattern; - } - - @Override - public GroupGraphPattern getOptionalGraphPattern() { - return optionalGraphPattern; - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java deleted file mode 100644 index c6b5fba..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.apache.clerezza.rdf.core.sparql.query.Expression; -import org.apache.clerezza.rdf.core.sparql.query.OrderCondition; - -/** - * - * @author hasan - */ -public class SimpleOrderCondition implements OrderCondition { - private Expression expression; - private boolean ascending; - - public SimpleOrderCondition(Expression expression, boolean ascending) { - this.expression = expression; - this.ascending = ascending; - } - - @Override - public Expression getExpression() { - return expression; - } - - @Override - public boolean isAscending() { - return ascending; - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java deleted file mode 100644 index 37711d6..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.LinkedHashSet; -import java.util.Set; -import org.apache.clerezza.rdf.core.sparql.query.PathSupportedBasicGraphPattern; -import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern; - -/** - * - * @author hasan - */ -public class SimplePathSupportedBasicGraphPattern implements PathSupportedBasicGraphPattern { - - private Set<PropertyPathPattern> propertyPathPatterns; - - public SimplePathSupportedBasicGraphPattern(Set<PropertyPathPattern> propertyPathPatterns) { - this.propertyPathPatterns = (propertyPathPatterns == null) - ? new LinkedHashSet<PropertyPathPattern>() - : propertyPathPatterns; - } - - @Override - public Set<PropertyPathPattern> getPropertyPathPatterns() { - return propertyPathPatterns; - } - - public void addPropertyPathPatterns(Set<PropertyPathPattern> propertyPathPatterns) { - this.propertyPathPatterns.addAll(propertyPathPatterns); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java deleted file mode 100644 index 36ed721..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 org.apache.clerezza.commons.rdf.BlankNodeOrIRI; -import org.apache.clerezza.commons.rdf.RDFTerm; -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.Variable; - -/** - * - * @author hasan - */ -public class SimplePropertyPathPattern implements PropertyPathPattern { - - private ResourceOrVariable subject; - private PropertyPathExpressionOrVariable propertyPathExpression; - private ResourceOrVariable object; - - public SimplePropertyPathPattern(ResourceOrVariable subject, - PropertyPathExpressionOrVariable propertyPathExpression, - ResourceOrVariable object) { - if (subject == null) { - throw new IllegalArgumentException("Invalid subject: 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.propertyPathExpression = propertyPathExpression; - this.object = object; - } - - public SimplePropertyPathPattern(Variable subject, Variable propertyPathExpression, Variable object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(BlankNodeOrIRI subject, Variable propertyPathExpression, Variable object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(Variable subject, Variable propertyPathExpression, RDFTerm object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(BlankNodeOrIRI subject, Variable propertyPathExpression, RDFTerm object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(Variable subject, PropertyPathExpression propertyPathExpression, Variable object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(BlankNodeOrIRI subject, PropertyPathExpression propertyPathExpression, Variable object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(Variable subject, PropertyPathExpression propertyPathExpression, RDFTerm object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - public SimplePropertyPathPattern(BlankNodeOrIRI subject, PropertyPathExpression propertyPathExpression, RDFTerm object) { - this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression), - new ResourceOrVariable(object)); - } - - @Override - public ResourceOrVariable getSubject() { - return subject; - } - - @Override - public PropertyPathExpressionOrVariable getPropertyPathExpression() { - return propertyPathExpression; - } - - @Override - public ResourceOrVariable getObject() { - return object; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (!(obj instanceof PropertyPathPattern)) { - return false; - } - final PropertyPathPattern other = (PropertyPathPattern) obj; - if (!this.subject.equals(other.getSubject())) { - return false; - } - if (!this.propertyPathExpression.equals(other.getPropertyPathExpression())) { - return false; - } - if (!this.object.equals(other.getObject())) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return (subject.hashCode() >> 1) ^ propertyPathExpression.hashCode() ^ (object.hashCode() << 1); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java deleted file mode 100644 index 7f8407b..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 org.apache.clerezza.commons.rdf.IRI; -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; - -/** - * - * @author hasan - */ -public abstract class SimpleQuery implements Query { - - 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 InlineData getInlineData() { - return inlineData; - } - - public void addDefaultGraph(IRI defaultGraph) { - if (dataSet == null) { - dataSet = new SimpleDataSet(); - } - dataSet.addDefaultGraph(defaultGraph); - } - - public void addNamedGraph(IRI namedGraph) { - if (dataSet == null) { - dataSet = new SimpleDataSet(); - } - dataSet.addNamedGraph(namedGraph); - } - - public void setQueryPattern(GroupGraphPattern queryPattern) { - this.queryPattern = queryPattern; - } - - public void setInlineData(InlineData inlineData) { - this.inlineData = inlineData; - } - - @Override - public abstract String toString(); -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java deleted file mode 100644 index eeb758f..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.sparql.query.Expression; -import org.apache.clerezza.rdf.core.sparql.query.OrderCondition; -import org.apache.clerezza.rdf.core.sparql.query.QueryWithSolutionModifier; - -/** - * - * @author hasan - */ -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>(); - - /** - * Result offset. 0 means no offset. - */ - private int offset = 0; - - /** - * Result limit. -1 means no limit. - */ - 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; - } - - @Override - public int getOffset() { - return offset; - } - - @Override - public int getLimit() { - 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); - } - - public void setOffset(int offset) { - this.offset = offset; - } - - public void setLimit(int limit) { - this.limit = limit; - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java deleted file mode 100644 index f71e1a8..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.sparql.query.SelectQuery; -import org.apache.clerezza.rdf.core.sparql.query.Variable; - -/** - * - * @author hasan - */ -public class SimpleSelectQuery extends SimpleQueryWithSolutionModifier - implements SelectQuery { - - private boolean distinct; - private boolean reduced; - private boolean selectAll; - private List<Variable> variables = new ArrayList<Variable>(); - - @Override - public boolean isDistinct() { - return distinct; - } - - @Override - public boolean isReduced() { - return reduced; - } - - @Override - public boolean isSelectAll() { - return selectAll; - } - - @Override - public List<Variable> getSelection() { - return variables; - } - - public void setDistinct() { - distinct = true; - } - - public void setReduced() { - reduced = true; - } - - public void setSelectAll() { - assert variables.isEmpty(); - selectAll = true; - } - - public void addSelection(Variable var) { - variables.add(var); - } - - @Override - public String toString() { - return (new SimpleStringQuerySerializer()).serialize(this); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java deleted file mode 100644 index 24d6797..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 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 SimpleServiceGraphPattern implements ServiceGraphPattern { - - private UriRefOrVariable service; - private GroupGraphPattern groupGraphPattern; - private boolean silent; - - public SimpleServiceGraphPattern(UriRefOrVariable service, - GroupGraphPattern groupGraphPattern) { - if (service == null) { - throw new IllegalArgumentException("Service endpoint may not be null"); - } - if (groupGraphPattern == null) { - throw new IllegalArgumentException("Group ImmutableGraph Pattern may not be null"); - } - this.service = service; - this.groupGraphPattern = groupGraphPattern; - this.silent = false; - } - - @Override - public UriRefOrVariable getService() { - return service; - } - - @Override - public GroupGraphPattern getGroupGraphPattern() { - return groupGraphPattern; - } - - public void setSilent(boolean silent) { - this.silent = silent; - } - - public boolean isSilent() { - return silent; - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java deleted file mode 100644 index 60e88c4..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 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 class SimpleSparqlUnit implements SparqlUnit { - - private final Query query; - private final Update update; - - public SimpleSparqlUnit(Query query) { - if (query == null) { - throw new IllegalArgumentException("Invalid query: null"); - } - this.query = query; - update = null; - } - - public SimpleSparqlUnit(Update update) { - if (update == null) { - throw new IllegalArgumentException("Invalid update: null"); - } - this.update = update; - query = null; - } - - - @Override - public boolean isQuery() { - return update == null; - } - - @Override - public Query getQuery() { - return query; - } - - @Override - public Update getUpdate() { - return update; - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java deleted file mode 100644 index 18266f6..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * 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.List; -import java.util.Set; -import org.apache.clerezza.commons.rdf.BlankNode; -import org.apache.clerezza.commons.rdf.RDFTerm; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.sparql.StringQuerySerializer; -import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern; -import org.apache.clerezza.rdf.core.sparql.query.AskQuery; -import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern; -import org.apache.clerezza.rdf.core.sparql.query.BinaryOperation; -import org.apache.clerezza.rdf.core.sparql.query.BuiltInCall; -import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery; -import org.apache.clerezza.rdf.core.sparql.query.DataSet; -import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery; -import org.apache.clerezza.rdf.core.sparql.query.Expression; -import org.apache.clerezza.rdf.core.sparql.query.FunctionCall; -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.LiteralExpression; -import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern; -import org.apache.clerezza.rdf.core.sparql.query.OrderCondition; -import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable; -import org.apache.clerezza.rdf.core.sparql.query.SelectQuery; -import org.apache.clerezza.rdf.core.sparql.query.TriplePattern; -import org.apache.clerezza.rdf.core.sparql.query.UnaryOperation; -import org.apache.clerezza.rdf.core.sparql.query.UriRefExpression; -import org.apache.clerezza.rdf.core.sparql.query.Variable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class implements abstract methods of {@link StringQuerySerializer} - * to serialize specific {@link Query} types. - * - * @author hasan - */ -public class SimpleStringQuerySerializer extends StringQuerySerializer { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Override - public String serialize(SelectQuery selectQuery) { - StringBuffer s = new StringBuffer("SELECT "); - if (selectQuery.isDistinct()) { - s.append("DISTINCT\n"); - } - if (selectQuery.isReduced()) { - s.append("REDUCED\n"); - } - if (selectQuery.isSelectAll()) { - s.append("*"); - } else { - for (Variable v : selectQuery.getSelection()) { - appendVariable(s, v); - s.append(" "); - } - } - s.append("\n"); - - appendDataSet(s, (SimpleQuery) selectQuery); - appendWhere(s, (SimpleQuery) selectQuery); - appendModifier(s, (SimpleQueryWithSolutionModifier) selectQuery); - - return s.toString(); - } - - private void appendVariable(StringBuffer s, Variable v) { - s.append("?").append(v.getName()); - } - - private void appendDataSet(StringBuffer s, SimpleQuery q) { - DataSet dataSet = q.getDataSet(); - if (dataSet != null) { - for (IRI dg : dataSet.getDefaultGraphs()) { - s.append("FROM ").append(dg.toString()).append("\n"); - } - for (IRI ng : dataSet.getNamedGraphs()) { - s.append("FROM NAMED ").append(ng.toString()).append("\n"); - } - } - } - - private void appendWhere(StringBuffer s, SimpleQuery q) { - GroupGraphPattern queryPattern = q.getQueryPattern(); - if (queryPattern == null) { - return; - } - s.append("WHERE\n"); - appendGroupGraphPattern(s, q.getQueryPattern()); - } - - private void appendGroupGraphPattern(StringBuffer s, - GroupGraphPattern groupGraphPattern) { - - s.append("{ "); - for (GraphPattern graphPattern : groupGraphPattern.getGraphPatterns()) { - appendGraphPattern(s, graphPattern); - } - for (Expression e : groupGraphPattern.getFilter()) { - boolean brackettedExpr = !((e instanceof BuiltInCall) - || (e instanceof FunctionCall)); - s.append("FILTER "); - if (brackettedExpr) { - s.append("("); - } - appendExpression(s, e); - if (brackettedExpr) { - s.append(")"); - } - s.append("\n"); - } - s.append("} "); - } - - private void appendGraphPattern(StringBuffer s, GraphPattern graphPattern) { - if (graphPattern instanceof BasicGraphPattern) { - appendTriplePatterns(s, - ((BasicGraphPattern) graphPattern).getTriplePatterns()); - } else if (graphPattern instanceof GroupGraphPattern) { - appendGroupGraphPattern(s, (GroupGraphPattern) graphPattern); - } else if (graphPattern instanceof OptionalGraphPattern) { - appendGraphPattern(s, - ((OptionalGraphPattern) graphPattern).getMainGraphPattern()); - s.append(" OPTIONAL "); - appendGroupGraphPattern(s, - ((OptionalGraphPattern) graphPattern).getOptionalGraphPattern()); - } else if (graphPattern instanceof AlternativeGraphPattern) { - List<GroupGraphPattern> alternativeGraphPatterns = - ((AlternativeGraphPattern) graphPattern).getAlternativeGraphPatterns(); - if ((alternativeGraphPatterns != null) && - (!alternativeGraphPatterns.isEmpty())) { - appendGroupGraphPattern(s, alternativeGraphPatterns.get(0)); - int size = alternativeGraphPatterns.size(); - int i = 1; - while (i < size) { - s.append(" UNION "); - appendGroupGraphPattern(s, alternativeGraphPatterns.get(i)); - i++; - } - } - } else if (graphPattern instanceof GraphGraphPattern) { - s.append("ImmutableGraph "); - appendResourceOrVariable(s, ((GraphGraphPattern) graphPattern).getGraph()); - s.append(" "); - appendGroupGraphPattern(s, ((GraphGraphPattern) graphPattern).getGroupGraphPattern()); - } else { - logger.warn("Unsupported GraphPattern {}", graphPattern.getClass()); - } - } - - private void appendTriplePatterns(StringBuffer s, - Set<TriplePattern> triplePatterns) { - - for (TriplePattern p : triplePatterns) { - appendResourceOrVariable(s, p.getSubject()); - s.append(" "); - appendResourceOrVariable(s, p.getPredicate()); - s.append(" "); - appendResourceOrVariable(s, p.getObject()); - s.append(" .\n"); - } - } - - private void appendResourceOrVariable(StringBuffer s, ResourceOrVariable n) { - if (n.isVariable()) { - appendVariable(s, n.getVariable()); - } else { - RDFTerm r = n.getResource(); - if (r instanceof BlankNode) { - s.append("_:").append(r.toString().replace("@", ".")); - } else { - s.append(r.toString()); - } - } - } - - private void appendExpression(StringBuffer s, Expression e) { - if (e instanceof Variable) { - appendVariable(s, (Variable) e); - } else if (e instanceof BinaryOperation) { - BinaryOperation bo = (BinaryOperation) e; - s.append("("); - appendExpression(s, bo.getLhsOperand()); - s.append(") ").append(bo.getOperatorString()).append(" ("); - appendExpression(s, bo.getRhsOperand()); - s.append(")"); - } else if (e instanceof UnaryOperation) { - UnaryOperation uo = (UnaryOperation) e; - s.append(uo.getOperatorString()).append(" ("); - appendExpression(s, uo.getOperand()); - s.append(")"); - } else if (e instanceof BuiltInCall) { - BuiltInCall b = (BuiltInCall) e; - appendCall(s, b.getName(), b.getArguements()); - } else if (e instanceof FunctionCall) { - FunctionCall f = (FunctionCall) e; - appendCall(s, f.getName().getUnicodeString(), f.getArguements()); - } else if (e instanceof LiteralExpression) { - appendLiteralExpression(s, (LiteralExpression) e); - } else if (e instanceof UriRefExpression) { - s.append(((UriRefExpression) e).getUriRef().toString()); - } - } - - private void appendCall(StringBuffer s, String name, List<Expression> expr) { - s.append(name).append("("); - for (Expression e : expr) { - appendExpression(s, e); - s.append(","); - } - if (expr.isEmpty()) { - s.append(")"); - } else { - s.setCharAt(s.length()-1, ')'); - } - } - - private void appendLiteralExpression(StringBuffer s, LiteralExpression le) { - s.append(le.getLiteral().toString()); - } - - private void appendModifier(StringBuffer s, SimpleQueryWithSolutionModifier q) { - List<OrderCondition> orderConditions = q.getOrderConditions(); - if ((orderConditions != null) && (!orderConditions.isEmpty())) { - s.append("ORDER BY "); - for (OrderCondition oc : orderConditions) { - appendOrderCondition(s, oc); - s.append("\n"); - } - } - if (q.getOffset() > 0) { - s.append("OFFSET ").append(q.getOffset()).append("\n"); - } - if (q.getLimit() >= 0) { - s.append("LIMIT ").append(q.getLimit()).append("\n"); - } - } - - private void appendOrderCondition(StringBuffer s, OrderCondition oc) { - if (!oc.isAscending()) { - s.append("DESC("); - } - appendExpression(s, oc.getExpression()); - if (!oc.isAscending()) { - s.append(")"); - } - s.append(" "); - } - - @Override - public String serialize(ConstructQuery constructQuery) { - StringBuffer s = new StringBuffer("CONSTRUCT\n"); - Set<TriplePattern> triplePatterns = constructQuery.getConstructTemplate(); - s.append("{ "); - if (triplePatterns != null && !triplePatterns.isEmpty()) { - appendTriplePatterns(s, triplePatterns); - } - s.append("}\n"); - - appendDataSet(s, (SimpleQuery) constructQuery); - appendWhere(s, (SimpleQuery) constructQuery); - appendModifier(s, (SimpleQueryWithSolutionModifier) constructQuery); - - return s.toString(); - } - - @Override - public String serialize(DescribeQuery describeQuery) { - StringBuffer s = new StringBuffer("DESCRIBE\n"); - - if (describeQuery.isDescribeAll()) { - s.append("*"); - } else { - for (ResourceOrVariable n : describeQuery.getResourcesToDescribe()) { - appendResourceOrVariable(s, n); - s.append(" "); - } - } - appendDataSet(s, (SimpleQuery) describeQuery); - appendWhere(s, (SimpleQuery) describeQuery); - appendModifier(s, (SimpleQueryWithSolutionModifier) describeQuery); - - return s.toString(); - } - - @Override - public String serialize(AskQuery askQuery) { - StringBuffer s = new StringBuffer("ASK\n"); - appendDataSet(s, (SimpleQuery) askQuery); - appendWhere(s, (SimpleQuery) askQuery); - - return s.toString(); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java deleted file mode 100644 index adad648..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 org.apache.clerezza.commons.rdf.BlankNodeOrIRI; -import org.apache.clerezza.commons.rdf.RDFTerm; -import org.apache.clerezza.commons.rdf.IRI; -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 { - - private ResourceOrVariable subject; - private UriRefOrVariable predicate; - private ResourceOrVariable object; - - public SimpleTriplePattern(ResourceOrVariable subject, - UriRefOrVariable predicate, - ResourceOrVariable object) { - if (subject == null) { - throw new IllegalArgumentException("Invalid subject: null"); - } - if (predicate == null) { - throw new IllegalArgumentException("Invalid predicate: null"); - } - if (object == null) { - throw new IllegalArgumentException("Invalid object: null"); - } - this.subject = subject; - this.predicate = predicate; - this.object = object; - } - - public SimpleTriplePattern(Variable subject, Variable predicate, Variable object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(BlankNodeOrIRI subject, Variable predicate, Variable object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(Variable subject, IRI predicate, Variable object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(BlankNodeOrIRI subject, IRI predicate, Variable object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(Variable subject, Variable predicate, RDFTerm object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(BlankNodeOrIRI subject, Variable predicate, RDFTerm object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(Variable subject, IRI predicate, RDFTerm object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - public SimpleTriplePattern(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) { - this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate), - new ResourceOrVariable(object)); - } - - @Override - public ResourceOrVariable getSubject() { - return subject; - } - - @Override - public UriRefOrVariable getPredicate() { - return predicate; - } - - @Override - public ResourceOrVariable getObject() { - return object; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (!(obj instanceof TriplePattern)) { - return false; - } - final TriplePattern other = (TriplePattern) obj; - if (!this.subject.equals(other.getSubject())) { - return false; - } - if (!this.predicate.equals(other.getPredicate())) { - return false; - } - if (!this.object.equals(other.getObject())) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return (subject.hashCode() >> 1) ^ subject.hashCode() ^ (subject.hashCode() << 1); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java deleted file mode 100644 index 944f3b9..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.update; - -import java.util.Set; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.access.TcProvider; - -/** - * <p>This interface represents a SPARQL Update.</p> - * - * @author hasan - */ -public interface Update { - - /** - * - * @param defaultGraph - * if default graph is referred either implicitly or explicitly in a SPARQL {@link Update} - * the specified defaultGraph should be returned in the resulting set. - * @param tcProvider - * the specified tcProvider is used to get the named graphs referred in the SPARQL {@link Update}. - * @return a set of graphs referred in the {@link Update}. - */ - public Set<IRI> getReferredGraphs(IRI defaultGraph, TcProvider tcProvider); - - public void addOperation(UpdateOperation updateOperation); - - /** - * - * @return A valid String representation of the {@link Update}. - */ - @Override - public abstract String toString(); -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java deleted file mode 100644 index b09d305..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.update; - -import java.util.Set; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.access.TcProvider; - -/** - * SPARQL Update Operation - * - * @author hasan - */ -public interface UpdateOperation { - public enum GraphSpec { - GRAPH, DEFAULT, NAMED, ALL - } - - /** - * - * @param defaultGraph - * if default graph is referred either implicitly or explicitly as an input graph in this operation - * the specified defaultGraph should be returned in the resulting set. - * @param tcProvider - * the specified tcProvider is used to get the named graphs referred as input graphs in this operation. - * @return a set of graphs referred as input graphs in this operation. - */ - public Set<IRI> getInputGraphs(IRI defaultGraph, TcProvider tcProvider); - - /** - * - * @param defaultGraph - * if default graph is referred either implicitly or explicitly as a destination graph in this operation - * the specified defaultGraph should be returned in the resulting set. - * @param tcProvider - * the specified tcProvider is used to get the named graphs referred as destination graphs in this operation. - * @return a set of graphs referred as destination graphs in this operation. - */ - public Set<IRI> getDestinationGraphs(IRI defaultGraph, TcProvider tcProvider); -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java deleted file mode 100644 index 36344b6..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.update.impl; - -/** - * The ADD operation is a shortcut for inserting all data from an input ImmutableGraph into a destination ImmutableGraph. - * Data from the input ImmutableGraph is not affected, and initial data from the destination ImmutableGraph, if any, is kept intact. - * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-update-20130321/#add">SPARQL 1.1 Update: 3.2.5 ADD</a> - * - * @author hasan - */ -public class AddOperation extends SimpleUpdateOperation { -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java deleted file mode 100644 index bc12710..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.update.impl; - -import java.util.HashSet; -import java.util.Set; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.access.TcProvider; -import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation; - -/** - * - * @author hasan - */ -public abstract class BaseUpdateOperation implements UpdateOperation { - - protected Set<IRI> inputGraphs = new HashSet<IRI>(); - protected Set<IRI> destinationGraphs = new HashSet<IRI>(); - protected GraphSpec inputGraphSpec = GraphSpec.GRAPH; - protected GraphSpec destinationGraphSpec = GraphSpec.GRAPH; - - public void setInputGraphSpec(GraphSpec inputGraphSpec) { - this.inputGraphSpec = inputGraphSpec; - } - - public GraphSpec getInputGraphSpec() { - return inputGraphSpec; - } - - public void setDestinationGraphSpec(GraphSpec destinationGraphSpec) { - this.destinationGraphSpec = destinationGraphSpec; - } - - public GraphSpec getDestinationGraphSpec() { - return destinationGraphSpec; - } - - @Override - public Set<IRI> getInputGraphs(IRI defaultGraph, TcProvider tcProvider) { - return getGraphs(defaultGraph, tcProvider, inputGraphSpec, inputGraphs); - } - - private Set<IRI> getGraphs(IRI defaultGraph, TcProvider tcProvider, GraphSpec graphSpec, Set<IRI> graphs) { - switch (graphSpec) { - case DEFAULT: - Set<IRI> result = new HashSet<IRI>(); - result.add(defaultGraph); - return result; - case NAMED: - case ALL: - return tcProvider.listGraphs(); - default: - return graphs; - } - } - - @Override - public Set<IRI> getDestinationGraphs(IRI defaultGraph, TcProvider tcProvider) { - return getGraphs(defaultGraph, tcProvider, destinationGraphSpec, destinationGraphs); - } - - public void addInputGraph(IRI ImmutableGraph) { - inputGraphs.add(ImmutableGraph); - } - - public void addDestinationGraph(IRI ImmutableGraph) { - destinationGraphs.add(ImmutableGraph); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java deleted file mode 100644 index 9fdfe95..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.update.impl; - -/** - * - * @author hasan - */ -public class ClearOperation extends ClearOrDropOperation { -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java deleted file mode 100644 index 2b356af..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.update.impl; - -import java.util.Set; -import org.apache.clerezza.commons.rdf.IRI; -import org.apache.clerezza.rdf.core.access.TcProvider; -import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation; - -/** - * - * @author hasan - */ -public class ClearOrDropOperation extends BaseUpdateOperation { - private boolean silent; - - public ClearOrDropOperation() { - this.silent = false; - destinationGraphSpec = UpdateOperation.GraphSpec.DEFAULT; - } - - public void setSilent(boolean silent) { - this.silent = silent; - } - - public boolean isSilent() { - return silent; - } - - public void setDestinationGraph(IRI destination) { - destinationGraphSpec = UpdateOperation.GraphSpec.GRAPH; - destinationGraphs.clear(); - destinationGraphs.add(destination); - } - - public IRI getDestinationGraph(IRI defaultGraph, TcProvider tcProvider) { - Set<IRI> result = getDestinationGraphs(defaultGraph, tcProvider); - if (result.isEmpty()) { - return null; - } else { - return result.iterator().next(); - } - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java deleted file mode 100644 index 6e9aa40..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.update.impl; - -/** - * - * @author hasan - */ -public class CopyOperation extends SimpleUpdateOperation { -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/f5d9dd84/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java ---------------------------------------------------------------------- diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java deleted file mode 100644 index 090f423..0000000 --- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.update.impl; - -import org.apache.clerezza.commons.rdf.IRI; - -/** - * - * @author hasan - */ -public class CreateOperation extends BaseUpdateOperation { - - private boolean silent; - - public CreateOperation() { - this.silent = false; - } - - public void setSilent(boolean silent) { - this.silent = silent; - } - - public boolean isSilent() { - return silent; - } - - public void setDestinationGraph(IRI destination) { - destinationGraphs.clear(); - destinationGraphs.add(destination); - } - - public IRI getDestinationGraph() { - if (destinationGraphs.isEmpty()) { - return null; - } else { - return destinationGraphs.iterator().next(); - } - } -}
