Author: ivol37 at gmail.com
Date: Tue Dec 28 15:09:10 2010
New Revision: 549
Log:
[AMDATU-183] Added RDF2GO API bundle. Deprecated
SesameService.executeSPARQLQuery and replaced use of this API with RDF2GO API
invocations. Added a simple integration test to test the working of the Sesame
application accessed by the RDF2GO API. Still to do:
- Refactor SesameService.getModelSet invocations to use service dependencies to
let the ModelSet injected such that bundles using the RDF2GO API do no longer
need to depend on the Sesame implementation
- Deprecate and refactor invocations of all methods on SesameService
Added:
trunk/amdatu-semanticweb/rdf2go-api/
trunk/amdatu-semanticweb/rdf2go-api/pom.xml
trunk/amdatu-semanticweb/rdf2go-sesamebridge/
trunk/amdatu-semanticweb/rdf2go-sesamebridge/pom.xml
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/RDF2GOTest.java
Modified:
trunk/amdatu-example/course-service/pom.xml
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseOntologyDataProvider.java
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseServiceImpl.java
trunk/amdatu-release/pom.xml
trunk/amdatu-semanticweb/pom.xml
trunk/amdatu-semanticweb/sesame/pom.xml
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/SesameService.java
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/osgi/Activator.java
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/service/SesameServiceImpl.java
trunk/amdatu-semanticweb/sparqlendpoint/pom.xml
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
trunk/integration-tests/pom.xml
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
trunk/pom.xml
trunk/src/main/resources/conf/felix-config.properties
Modified: trunk/amdatu-example/course-service/pom.xml
==============================================================================
--- trunk/amdatu-example/course-service/pom.xml (original)
+++ trunk/amdatu-example/course-service/pom.xml Tue Dec 28 15:09:10 2010
@@ -58,7 +58,13 @@
<artifactId>sesame</artifactId>
<scope>provided</scope>
<type>bundle</type>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Modified:
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseOntologyDataProvider.java
==============================================================================
---
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseOntologyDataProvider.java
(original)
+++
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseOntologyDataProvider.java
Tue Dec 28 15:09:10 2010
@@ -25,16 +25,18 @@
import java.util.List;
import java.util.Map;
-import org.amdatu.example.course.service.CourseService;
import org.amdatu.core.config.templates.ConfigTemplateManager;
-import org.amdatu.semanticweb.sesame.SPARQLQueryHandler;
+import org.amdatu.example.course.service.CourseService;
import org.amdatu.semanticweb.sesame.SesameService;
+import org.ontoware.aifbcommons.collection.ClosableIterator;
+import org.ontoware.rdf2go.model.Model;
+import org.ontoware.rdf2go.model.ModelSet;
+import org.ontoware.rdf2go.model.QueryResultTable;
+import org.ontoware.rdf2go.model.QueryRow;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.model.vocabulary.RDF;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.query.TupleQueryResult;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.osgi.framework.BundleContext;
@@ -58,8 +60,8 @@
// The list of all course names available for all educations
private static final String[] COURSE_NAMES =
- new String[]{"Mathematics A", "Mathematics B", "Physics",
"Biology", "History", "Geography", "Chemistry",
- "Dutch", "English", "French", "German"};
+ new String[]{"Mathematics A", "Mathematics B", "Physics", "Biology",
"History", "Geography", "Chemistry",
+ "Dutch", "English", "French", "German"};
// Used services
private SesameService m_sesameService;
@@ -90,13 +92,13 @@
rdfsUrl =
m_configTemplateManager.getConfigurationAsURL(rdfsUrl);
} catch (IOException e) {
m_logService.log(LogService.LOG_ERROR, "Could not replace
configuration entries in url '" + rdfsUrl
- + "'");
+ + "'");
}
try {
rdfUrl =
m_configTemplateManager.getConfigurationAsURL(rdfUrl);
} catch (IOException e) {
m_logService.log(LogService.LOG_ERROR, "Could not replace
configuration entries in url '" + rdfUrl
- + "'");
+ + "'");
}
m_sesameService.importRDFFile(rdfsUrl);
@@ -132,7 +134,7 @@
// Loop over all course names and create a Course for each grade
and education
m_logService.log(LogService.LOG_DEBUG, "Adding " +
COURSE_NAMES.length * grades.size() * educations.size()
- + " courses");
+ + " courses");
long currentTimeInMs = System.currentTimeMillis();
int count = 0;
int batchSize = grades.size() * educations.size();
@@ -164,7 +166,7 @@
long diff = System.currentTimeMillis() - currentTimeInMs;
currentTimeInMs = System.currentTimeMillis();
m_logService.log(LogService.LOG_DEBUG, batchSize + " courses
(" + count * batchSize + " of "
- + totalSize + ") added in " + diff + " ms");
+ + totalSize + ") added in " + diff + " ms");
}
} catch (IOException e) {
m_logService.log(LogService.LOG_ERROR, "Failed to store Courses in
RDF database", e);
@@ -190,17 +192,17 @@
private boolean ontologyDataExists() throws IOException {
String baseUrl = m_courseService.getOntologyBaseUrl();
String queryString = "SELECT ?subject WHERE { ?subject a <" + baseUrl
+ EDUCA_ONTOLOGY_PERSON_URI + ">}";
- return m_sesameService.executeSPARQLQuery(queryString, new
SPARQLQueryHandler<Boolean>() {
- public Boolean handleResult(TupleQueryResult result) {
- try {
- if (result.hasNext()) {
- return Boolean.TRUE;
- }
- } catch (QueryEvaluationException e) {
- m_logService.log(LogService.LOG_ERROR, "Failed to handle
results of SPARQL query", e);
- }
- return Boolean.FALSE;
+ ModelSet modelSet = m_sesameService.getModelSet();
+ Model model = modelSet.getDefaultModel();
+ QueryResultTable result = model.sparqlSelect(queryString);
+ ClosableIterator<QueryRow> iterator = result.iterator();
+ try {
+ if (iterator.hasNext()) {
+ return Boolean.TRUE;
}
- });
+ } finally {
+ iterator.close();
+ }
+ return Boolean.FALSE;
}
}
Modified:
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseServiceImpl.java
==============================================================================
---
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseServiceImpl.java
(original)
+++
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseServiceImpl.java
Tue Dec 28 15:09:10 2010
@@ -22,12 +22,13 @@
import org.amdatu.example.course.service.Course;
import org.amdatu.example.course.service.CourseService;
-import org.amdatu.semanticweb.sesame.SPARQLQueryHandler;
import org.amdatu.semanticweb.sesame.SesameService;
import org.apache.shindig.social.opensocial.model.Person;
-import org.openrdf.query.BindingSet;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.query.TupleQueryResult;
+import org.ontoware.aifbcommons.collection.ClosableIterator;
+import org.ontoware.rdf2go.model.Model;
+import org.ontoware.rdf2go.model.ModelSet;
+import org.ontoware.rdf2go.model.QueryResultTable;
+import org.ontoware.rdf2go.model.QueryRow;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.log.LogService;
@@ -43,12 +44,12 @@
private volatile LogService m_logService;
private volatile SesameService m_sesameService;
private volatile ConfigurationAdmin m_configAdmin;
-
+
/**
* Returns the list of available courses.
*/
public List<Course> getAvailableCourses(Person person) throws IOException {
- // -1- Retrieve the courses available for the current grade and
education of the Student
+ // -1- Retrieve the courses available for the current grade and
education of the Student
// which matches the specified profile id
String personId = person.getId();
String baseUrl = getOntologyBaseUrl();
@@ -65,31 +66,28 @@
" ?subject educa:grade ?grade . " +
" ?subject educa:education ?education . " +
" ?grade educa:name ?gradename . " +
- " ?education educa:name ?educationname " +
+ " ?education educa:name ?educationname " +
"}";
- ArrayList<Course> courses =
- m_sesameService.executeSPARQLQuery(sparqlQuery, new
SPARQLQueryHandler<ArrayList<Course>>() {
- ArrayList<Course> courseList = new ArrayList<Course>();
- public ArrayList<Course> handleResult(TupleQueryResult result)
{
- try {
- while (result.hasNext()) {
- BindingSet bs = result.next();
- String course =
bs.getBinding("coursename").getValue().stringValue();
- String grade =
bs.getBinding("gradename").getValue().stringValue();
- String education =
bs.getBinding("educationname").getValue().stringValue();
- Course c = new Course(course);
- c.setGrade(grade);
- c.setEducation(education);
- courseList.add(c);
- }
- } catch (QueryEvaluationException e) {
- m_logService.log(LogService.LOG_ERROR, "Failed to
handle results of SPARQL query", e);
- }
- return courseList;
- }
- });
-
+ ArrayList<Course> courses = new ArrayList<Course>();
+ ModelSet modelSet = m_sesameService.getModelSet();
+ Model model = modelSet.getDefaultModel();
+ QueryResultTable result = model.sparqlSelect(sparqlQuery);
+ ClosableIterator<QueryRow> iterator = result.iterator();
+ try {
+ while (iterator.hasNext()) {
+ QueryRow queryRow = iterator.next();
+ String course = queryRow.getLiteralValue("coursename");
+ String grade = queryRow.getLiteralValue("gradename");
+ String education = queryRow.getLiteralValue("educationname");
+ Course c = new Course(course);
+ c.setGrade(grade);
+ c.setEducation(education);
+ courses.add(c);
+ }
+ } finally {
+ iterator.close();
+ }
return courses;
}
Modified: trunk/amdatu-release/pom.xml
==============================================================================
--- trunk/amdatu-release/pom.xml (original)
+++ trunk/amdatu-release/pom.xml Tue Dec 28 15:09:10 2010
@@ -227,6 +227,20 @@
<!-- Semantic Web bundles -->
<dependency>
<groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${platform.version}</version>
+ <scope>compile</scope>
+ <type>bundle</type>
+ </dependency>
+ <dependency>
+ <groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>rdf2go.sesamebridge</artifactId>
+ <version>${platform.version}</version>
+ <scope>compile</scope>
+ <type>bundle</type>
+ </dependency>
+ <dependency>
+ <groupId>org.amdatu.semanticweb</groupId>
<artifactId>sesame</artifactId>
<version>${platform.version}</version>
<scope>runtime</scope>
Modified: trunk/amdatu-semanticweb/pom.xml
==============================================================================
--- trunk/amdatu-semanticweb/pom.xml (original)
+++ trunk/amdatu-semanticweb/pom.xml Tue Dec 28 15:09:10 2010
@@ -46,6 +46,8 @@
</dependencyManagement>
<modules>
+ <module>rdf2go-api</module>
+ <module>rdf2go-sesamebridge</module>
<module>sesame</module>
<module>sparqlendpoint</module>
</modules>
Added: trunk/amdatu-semanticweb/rdf2go-api/pom.xml
==============================================================================
--- (empty file)
+++ trunk/amdatu-semanticweb/rdf2go-api/pom.xml Tue Dec 28 15:09:10 2010
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.amdatu</groupId>
+ <artifactId>org.amdatu.semanticweb</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <packaging>bundle</packaging>
+ <name>Amdatu Semantic Web - RDF 2 GO API</name>
+ <description>This bundle is a redistribution of the RDF 2 GO API
bundle</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.5.6</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+
<Bundle-Activator>org.ontoware.rdf2go.osgi.RDF2GoActivator</Bundle-Activator>
+
<Bundle-SymbolicName>org.amdatu.semanticweb.rdf2go</Bundle-SymbolicName>
+ <Embed-Dependency>*;scope=compile</Embed-Dependency>
+ <Import-Package>*</Import-Package>
+ <_exportcontents>
+ org.ontoware.aifbcommons.collection,
+ org.ontoware.rdf2go,
+ org.ontoware.rdf2go.exception,
+ org.ontoware.rdf2go.impl,
+ org.ontoware.rdf2go.model,
+ org.ontoware.rdf2go.model.impl,
+ org.ontoware.rdf2go.model.node,
+ org.ontoware.rdf2go.model.node.impl,
+ org.ontoware.rdf2go.model.persistent,
+ org.ontoware.rdf2go.osgi,
+ org.ontoware.rdf2go.util,
+ org.ontoware.rdf2go.vocabulary
+ </_exportcontents>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: trunk/amdatu-semanticweb/rdf2go-sesamebridge/pom.xml
==============================================================================
--- (empty file)
+++ trunk/amdatu-semanticweb/rdf2go-sesamebridge/pom.xml Tue Dec 28
15:09:10 2010
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.amdatu</groupId>
+ <artifactId>org.amdatu.semanticweb</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>rdf2go.sesamebridge</artifactId>
+ <packaging>bundle</packaging>
+ <name>Amdatu Semantic Web - RDF 2 GO Sesame Bridge</name>
+ <description>This bundle is a redistribution of the RDF 2 GO Sesame bridge
bundle</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.impl.sesame23</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.5.6</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+
<Bundle-Activator>org.openrdf.rdf2go.osgi.Activator</Bundle-Activator>
+
<Bundle-SymbolicName>org.amdatu.semanticweb.rdf2go.sesamebridge</Bundle-SymbolicName>
+ <Embed-Dependency>*;scope=compile</Embed-Dependency>
+ <Import-Package>
+ org.ontoware.rdf2go.impl,
+ *</Import-Package>
+ <_exportcontents>
+ org.openrdf.rdf2go.*
+ </_exportcontents>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
Modified: trunk/amdatu-semanticweb/sesame/pom.xml
==============================================================================
--- trunk/amdatu-semanticweb/sesame/pom.xml (original)
+++ trunk/amdatu-semanticweb/sesame/pom.xml Tue Dec 28 15:09:10 2010
@@ -7,7 +7,7 @@
<artifactId>org.amdatu.semanticweb</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
- <groupId>org.amdatu.semanticweb </groupId>
+ <groupId>org.amdatu.semanticweb</groupId>
<artifactId>sesame</artifactId>
<packaging>bundle</packaging>
<name>Amdatu Semantic Web - Sesame Application</name>
@@ -15,23 +15,47 @@
<dependencies>
<dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>provided</scope>
+ <type>bundle</type>
+ </dependency>
+ <dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.impl.sesame23</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>provided</scope>
+ <type>bundle</type>
+ </dependency>
+ <dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime-osgi</artifactId>
<version>${org.openrdf.sesame.version}</version>
<scope>compile</scope>
- </dependency>
+ <exclusions>
+ <exclusion>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-http-client</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-http-server-spring</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ <scope>compile</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.11</version>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.amdatu.web</groupId>
- <artifactId>httpcontext</artifactId>
- <scope>provided</scope>
- <type>bundle</type>
- </dependency>
</dependencies>
<build>
@@ -44,7 +68,7 @@
<Bundle-Activator>org.amdatu.semanticweb.sesame.osgi.Activator</Bundle-Activator>
<Bundle-SymbolicName>org.amdatu.semanticweb.sesame</Bundle-SymbolicName>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
+ <Embed-Transitive>false</Embed-Transitive>
<Import-Package>
!bsh,
!com.caucho.*,
@@ -89,9 +113,8 @@
</Import-Package>
<_exportcontents>
org.amdatu.semanticweb.sesame,
- org.openrdf.model.*,
- org.openrdf.query.*,
- org.openrdf.repository.*
+ org.openrdf.*,
+ info.aduna.*
</_exportcontents>
</instructions>
</configuration>
Modified:
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/SesameService.java
==============================================================================
---
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/SesameService.java
(original)
+++
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/SesameService.java
Tue Dec 28 15:09:10 2010
@@ -19,35 +19,58 @@
import java.net.URL;
import java.util.List;
+import org.ontoware.rdf2go.model.ModelSet;
import org.openrdf.repository.Repository;
/**
* Interface for a Sesame service. Sesame is a fast and scalable RDF database.
Sesame also provides
* two query languages for searching through the RDF documents in a Sesame
database: SeRQL and SPARQL.
+ *
* @author ivol
*/
public interface SesameService {
/**
* Returns the Sesame repository that stores the RDF documents.
+ *
* @return the Sesame repository that stores the RDF documents.
*/
Repository getRepository();
-
+
+ ModelSet getModelSet();
+
/**
* Imports an RDF file into the RDF storage.
+ *
* @param rdfFile The URL to the file to import.
*/
void importRDFFile(URL rdfFile);
-
+
/**
- * Executes a SPARQL query and invokes
+ * Executes a SPARQL query and invokes.
+ * This method has been deprecated, use the RDF2GO API instead. The RDF 2
GO API is quite similar to this method.
+ * Use instead:
+ * <pre>
+ * ModelSet modelSet = m_sesameService.getModelSet();
+ * Model model = modelSet.getDefaultModel();
+ * QueryResultTable result = model.sparqlSelect("select ?subject");
+ * try {
+ * while (iterator.hasNext()) {
+ * QueryRow queryRow = iterator.next();
+ * ...
+ * }
+ * } finally {
+ * iterator.close();
+ * } </pre>
+ *
* @param query
* @param handler
*/
+ @Deprecated
<T> T executeSPARQLQuery(String query, SPARQLQueryHandler<T> handler);
-
+
/**
* Retrieve a list of subject URI's that are instances of the specified
class.
+ *
* @param classURI The URI of the class of which the subjects must be
instances
* @return List of resource URI's of the selected subjects
*/
Modified:
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/osgi/Activator.java
==============================================================================
---
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/osgi/Activator.java
(original)
+++
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/osgi/Activator.java
Tue Dec 28 15:09:10 2010
@@ -23,7 +23,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
-
/**
* This is the OSGi activator for this Cassandra application bundle.
* @author ivol
@@ -33,12 +32,14 @@
public void init(BundleContext context, DependencyManager manager) throws
Exception {
System.out.println("Starting Sesame application bundle...");
- // Register the Sesame service
+
+ // Register the Sesame service
manager.add(
- createComponent()
- .setImplementation(SesameServiceImpl.class)
- .setInterface(SesameService.class.getName(), null)
-
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
+ createComponent()
+ .setImplementation(SesameServiceImpl.class)
+ .setInterface(SesameService.class.getName(), null)
+
.add(createServiceDependency().setService(LogService.class).setRequired(true))
+
.add(createConfigurationDependency().setPid(SesameServiceImpl.PID)));
}
@Override
Modified:
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/service/SesameServiceImpl.java
==============================================================================
---
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/service/SesameServiceImpl.java
(original)
+++
trunk/amdatu-semanticweb/sesame/src/main/java/org/amdatu/semanticweb/sesame/service/SesameServiceImpl.java
Tue Dec 28 15:09:10 2010
@@ -20,13 +20,26 @@
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Dictionary;
import java.util.List;
import org.amdatu.semanticweb.sesame.SPARQLQueryHandler;
import org.amdatu.semanticweb.sesame.SesameService;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.ontoware.aifbcommons.collection.ClosableIterator;
+import org.ontoware.rdf2go.model.Model;
+import org.ontoware.rdf2go.model.ModelSet;
+import org.ontoware.rdf2go.model.QueryResultTable;
+import org.ontoware.rdf2go.model.QueryRow;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
-import org.openrdf.query.*;
+import org.openrdf.query.MalformedQueryException;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.query.TupleQuery;
+import org.openrdf.query.TupleQueryResult;
+import org.openrdf.rdf2go.RepositoryModelSet;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
@@ -35,17 +48,23 @@
import org.openrdf.rio.RDFParseException;
import org.openrdf.sail.inferencer.fc.ForwardChainingRDFSInferencer;
import org.openrdf.sail.memory.MemoryStore;
-import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
import org.osgi.service.log.LogService;
-public class SesameServiceImpl implements SesameService {
+public class SesameServiceImpl implements SesameService, ManagedService {
+ // Configuration of the RDF store directory
+ public static final String PID = "org.amdatu.semanticweb.sesame";
+ public static final String DATA_DIRECTORY = "datadir";
- // Service depedencies, injected by the Felix dependency manager
- private volatile BundleContext m_bundleContext;
+ // Service dependencies, injected by the Felix dependency manager
private volatile LogService m_logService;
+ private volatile DependencyManager m_dependencyManager;
// The Sesame repository
private Repository m_repository;
+ private String m_repositoryDir;
+ private ModelSet m_rdf2goModelSet;
/**
* The init() method is invoked by the Felix dependency manager.
@@ -54,41 +73,41 @@
// Create a new repository, writing to disk. Note that we could use
several storages, as long
// as they implement the SAIL interface. Alternatives could be OWLim,
AllegroGraph, Open Virtuoso
// and Neo4j
- File reposDir = new File(getRepositoryDirectory());
+ File reposDir = new File(m_repositoryDir);
ForwardChainingRDFSInferencer inferencer = new
ForwardChainingRDFSInferencer(new MemoryStore(reposDir));
m_repository = new SailRepository(inferencer);
try {
m_repository.initialize();
+ m_rdf2goModelSet = new RepositoryModelSet(m_repository);
+ m_rdf2goModelSet.open();
} catch (RepositoryException e) {
m_logService.log(LogService.LOG_ERROR, "Failed to initialize
Sesame SailRepository in repository "
- + "directory '" + getRepositoryDirectory() + "'", e);
+ + "directory '" + m_repositoryDir + "'", e);
}
}
public Repository getRepository() {
return m_repository;
}
-
+
+ public ModelSet getModelSet() {
+ return m_rdf2goModelSet;
+ }
+
/**
* The destroy() method is invoked by the Felix dependency manager.
*/
public void destroy() {
try {
+ if (m_rdf2goModelSet != null) {
+ m_rdf2goModelSet.close();
+ }
m_repository.shutDown();
} catch (RepositoryException e) {
m_logService.log(LogService.LOG_ERROR, "Failed to shutdown Sesame
SailRepository", e);
}
}
- /**
- * Returns the location of the repository directory.
- * @return the location of the repository directory.
- */
- private String getRepositoryDirectory() {
- String felixCacheDir =
m_bundleContext.getProperty("felix.cache.rootdir");
- return felixCacheDir.substring(0, felixCacheDir.indexOf("/")) +
"/sesame";
- }
-
public void importRDFFile(URL rdfFile) {
RepositoryConnection connection = null;
try {
@@ -108,9 +127,9 @@
m_logService.log(LogService.LOG_ERROR, "Failed to close
RDF database connection", e);
}
}
- }
+ }
}
-
+
public <T> T executeSPARQLQuery(String queryString, SPARQLQueryHandler<T>
handler) {
RepositoryConnection connection = null;
TupleQueryResult result = null;
@@ -143,24 +162,41 @@
}
return null;
}
-
- public List<String> getSubjects(String classURI) {
+
+ public List<String> getSubjects(String subjectUri) {
ValueFactory factory = getRepository().getValueFactory();
- URI grade = factory.createURI(classURI);
- String query = "SELECT ?subject WHERE { ?subject a <" + grade + ">}";
- return executeSPARQLQuery(query, new
SPARQLQueryHandler<List<String>>() {
- public List<String> handleResult(TupleQueryResult result) {
- ArrayList<String> grades = new ArrayList<String>();
- try {
- while (result.hasNext()) {
- BindingSet bs = result.next();
-
grades.add(bs.getBinding("subject").getValue().stringValue());
- }
- } catch (QueryEvaluationException e) {
- m_logService.log(LogService.LOG_ERROR, "Failed to handle
results of SPARQL query", e);
- }
- return grades;
+ URI uri = factory.createURI(subjectUri);
+ String query = "SELECT ?subject WHERE { ?subject a <" + uri + ">}";
+ Model model = m_rdf2goModelSet.getDefaultModel();
+ QueryResultTable result = model.sparqlSelect(query);
+ ClosableIterator<QueryRow> iterator = result.iterator();
+ ArrayList<String> subjects = new ArrayList<String>();
+ try {
+ while (iterator.hasNext()) {
+ QueryRow bs = iterator.next();
+ subjects.add(bs.getValue("subject").toString());
}
- });
- };
+ } finally {
+ iterator.close();
+ }
+ return subjects;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void updated(Dictionary dictionary) throws ConfigurationException {
+ if (dictionary != null) {
+ m_repositoryDir = (String) dictionary.get(DATA_DIRECTORY);
+ if (m_repositoryDir == null || "".equals(m_repositoryDir)) {
+ throw new ConfigurationException(DATA_DIRECTORY, "Missing
mandatory data directory configuration");
+ }
+ }
+ }
+
+ private void registerModelSet() {
+ // Register this available ModelSet as a service such that it can be
used by anyone who wants it
+ Component component = m_dependencyManager.createComponent();
+ component.setInterface(ModelSet.class.getName(), null);
+ component.setImplementation(m_rdf2goModelSet);
+ m_dependencyManager.add(component);
+ }
}
\ No newline at end of file
Modified: trunk/amdatu-semanticweb/sparqlendpoint/pom.xml
==============================================================================
--- trunk/amdatu-semanticweb/sparqlendpoint/pom.xml (original)
+++ trunk/amdatu-semanticweb/sparqlendpoint/pom.xml Tue Dec 28 15:09:10 2010
@@ -19,7 +19,13 @@
<artifactId>sesame</artifactId>
<scope>provided</scope>
<type>bundle</type>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.semweb4j</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${rdf2go.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.amdatu.web.rest</groupId>
<artifactId>jaxrs</artifactId>
Modified:
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
==============================================================================
---
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
(original)
+++
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
Tue Dec 28 15:09:10 2010
@@ -16,28 +16,39 @@
*/
package org.amdatu.semanticweb.sparqlendpoint.service;
-import javax.ws.rs.*;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import java.net.URL;
import java.util.Dictionary;
import java.util.List;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
import org.amdatu.opensocial.gadgetmanagement.GadgetManagement;
+import org.amdatu.opensocial.shindig.GadgetCategory;
+import org.amdatu.opensocial.shindig.GadgetDefinition;
+import org.amdatu.semanticweb.sesame.SesameService;
import org.amdatu.semanticweb.sparqlendpoint.Activator;
import org.amdatu.web.httpcontext.HttpContextServiceFactory;
import org.amdatu.web.httpcontext.ResourceProvider;
-import org.amdatu.semanticweb.sesame.SPARQLQueryHandler;
-import org.amdatu.semanticweb.sesame.SesameService;
-import org.amdatu.opensocial.shindig.GadgetCategory;
-import org.amdatu.opensocial.shindig.GadgetDefinition;
import org.apache.felix.dm.Component;
import org.json.JSONException;
import org.json.JSONObject;
-import org.openrdf.query.BindingSet;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.query.TupleQueryResult;
+import org.ontoware.aifbcommons.collection.ClosableIterator;
+import org.ontoware.rdf2go.exception.ModelRuntimeException;
+import org.ontoware.rdf2go.model.Model;
+import org.ontoware.rdf2go.model.ModelSet;
+import org.ontoware.rdf2go.model.QueryResultTable;
+import org.ontoware.rdf2go.model.QueryRow;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
@@ -70,7 +81,7 @@
private Component m_httpContextComponent;
private String m_hostname;
private String m_portnr;
-
+
// HTTP caching policy for this REST interface
private static CacheControl m_cacheControl;
static {
@@ -89,7 +100,7 @@
// FIXME: Because of a bug in the Felix dependency manager,
update() is not invoked when the bundle
// is stopped/started. Hence m_hostname and m_portnr will be null.
To prevent serious problems as
// described in issue
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
- // For the bug description, see
http://jira.amdatu.org/jira/browse/AMDATU-174
+ // For the bug description, see
http://jira.amdatu.org/jira/browse/AMDATU-174
// and https://issues.apache.org/jira/browse/FELIX-2696
} else {
// Register the gadget with the Gadget management service. Note
that we can do this as
@@ -106,7 +117,7 @@
// Stop the HTTP context service we created ourselves
m_httpContextComponent.stop();
}
-
+
/**
* This method can be used to check the availability of the SPARQL
Endpoint.
* @return The text "SPARQL Endpoint online"
@@ -115,7 +126,7 @@
@Produces({MediaType.TEXT_PLAIN})
public String status() {
return "SPARQL Endpoint online";
- }
+ }
/**
* Executes a SPARQL query and returns the result.
@@ -127,47 +138,49 @@
public Response executeSPARQLQuery(@FormParam("query") final String query,
@DefaultValue("1") @QueryParam("startIndex") final int startIndex,
@DefaultValue("0") @QueryParam("endIndex") final int endIndexParam) {
- m_logService.log(LogService.LOG_DEBUG, "Executing SPARQL query: " +
query);
- final int endIndex = endIndexParam > 0 ? endIndexParam : MAX_ROW_COUNT;
- JSONObject jsonObject = m_sesameService.executeSPARQLQuery(query, new
SPARQLQueryHandler<JSONObject>() {
- public JSONObject handleResult(TupleQueryResult result) {
- JSONObject jsonObject = null;
- try {
- jsonObject = new JSONObject();
- try {
- List<String> bindingNames = result.getBindingNames();
- int resultRow = 1;
- int returnRowCount = 0;
- while (result.hasNext()) {
- if (startIndex <= resultRow && resultRow <=
endIndex && returnRowCount < MAX_ROW_COUNT) {
- JSONObject row = new JSONObject();
- BindingSet bs = result.next();
- for (String bindingName : bindingNames) {
- String value =
bs.getBinding(bindingName).getValue().stringValue();
- row.put(bindingName, value);
- }
- returnRowCount++;
- jsonObject.append("row", row);
- } else {
- result.next();
- }
- resultRow++;
+ JSONObject jsonObject = new JSONObject();
+ try {
+ m_logService.log(LogService.LOG_DEBUG, "Executing SPARQL query: "
+ query);
+ ModelSet modelSet = m_sesameService.getModelSet();
+ Model model = modelSet.getDefaultModel();
+ QueryResultTable result = model.sparqlSelect(query);
+ List<String> names = result.getVariables();
+ ClosableIterator<QueryRow> iterator = result.iterator();
+ int resultRow = 1;
+ int returnRowCount = 0;
+ final int endIndex = endIndexParam > 0 ? endIndexParam :
MAX_ROW_COUNT;
+ while (iterator.hasNext()) {
+ if (startIndex <= resultRow && resultRow <= endIndex &&
returnRowCount < MAX_ROW_COUNT) {
+ JSONObject row = new JSONObject();
+ QueryRow queryRow = iterator.next();
+ for (String name : names) {
+ String value;
+ try {
+ value = queryRow.getLiteralValue(name);
+ } catch (ModelRuntimeException e) {
+ value = queryRow.getValue(name).toString();
}
- jsonObject.put("startIndex", resultRow - 1 > 0 ?
startIndex : 0);
- jsonObject.put("endIndex", Math.min(endIndex,
(startIndex + returnRowCount - 1)));
- jsonObject.put("firstStartIndex", 1);
- jsonObject.put("lastStartIndex", (resultRow - 1) -
((resultRow - 1) % MAX_ROW_COUNT));
- jsonObject.put("batchSize", MAX_ROW_COUNT);
- jsonObject.put("resultCount", resultRow - 1);
- } catch (QueryEvaluationException e) {
- m_logService.log(LogService.LOG_ERROR, "Failed to
handle results of SPARQL query", e);
+ row.put(name, value);
+ returnRowCount++;
+ jsonObject.append("row", row);
}
- } catch (JSONException e) {
- m_logService.log(LogService.LOG_ERROR, "Could not write
result to JSON object", e);
+ } else {
+ iterator.next();
}
- return jsonObject;
+ resultRow++;
}
- });
+
+ jsonObject.put("startIndex", resultRow - 1 > 0 ? startIndex : 0);
+ jsonObject.put("endIndex", Math.min(endIndex, (startIndex +
returnRowCount - 1)));
+ jsonObject.put("firstStartIndex", 1);
+ jsonObject.put("lastStartIndex", (resultRow - 1) - ((resultRow -
1) % MAX_ROW_COUNT));
+ jsonObject.put("batchSize", MAX_ROW_COUNT);
+ jsonObject.put("resultCount", resultRow - 1);
+ }
+ catch (JSONException e) {
+ m_logService.log(LogService.LOG_ERROR, "Could not execute SPARQL
query '" + query + "'", e);
+ throw new WebApplicationException(e);
+ }
return Response.ok(jsonObject.toString(),
MediaType.APPLICATION_JSON_TYPE).cacheControl(m_cacheControl).build();
}
Modified: trunk/integration-tests/pom.xml
==============================================================================
--- trunk/integration-tests/pom.xml (original)
+++ trunk/integration-tests/pom.xml Tue Dec 28 15:09:10 2010
@@ -230,7 +230,28 @@
<version>${platform.version}</version>
<scope>test</scope>
<type>bundle</type>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>rdf2go.sesamebridge</artifactId>
+ <version>${platform.version}</version>
+ <scope>test</scope>
+ <type>bundle</type>
+ </dependency>
+ <dependency>
+ <groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>rdf2go.api</artifactId>
+ <version>${platform.version}</version>
+ <scope>test</scope>
+ <type>bundle</type>
+ </dependency>
+ <dependency>
+ <groupId>org.amdatu.semanticweb</groupId>
+ <artifactId>sesame</artifactId>
+ <version>${platform.version}</version>
+ <scope>test</scope>
+ <type>bundle</type>
+ </dependency>
<dependency>
<groupId>org.apache.felix</groupId>
Modified:
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
==============================================================================
---
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
(original)
+++
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
Tue Dec 28 15:09:10 2010
@@ -147,6 +147,7 @@
return new Component[0];
}
+ @SuppressWarnings("unchecked")
@Before
public void setupTest() throws Exception {
initConfiguration();
@@ -450,6 +451,18 @@
return
mavenBundle().groupId("org.amdatu.opensocial").artifactId("shindig").versionAsInProject();
}
+ protected static MavenArtifactProvisionOption amdatuRdf2goApi() {
+ return
mavenBundle().groupId("org.amdatu.semanticweb").artifactId("rdf2go.api").versionAsInProject();
+ }
+
+ protected static MavenArtifactProvisionOption amdatuRdf2goSesameBridge() {
+ return
mavenBundle().groupId("org.amdatu.semanticweb").artifactId("rdf2go.sesamebridge").versionAsInProject();
+ }
+
+ protected static MavenArtifactProvisionOption amdatuSesameApplication() {
+ return
mavenBundle().groupId("org.amdatu.semanticweb").artifactId("sesame").versionAsInProject();
+ }
+
// Jar files wrapper in a bundle
protected static WrappedUrlProvisionOption commonsHttpClient() {
return
wrappedBundle(mavenBundle().groupId("commons-httpclient").artifactId("commons-httpclient"));
Added:
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/RDF2GOTest.java
==============================================================================
--- (empty file)
+++
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/RDF2GOTest.java
Tue Dec 28 15:09:10 2010
@@ -0,0 +1,121 @@
+/*
+ Copyright (C) 2010 Amdatu.org
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.test.integration.tests;
+
+import static org.ops4j.pax.exam.CoreOptions.provision;
+
+import java.io.IOException;
+
+import org.amdatu.test.integration.base.ConfigProvider;
+import org.amdatu.test.integration.base.IntegrationTestBase;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ontoware.aifbcommons.collection.ClosableIterator;
+import org.ontoware.rdf2go.ModelFactory;
+import org.ontoware.rdf2go.RDF2Go;
+import org.ontoware.rdf2go.model.Model;
+import org.ontoware.rdf2go.model.QueryResultTable;
+import org.ontoware.rdf2go.model.QueryRow;
+import org.ontoware.rdf2go.model.node.Node;
+import org.ontoware.rdf2go.model.node.URI;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.BundleException;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.log.LogService;
+
+ at RunWith(JUnit4TestRunner.class)
+public class RDF2GOTest extends IntegrationTestBase {
+ private volatile LogService m_logService;
+ private volatile ConfigurationAdmin m_configAdmin;
+
+ @Configuration
+ public Option[] configure() {
+ return super.configure();
+ }
+
+ protected Option provisionBundles() {
+ return provision(
+ javaxServlet(),
+ log4j(),
+ amdatuRdf2goApi(),
+ amdatuRdf2goSesameBridge(),
+ amdatuSesameApplication()
+ );
+ }
+
+ @Override
+ protected Component[] getDependencies(DependencyManager manager) {
+ // We register a servlet filter (whiteboard-style) that adds a test
header to each HTTP response
+ Component testComponent = manager.createComponent()
+ .setImplementation(this)
+
.add(manager.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
+
.add(manager.createServiceDependency().setService(LogService.class).setRequired(true));
+
+ return new Component[] { testComponent };
+ }
+
+ @Before
+ public void initConfig() throws IOException, BundleException {
+ m_configAdmin = getService(ConfigurationAdmin.class);
+
+ // Add cassandra and templates configs
+ ConfigProvider configProvider = new ConfigProvider();
+ configProvider.addSesameConfig(m_configAdmin);
+ }
+
+ @Test
+ public void test() throws Exception {
+ m_logService.log(LogService.LOG_DEBUG, "Creating new in-memory RDF
model");
+ ModelFactory modelFactory = RDF2Go.getModelFactory();
+ Model model = modelFactory.createModel();
+ model.open();
+ m_logService.log(LogService.LOG_DEBUG, "Model opened successfully");
+
+ // creating URIs
+ URI max = model.createURI("http://xam.de/foaf.rdf.xml#i");
+ URI currentProject =
model.createURI("http://xmlns.com/foaf/0.1/#term_currentProject");
+ URI name = model.createURI("http://xmlns.com/foaf/0.1/#term_name");
+ URI semweb4j = model.createURI("http://amdatu.org");
+
+ // adding a statement to the model
+ model.addStatement(max, currentProject, semweb4j);
+ model.addStatement(max, name, "Ivo Ladage-van Doorn");
+
+ // dumping model to the screen
+ model.dump();
+
+ // query model for all names of max
+ String sparqQuery = "SELECT ?subject ?predicate ?object WHERE
{?subject ?predicate ?object}";
+ QueryResultTable resultTable = model.sparqlSelect(sparqQuery);
+ ClosableIterator<QueryRow> iter = resultTable.iterator();
+ while (iter.hasNext()) {
+ QueryRow row = iter.next();
+ Node subject = row.getValue("subject");
+ Node predicate = row.getValue("predicate");
+ Node object = row.getValue("object");
+ m_logService.log(LogService.LOG_DEBUG, "subject='" +
subject.toString() + "', predicate='"
+ + predicate.toString() + "', object='" + object + "'");
+ }
+
+ model.close();
+ }
+}
Modified: trunk/pom.xml
==============================================================================
--- trunk/pom.xml (original)
+++ trunk/pom.xml Tue Dec 28 15:09:10 2010
@@ -72,7 +72,8 @@
<net.kornr.osgi.commons-logging-osgi.version>20081215</net.kornr.osgi.commons-logging-osgi.version>
<junit.version>4.8.1</junit.version>
<jmock.version>2.5.1</jmock.version>
-
+ <rdf2go.version>4.7.3</rdf2go.version>
+
<!--
Version numbers of platform bundles
-->
@@ -246,6 +247,14 @@
<enabled>false</enabled>
</snapshots>
</repository>
+ <repository>
+ <id>semweb4j-repo</id>
+ <name>Semweb4j.org maven repo</name>
+ <url>http://semweb4j.org/repo/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
</repositories>
<!--
Modified: trunk/src/main/resources/conf/felix-config.properties
==============================================================================
--- trunk/src/main/resources/conf/felix-config.properties (original)
+++ trunk/src/main/resources/conf/felix-config.properties Tue Dec 28
15:09:10 2010
@@ -122,6 +122,8 @@
reference:file:amdatu-application/org.amdatu.opensocial.gadgetmanagement-${platform.version}.jar
\
reference:file:amdatu-application/org.amdatu.opensocial.profile-${platform.version}.jar
\
reference:file:amdatu-application/org.amdatu.opensocial.shindig-${platform.version}.jar
\
+
reference:file:amdatu-application/org.amdatu.semanticweb.rdf2go.api-${platform.version}.jar
\
+
reference:file:amdatu-application/org.amdatu.semanticweb.rdf2go.sesamebridge-${platform.version}.jar
\
reference:file:amdatu-application/org.amdatu.semanticweb.sesame-${platform.version}.jar
\
reference:file:amdatu-application/org.amdatu.semanticweb.sparqlendpoint-${platform.version}.jar
\
reference:file:amdatu-examples/org.amdatu.example.friends.gadget-${platform.version}.jar
\