You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/21 12:23:27 UTC
[17/19] MARMOTTA-104: renamed packages in ldpath (resolved)
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-api/src/main/java/org/apache/marmotta/ldpath/api/transformers/NodeTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-api/src/main/java/org/apache/marmotta/ldpath/api/transformers/NodeTransformer.java b/libraries/ldpath/ldpath-api/src/main/java/org/apache/marmotta/ldpath/api/transformers/NodeTransformer.java
new file mode 100644
index 0000000..b1fe0ab
--- /dev/null
+++ b/libraries/ldpath/ldpath-api/src/main/java/org/apache/marmotta/ldpath/api/transformers/NodeTransformer.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.
+ */
+package org.apache.marmotta.ldpath.api.transformers;
+
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
+
+/**
+ * Implementations of this interface allow to transform KiWiNode objects into the type T. This is
+ * currently required by the indexer to map KiWiNodes to the Java types corresponding to the
+ * respective XML Schema datatypes.
+ *
+ * <p/>
+ * Author: Sebastian Schaffert <se...@salzburgresearch.at>
+ */
+public interface NodeTransformer<T,Node> {
+
+ /**
+ * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+ * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+ * carrying out the transformation.
+ *
+ * @param node
+ * @return
+ */
+ public T transform(RDFBackend<Node> backend, Node node) throws IllegalArgumentException;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileBackend.java b/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileBackend.java
deleted file mode 100644
index 1d0c61b..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileBackend.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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.
- */
-package at.newmedialab.ldpath.backend.file;
-
-import at.newmedialab.ldpath.backend.sesame.SesameRepositoryBackend;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-import org.openrdf.sail.memory.MemoryStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class FileBackend extends SesameRepositoryBackend {
-
- private static final Logger log = LoggerFactory.getLogger(FileBackend.class);
-
-
- public FileBackend(File file) {
- this(file,null);
- }
-
- public FileBackend(File file, String mimetype) {
- super();
-
- RDFFormat format = null;
-
- if(mimetype != null) {
- format = RDFFormat.forMIMEType(mimetype);
- }
-
- try {
- Repository repository = new SailRepository(new MemoryStore());
- repository.initialize();
- setRepository(repository);
-
-
- RepositoryConnection connection = repository.getConnection();
- try {
- connection.add(file,null,format);
- } finally {
- connection.close();
- }
-
-
- } catch (RDFParseException e) {
- log.error("error parsing RDF input data from file {}",file,e);
- } catch (IOException e) {
- log.error("I/O error while reading input data from file {}", file, e);
- } catch (RepositoryException e) {
- log.error("error initialising connection to Sesame in-memory repository",e);
- }
- }
-
-
- /**
- * Initialise a new sesame backend. Repository needs to be set using setRepository.
- */
- public FileBackend(String fileName) {
- this(new File(fileName));
- }
-
- public FileBackend(String fileName, String mimetype) {
- this(new File(fileName), mimetype);
- }
-
-
- public FileBackend(URL url) {
- this(url,null);
- }
-
- public FileBackend(URL url, String mimetype) {
- super();
-
- RDFFormat format = null;
-
- if(mimetype != null) {
- format = RDFFormat.forMIMEType(mimetype);
- }
-
- try {
- Repository repository = new SailRepository(new MemoryStore());
- repository.initialize();
- setRepository(repository);
-
-
- RepositoryConnection connection = repository.getConnection();
- try {
- connection.add(url,null,format);
- } finally {
- connection.close();
- }
-
-
- } catch (RDFParseException e) {
- log.error("error parsing RDF input data from url {}",url,e);
- } catch (IOException e) {
- log.error("I/O error while reading input data from url {}", url, e);
- } catch (RepositoryException e) {
- log.error("error initialising connection to Sesame in-memory repository",e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileQuery.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileQuery.java b/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileQuery.java
deleted file mode 100644
index 0b85b6a..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/main/java/at/newmedialab/ldpath/backend/file/FileQuery.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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.
- */
-package at.newmedialab.ldpath.backend.file;
-
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.exception.LDPathParseException;
-import ch.qos.logback.classic.Level;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.OptionGroup;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Value;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Command line application for querying input from files.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class FileQuery {
-
- private static final Logger log = LoggerFactory.getLogger(FileQuery.class);
-
- public static void main(String[] args) {
- Options options = buildOptions();
-
- CommandLineParser parser = new PosixParser();
- try {
- CommandLine cmd = parser.parse( options, args);
-
- Level logLevel = Level.WARN;
-
- if(cmd.hasOption("loglevel")) {
- String logLevelName = cmd.getOptionValue("loglevel");
- if("DEBUG".equals(logLevelName.toUpperCase())) {
- logLevel = Level.DEBUG;
- } else if("INFO".equals(logLevelName.toUpperCase())) {
- logLevel = Level.INFO;
- } else if("WARN".equals(logLevelName.toUpperCase())) {
- logLevel = Level.WARN;
- } else if("ERROR".equals(logLevelName.toUpperCase())) {
- logLevel = Level.ERROR;
- } else {
- log.error("unsupported log level: {}",logLevelName);
- }
- }
-
- if(logLevel != null) {
- for(String logname : new String [] {"at","org","net","com"}) {
-
- ch.qos.logback.classic.Logger logger =
- (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logname);
- logger.setLevel(logLevel);
- }
- }
-
-
- String format = null;
- if(cmd.hasOption("format")) {
- format = cmd.getOptionValue("format");
- }
-
- FileBackend backend = null;
- if(cmd.hasOption("file")) {
- backend = new FileBackend(cmd.getOptionValue("file"),format);
- } else if(cmd.hasOption("url")) {
- URL url = new URL(cmd.getOptionValue("url"));
- backend = new FileBackend(url,format);
- }
-
- Resource context = null;
- if(cmd.hasOption("context")) {
- context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
- }
-
- if(backend != null && context != null) {
- LDPath<Value> ldpath = new LDPath<Value>(backend);
-
- if(cmd.hasOption("path")) {
- String path = cmd.getOptionValue("path");
-
- for(Value v : ldpath.pathQuery(context,path,null)) {
- System.out.println(v.stringValue());
- }
- } else if(cmd.hasOption("program")) {
- File file = new File(cmd.getOptionValue("program"));
-
- Map<String,Collection<?>> result = ldpath.programQuery(context,new FileReader(file));
-
- for(String field : result.keySet()) {
- StringBuilder line = new StringBuilder();
- line.append(field);
- line.append(" = ");
- line.append("{");
- for(Iterator<?> it = result.get(field).iterator(); it.hasNext(); ) {
- line.append(it.next().toString());
- if(it.hasNext()) {
- line.append(", ");
- }
- }
- line.append("}");
- System.out.println(line);
-
- }
- }
- }
-
-
- } catch (ParseException e) {
- System.err.println("invalid arguments");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "FileQuery", options, true );
- } catch (MalformedURLException e) {
- System.err.println("url could not be parsed");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("FileQuery", options, true);
- } catch (LDPathParseException e) {
- System.err.println("path or program could not be parsed");
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- System.err.println("file or program could not be found");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("FileQuery", options, true);
- }
-
-
- }
-
- @SuppressWarnings("static-access")
- private static Options buildOptions() {
- Options result = new Options();
-
- OptionGroup input = new OptionGroup();
- Option file = OptionBuilder.withArgName("file").hasArg().withDescription("query the contents of a file").create("file");
- Option url = OptionBuilder.withArgName("url").hasArg().withDescription("query the contents of a remote URL").create("url");
-
- input.addOption(file);
- input.addOption(url);
- input.setRequired(true);
-
- result.addOptionGroup(input);
-
- Option format = OptionBuilder.withArgName("mimetype").hasArg().withDescription("MIME type of the input document").create("format");
- result.addOption(format);
-
- OptionGroup query = new OptionGroup();
- Option path = OptionBuilder.withArgName("path").hasArg().withDescription("LD Path to evaluate on the file starting from the context").create("path");
- Option program = OptionBuilder.withArgName("file").hasArg().withDescription("LD Path program to evaluate on the file starting from the context").create("program");
- query.addOption(path);
- query.addOption(program);
- query.setRequired(true);
- result.addOptionGroup(query);
-
- Option context = OptionBuilder.withArgName("uri").hasArg().withDescription("URI of the context node to start from").create("context");
- context.setRequired(true);
- result.addOption(context);
-
- Option loglevel = OptionBuilder.withArgName("level").hasArg().withDescription("set the log level; default is 'warn'").create("loglevel");
- result.addOption(loglevel);
-
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileBackend.java b/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileBackend.java
new file mode 100644
index 0000000..b86078f
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileBackend.java
@@ -0,0 +1,129 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.
+ */
+package org.apache.marmotta.ldpath.backend.file;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.sail.memory.MemoryStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class FileBackend extends SesameRepositoryBackend {
+
+ private static final Logger log = LoggerFactory.getLogger(FileBackend.class);
+
+
+ public FileBackend(File file) {
+ this(file,null);
+ }
+
+ public FileBackend(File file, String mimetype) {
+ super();
+
+ RDFFormat format = null;
+
+ if(mimetype != null) {
+ format = RDFFormat.forMIMEType(mimetype);
+ }
+
+ try {
+ Repository repository = new SailRepository(new MemoryStore());
+ repository.initialize();
+ setRepository(repository);
+
+
+ RepositoryConnection connection = repository.getConnection();
+ try {
+ connection.add(file,null,format);
+ } finally {
+ connection.close();
+ }
+
+
+ } catch (RDFParseException e) {
+ log.error("error parsing RDF input data from file {}",file,e);
+ } catch (IOException e) {
+ log.error("I/O error while reading input data from file {}", file, e);
+ } catch (RepositoryException e) {
+ log.error("error initialising connection to Sesame in-memory repository",e);
+ }
+ }
+
+
+ /**
+ * Initialise a new sesame backend. Repository needs to be set using setRepository.
+ */
+ public FileBackend(String fileName) {
+ this(new File(fileName));
+ }
+
+ public FileBackend(String fileName, String mimetype) {
+ this(new File(fileName), mimetype);
+ }
+
+
+ public FileBackend(URL url) {
+ this(url,null);
+ }
+
+ public FileBackend(URL url, String mimetype) {
+ super();
+
+ RDFFormat format = null;
+
+ if(mimetype != null) {
+ format = RDFFormat.forMIMEType(mimetype);
+ }
+
+ try {
+ Repository repository = new SailRepository(new MemoryStore());
+ repository.initialize();
+ setRepository(repository);
+
+
+ RepositoryConnection connection = repository.getConnection();
+ try {
+ connection.add(url,null,format);
+ } finally {
+ connection.close();
+ }
+
+
+ } catch (RDFParseException e) {
+ log.error("error parsing RDF input data from url {}",url,e);
+ } catch (IOException e) {
+ log.error("I/O error while reading input data from url {}", url, e);
+ } catch (RepositoryException e) {
+ log.error("error initialising connection to Sesame in-memory repository",e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileQuery.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileQuery.java b/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileQuery.java
new file mode 100644
index 0000000..b80e8fc
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/main/java/org/apache/marmotta/ldpath/backend/file/FileQuery.java
@@ -0,0 +1,194 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.
+ */
+package org.apache.marmotta.ldpath.backend.file;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.apache.marmotta.ldpath.LDPath;
+import org.apache.marmotta.ldpath.exception.LDPathParseException;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Value;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Level;
+
+/**
+ * Command line application for querying input from files.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class FileQuery {
+
+ private static final Logger log = LoggerFactory.getLogger(FileQuery.class);
+
+ public static void main(String[] args) {
+ Options options = buildOptions();
+
+ CommandLineParser parser = new PosixParser();
+ try {
+ CommandLine cmd = parser.parse( options, args);
+
+ Level logLevel = Level.WARN;
+
+ if(cmd.hasOption("loglevel")) {
+ String logLevelName = cmd.getOptionValue("loglevel");
+ if("DEBUG".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.DEBUG;
+ } else if("INFO".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.INFO;
+ } else if("WARN".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.WARN;
+ } else if("ERROR".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.ERROR;
+ } else {
+ log.error("unsupported log level: {}",logLevelName);
+ }
+ }
+
+ if(logLevel != null) {
+ for(String logname : new String [] {"at","org","net","com"}) {
+
+ ch.qos.logback.classic.Logger logger =
+ (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logname);
+ logger.setLevel(logLevel);
+ }
+ }
+
+
+ String format = null;
+ if(cmd.hasOption("format")) {
+ format = cmd.getOptionValue("format");
+ }
+
+ FileBackend backend = null;
+ if(cmd.hasOption("file")) {
+ backend = new FileBackend(cmd.getOptionValue("file"),format);
+ } else if(cmd.hasOption("url")) {
+ URL url = new URL(cmd.getOptionValue("url"));
+ backend = new FileBackend(url,format);
+ }
+
+ Resource context = null;
+ if(cmd.hasOption("context")) {
+ context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
+ }
+
+ if(backend != null && context != null) {
+ LDPath<Value> ldpath = new LDPath<Value>(backend);
+
+ if(cmd.hasOption("path")) {
+ String path = cmd.getOptionValue("path");
+
+ for(Value v : ldpath.pathQuery(context,path,null)) {
+ System.out.println(v.stringValue());
+ }
+ } else if(cmd.hasOption("program")) {
+ File file = new File(cmd.getOptionValue("program"));
+
+ Map<String,Collection<?>> result = ldpath.programQuery(context,new FileReader(file));
+
+ for(String field : result.keySet()) {
+ StringBuilder line = new StringBuilder();
+ line.append(field);
+ line.append(" = ");
+ line.append("{");
+ for(Iterator<?> it = result.get(field).iterator(); it.hasNext(); ) {
+ line.append(it.next().toString());
+ if(it.hasNext()) {
+ line.append(", ");
+ }
+ }
+ line.append("}");
+ System.out.println(line);
+
+ }
+ }
+ }
+
+
+ } catch (ParseException e) {
+ System.err.println("invalid arguments");
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp( "FileQuery", options, true );
+ } catch (MalformedURLException e) {
+ System.err.println("url could not be parsed");
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("FileQuery", options, true);
+ } catch (LDPathParseException e) {
+ System.err.println("path or program could not be parsed");
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ System.err.println("file or program could not be found");
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("FileQuery", options, true);
+ }
+
+
+ }
+
+ @SuppressWarnings("static-access")
+ private static Options buildOptions() {
+ Options result = new Options();
+
+ OptionGroup input = new OptionGroup();
+ Option file = OptionBuilder.withArgName("file").hasArg().withDescription("query the contents of a file").create("file");
+ Option url = OptionBuilder.withArgName("url").hasArg().withDescription("query the contents of a remote URL").create("url");
+
+ input.addOption(file);
+ input.addOption(url);
+ input.setRequired(true);
+
+ result.addOptionGroup(input);
+
+ Option format = OptionBuilder.withArgName("mimetype").hasArg().withDescription("MIME type of the input document").create("format");
+ result.addOption(format);
+
+ OptionGroup query = new OptionGroup();
+ Option path = OptionBuilder.withArgName("path").hasArg().withDescription("LD Path to evaluate on the file starting from the context").create("path");
+ Option program = OptionBuilder.withArgName("file").hasArg().withDescription("LD Path program to evaluate on the file starting from the context").create("program");
+ query.addOption(path);
+ query.addOption(program);
+ query.setRequired(true);
+ result.addOptionGroup(query);
+
+ Option context = OptionBuilder.withArgName("uri").hasArg().withDescription("URI of the context node to start from").create("context");
+ context.setRequired(true);
+ result.addOption(context);
+
+ Option loglevel = OptionBuilder.withArgName("level").hasArg().withDescription("set the log level; default is 'warn'").create("loglevel");
+ result.addOption(loglevel);
+
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/java/ParserTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/java/ParserTest.java b/libraries/ldpath/ldpath-backend-file/src/test/java/ParserTest.java
deleted file mode 100644
index 3f0f87a..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/test/java/ParserTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2011 Salzburg Research.
- *
- * 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.
- */
-
-import at.newmedialab.ldpath.api.selectors.NodeSelector;
-import at.newmedialab.ldpath.backend.sesame.SesameRepositoryBackend;
-import at.newmedialab.ldpath.model.programs.Program;
-import at.newmedialab.ldpath.model.selectors.PathSelector;
-import at.newmedialab.ldpath.model.selectors.PropertySelector;
-import at.newmedialab.ldpath.model.selectors.TestingSelector;
-import at.newmedialab.ldpath.model.selectors.UnionSelector;
-import at.newmedialab.ldpath.model.transformers.StringTransformer;
-import at.newmedialab.ldpath.parser.ParseException;
-import at.newmedialab.ldpath.parser.RdfPathParser;
-import com.google.common.collect.ImmutableMap;
-import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openrdf.model.Value;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.io.StringReader;
-import java.util.Map;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class ParserTest {
-
- private static SesameRepositoryBackend backend;
-
- @BeforeClass
- public static void setupRepository() throws RepositoryException {
- Repository repository = new SailRepository(new MemoryStore());
- repository.initialize();
-
- backend = new SesameRepositoryBackend(repository);
- }
-
-
-
- @Test
- public void testParsePath() throws Exception {
- String path1 = "rdfs:label";
-
- NodeSelector<Value> s1 = parseSelector(path1, null);
- Assert.assertTrue(s1 instanceof PropertySelector);
- Assert.assertEquals("<http://www.w3.org/2000/01/rdf-schema#label>",s1.getPathExpression(backend));
-
-
- Map<String,String> namespaces2 = ImmutableMap.of(
- "dct","http://purl.org/dc/terms/",
- "dbp-ont","http://dbpedia.org/ontology/"
- );
- String path2 = "(*[rdf:type is dbp-ont:Person]) | (dct:subject/^dct:subject[rdf:type is dbp-ont:Person]) | (dct:subject/^skos:broader/^dct:subject[rdf:type is dbp-ont:Person])";
- NodeSelector<Value> s2 = parseSelector(path2,namespaces2);
- Assert.assertTrue(s2 instanceof UnionSelector);
-
- String path3 = "*[rdf:type is dbp-ont:Person] | dct:subject/^dct:subject[rdf:type is dbp-ont:Person] | dct:subject/^skos:broader/^dct:subject[rdf:type is dbp-ont:Person]";
- NodeSelector<Value> s3 = parseSelector(path3,namespaces2);
- Assert.assertTrue(s3 instanceof UnionSelector);
-
- Assert.assertEquals(s2,s3);
-
- String path4 = "(* | dct:subject/^dct:subject | dct:subject/^skos:broader/^dct:subject)[rdf:type is dbp-ont:Person]";
- NodeSelector<Value> s4 = parseSelector(path4,namespaces2);
- Assert.assertTrue(s4 instanceof TestingSelector);
- }
-
- private NodeSelector<Value> parseSelector(String selector, Map<String,String> namespaces) throws ParseException {
- return new RdfPathParser<Value>(backend,new StringReader(selector)).parseSelector(namespaces);
- }
-
- @Test
- public void testParseProgram() throws Exception {
-
- Program<Value> p1 = parseProgram(IOUtils.toString(ParserTest.class.getResource("stanbol.search")));
- Assert.assertEquals(12,p1.getFields().size());
- Assert.assertNull(p1.getBooster());
- Assert.assertNotNull(p1.getFilter());
- Assert.assertEquals(5,p1.getNamespaces().size());
-
-
- Program<Value> p2 = parseProgram(IOUtils.toString(ParserTest.class.getResource("sn.search")));
- Assert.assertEquals(11,p2.getFields().size());
- Assert.assertNotNull(p2.getBooster());
- Assert.assertNotNull(p2.getFilter());
- Assert.assertEquals(8,p2.getNamespaces().size());
-
- Program<Value> p3 = parseProgram(IOUtils.toString(ParserTest.class.getResource("orf.search")));
- Assert.assertEquals(18,p3.getFields().size());
- Assert.assertNull(p3.getBooster());
- Assert.assertNotNull(p3.getFilter());
- Assert.assertEquals(5, p3.getNamespaces().size());
- Assert.assertNotNull(p3.getField("person"));
- Assert.assertTrue(p3.getField("person").getSelector() instanceof PathSelector);
- Assert.assertTrue(p3.getField("person").getTransformer() instanceof StringTransformer);
-
- }
-
- private Program<Value> parseProgram(String selector) throws ParseException {
- return new RdfPathParser<Value>(backend,new StringReader(selector)).parseProgram();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/java/PathTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/java/PathTest.java b/libraries/ldpath/ldpath-backend-file/src/test/java/PathTest.java
deleted file mode 100644
index f32f6bc..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/test/java/PathTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2011 Salzburg Research.
- *
- * 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.
- */
-
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.backend.file.FileBackend;
-import at.newmedialab.ldpath.backend.sesame.SesameRepositoryBackend;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openrdf.model.Value;
-import org.openrdf.repository.RepositoryException;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasItems;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class PathTest {
-
-
- private static SesameRepositoryBackend backend;
- private static LDPath<Value> ldPath;
-
- @BeforeClass
- public static void setupRepository() throws RepositoryException {
- backend = new FileBackend(PathTest.class.getResource("demo-data.foaf"),"application/rdf+xml");
- ldPath = new LDPath<Value>(backend);
- }
-
- @Test
- public void simpleResourcePath() throws Exception {
-
- Map<Value, List<Value>> paths = new HashMap<Value, List<Value>>();
- Collection<Value> values = ldPath.pathQuery(backend.createURI("http://localhost:8080/LMF/resource/hans_meier"), "foaf:interest", null, paths);
- Assert.assertEquals(4,values.size());
- Assert.assertThat(values,hasItems(
- backend.createURI("http://rdf.freebase.com/ns/en.software_engineering"),
- backend.createURI("http://rdf.freebase.com/ns/en.linux"),
- backend.createURI("http://dbpedia.org/resource/Java"),
- backend.createURI("http://dbpedia.org/resource/Climbing")
- ));
-
- }
-
- @Test
- public void simpleValuePath() throws Exception {
-
- Collection<String> values = ldPath.pathTransform(backend.createURI("http://localhost:8080/LMF/resource/hans_meier"), "foaf:name :: xsd:string", null);
- Assert.assertEquals(1,values.size());
- Assert.assertThat(values,hasItem("Hans Meier"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/ParserTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/ParserTest.java b/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/ParserTest.java
new file mode 100644
index 0000000..5f5286c
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/ParserTest.java
@@ -0,0 +1,127 @@
+package org.apache.marmotta.ldpath.backend.file;
+/*
+ * Copyright (c) 2011 Salzburg Research.
+ *
+ * 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.
+ */
+
+import java.io.StringReader;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.ldpath.api.selectors.NodeSelector;
+import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
+import org.apache.marmotta.ldpath.model.programs.Program;
+import org.apache.marmotta.ldpath.model.selectors.PathSelector;
+import org.apache.marmotta.ldpath.model.selectors.PropertySelector;
+import org.apache.marmotta.ldpath.model.selectors.TestingSelector;
+import org.apache.marmotta.ldpath.model.selectors.UnionSelector;
+import org.apache.marmotta.ldpath.model.transformers.StringTransformer;
+import org.apache.marmotta.ldpath.parser.ParseException;
+import org.apache.marmotta.ldpath.parser.RdfPathParser;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openrdf.model.Value;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.sail.memory.MemoryStore;
+
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ParserTest {
+
+ private static SesameRepositoryBackend backend;
+
+ @BeforeClass
+ public static void setupRepository() throws RepositoryException {
+ Repository repository = new SailRepository(new MemoryStore());
+ repository.initialize();
+
+ backend = new SesameRepositoryBackend(repository);
+ }
+
+
+
+ @Test
+ public void testParsePath() throws Exception {
+ String path1 = "rdfs:label";
+
+ NodeSelector<Value> s1 = parseSelector(path1, null);
+ Assert.assertTrue(s1 instanceof PropertySelector);
+ Assert.assertEquals("<http://www.w3.org/2000/01/rdf-schema#label>",s1.getPathExpression(backend));
+
+
+ Map<String,String> namespaces2 = ImmutableMap.of(
+ "dct","http://purl.org/dc/terms/",
+ "dbp-ont","http://dbpedia.org/ontology/"
+ );
+ String path2 = "(*[rdf:type is dbp-ont:Person]) | (dct:subject/^dct:subject[rdf:type is dbp-ont:Person]) | (dct:subject/^skos:broader/^dct:subject[rdf:type is dbp-ont:Person])";
+ NodeSelector<Value> s2 = parseSelector(path2,namespaces2);
+ Assert.assertTrue(s2 instanceof UnionSelector);
+
+ String path3 = "*[rdf:type is dbp-ont:Person] | dct:subject/^dct:subject[rdf:type is dbp-ont:Person] | dct:subject/^skos:broader/^dct:subject[rdf:type is dbp-ont:Person]";
+ NodeSelector<Value> s3 = parseSelector(path3,namespaces2);
+ Assert.assertTrue(s3 instanceof UnionSelector);
+
+ Assert.assertEquals(s2,s3);
+
+ String path4 = "(* | dct:subject/^dct:subject | dct:subject/^skos:broader/^dct:subject)[rdf:type is dbp-ont:Person]";
+ NodeSelector<Value> s4 = parseSelector(path4,namespaces2);
+ Assert.assertTrue(s4 instanceof TestingSelector);
+ }
+
+ private NodeSelector<Value> parseSelector(String selector, Map<String,String> namespaces) throws ParseException {
+ return new RdfPathParser<Value>(backend,new StringReader(selector)).parseSelector(namespaces);
+ }
+
+ @Test
+ public void testParseProgram() throws Exception {
+
+ Program<Value> p1 = parseProgram(IOUtils.toString(ParserTest.class.getResource("stanbol.search")));
+ Assert.assertEquals(12,p1.getFields().size());
+ Assert.assertNull(p1.getBooster());
+ Assert.assertNotNull(p1.getFilter());
+ Assert.assertEquals(5,p1.getNamespaces().size());
+
+
+ Program<Value> p2 = parseProgram(IOUtils.toString(ParserTest.class.getResource("sn.search")));
+ Assert.assertEquals(11,p2.getFields().size());
+ Assert.assertNotNull(p2.getBooster());
+ Assert.assertNotNull(p2.getFilter());
+ Assert.assertEquals(8,p2.getNamespaces().size());
+
+ Program<Value> p3 = parseProgram(IOUtils.toString(ParserTest.class.getResource("orf.search")));
+ Assert.assertEquals(18,p3.getFields().size());
+ Assert.assertNull(p3.getBooster());
+ Assert.assertNotNull(p3.getFilter());
+ Assert.assertEquals(5, p3.getNamespaces().size());
+ Assert.assertNotNull(p3.getField("person"));
+ Assert.assertTrue(p3.getField("person").getSelector() instanceof PathSelector);
+ Assert.assertTrue(p3.getField("person").getTransformer() instanceof StringTransformer);
+
+ }
+
+ private Program<Value> parseProgram(String selector) throws ParseException {
+ return new RdfPathParser<Value>(backend,new StringReader(selector)).parseProgram();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/PathTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/PathTest.java b/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/PathTest.java
new file mode 100644
index 0000000..f0da1c9
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/test/java/org/apache/marmotta/ldpath/backend/file/PathTest.java
@@ -0,0 +1,75 @@
+package org.apache.marmotta.ldpath.backend.file;
+/*
+ * Copyright (c) 2011 Salzburg Research.
+ *
+ * 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.
+ */
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasItems;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.marmotta.ldpath.LDPath;
+import org.apache.marmotta.ldpath.backend.file.FileBackend;
+import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openrdf.model.Value;
+import org.openrdf.repository.RepositoryException;
+
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class PathTest {
+
+
+ private static SesameRepositoryBackend backend;
+ private static LDPath<Value> ldPath;
+
+ @BeforeClass
+ public static void setupRepository() throws RepositoryException {
+ backend = new FileBackend(PathTest.class.getResource("demo-data.foaf"),"application/rdf+xml");
+ ldPath = new LDPath<Value>(backend);
+ }
+
+ @Test
+ public void simpleResourcePath() throws Exception {
+
+ Map<Value, List<Value>> paths = new HashMap<Value, List<Value>>();
+ Collection<Value> values = ldPath.pathQuery(backend.createURI("http://localhost:8080/LMF/resource/hans_meier"), "foaf:interest", null, paths);
+ Assert.assertEquals(4,values.size());
+ Assert.assertThat(values,hasItems(
+ backend.createURI("http://rdf.freebase.com/ns/en.software_engineering"),
+ backend.createURI("http://rdf.freebase.com/ns/en.linux"),
+ backend.createURI("http://dbpedia.org/resource/Java"),
+ backend.createURI("http://dbpedia.org/resource/Climbing")
+ ));
+
+ }
+
+ @Test
+ public void simpleValuePath() throws Exception {
+
+ Collection<String> values = ldPath.pathTransform(backend.createURI("http://localhost:8080/LMF/resource/hans_meier"), "foaf:name :: xsd:string", null);
+ Assert.assertEquals(1,values.size());
+ Assert.assertThat(values,hasItem("Hans Meier"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/demo-data.foaf
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/demo-data.foaf b/libraries/ldpath/ldpath-backend-file/src/test/resources/demo-data.foaf
deleted file mode 100644
index c80c76e..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/test/resources/demo-data.foaf
+++ /dev/null
@@ -1,62 +0,0 @@
-<!--
- ~ Copyright (c) 2011 Salzburg Research.
- ~
- ~ 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.
- -->
-
-<rdf:RDF
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:dc="http://purl.org/dc/elements/1.1/">
-
- <foaf:Person rdf:about="http://localhost:8080/LMF/resource/hans_meier" xmlns:foaf="http://xmlns.com/foaf/0.1/">
- <foaf:name>Hans Meier</foaf:name>
- <dc:description>Hans Meier is a software engineer living in Salzburg</dc:description>
- <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.software_engineering"/>
- <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.linux"/>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Java" />
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
- <foaf:based_near rdf:resource="http://sws.geonames.org/2766824/"/>
- <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/hans_meier.jpg"/>
-
- <foaf:knows rdf:resource="http://bblfish.net/people/henry/card#me" />
- <foaf:knows rdf:resource="http://dbpedia.org/resource/James_Gosling"/>
- </foaf:Person>
-
- <foaf:Person rdf:about="http://localhost:8080/LMF/resource/sepp_huber" xmlns:foaf="http://xmlns.com/foaf/0.1/">
- <foaf:name>Sepp Huber</foaf:name>
- <dc:description>Sepp Huber is an alpinist living in Traunstein. He is a good climber, but not as famous as his cousin Alexander Huber.</dc:description>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
- <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
- <foaf:based_near rdf:resource="http://dbpedia.org/resource/Traunstein"/>
-
- <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
- <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/hans_meier" />
- </foaf:Person>
-
- <foaf:Person rdf:about="http://localhost:8080/LMF/resource/anna_schmidt" xmlns:foaf="http://xmlns.com/foaf/0.1/">
- <foaf:name>Anna Schmidt</foaf:name>
- <dc:description>Anna Schmidt is working as PR manager for mountaineers coming from Garmisch-Partenkirchen. She likes mountaineering and is also a Linux enthusiast.</dc:description>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Linux"/>
- <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
- <foaf:based_near rdf:resource="http://dbpedia.org/resource/Garmisch-Partenkirchen"/>
- <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/anna_schmidt.jpg"/>
-
- <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
- <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/sepp_huber" />
- </foaf:Person>
-
-
-</rdf:RDF>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/orf.search
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/orf.search b/libraries/ldpath/ldpath-backend-file/src/test/resources/orf.search
deleted file mode 100644
index de5f174..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/test/resources/orf.search
+++ /dev/null
@@ -1,24 +0,0 @@
-@prefix foaf : <http://xmlns.com/foaf/0.1/> ;
-@prefix geo : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
-@prefix basket : <http://www.orf.at/ontology/Entry/> ;
-@prefix orf : <http://www.orf.at/ontology/> ;
-@prefix hgtags : <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> ;
-@filter rdf:type is orf:Entry ;
- summary = basket:inhalt :: xsd:string ;
- thumbnail = basket:keyframeIn :: xsd:anyURI ;
- gestaltung = orf:Role_GES / rdfs:label :: xsd:string ;
- tag = hgtags:taggedWithTag / hgtags:name :: xsd:string ;
- type = rdf:type :: xsd:anyURI ;
- other = orf:related / (rdfs:label[@de] | (rdfs:label[@none] | skos:prefLabel[@de])) :: xsd:string ;
- lat = basket:location / geo:lat :: xsd:double ;
- key = basket:key :: xsd:string ;
- title = basket:subTitle :: xsd:string ;
- pool = basket:pool :: xsd:string ;
- title2 = basket:title :: xsd:string ;
- countrycode = basket:location / <http://www.geonames.org/ontology#countryCode> :: xsd:string ;
- location = (basket:location / <http://www.geonames.org/ontology#name>) | (orf:relatedPlace / (rdfs:label[@de] | rdfs:label[@none])) :: xsd:string ;
- date = basket:broadcastDate :: xsd:dateTime ;
- person = (orf:Role_IMB | (orf:Role_RDE | orf:relatedPerson)) / rdfs:label :: xsd:string ;
- long = basket:location / geo:long :: xsd:double ;
- moderator = orf:Role_MOD / rdfs:label :: xsd:string ;
- company = orf:relatedOrganisation / (rdfs:label[@de] | rdfs:label[@none]) :: xsd:string ;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/demo-data.foaf
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/demo-data.foaf b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/demo-data.foaf
new file mode 100644
index 0000000..c80c76e
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/demo-data.foaf
@@ -0,0 +1,62 @@
+<!--
+ ~ Copyright (c) 2011 Salzburg Research.
+ ~
+ ~ 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.
+ -->
+
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+
+ <foaf:Person rdf:about="http://localhost:8080/LMF/resource/hans_meier" xmlns:foaf="http://xmlns.com/foaf/0.1/">
+ <foaf:name>Hans Meier</foaf:name>
+ <dc:description>Hans Meier is a software engineer living in Salzburg</dc:description>
+ <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.software_engineering"/>
+ <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.linux"/>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Java" />
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
+ <foaf:based_near rdf:resource="http://sws.geonames.org/2766824/"/>
+ <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/hans_meier.jpg"/>
+
+ <foaf:knows rdf:resource="http://bblfish.net/people/henry/card#me" />
+ <foaf:knows rdf:resource="http://dbpedia.org/resource/James_Gosling"/>
+ </foaf:Person>
+
+ <foaf:Person rdf:about="http://localhost:8080/LMF/resource/sepp_huber" xmlns:foaf="http://xmlns.com/foaf/0.1/">
+ <foaf:name>Sepp Huber</foaf:name>
+ <dc:description>Sepp Huber is an alpinist living in Traunstein. He is a good climber, but not as famous as his cousin Alexander Huber.</dc:description>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
+ <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
+ <foaf:based_near rdf:resource="http://dbpedia.org/resource/Traunstein"/>
+
+ <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
+ <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/hans_meier" />
+ </foaf:Person>
+
+ <foaf:Person rdf:about="http://localhost:8080/LMF/resource/anna_schmidt" xmlns:foaf="http://xmlns.com/foaf/0.1/">
+ <foaf:name>Anna Schmidt</foaf:name>
+ <dc:description>Anna Schmidt is working as PR manager for mountaineers coming from Garmisch-Partenkirchen. She likes mountaineering and is also a Linux enthusiast.</dc:description>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Linux"/>
+ <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
+ <foaf:based_near rdf:resource="http://dbpedia.org/resource/Garmisch-Partenkirchen"/>
+ <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/anna_schmidt.jpg"/>
+
+ <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
+ <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/sepp_huber" />
+ </foaf:Person>
+
+
+</rdf:RDF>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/orf.search
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/orf.search b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/orf.search
new file mode 100644
index 0000000..de5f174
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/orf.search
@@ -0,0 +1,24 @@
+@prefix foaf : <http://xmlns.com/foaf/0.1/> ;
+@prefix geo : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
+@prefix basket : <http://www.orf.at/ontology/Entry/> ;
+@prefix orf : <http://www.orf.at/ontology/> ;
+@prefix hgtags : <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> ;
+@filter rdf:type is orf:Entry ;
+ summary = basket:inhalt :: xsd:string ;
+ thumbnail = basket:keyframeIn :: xsd:anyURI ;
+ gestaltung = orf:Role_GES / rdfs:label :: xsd:string ;
+ tag = hgtags:taggedWithTag / hgtags:name :: xsd:string ;
+ type = rdf:type :: xsd:anyURI ;
+ other = orf:related / (rdfs:label[@de] | (rdfs:label[@none] | skos:prefLabel[@de])) :: xsd:string ;
+ lat = basket:location / geo:lat :: xsd:double ;
+ key = basket:key :: xsd:string ;
+ title = basket:subTitle :: xsd:string ;
+ pool = basket:pool :: xsd:string ;
+ title2 = basket:title :: xsd:string ;
+ countrycode = basket:location / <http://www.geonames.org/ontology#countryCode> :: xsd:string ;
+ location = (basket:location / <http://www.geonames.org/ontology#name>) | (orf:relatedPlace / (rdfs:label[@de] | rdfs:label[@none])) :: xsd:string ;
+ date = basket:broadcastDate :: xsd:dateTime ;
+ person = (orf:Role_IMB | (orf:Role_RDE | orf:relatedPerson)) / rdfs:label :: xsd:string ;
+ long = basket:location / geo:long :: xsd:double ;
+ moderator = orf:Role_MOD / rdfs:label :: xsd:string ;
+ company = orf:relatedOrganisation / (rdfs:label[@de] | rdfs:label[@none]) :: xsd:string ;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/sn.search
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/sn.search b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/sn.search
new file mode 100644
index 0000000..4ff01a6
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/sn.search
@@ -0,0 +1,24 @@
+@prefix dc : <http://purl.org/dc/elements/1.1/> ;
+@prefix sn : <http://lmf.salzburg.com/news-ns/> ;
+@prefix snc : <http://lmf.salzburg.com/news-ns/concepts/> ;
+@prefix iptc : <http://iptc.org/std/nar/2006-10-01/> ;
+@prefix hg : <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> ;
+@prefix geo : <http://www.geonames.org/ontology#> ;
+@prefix wgs84 : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
+@prefix skos : <http://www.w3.org/2004/02/skos/core#> ;
+
+@filter rdf:type is snc:PublicationItem ;
+
+@boost sn:boostFactor ;
+
+ tag = hg:taggedWithTag / hg:name :: xsd:string ;
+ ressort = (sn:inRessort | sn:inCategory | ((sn:inRessort | sn:inCategory) / (skos:narrower)+)) / fn:first(skos:prefLabel[@de], skos:prefLabel) :: xsd:string ;
+ real_ressort = (sn:inRessort | sn:inCategory) / fn:first(skos:prefLabel[@de], skos:prefLabel) :: xsd:string ;
+ ort = iptc:located / fn:first(geo:officialName[@de], geo:alternateName[@de], geo:name[@de], geo:name) :: xsd:string ;
+ countrycode = iptc:located / geo:countryCode :: xsd:string ;
+ title = dc:title :: xsd:string ;
+ summary = fn:removeTags(dc:description) :: xsd:string ;
+ kind = rdf:type / rdfs:label :: xsd:string ;
+ type = rdf:type :: xsd:anyURI ;
+ thumbnail = sn:hasPreviewImage :: xsd:anyURI ;
+ geo = iptc:located :: xsd:string ;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/stanbol.search
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/stanbol.search b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/stanbol.search
new file mode 100644
index 0000000..e11062c
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-file/src/test/resources/org/apache/marmotta/ldpath/backend/file/stanbol.search
@@ -0,0 +1,18 @@
+@prefix foaf : <http://xmlns.com/foaf/0.1/> ;
+@prefix geo : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
+@prefix hgtags : <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> ;
+@prefix dcterms : <http://purl.org/dc/terms/> ;
+@prefix labs : <http://labs.newmedialab.at/ontology/> ;
+@filter rdf:type is foaf:Document ;
+ summary = fn:removeTags(fn:cleanHtml(dc:description)) :: xsd:string ;
+ tag = hgtags:taggedWithTag / hgtags:name :: xsd:string ;
+ other = labs:related / (rdfs:label[@en] | (rdfs:label[@none] | skos:prefLabel[@en])) :: xsd:string ;
+ lat = labs:relatedLocation / geo:lat :: xsd:double ;
+ title = dcterms:title :: xsd:string ;
+ long = labs:relatedLocation / geo:long :: xsd:double ;
+ location = labs:relatedLocation / rdfs:label[@en] :: xsd:string ;
+ countrycode = labs:relatedLocation / <http://www.geonames.org/ontology#countryCode> :: xsd:string ;
+ type = rdf:type :: xsd:anyURI ;
+ person = labs:relatedPerson / rdfs:label[@en] :: xsd:string ;
+ date = dcterms:created :: xsd:dateTime ;
+ company = labs:relatedOrganisation / rdfs:label[@en] :: xsd:string ;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/sn.search
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/sn.search b/libraries/ldpath/ldpath-backend-file/src/test/resources/sn.search
deleted file mode 100644
index 4ff01a6..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/test/resources/sn.search
+++ /dev/null
@@ -1,24 +0,0 @@
-@prefix dc : <http://purl.org/dc/elements/1.1/> ;
-@prefix sn : <http://lmf.salzburg.com/news-ns/> ;
-@prefix snc : <http://lmf.salzburg.com/news-ns/concepts/> ;
-@prefix iptc : <http://iptc.org/std/nar/2006-10-01/> ;
-@prefix hg : <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> ;
-@prefix geo : <http://www.geonames.org/ontology#> ;
-@prefix wgs84 : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
-@prefix skos : <http://www.w3.org/2004/02/skos/core#> ;
-
-@filter rdf:type is snc:PublicationItem ;
-
-@boost sn:boostFactor ;
-
- tag = hg:taggedWithTag / hg:name :: xsd:string ;
- ressort = (sn:inRessort | sn:inCategory | ((sn:inRessort | sn:inCategory) / (skos:narrower)+)) / fn:first(skos:prefLabel[@de], skos:prefLabel) :: xsd:string ;
- real_ressort = (sn:inRessort | sn:inCategory) / fn:first(skos:prefLabel[@de], skos:prefLabel) :: xsd:string ;
- ort = iptc:located / fn:first(geo:officialName[@de], geo:alternateName[@de], geo:name[@de], geo:name) :: xsd:string ;
- countrycode = iptc:located / geo:countryCode :: xsd:string ;
- title = dc:title :: xsd:string ;
- summary = fn:removeTags(dc:description) :: xsd:string ;
- kind = rdf:type / rdfs:label :: xsd:string ;
- type = rdf:type :: xsd:anyURI ;
- thumbnail = sn:hasPreviewImage :: xsd:anyURI ;
- geo = iptc:located :: xsd:string ;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-file/src/test/resources/stanbol.search
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-file/src/test/resources/stanbol.search b/libraries/ldpath/ldpath-backend-file/src/test/resources/stanbol.search
deleted file mode 100644
index e11062c..0000000
--- a/libraries/ldpath/ldpath-backend-file/src/test/resources/stanbol.search
+++ /dev/null
@@ -1,18 +0,0 @@
-@prefix foaf : <http://xmlns.com/foaf/0.1/> ;
-@prefix geo : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
-@prefix hgtags : <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> ;
-@prefix dcterms : <http://purl.org/dc/terms/> ;
-@prefix labs : <http://labs.newmedialab.at/ontology/> ;
-@filter rdf:type is foaf:Document ;
- summary = fn:removeTags(fn:cleanHtml(dc:description)) :: xsd:string ;
- tag = hgtags:taggedWithTag / hgtags:name :: xsd:string ;
- other = labs:related / (rdfs:label[@en] | (rdfs:label[@none] | skos:prefLabel[@en])) :: xsd:string ;
- lat = labs:relatedLocation / geo:lat :: xsd:double ;
- title = dcterms:title :: xsd:string ;
- long = labs:relatedLocation / geo:long :: xsd:double ;
- location = labs:relatedLocation / rdfs:label[@en] :: xsd:string ;
- countrycode = labs:relatedLocation / <http://www.geonames.org/ontology#countryCode> :: xsd:string ;
- type = rdf:type :: xsd:anyURI ;
- person = labs:relatedPerson / rdfs:label[@en] :: xsd:string ;
- date = dcterms:created :: xsd:dateTime ;
- company = labs:relatedOrganisation / rdfs:label[@en] :: xsd:string ;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-jena/src/main/java/at/newmedialab/ldpath/backend/jena/GenericJenaBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-jena/src/main/java/at/newmedialab/ldpath/backend/jena/GenericJenaBackend.java b/libraries/ldpath/ldpath-backend-jena/src/main/java/at/newmedialab/ldpath/backend/jena/GenericJenaBackend.java
deleted file mode 100644
index bac4c91..0000000
--- a/libraries/ldpath/ldpath-backend-jena/src/main/java/at/newmedialab/ldpath/backend/jena/GenericJenaBackend.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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.
- */
-package at.newmedialab.ldpath.backend.jena;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.util.FormatUtils;
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterators;
-import com.hp.hpl.jena.datatypes.TypeMapper;
-import com.hp.hpl.jena.rdf.model.Literal;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Statement;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Locale;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class GenericJenaBackend implements RDFBackend<RDFNode> {
-
-
- private Model model;
-
- public GenericJenaBackend(Model model) {
- this.model = model;
- }
-
-
- /**
- * Return true if the underlying backend supports the parallel execution of queries.
- *
- * @return
- */
- @Override
- public boolean supportsThreading() {
- return false;
- }
-
-
- /**
- * In case the backend supports threading, this method should return the ExecutorService representing the
- * thread pool. LDPath lets the backend manage the thread pool to avoid excessive threading.
- *
- * @return
- */
- @Override
- public ThreadPoolExecutor getThreadPool() {
- return null;
- }
-
- /**
- * Test whether the node passed as argument is a literal
- *
- * @param n the node to check
- * @return true if the node is a literal
- */
- @Override
- public boolean isLiteral(RDFNode n) {
- return n.isLiteral();
- }
-
- /**
- * Test whether the node passed as argument is a URI
- *
- * @param n the node to check
- * @return true if the node is a URI
- */
- @Override
- public boolean isURI(RDFNode n) {
- return n.isURIResource();
- }
-
- /**
- * Test whether the node passed as argument is a blank node
- *
- * @param n the node to check
- * @return true if the node is a blank node
- */
- @Override
- public boolean isBlank(RDFNode n) {
- return n.isAnon();
- }
-
- /**
- * Return the language of the literal node passed as argument.
- *
- * @param n the literal node for which to return the language
- * @return a Locale representing the language of the literal, or null if the literal node has no language
- * @throws IllegalArgumentException in case the node is no literal
- */
- @Override
- public Locale getLiteralLanguage(RDFNode n) {
- if(n.isLiteral()) {
- if (((Literal)n).getLanguage() != null) {
- return new Locale(((Literal)n).getLanguage());
- } else {
- return null;
- }
- } else {
- throw new IllegalArgumentException("the node "+n+" is not a literal, cannot return language");
- }
- }
-
- /**
- * Return the URI of the type of the literal node passed as argument.
- *
- * @param n the literal node for which to return the typer
- * @return a URI representing the type of the literal content, or null if the literal is untyped
- * @throws IllegalArgumentException in case the node is no literal
- */
- @Override
- public URI getLiteralType(RDFNode n) {
- if(n.isLiteral()) {
- if (((Literal)n).getLanguage() != null) {
- try {
- return new URI(((Literal)n).getDatatypeURI());
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("the type of node "+n+" was not a valid URI");
- }
- } else {
- return null;
- }
- } else {
- throw new IllegalArgumentException("the node "+n+" is not a literal, cannot return literal type");
- }
- }
-
- /**
- * Create a literal node with the content passed as argument
- *
- * @param content string content to represent inside the literal
- * @return a literal node in using the model used by this backend
- */
- @Override
- public RDFNode createLiteral(String content) {
- return model.createLiteral(content);
- }
-
- /**
- * Create a literal node with the content passed as argument
- *
- * @param content string content to represent inside the literal
- * @return a literal node in using the model used by this backend
- */
- @Override
- public RDFNode createLiteral(String content, Locale language, URI type) {
- if(language != null && type == null) {
- return model.createLiteral(content,language.getLanguage());
- } else if(language == null && type != null) {
- return model.createTypedLiteral(content, TypeMapper.getInstance().getSafeTypeByName(type.toString()));
- } else {
- return model.createLiteral(content);
- }
- }
-
- /**
- * Create a URI mode with the URI passed as argument
- *
- * @param uri URI of the resource to create
- * @return a URI node using the model used by this backend
- */
- @Override
- public RDFNode createURI(String uri) {
- return model.createProperty(uri);
- }
-
- /**
- * Return the lexial representation of a node. For a literal, this will be the content, for a URI node it will be the
- * URI itself, and for a blank node it will be the identifier of the node.
- *
- * @param rdfNode
- * @return
- */
- @Override
- public String stringValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return ((Literal)rdfNode).getString();
- } else if(isURI(rdfNode)) {
- return ((Resource)rdfNode).getURI();
- } else if(isBlank(rdfNode)) {
- return ((Resource)rdfNode).getId().getLabelString();
- } else {
- return rdfNode.toString();
- }
- }
-
- /**
- * Return the double value of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation. The method can throw
- * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as double, and an
- * IllegalArgumentException, indicating that the passed node is not a literal
- *
- * @param rdfNode the literal node for which to return the double value
- * @return double value of the literal node
- * @throws NumberFormatException in case the literal cannot be represented as double value
- * @throws ArithmeticException in case the literal cannot be represented as double value
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Double doubleValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return ((Literal)rdfNode).getDouble();
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * Return the long value of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation. The method can throw
- * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as long, and an
- * IllegalArgumentException, indicating that the passed node is not a literal
- *
- * @param rdfNode the literal node for which to return the long value
- * @return long value of the literal node
- * @throws NumberFormatException in case the literal cannot be represented as long value
- * @throws ArithmeticException in case the literal cannot be represented as long value
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Long longValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return ((Literal)rdfNode).getLong();
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * Return the boolean value of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation.
- * TODO: Define:<ul>
- * <li> Do we also support '0' '1', 'yes', 'no'; whats about case insensitive
- * such as TRUE, False
- * <li> should we throw an RuntimeException of not an boolean value or return
- * false as {@link Boolean#parseBoolean(String)}
- * </ul>
- *
- * @param rdfNode the literal node for which to return the boolean value
- * @return long value of the literal node
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Boolean booleanValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return ((Literal)rdfNode).getBoolean();
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * TODO
- *
- * @param rdfNode the literal node for which to return the dateTime value
- * @return long value of the literal node
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Date dateTimeValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return FormatUtils.parseDate(((Literal)rdfNode).getString());
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * TODO
- *
- * @param rdfNode the literal node for which to return the date value
- * @return long value of the literal node
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Date dateValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return FormatUtils.parseDate(((Literal)rdfNode).getString());
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * TODO
- *
- * @param rdfNode the literal node for which to return the time value
- * @return long value of the literal node
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Date timeValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return FormatUtils.parseDate(((Literal)rdfNode).getString());
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * Return the float value of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation. The method can throw
- * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as float, and an
- * IllegalArgumentException, indicating that the passed node is not a literal
- *
- * @param rdfNode the literal node for which to return the float value
- * @return long value of the literal node
- * @throws NumberFormatException in case the literal cannot be represented as float value
- * @throws ArithmeticException in case the literal cannot be represented as float value
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Float floatValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return ((Literal)rdfNode).getFloat();
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * Return the 32bit integer value of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation. The method can throw
- * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as integer, and an
- * IllegalArgumentException, indicating that the passed node is not a literal.
- * <p/>
- * Note that this is restricted to 32bit singed integer values as defined by
- * xsd:int and {@link Integer}. For bigger nuber one might want to use
- * xsd:integer represented by {@link java.math.BigInteger}.
- *
- * @param rdfNode the literal node for which to return the Integer (xsd:int) value
- * @return long value of the literal node
- * @throws NumberFormatException in case the literal cannot be represented as 32 bit integer value
- * @throws ArithmeticException in case the literal cannot be represented as 32 bit integer value
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public Integer intValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return ((Literal)rdfNode).getInt();
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * Return the arbitrary length integer value of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation. The method can throw
- * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as integer, and an
- * IllegalArgumentException, indicating that the passed node is not a literal.
- *
- * @param rdfNode the literal node for which to return the {@link java.math.BigInteger xsd:integer} value
- * @return long value of the literal node
- * @throws NumberFormatException in case the literal cannot be represented as integer value
- * @throws ArithmeticException in case the literal cannot be represented as long value
- * @throws IllegalArgumentException in case the node passed as argument is integer a literal
- */
- @Override
- public BigInteger integerValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return new BigInteger(((Literal)rdfNode).getString());
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * Return the decimal number of a literal node. Depending on the backend implementing this method,
- * the value can be retrieved directly or must be parsed from the string representation. The method can throw
- * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as decimal, and an
- * IllegalArgumentException, indicating that the passed node is not a literal.
- *
- * @param rdfNode the literal node for which to return the xsd:decimal value
- * @return long value of the literal node
- * @throws NumberFormatException in case the literal cannot be represented as decimal value
- * @throws ArithmeticException in case the literal cannot be represented as decimal value
- * @throws IllegalArgumentException in case the node passed as argument is not a literal
- */
- @Override
- public BigDecimal decimalValue(RDFNode rdfNode) {
- if(isLiteral(rdfNode)) {
- return new BigDecimal(((Literal)rdfNode).getString());
- } else {
- throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value");
- }
- }
-
- /**
- * List the objects of triples in the triple store underlying this backend that have the subject and
- * property given as argument.
- *
- * @param subject the subject of the triples to look for
- * @param property the property of the triples to look for, <code>null</code> is interpreted as wildcard
- * @return all objects of triples with matching subject and property
- */
- @Override
- public Collection<RDFNode> listObjects(RDFNode subject, RDFNode property) {
- try {
- return ImmutableSet.copyOf(
- Iterators.transform(
- model.listStatements((Resource)subject,(Property)property,(RDFNode)null),
- new Function<Statement, RDFNode>() {
- @Override
- public RDFNode apply(Statement input) {
- return input.getObject();
- }
- })
- );
-
- } catch(ClassCastException ex) {
- throw new IllegalArgumentException("subject or property where no valid resources in the Jena model",ex);
- }
-
- }
-
- /**
- * List the subjects of triples in the triple store underlying this backend that have the object and
- * property given as argument.
- *
- * @param object the object of the triples to look for
- * @param property the property of the triples to look for, <code>null</code> is interpreted as wildcard
- * @return all subjects of triples with matching object and property
- * @throws UnsupportedOperationException in case reverse selection is not supported (e.g. when querying Linked Data)
- */
- @Override
- public Collection<RDFNode> listSubjects(RDFNode property, RDFNode object) {
- try {
- return ImmutableSet.copyOf(
- Iterators.transform(
- model.listStatements((Resource)null,(Property)property,object),
- new Function<Statement, RDFNode>() {
- @Override
- public RDFNode apply(Statement input) {
- return input.getSubject();
- }
- })
- );
- } catch(ClassCastException ex) {
- throw new IllegalArgumentException("property was no valid resource in the Jena model",ex);
- }
- }
-}