clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [3/3] clerezza git commit: CLEREZZA-972: using rdf-commons from clerezza-rdf-core repository
Date Sun, 22 Mar 2015 15:31:52 GMT
CLEREZZA-972: using rdf-commons from clerezza-rdf-core repository

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/39b02c14
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/39b02c14
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/39b02c14

Branch: refs/heads/rdf-commons
Commit: 39b02c14b7df37a04cfaefb2c2443338f9470f53
Parents: ee4b8b3
Author: Reto Gmuer <reto@apache.org>
Authored: Sun Mar 22 15:30:31 2015 +0000
Committer: Reto Gmuer <reto@apache.org>
Committed: Sun Mar 22 15:30:31 2015 +0000

----------------------------------------------------------------------
 provisioning/rdf/pom.xml                        |   4 +-
 rdf.jena.sparql/LICENSE                         | 201 -------------------
 rdf.jena.sparql/nbactions.xml                   |  11 -
 rdf.jena.sparql/pom.xml                         |  73 -------
 .../rdf/jena/sparql/HashMapSolutionMapping.java |  54 -----
 .../rdf/jena/sparql/JenaSparqlEngine.java       | 163 ---------------
 .../rdf/jena/sparql/ResultSetWrapper.java       |  66 ------
 .../rdf/jena/sparql/TcDatasetGraph.java         | 193 ------------------
 ....apache.clerezza.rdf.core.sparql.QueryEngine |   1 -
 .../clerezza/rdf/jena/sparql/SimpleTest.java    | 149 --------------
 rdf/jena/pom.xml                                |   1 +
 rdf/jena/sparql/LICENSE                         | 201 +++++++++++++++++++
 rdf/jena/sparql/nbactions.xml                   |  11 +
 rdf/jena/sparql/pom.xml                         |  79 ++++++++
 .../rdf/jena/sparql/HashMapSolutionMapping.java |  54 +++++
 .../rdf/jena/sparql/JenaSparqlEngine.java       | 157 +++++++++++++++
 .../rdf/jena/sparql/ResultSetWrapper.java       |  66 ++++++
 .../rdf/jena/sparql/TcDatasetGraph.java         | 192 ++++++++++++++++++
 ....apache.clerezza.rdf.core.sparql.QueryEngine |   1 +
 .../clerezza/rdf/jena/sparql/SimpleTest.java    | 149 ++++++++++++++
 .../rdf/simple/storage/AccessViaTcManager.java  |  37 ++++
 21 files changed, 950 insertions(+), 913 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/provisioning/rdf/pom.xml
----------------------------------------------------------------------
diff --git a/provisioning/rdf/pom.xml b/provisioning/rdf/pom.xml
index c33868c..8cdbac7 100644
--- a/provisioning/rdf/pom.xml
+++ b/provisioning/rdf/pom.xml
@@ -132,7 +132,7 @@
         <dependency>
             <groupId>org.apache.clerezza</groupId>
             <artifactId>rdf.jena.serializer</artifactId>
-            <version>0.11</version>
+            <version>1.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.clerezza</groupId>
@@ -147,7 +147,7 @@
         <dependency>
             <groupId>org.apache.clerezza</groupId>
             <artifactId>rdf.jena.storage</artifactId>
-            <version>0.7</version>
+            <version>1.0.0-SNAPSHOT</version>
         </dependency>
         <!-- <dependency>
             <groupId>org.apache.clerezza</groupId>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/LICENSE
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/LICENSE b/rdf.jena.sparql/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/rdf.jena.sparql/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed 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.

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/nbactions.xml
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/nbactions.xml b/rdf.jena.sparql/nbactions.xml
deleted file mode 100644
index 49e8307..0000000
--- a/rdf.jena.sparql/nbactions.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<actions>
-    <action>
-        <actionName>CUSTOM-deploy to localhost:8080</actionName>
-        <displayName>deploy to localhost:8080</displayName>
-        <goals>
-            <goal>install</goal>
-            <goal>org.apache.sling:maven-sling-plugin:install</goal>
-        </goals>
-    </action>
-</actions>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/pom.xml b/rdf.jena.sparql/pom.xml
deleted file mode 100644
index 3fdc200..0000000
--- a/rdf.jena.sparql/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-<!--
-
- 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.
-
--->
-
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <artifactId>clerezza</artifactId>
-        <groupId>org.apache.clerezza</groupId>
-        <version>0.5</version>
-        <relativePath>../parent</relativePath>
-    </parent>
-    <groupId>org.apache.clerezza</groupId>
-    <artifactId>rdf.jena.sparql</artifactId>
-    <packaging>bundle</packaging>
-    <version>1.0.0-SNAPSHOT</version>
-    <name>Clerezza - SCB Jena SPARQL engine</name>
-    <description>Allows executing SPARQL queries on SCB using the jena sparql engine.</description>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>rdf.jena.storage</artifactId>
-            <version>0.7</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>rdf.jena.facade</artifactId>
-            <version>0.14</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.jena</groupId>
-            <artifactId>jena-arq</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>rdf.simple.storage</artifactId>
-            <scope>test</scope>
-            <version>0.8</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>rdf.ontologies</artifactId>
-            <scope>test</scope>
-            <version>0.12</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java b/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java
deleted file mode 100644
index f4ec8df..0000000
--- a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java
+++ /dev/null
@@ -1,54 +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.jena.sparql;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.query.QuerySolution;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import java.util.HashMap;
-import java.util.Iterator;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import org.apache.clerezza.rdf.jena.commons.Jena2TriaUtil;
-
-/**
- *
- * @author rbn
- */
-class HashMapSolutionMapping extends HashMap<Variable, Resource> implements SolutionMapping {
-
-    transient Jena2TriaUtil convertor = new Jena2TriaUtil(new HashMap<Node,BNode>());
-    public HashMapSolutionMapping(QuerySolution querySolution) {
-        final Iterator<String> varNames = querySolution.varNames();
-        while (varNames.hasNext()) {
-            final String varName = varNames.next();
-            put(new Variable(varName), toResource(querySolution.get(varName)));
-        }
-    }
-    @Override
-    public Resource get(String name) {
-        return get(new Variable(name));
-    }
-
-    private Resource toResource(RDFNode node) {
-        return convertor.convertJenaNode2Resource(node.asNode());
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java b/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java
deleted file mode 100644
index 71a58ac..0000000
--- a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java
+++ /dev/null
@@ -1,163 +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.jena.sparql;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.sparql.QueryEngine;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.apache.clerezza.rdf.jena.storage.JenaGraphAdaptor;
-
-import com.hp.hpl.jena.query.Dataset;
-import com.hp.hpl.jena.query.DatasetFactory;
-import com.hp.hpl.jena.query.QueryException;
-import com.hp.hpl.jena.query.QueryExecException;
-import com.hp.hpl.jena.query.QueryExecution;
-import com.hp.hpl.jena.query.QueryExecutionFactory;
-import com.hp.hpl.jena.query.QueryFactory;
-import com.hp.hpl.jena.sparql.core.DatasetDescription;
-import com.hp.hpl.jena.sparql.core.DatasetGraph;
-import com.hp.hpl.jena.sparql.core.DynamicDatasets;
-import com.hp.hpl.jena.update.GraphStore;
-import com.hp.hpl.jena.update.GraphStoreFactory;
-import com.hp.hpl.jena.update.UpdateAction;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.locks.Lock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
-import org.apache.clerezza.rdf.core.sparql.ParseException;
-import org.apache.clerezza.rdf.core.sparql.SparqlPreParser;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
-
-
-@Component
-@Service(QueryEngine.class)
-public class JenaSparqlEngine implements QueryEngine {
-
-    // ------------------------------------------------------------------------
-    // Implementing QueryEngine
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Object execute(TcManager tcManager, TripleCollection defaultGraph,
-            final Query query) {
-        return execute(tcManager, defaultGraph, query.toString());
-    }
-
-    @Override
-    public Object execute(TcManager tcManager, TripleCollection defaultGraph,
-            final String query) {
-        final SparqlPreParser sparqlPreParser = new SparqlPreParser(tcManager);
-        final UriRef defaultGraphName = new UriRef("http://fake-default.uri/879872");
-        Set<UriRef> referencedGraphs;
-        try {
-            referencedGraphs = sparqlPreParser.getReferredGraphs(query, defaultGraphName);
-        } catch (ParseException ex) {
-            throw new RuntimeException(ex);
-        }
-        Set<UriRef> graphsToLock = referencedGraphs != null ? referencedGraphs : tcManager.listTripleCollections();
-        List<Lock> locks = new ArrayList<Lock>(graphsToLock.size());
-        for (UriRef uriRef : graphsToLock) {
-            TripleCollection tc;
-            if (uriRef.equals(defaultGraphName)) {
-                tc = defaultGraph;
-            } else {
-                tc = tcManager.getTriples(uriRef);
-            }
-            if (tc instanceof LockableMGraph) {
-                locks.add(((LockableMGraph) tc).getLock().readLock());
-            }
-        }
-        for (Lock lock : locks) {
-            lock.lock();
-        }
-        try {
-            final DatasetGraph datasetGraph = new TcDatasetGraph(tcManager, defaultGraph);
-            final Dataset dataset = DatasetFactory.create(datasetGraph);
-
-            // Missing permission (java.lang.RuntimePermission getClassLoader)
-            // when calling QueryFactory.create causes ExceptionInInitializerError
-            // to be thrown.
-            // QueryExecutionFactory.create requires
-            // (java.io.FilePermission [etc/]location-mapping.* read)
-            // Thus, they are placed within doPrivileged
-            QueryExecution qexec = AccessController
-                    .doPrivileged(new PrivilegedAction<QueryExecution>() {
-
-                        @Override
-                        public QueryExecution run() {
-                            try {
-                                com.hp.hpl.jena.query.Query jenaQuery = QueryFactory
-                                        .create(query);
-                                if (jenaQuery.isUnknownType()) {
-                                    return null;
-                                }
-                                DatasetDescription dd = DatasetDescription.create(jenaQuery);
-                                Dataset dynaDataset = DynamicDatasets.dynamicDataset(dd, dataset, false);
-                                return QueryExecutionFactory.create(jenaQuery, dynaDataset);
-                            } catch (QueryException ex) {
-                                return null;
-                            }
-
-                        }
-                    });
-            if (qexec == null) {
-                return executeUpdate(dataset, query);
-            }
-            //TODO check with rather than trial and error: if (qexec.getQuery().isSelectType()) {
-            try {
-                try {
-                    return new ResultSetWrapper(qexec.execSelect());
-                } catch (QueryExecException e) {
-                    try {
-                        return Boolean.valueOf(qexec.execAsk());
-                    } catch (QueryExecException e2) {
-                        try {
-                            return new JenaGraphAdaptor(qexec.execDescribe()
-                                    .getGraph()).getGraph();
-                        } catch (QueryExecException e3) {
-                            return new JenaGraphAdaptor(qexec.execConstruct()
-                                    .getGraph()).getGraph();
-                        }
-                    }
-                }
-            } finally {
-                qexec.close();
-            }
-        } finally {
-            for (Lock lock : locks) {
-                lock.unlock();
-            }
-        }
-    }
-
-    private Object executeUpdate(Dataset dataset, String query) {
-        GraphStore graphStore = GraphStoreFactory.create(dataset) ;
-        UpdateAction.parseExecute(query, graphStore) ;
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java b/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java
deleted file mode 100644
index 8da8600..0000000
--- a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.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.jena.sparql;
-
-import com.hp.hpl.jena.query.QuerySolution;
-import com.hp.hpl.jena.query.ResultSet;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
-
-/**
- *
- * @author rbn
- */
-public class ResultSetWrapper implements org.apache.clerezza.rdf.core.sparql.ResultSet {
-
-    private final Iterator<QuerySolution> solutionsIter;
-    private final List<String> resultVars;
-
-
-    public ResultSetWrapper(final ResultSet jenaResultSet) {
-        final List<QuerySolution> solutions = new ArrayList<QuerySolution>();
-        while (jenaResultSet.hasNext()) {
-            solutions.add(jenaResultSet.nextSolution());
-        }
-        solutionsIter = solutions.iterator();
-        resultVars = jenaResultSet.getResultVars();
-    }
-
-    @Override
-    public boolean hasNext() {
-        return solutionsIter.hasNext();
-    }
-
-    @Override
-    public SolutionMapping next() {
-        return new HashMapSolutionMapping(solutionsIter.next());
-    }
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public List<String> getResultVars() {
-    	return resultVars;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java b/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java
deleted file mode 100644
index 1f085cb..0000000
--- a/rdf.jena.sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java
+++ /dev/null
@@ -1,193 +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.jena.sparql;
-
-import com.hp.hpl.jena.graph.Graph;
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Node_URI;
-import com.hp.hpl.jena.shared.Lock;
-import com.hp.hpl.jena.sparql.core.DatasetGraph;
-import com.hp.hpl.jena.sparql.core.Quad;
-import com.hp.hpl.jena.sparql.util.Context;
-import java.util.Iterator;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.jena.facade.JenaGraph;
-
-/**
- *
- * @author rbn
- */
-class TcDatasetGraph implements DatasetGraph {
-
-    private TcManager tcManager;
-    private TripleCollection defaultGraph;
-
-    TcDatasetGraph(TcManager tcManager, TripleCollection defaultGraph) {
-        this.tcManager = tcManager;
-        this.defaultGraph = defaultGraph;
-    
-    }
-
-    @Override
-    public Graph getDefaultGraph() {
-        final JenaGraph jenaGraph = new JenaGraph(defaultGraph);
-        return jenaGraph;
-    }
-
-    @Override
-    public Graph getGraph(Node node) {
-        final JenaGraph jenaGraph = new JenaGraph(
-                tcManager.getTriples(new UriRef(node.getURI())));
-        return jenaGraph;
-    }
-
-    @Override
-    public boolean containsGraph(Node node) {
-        try {
-            tcManager.getTriples(new UriRef(node.getURI()));
-            return true;
-        } catch (NoSuchEntityException e) {
-            return false;
-        }
-    }
-
-    @Override
-    public Iterator<Node> listGraphNodes() {
-        final Iterator<UriRef> graphsIter = tcManager.listTripleCollections().iterator();
-        return new Iterator<Node>() {
-
-            @Override
-            public boolean hasNext() {
-                return graphsIter.hasNext();
-            }
-
-            @Override
-            public Node next() {
-                UriRef uriRef = graphsIter.next();
-                if (uriRef == null) {
-                    return null;
-                }
-                return new Node_URI(uriRef.getUnicodeString()) {};
-            }
-
-            @Override
-            public void remove() {
-                throw new UnsupportedOperationException("Not supported yet.");
-            }
-
-        };
-    }
-
-    @Override
-    public Lock getLock() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public long size() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void close() {
-    }
-
-    @Override
-    public Context getContext() {
-        return null;
-    }
-
-    @Override
-    public boolean isEmpty() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void add(Quad quad) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void addGraph(Node graphName, Graph graph) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public boolean contains(Node g, Node s, Node p, Node o) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public boolean contains(Quad quad) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void delete(Quad quad) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void deleteAny(Node g, Node s, Node p, Node o) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Iterator<Quad> find(Quad quad) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Iterator<Quad> find(Node g, Node s, Node p, Node o) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void removeGraph(Node graphName) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setDefaultGraph(Graph g) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Iterator<Quad> find() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Iterator<Quad> findNG(Node node, Node node1, Node node2, Node node3) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-	
-	@Override
-	public void add( Node g, Node s, Node p, Node o ) {
-        throw new UnsupportedOperationException("Not supported yet.");
-	}
-	
-	@Override
-	public void delete( Node g, Node s, Node p, Node o ) {
-        throw new UnsupportedOperationException("Not supported yet.");
-	}
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine b/rdf.jena.sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine
deleted file mode 100644
index a370093..0000000
--- a/rdf.jena.sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.clerezza.rdf.jena.sparql.JenaSparqlEngine
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf.jena.sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java
----------------------------------------------------------------------
diff --git a/rdf.jena.sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java b/rdf.jena.sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java
deleted file mode 100644
index a81e05d..0000000
--- a/rdf.jena.sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java
+++ /dev/null
@@ -1,149 +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.jena.sparql;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.core.sparql.ParseException;
-import org.apache.clerezza.rdf.core.sparql.QueryParser;
-import org.apache.clerezza.rdf.core.sparql.ResultSet;
-import org.apache.clerezza.rdf.ontologies.DC;
-
-/**
- * 
- * @author rbn
- */
-public class SimpleTest {
-
-	@Test
-	public void simpleStringQuery() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-		String query = "SELECT ?title WHERE" + "{"
-				+ "    <http://example.org/book/book1> <"
-				+ DC.title.getUnicodeString() + "> ?title ." + "}";
-		ResultSet resultSet = (ResultSet) TcManager.getInstance()
-				.executeSparqlQuery(query, data);
-		Assert.assertEquals(titleValue, ((Literal) resultSet.next()
-				.get("title")).getLexicalForm());
-
-		List<String> columnNames = resultSet.getResultVars();
-		Assert.assertEquals(columnNames.size(), 1);
-		Assert.assertEquals(columnNames.get(0), "title");
-	}
-
-	@Test
-	public void simpleSelectQuery() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-		String query = "SELECT ?title WHERE" + "{"
-				+ "    <http://example.org/book/book1> <"
-				+ DC.title.getUnicodeString() + "> ?title ." + "}";
-		ResultSet resultSet = (ResultSet) TcManager.getInstance()
-				.executeSparqlQuery(QueryParser.getInstance().parse(query),
-						data);
-		Assert.assertEquals(titleValue, ((Literal) resultSet.next()
-				.get("title")).getLexicalForm());
-	}
-
-	@Test
-	public void simpleAskQuery() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-		String query = "ASK WHERE" + "{"
-				+ "    <http://example.org/book/book1> <"
-				+ DC.title.getUnicodeString() + "> ?title ." + "}";
-		Assert.assertEquals(
-				Boolean.TRUE,
-				TcManager.getInstance().executeSparqlQuery(
-						QueryParser.getInstance().parse(query), data));
-	}
-
-	/* Uncommented due to problem with resolution of CLEREZZA-761
-          
-         @Test
-	public void simpleDescribe() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-		String query = "DESCRIBE " + "    <http://example.org/book/book1>";
-		Assert.assertEquals(
-				1,
-				((Graph) TcManager.getInstance().executeSparqlQuery(
-						QueryParser.getInstance().parse(query), data)).size());
-	}*/
-
-	@Test
-	public void simpleConstruct() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-		String query = "PREFIX foaf:   <http://xmlns.com/foaf/0.1/> "
-				+ "CONSTRUCT { <http://foo/bar> foaf:name ?title } WHERE" + "{"
-				+ "    <http://example.org/book/book1> <"
-				+ DC.title.getUnicodeString() + "> ?title ." + "}";
-		Assert.assertEquals(
-				1,
-				((Graph) TcManager.getInstance().executeSparqlQuery(
-						QueryParser.getInstance().parse(query), data)).size());
-	}
-    
-    /* Currently fails because of Preparser not yet supporting this type of queries
-    @Test
-	public void simpleInsert() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-        
-		String query = "PREFIX foaf:   <http://xmlns.com/foaf/0.1/> "
-				+ "INSERT DATA { <http://foo/bar> foaf:name 'Fred'}";
-        TcManager.getInstance().executeSparqlQuery(query, data);
-		Assert.assertEquals("Not having the right number of triples after insert",2,data.size());
-	}*/
-    
-    @Test
-	public void simpleDrop() throws ParseException {
-		SimpleMGraph data = new SimpleMGraph();
-		final String titleValue = "SPARQL Tutorial";
-		data.add(new TripleImpl(new UriRef("http://example.org/book/book1"),
-				DC.title, new PlainLiteralImpl(titleValue)));
-        
-		String query = "DROP ALL";
-        TcManager.getInstance().executeSparqlQuery(query, data);
-		Assert.assertEquals("GRAPH not empty after DROP ALL",0,data.size());
-	}
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/jena/pom.xml b/rdf/jena/pom.xml
index 8eb1756..e0d7b97 100644
--- a/rdf/jena/pom.xml
+++ b/rdf/jena/pom.xml
@@ -48,6 +48,7 @@
         <module>parser</module>
         <module>serializer</module>
         <module>storage</module>
+        <module>sparql</module>
     </modules>
 
 </project>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/LICENSE
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/LICENSE b/rdf/jena/sparql/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/rdf/jena/sparql/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/nbactions.xml
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/nbactions.xml b/rdf/jena/sparql/nbactions.xml
new file mode 100644
index 0000000..49e8307
--- /dev/null
+++ b/rdf/jena/sparql/nbactions.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+    <action>
+        <actionName>CUSTOM-deploy to localhost:8080</actionName>
+        <displayName>deploy to localhost:8080</displayName>
+        <goals>
+            <goal>install</goal>
+            <goal>org.apache.sling:maven-sling-plugin:install</goal>
+        </goals>
+    </action>
+</actions>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/pom.xml b/rdf/jena/sparql/pom.xml
new file mode 100644
index 0000000..cf0b4a3
--- /dev/null
+++ b/rdf/jena/sparql/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+ 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.
+
+-->
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>clerezza</artifactId>
+        <groupId>org.apache.clerezza</groupId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath />
+    </parent>
+    <groupId>org.apache.clerezza</groupId>
+    <artifactId>rdf.jena.sparql</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>Clerezza - SCB Jena SPARQL engine</name>
+    <description>Allows executing SPARQL queries on SCB using the jena sparql engine.</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.core</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.jena.storage</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.jena.facade</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jena</groupId>
+            <artifactId>jena-arq</artifactId>
+            <version>2.11.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.simple.storage</artifactId>
+            <scope>test</scope>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.ontologies</artifactId>
+            <scope>test</scope>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java
new file mode 100644
index 0000000..a8c83c3
--- /dev/null
+++ b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/HashMapSolutionMapping.java
@@ -0,0 +1,54 @@
+/*
+ * 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.jena.sparql;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import java.util.HashMap;
+import java.util.Iterator;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
+import org.apache.clerezza.rdf.core.sparql.query.Variable;
+import org.apache.clerezza.rdf.jena.commons.Jena2TriaUtil;
+
+/**
+ *
+ * @author rbn
+ */
+class HashMapSolutionMapping extends HashMap<Variable, RdfTerm> implements SolutionMapping {
+
+    transient Jena2TriaUtil convertor = new Jena2TriaUtil(new HashMap<Node,BlankNode>());
+    public HashMapSolutionMapping(QuerySolution querySolution) {
+        final Iterator<String> varNames = querySolution.varNames();
+        while (varNames.hasNext()) {
+            final String varName = varNames.next();
+            put(new Variable(varName), toRdfTerm(querySolution.get(varName)));
+        }
+    }
+    @Override
+    public RdfTerm get(String name) {
+        return get(new Variable(name));
+    }
+
+    private RdfTerm toRdfTerm(RDFNode node) {
+        return convertor.convertJenaNode2Resource(node.asNode());
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java
new file mode 100644
index 0000000..940b963
--- /dev/null
+++ b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/JenaSparqlEngine.java
@@ -0,0 +1,157 @@
+/*
+ * 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.jena.sparql;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.sparql.QueryEngine;
+import org.apache.clerezza.rdf.core.sparql.query.Query;
+import org.apache.clerezza.rdf.jena.storage.JenaGraphAdaptor;
+
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.DatasetFactory;
+import com.hp.hpl.jena.query.QueryException;
+import com.hp.hpl.jena.query.QueryExecException;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.sparql.core.DatasetDescription;
+import com.hp.hpl.jena.sparql.core.DatasetGraph;
+import com.hp.hpl.jena.sparql.core.DynamicDatasets;
+import com.hp.hpl.jena.update.GraphStore;
+import com.hp.hpl.jena.update.GraphStoreFactory;
+import com.hp.hpl.jena.update.UpdateAction;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.locks.Lock;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.sparql.ParseException;
+import org.apache.clerezza.rdf.core.sparql.SparqlPreParser;
+import org.apache.commons.rdf.Graph;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+
+@Component
+@Service(QueryEngine.class)
+public class JenaSparqlEngine implements QueryEngine {
+
+    // ------------------------------------------------------------------------
+    // Implementing QueryEngine
+    // ------------------------------------------------------------------------
+    @Override
+    public Object execute(TcManager tcManager, Graph defaultGraph,
+            final Query query) {
+        return execute(tcManager, defaultGraph, query.toString());
+    }
+
+    @Override
+    public Object execute(TcManager tcManager, Graph defaultGraph,
+            final String query) {
+        final SparqlPreParser sparqlPreParser = new SparqlPreParser(tcManager);
+        final Iri defaultGraphName = new Iri("http://fake-default.uri/879872");
+        Set<Iri> referencedGraphs;
+        try {
+            referencedGraphs = sparqlPreParser.getReferredGraphs(query, defaultGraphName);
+        } catch (ParseException ex) {
+            throw new RuntimeException(ex);
+        }
+        Set<Iri> graphsToLock = referencedGraphs != null ? referencedGraphs : tcManager.listGraphs();
+        final DatasetGraph datasetGraph = new TcDatasetGraph(tcManager, defaultGraph);
+        final Dataset dataset = DatasetFactory.create(datasetGraph);
+
+            // Missing permission (java.lang.RuntimePermission getClassLoader)
+        // when calling QueryFactory.create causes ExceptionInInitializerError
+        // to be thrown.
+        // QueryExecutionFactory.create requires
+        // (java.io.FilePermission [etc/]location-mapping.* read)
+        // Thus, they are placed within doPrivileged
+        QueryExecution qexec = AccessController
+                .doPrivileged(new PrivilegedAction<QueryExecution>() {
+
+                    @Override
+                    public QueryExecution run() {
+                        try {
+                            com.hp.hpl.jena.query.Query jenaQuery = QueryFactory
+                            .create(query);
+                            if (jenaQuery.isUnknownType()) {
+                                return null;
+                            }
+                            DatasetDescription dd = DatasetDescription.create(jenaQuery);
+                            Dataset dynaDataset = DynamicDatasets.dynamicDataset(dd, dataset, false);
+                            return QueryExecutionFactory.create(jenaQuery, dynaDataset);
+                        } catch (QueryException ex) {
+                            return null;
+                        }
+
+                    }
+                });
+        if (qexec == null) {
+            return executeUpdate(dataset, query);
+        }
+        List<Lock> locks = new ArrayList<Lock>(graphsToLock.size());
+        for (Iri uriRef : graphsToLock) {
+            Graph tc;
+            if (uriRef.equals(defaultGraphName)) {
+                tc = defaultGraph;
+            } else {
+                tc = tcManager.getGraph(uriRef);
+            }
+            locks.add(tc.getLock().readLock());
+        }
+        for (Lock lock : locks) {
+            lock.lock();
+        }
+        try {
+
+            //TODO check with rather than trial and error: if (qexec.getQuery().isSelectType()) {
+            try {
+                try {
+                    return new ResultSetWrapper(qexec.execSelect());
+                } catch (QueryExecException e) {
+                    try {
+                        return Boolean.valueOf(qexec.execAsk());
+                    } catch (QueryExecException e2) {
+                        try {
+                            return new JenaGraphAdaptor(qexec.execDescribe()
+                                    .getGraph()).getImmutableGraph();
+                        } catch (QueryExecException e3) {
+                            return new JenaGraphAdaptor(qexec.execConstruct()
+                                    .getGraph()).getImmutableGraph();
+                        }
+                    }
+                }
+            } finally {
+                qexec.close();
+            }
+        } finally {
+            for (Lock lock : locks) {
+                lock.unlock();
+            }
+        }
+    }
+
+    private Object executeUpdate(Dataset dataset, String query) {
+        GraphStore graphStore = GraphStoreFactory.create(dataset);
+        UpdateAction.parseExecute(query, graphStore);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java
new file mode 100644
index 0000000..8da8600
--- /dev/null
+++ b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/ResultSetWrapper.java
@@ -0,0 +1,66 @@
+/*
+ * 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.jena.sparql;
+
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
+
+/**
+ *
+ * @author rbn
+ */
+public class ResultSetWrapper implements org.apache.clerezza.rdf.core.sparql.ResultSet {
+
+    private final Iterator<QuerySolution> solutionsIter;
+    private final List<String> resultVars;
+
+
+    public ResultSetWrapper(final ResultSet jenaResultSet) {
+        final List<QuerySolution> solutions = new ArrayList<QuerySolution>();
+        while (jenaResultSet.hasNext()) {
+            solutions.add(jenaResultSet.nextSolution());
+        }
+        solutionsIter = solutions.iterator();
+        resultVars = jenaResultSet.getResultVars();
+    }
+
+    @Override
+    public boolean hasNext() {
+        return solutionsIter.hasNext();
+    }
+
+    @Override
+    public SolutionMapping next() {
+        return new HashMapSolutionMapping(solutionsIter.next());
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public List<String> getResultVars() {
+    	return resultVars;
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java
new file mode 100644
index 0000000..9fe0cc8
--- /dev/null
+++ b/rdf/jena/sparql/src/main/java/org/apache/clerezza/rdf/jena/sparql/TcDatasetGraph.java
@@ -0,0 +1,192 @@
+/*
+ * 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.jena.sparql;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Node_URI;
+import com.hp.hpl.jena.shared.Lock;
+import com.hp.hpl.jena.sparql.core.DatasetGraph;
+import com.hp.hpl.jena.sparql.core.Quad;
+import com.hp.hpl.jena.sparql.util.Context;
+import java.util.Iterator;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.jena.facade.JenaGraph;
+
+/**
+ *
+ * @author rbn
+ */
+class TcDatasetGraph implements DatasetGraph {
+
+    private TcManager tcManager;
+    private Graph defaultGraph;
+
+    TcDatasetGraph(TcManager tcManager, Graph defaultGraph) {
+        this.tcManager = tcManager;
+        this.defaultGraph = defaultGraph;
+    
+    }
+
+    @Override
+    public com.hp.hpl.jena.graph.Graph getDefaultGraph() {
+        final JenaGraph jenaGraph = new JenaGraph(defaultGraph);
+        return jenaGraph;
+    }
+
+    @Override
+    public com.hp.hpl.jena.graph.Graph getGraph(Node node) {
+        final JenaGraph jenaGraph = new JenaGraph(
+                tcManager.getGraph(new Iri(node.getURI())));
+        return jenaGraph;
+    }
+
+    @Override
+    public boolean containsGraph(Node node) {
+        try {
+            tcManager.getGraph(new Iri(node.getURI()));
+            return true;
+        } catch (NoSuchEntityException e) {
+            return false;
+        }
+    }
+
+    @Override
+    public Iterator<Node> listGraphNodes() {
+        final Iterator<Iri> graphsIter = tcManager.listGraphs().iterator();
+        return new Iterator<Node>() {
+
+            @Override
+            public boolean hasNext() {
+                return graphsIter.hasNext();
+            }
+
+            @Override
+            public Node next() {
+                Iri uriRef = graphsIter.next();
+                if (uriRef == null) {
+                    return null;
+                }
+                return new Node_URI(uriRef.getUnicodeString()) {};
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+        };
+    }
+
+    @Override
+    public Lock getLock() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public long size() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void close() {
+    }
+
+    @Override
+    public Context getContext() {
+        return null;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void add(Quad quad) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void addGraph(Node graphName, com.hp.hpl.jena.graph.Graph graph) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean contains(Node g, Node s, Node p, Node o) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean contains(Quad quad) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void delete(Quad quad) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void deleteAny(Node g, Node s, Node p, Node o) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Iterator<Quad> find(Quad quad) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Iterator<Quad> find(Node g, Node s, Node p, Node o) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void removeGraph(Node graphName) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setDefaultGraph(com.hp.hpl.jena.graph.Graph g) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Iterator<Quad> find() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Iterator<Quad> findNG(Node node, Node node1, Node node2, Node node3) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+	
+	@Override
+	public void add( Node g, Node s, Node p, Node o ) {
+        throw new UnsupportedOperationException("Not supported yet.");
+	}
+	
+	@Override
+	public void delete( Node g, Node s, Node p, Node o ) {
+        throw new UnsupportedOperationException("Not supported yet.");
+	}
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine b/rdf/jena/sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine
new file mode 100644
index 0000000..a370093
--- /dev/null
+++ b/rdf/jena/sparql/src/main/resources/META-INF/services/org.apache.clerezza.rdf.core.sparql.QueryEngine
@@ -0,0 +1 @@
+org.apache.clerezza.rdf.jena.sparql.JenaSparqlEngine
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/39b02c14/rdf/jena/sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java
----------------------------------------------------------------------
diff --git a/rdf/jena/sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java b/rdf/jena/sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java
new file mode 100644
index 0000000..8fabc4e
--- /dev/null
+++ b/rdf/jena/sparql/src/test/java/org/apache/clerezza/rdf/jena/sparql/SimpleTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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.jena.sparql;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.rdf.core.sparql.ParseException;
+import org.apache.clerezza.rdf.core.sparql.QueryParser;
+import org.apache.clerezza.rdf.core.sparql.ResultSet;
+import org.apache.clerezza.rdf.ontologies.DC;
+
+/**
+ * 
+ * @author rbn
+ */
+public class SimpleTest {
+
+	@Test
+	public void simpleStringQuery() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+		String query = "SELECT ?title WHERE" + "{"
+				+ "    <http://example.org/book/book1> <"
+				+ DC.title.getUnicodeString() + "> ?title ." + "}";
+		ResultSet resultSet = (ResultSet) TcManager.getInstance()
+				.executeSparqlQuery(query, data);
+		Assert.assertEquals(titleValue, ((Literal) resultSet.next()
+				.get("title")).getLexicalForm());
+
+		List<String> columnNames = resultSet.getResultVars();
+		Assert.assertEquals(columnNames.size(), 1);
+		Assert.assertEquals(columnNames.get(0), "title");
+	}
+
+	@Test
+	public void simpleSelectQuery() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+		String query = "SELECT ?title WHERE" + "{"
+				+ "    <http://example.org/book/book1> <"
+				+ DC.title.getUnicodeString() + "> ?title ." + "}";
+		ResultSet resultSet = (ResultSet) TcManager.getInstance()
+				.executeSparqlQuery(QueryParser.getInstance().parse(query),
+						data);
+		Assert.assertEquals(titleValue, ((Literal) resultSet.next()
+				.get("title")).getLexicalForm());
+	}
+
+	@Test
+	public void simpleAskQuery() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+		String query = "ASK WHERE" + "{"
+				+ "    <http://example.org/book/book1> <"
+				+ DC.title.getUnicodeString() + "> ?title ." + "}";
+		Assert.assertEquals(
+				Boolean.TRUE,
+				TcManager.getInstance().executeSparqlQuery(
+						QueryParser.getInstance().parse(query), data));
+	}
+
+	/* Uncommented due to problem with resolution of CLEREZZA-761
+          
+         @Test
+	public void simpleDescribe() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+		String query = "DESCRIBE " + "    <http://example.org/book/book1>";
+		Assert.assertEquals(
+				1,
+				((ImmutableGraph) TcManager.getInstance().executeSparqlQuery(
+						QueryParser.getInstance().parse(query), data)).size());
+	}*/
+
+	@Test
+	public void simpleConstruct() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+		String query = "PREFIX foaf:   <http://xmlns.com/foaf/0.1/> "
+				+ "CONSTRUCT { <http://foo/bar> foaf:name ?title } WHERE" + "{"
+				+ "    <http://example.org/book/book1> <"
+				+ DC.title.getUnicodeString() + "> ?title ." + "}";
+		Assert.assertEquals(
+				1,
+				((ImmutableGraph) TcManager.getInstance().executeSparqlQuery(
+						QueryParser.getInstance().parse(query), data)).size());
+	}
+    
+    /* Currently fails because of Preparser not yet supporting this type of queries
+    @Test
+	public void simpleInsert() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+        
+		String query = "PREFIX foaf:   <http://xmlns.com/foaf/0.1/> "
+				+ "INSERT DATA { <http://foo/bar> foaf:name 'Fred'}";
+        TcManager.getInstance().executeSparqlQuery(query, data);
+		Assert.assertEquals("Not having the right number of triples after insert",2,data.size());
+	}*/
+    
+    @Test
+	public void simpleDrop() throws ParseException {
+		SimpleGraph data = new SimpleGraph();
+		final String titleValue = "SPARQL Tutorial";
+		data.add(new TripleImpl(new Iri("http://example.org/book/book1"),
+				DC.title, new PlainLiteralImpl(titleValue)));
+        
+		String query = "DROP ALL";
+        TcManager.getInstance().executeSparqlQuery(query, data);
+		Assert.assertEquals("GRAPH not empty after DROP ALL",0,data.size());
+	}
+}


Mime
View raw message