Author: [email protected]
Date: Mon Dec 5 14:48:29 2011
New Revision: 1806
Log:
Added several shell commands and API methods.
Modified:
trunk/amdatu-semanticweb/rdf2go-sesame/pom.xml
trunk/amdatu-semanticweb/semantic-shell/pom.xml
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/Activator.java
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/SemanticQueryCommand.java
trunk/amdatu-semanticweb/semanticservice-rdf2go/pom.xml
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/Model.java
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/impl/RDF2GOSemanticServiceImpl.java
Modified: trunk/amdatu-semanticweb/rdf2go-sesame/pom.xml
==============================================================================
--- trunk/amdatu-semanticweb/rdf2go-sesame/pom.xml (original)
+++ trunk/amdatu-semanticweb/rdf2go-sesame/pom.xml Mon Dec 5 14:48:29 2011
@@ -76,7 +76,6 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Bundle-Activator>org.amdatu.semanticweb.sesame.osgi.Activator</Bundle-Activator>
<Bundle-SymbolicName>org.amdatu.semanticweb.rdf2go.sesame</Bundle-SymbolicName>
<Embed-Dependency>*;scope=compile;inline=true</Embed-Dependency>
@@ -85,7 +84,6 @@
org.amdatu.semanticweb.sesame.service
</Private-Package>
<Import-Package>
-org.apache.felix.dm;provide:=true,
!org.apache.commons.*,
!org.springframework.*,
!javax.swing,*</Import-Package>
@@ -99,7 +97,6 @@
</instructions>
</configuration>
</plugin>
-
</plugins>
</build>
</project>
Modified: trunk/amdatu-semanticweb/semantic-shell/pom.xml
==============================================================================
--- trunk/amdatu-semanticweb/semantic-shell/pom.xml (original)
+++ trunk/amdatu-semanticweb/semantic-shell/pom.xml Mon Dec 5 14:48:29 2011
@@ -39,7 +39,7 @@
org.amdatu.semantic.shell
</Private-Package>
<Import-Package>
- org.apache.felix.dm,*
+ *
</Import-Package>
</instructions>
</configuration>
Modified:
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/Activator.java
==============================================================================
---
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/Activator.java
(original)
+++
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/Activator.java
Mon Dec 5 14:48:29 2011
@@ -31,7 +31,7 @@
throws Exception {
Properties props = new Properties();
props.put(CommandProcessor.COMMAND_SCOPE, "semantic");
- props.put(CommandProcessor.COMMAND_FUNCTION, new String[] { "query",
"ask", "add" });
+ props.put(CommandProcessor.COMMAND_FUNCTION, new String[] { "query",
"ask", "add", "describe", "construct", "print", "load", "save", "clear"});
manager.add(createComponent()
.setInterface(Object.class.getName(), props)
.setImplementation(SemanticQueryCommand.class)
Modified:
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/SemanticQueryCommand.java
==============================================================================
---
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/SemanticQueryCommand.java
(original)
+++
trunk/amdatu-semanticweb/semantic-shell/src/main/java/org/amdatu/semantic/shell/SemanticQueryCommand.java
Mon Dec 5 14:48:29 2011
@@ -15,6 +15,12 @@
*/
package org.amdatu.semantic.shell;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.StringWriter;
+
import org.amdatu.semantic.Model;
import org.amdatu.semantic.Row;
import org.amdatu.semantic.RowSet;
@@ -85,10 +91,52 @@
public void add(final String subject, final String predicate, final String
object) throws Exception {
m_service.update(new Updater<Void>() {
- public Void update(Model model) {
+ public Void update(Model model) throws Exception {
model.add(subject, predicate, object);
return null;
}
}).get();
}
+
+ public void print() throws Exception {
+ m_service.read(new Reader<Void>() {
+ public Void read(Model model) throws Exception {
+ StringWriter sw = new StringWriter();
+ model.writeTo(sw);
+ System.out.println(sw.toString());
+ return null;
+ }
+ }).get();
+ }
+
+ public void load(final String file) throws Exception {
+ m_service.update(new Updater<Void>() {
+ public Void update(Model model) throws Exception {
+ FileReader sw = new FileReader(new File(file));
+ model.readFrom(sw);
+ sw.close();
+ return null;
+ }
+ }).get();
+ }
+
+ public void save(final String file) throws Exception {
+ m_service.read(new Reader<Void>() {
+ public Void read(Model model) throws Exception {
+ FileWriter sw = new FileWriter(new File(file));
+ model.writeTo(sw);
+ sw.close();
+ return null;
+ }
+ }).get();
+ }
+
+ public void clear() throws Exception {
+ m_service.update(new Updater<Void>() {
+ public Void update(Model model) throws Exception {
+ model.clear();
+ return null;
+ }
+ }).get();
+ }
}
Modified: trunk/amdatu-semanticweb/semanticservice-rdf2go/pom.xml
==============================================================================
--- trunk/amdatu-semanticweb/semanticservice-rdf2go/pom.xml (original)
+++ trunk/amdatu-semanticweb/semanticservice-rdf2go/pom.xml Mon Dec 5
14:48:29 2011
@@ -41,7 +41,7 @@
</Private-Package>
<Embed-Dependency>commons-codec;scope=compile;inline=true</Embed-Dependency>
<Import-Package>
- org.apache.felix.dm;provide:=true,*
+ *
</Import-Package>
<Export-Package>
org.amdatu.semantic;provide:=true,
Modified:
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/Model.java
==============================================================================
---
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/Model.java
(original)
+++
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/Model.java
Mon Dec 5 14:48:29 2011
@@ -15,6 +15,10 @@
*/
package org.amdatu.semantic;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
/**
* The {@link Model} is the basic abstraction of a semantic storage.
*/
@@ -58,4 +62,8 @@
* </ul>
*/
public void remove(String subject, String predicate, String object);
+
+ public void readFrom(Reader reader) throws IOException;
+ public void writeTo(Writer writer) throws IOException;
+ public void clear();
}
\ No newline at end of file
Modified:
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/impl/RDF2GOSemanticServiceImpl.java
==============================================================================
---
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/impl/RDF2GOSemanticServiceImpl.java
(original)
+++
trunk/amdatu-semanticweb/semanticservice-rdf2go/src/main/java/org/amdatu/semantic/impl/RDF2GOSemanticServiceImpl.java
Mon Dec 5 14:48:29 2011
@@ -15,6 +15,9 @@
*/
package org.amdatu.semantic.impl;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
@@ -33,6 +36,7 @@
import org.amdatu.semantic.TripleSet;
import org.ontoware.aifbcommons.collection.ClosableIterable;
import org.ontoware.aifbcommons.collection.ClosableIterator;
+import org.ontoware.rdf2go.exception.ModelRuntimeException;
import org.ontoware.rdf2go.model.ModelSet;
import org.ontoware.rdf2go.model.QueryResultTable;
import org.ontoware.rdf2go.model.QueryRow;
@@ -151,6 +155,21 @@
m_rdf2goModel.close();
}
+ public void writeTo(Writer output) throws IOException {
+ checkState(false);
+ m_rdf2goModel.writeTo(output);
+ }
+
+ public void readFrom(java.io.Reader reader) throws IOException {
+ checkState(true);
+ m_rdf2goModel.readFrom(reader);
+ }
+
+ public void clear() {
+ checkState(true);
+ m_rdf2goModel.removeAll();
+ }
+
private Statement createStatement(String subject, String predicate,
String object) {
URI subjectUri = null;
URI predicateUri =
m_rdf2goModel.createURI(stripAngleBrackets(predicate));
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits