You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by sf...@apache.org on 2010/12/12 17:10:52 UTC
svn commit: r1044841 [9/11] - in /incubator/stanbol/trunk/fise:
SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/
SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/
SemiAutomaticContentEnhancer/src/main/java/eu/iks...
Modified: incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/commons/testing/it/JarExecutor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/commons/testing/it/JarExecutor.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/commons/testing/it/JarExecutor.java (original)
+++ incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/commons/testing/it/JarExecutor.java Sun Dec 12 16:10:48 2010
@@ -30,7 +30,7 @@ import org.apache.commons.exec.ShutdownH
/** Start a runnable jar by forking a JVM process,
* and terminate the process when this VM exits.
- *
+ *
* TODO: move to a commons/testing library?
*/
public class JarExecutor {
@@ -38,11 +38,11 @@ public class JarExecutor {
private final File jarToExecute;
private final String javaExecutable;
private final int serverPort;
-
+
public static final int DEFAULT_PORT = 8765;
public static final String PROP_PREFIX = "jar.executor.";
public static final String PROP_SERVER_PORT = PROP_PREFIX + "server.port";
-
+
@SuppressWarnings("serial")
public static class ExecutorException extends Exception {
ExecutorException(String reason) {
@@ -52,7 +52,7 @@ public class JarExecutor {
super(reason, cause);
}
}
-
+
public static JarExecutor getInstance(Properties config) throws ExecutorException {
if(instance == null) {
synchronized (JarExecutor.class) {
@@ -63,19 +63,19 @@ public class JarExecutor {
}
return instance;
}
-
+
/** Build a JarExecutor, locate the jar to run, etc */
private JarExecutor(Properties config) throws ExecutorException {
final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
-
+
String str = config.getProperty(PROP_SERVER_PORT);
serverPort = str == null ? DEFAULT_PORT : Integer.valueOf(str);
-
+
// TODO make those configurable
javaExecutable = isWindows ? "java.exe" : "java";
final File jarFolder = new File("./target/dependency");
final Pattern jarPattern = Pattern.compile("eu.iksproject.*full.*jar$");
-
+
// Find executable jar
final String [] candidates = jarFolder.list();
File f = null;
@@ -87,15 +87,15 @@ public class JarExecutor {
}
}
}
-
+
if(f == null) {
- throw new ExecutorException("Executable jar matching " + jarPattern
+ throw new ExecutorException("Executable jar matching " + jarPattern
+ " not found in " + jarFolder.getAbsolutePath()
+ ", candidates are " + Arrays.asList(candidates));
}
jarToExecute = f;
}
-
+
/** Start the jar if not done yet, and setup runtime hook
* to stop it.
*/
@@ -105,13 +105,13 @@ public class JarExecutor {
public void onProcessFailed(ExecuteException ex) {
info("Process execution failed:" + ex);
}
-
+
@Override
public void onProcessComplete(int result) {
info("Process execution complete, exit code=" + result);
}
};
-
+
// TODO add optional memory settings
final Executor e = new DefaultExecutor();
final CommandLine cl = new CommandLine(javaExecutable);
@@ -123,8 +123,8 @@ public class JarExecutor {
e.setProcessDestroyer(new ShutdownHookProcessDestroyer());
e.execute(cl, h);
}
-
+
protected void info(String msg) {
System.out.println(getClass().getName() + ": " + msg);
}
-}
\ No newline at end of file
+}
Modified: incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/DummyTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/DummyTest.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/DummyTest.java (original)
+++ incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/DummyTest.java Sun Dec 12 16:10:48 2010
@@ -25,18 +25,18 @@ import org.junit.Test;
* integration tests that talk to the server via http.
*/
public class DummyTest {
-
+
@BeforeClass
public static void startRunnableJar() throws Exception {
JarExecutor.getInstance(System.getProperties()).start();
}
-
+
@Test
public void testNothing() throws Exception {
// TODO check that server is started and test it...
final long delay = 10000;
- System.out.println(getClass().getName()
- + " - this test does nothing for now, just waits "
+ System.out.println(getClass().getName()
+ + " - this test does nothing for now, just waits "
+ delay + " msec to let you check that the server is starting ...");
Thread.sleep(delay);
System.out.println(getClass().getName() + " - done waiting");
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JerseyEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JerseyEndpoint.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JerseyEndpoint.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JerseyEndpoint.java Sun Dec 12 16:10:48 2010
@@ -180,4 +180,4 @@ public class JerseyEndpoint {
this.httpService = null;
}
-}
\ No newline at end of file
+}
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JettyServer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JettyServer.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JettyServer.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JettyServer.java Sun Dec 12 16:10:48 2010
@@ -91,4 +91,4 @@ public class JettyServer {
server.stop();
}
-}
\ No newline at end of file
+}
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/processors/FreemarkerViewProcessor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/processors/FreemarkerViewProcessor.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/processors/FreemarkerViewProcessor.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/processors/FreemarkerViewProcessor.java Sun Dec 12 16:10:48 2010
@@ -217,4 +217,4 @@ public class FreemarkerViewProcessor imp
}
}
-}
\ No newline at end of file
+}
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/GraphWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/GraphWriter.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/GraphWriter.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/GraphWriter.java Sun Dec 12 16:10:48 2010
@@ -57,4 +57,4 @@ public class GraphWriter implements Mess
getSerializer().serialize(entityStream, t, mediaType.toString());
}
}
-}
\ No newline at end of file
+}
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProvider.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProvider.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProvider.java Sun Dec 12 16:10:48 2010
@@ -29,126 +29,126 @@ import eu.iksproject.fise.jsonld.JsonLdR
* <br>
* Note: This implementation is based on <a href="http://json-ld.org/spec/">JSON-LD
* specification</a> draft from 25 October 2010.
- *
+ *
* @author Fabian Christ
- *
+ *
* @scr.component immediate="true"
- * @scr.service
- * interface="org.apache.clerezza.rdf.core.serializedform.SerializingProvider"
+ * @scr.service
+ * interface="org.apache.clerezza.rdf.core.serializedform.SerializingProvider"
*/
@SupportedFormat(JsonLdSerializerProvider.SUPPORTED_FORMAT)
public class JsonLdSerializerProvider implements SerializingProvider {
- public static final String SUPPORTED_FORMAT = MediaType.APPLICATION_JSON;
-
- private static final String RDF_NS_TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
-
- private static final Logger logger = LoggerFactory.getLogger(JsonLdSerializerProvider.class);
-
- // Map from Namespace -> to Prefix
- private Map<String, String> namespacePrefixMap = new HashMap<String, String>();
-
- private int indentation = 2;
-
- @Override
- public void serialize(OutputStream serializedGraph, TripleCollection tc, String formatIdentifier) {
- if (!formatIdentifier.equals(SUPPORTED_FORMAT)) {
- logger.info("serialize() the format '" + formatIdentifier + "' is not supported by this implementation");
- return;
- }
-
- JsonLd jsonLd = new JsonLd();
- jsonLd.setNamespacePrefixMap(this.namespacePrefixMap);
-
- Map<NonLiteral, String> subjects = createSubjectsMap(tc);
- for (NonLiteral subject : subjects.keySet()) {
- JsonLdResource resource = new JsonLdResource();
- resource.setSubject(subject.toString());
-
- Iterator<Triple> triplesFromSubject = tc.filter(subject, null, null);
- while (triplesFromSubject.hasNext()) {
- Triple currentTriple = triplesFromSubject.next();
- if (currentTriple.getPredicate().getUnicodeString().equals(RDF_NS_TYPE)) {
- if (logger.isDebugEnabled()) {
- logger.debug("serialize() adding rdf:type: \"a\":" + currentTriple.getObject());
- }
- resource.addType(currentTriple.getObject().toString());
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("serializer() adding predicate " + currentTriple.getPredicate().toString() + " with object " + currentTriple.getObject().toString());
- }
-
- String property = currentTriple.getPredicate().getUnicodeString();
- String value = currentTriple.getObject().toString();
- resource.putProperty(property, value);
- }
- }
-
- jsonLd.put(resource.getSubject(), resource);
- }
-
- try {
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(serializedGraph));
- writer.write(jsonLd.toString(this.indentation));
- writer.flush();
- } catch (IOException ioe) {
- logger.error(ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
- }
- }
-
- private Map<NonLiteral, String> createSubjectsMap(TripleCollection tc) {
- Map<NonLiteral, String> subjects = new HashMap<NonLiteral, String>();
- int bNodeCounter = 0;
- for (Triple triple : tc) {
- NonLiteral subject = triple.getSubject();
- if (!subjects.containsKey(subject)) {
- if (subject instanceof UriRef) {
- subjects.put(subject, subject.toString());
- } else if (subject instanceof BNode) {
- bNodeCounter++;
- subjects.put(subject, "_:bnode" + bNodeCounter);
- }
- }
- }
- return subjects;
- }
-
- /**
- * Get the known namespace to prefix mapping.
- *
- * @return A {@link Map} from namespace String to prefix String.
- */
- public Map<String, String> getNamespacePrefixMap() {
- return namespacePrefixMap;
- }
-
- /**
- * Sets the known namespaces for the serializer.
- *
- * @param knownNamespaces A {@link Map} from namespace String to prefix String.
- */
- public void setNamespacePrefixMap(Map<String, String> knownNamespaces) {
- this.namespacePrefixMap = knownNamespaces;
- }
-
- /**
- * Returns the current number of space characters which are used
- * to indent the serialized output.
- *
- * @return Number of space characters used for indentation.
- */
- public int getIndentation() {
- return indentation;
- }
-
- /**
- * Sets the number of characters used per indentation level for the serialized output.<br />
- * Set this value to zero (0) if you don't want indentation. Default value is 2.
- *
- * @param indentation Number of space characters used for indentation.
- */
- public void setIndentation(int indentation) {
- this.indentation = indentation;
- }
+ public static final String SUPPORTED_FORMAT = MediaType.APPLICATION_JSON;
+
+ private static final String RDF_NS_TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
+
+ private static final Logger logger = LoggerFactory.getLogger(JsonLdSerializerProvider.class);
+
+ // Map from Namespace -> to Prefix
+ private Map<String, String> namespacePrefixMap = new HashMap<String, String>();
+
+ private int indentation = 2;
+
+ @Override
+ public void serialize(OutputStream serializedGraph, TripleCollection tc, String formatIdentifier) {
+ if (!formatIdentifier.equals(SUPPORTED_FORMAT)) {
+ logger.info("serialize() the format '" + formatIdentifier + "' is not supported by this implementation");
+ return;
+ }
+
+ JsonLd jsonLd = new JsonLd();
+ jsonLd.setNamespacePrefixMap(this.namespacePrefixMap);
+
+ Map<NonLiteral, String> subjects = createSubjectsMap(tc);
+ for (NonLiteral subject : subjects.keySet()) {
+ JsonLdResource resource = new JsonLdResource();
+ resource.setSubject(subject.toString());
+
+ Iterator<Triple> triplesFromSubject = tc.filter(subject, null, null);
+ while (triplesFromSubject.hasNext()) {
+ Triple currentTriple = triplesFromSubject.next();
+ if (currentTriple.getPredicate().getUnicodeString().equals(RDF_NS_TYPE)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("serialize() adding rdf:type: \"a\":" + currentTriple.getObject());
+ }
+ resource.addType(currentTriple.getObject().toString());
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("serializer() adding predicate " + currentTriple.getPredicate().toString() + " with object " + currentTriple.getObject().toString());
+ }
+
+ String property = currentTriple.getPredicate().getUnicodeString();
+ String value = currentTriple.getObject().toString();
+ resource.putProperty(property, value);
+ }
+ }
+
+ jsonLd.put(resource.getSubject(), resource);
+ }
+
+ try {
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(serializedGraph));
+ writer.write(jsonLd.toString(this.indentation));
+ writer.flush();
+ } catch (IOException ioe) {
+ logger.error(ioe.getMessage());
+ throw new RuntimeException(ioe.getMessage());
+ }
+ }
+
+ private Map<NonLiteral, String> createSubjectsMap(TripleCollection tc) {
+ Map<NonLiteral, String> subjects = new HashMap<NonLiteral, String>();
+ int bNodeCounter = 0;
+ for (Triple triple : tc) {
+ NonLiteral subject = triple.getSubject();
+ if (!subjects.containsKey(subject)) {
+ if (subject instanceof UriRef) {
+ subjects.put(subject, subject.toString());
+ } else if (subject instanceof BNode) {
+ bNodeCounter++;
+ subjects.put(subject, "_:bnode" + bNodeCounter);
+ }
+ }
+ }
+ return subjects;
+ }
+
+ /**
+ * Get the known namespace to prefix mapping.
+ *
+ * @return A {@link Map} from namespace String to prefix String.
+ */
+ public Map<String, String> getNamespacePrefixMap() {
+ return namespacePrefixMap;
+ }
+
+ /**
+ * Sets the known namespaces for the serializer.
+ *
+ * @param knownNamespaces A {@link Map} from namespace String to prefix String.
+ */
+ public void setNamespacePrefixMap(Map<String, String> knownNamespaces) {
+ this.namespacePrefixMap = knownNamespaces;
+ }
+
+ /**
+ * Returns the current number of space characters which are used
+ * to indent the serialized output.
+ *
+ * @return Number of space characters used for indentation.
+ */
+ public int getIndentation() {
+ return indentation;
+ }
+
+ /**
+ * Sets the number of characters used per indentation level for the serialized output.<br />
+ * Set this value to zero (0) if you don't want indentation. Default value is 2.
+ *
+ * @param indentation Number of space characters used for indentation.
+ */
+ public void setIndentation(int indentation) {
+ this.indentation = indentation;
+ }
}
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetToXml.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetToXml.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetToXml.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetToXml.java Sun Dec 12 16:10:48 2010
@@ -19,79 +19,79 @@ import org.w3c.dom.Element;
class ResultSetToXml {
- private final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
- Document toDocument(ResultSet rs) throws ParserConfigurationException {
- final Document doc = dbf.newDocumentBuilder().newDocument();
-
- // root element
- Element root = doc.createElement("sparql");
- root.setAttribute("xmlns", "http://www.w3.org/2005/sparql-results#");
- doc.appendChild(root);
- Element head = doc.createElement("head");
- root.appendChild(head);
-
- // result set
- Element results = doc.createElement("results");
- SolutionMapping solutionMapping = null;
- while (rs.hasNext()) {
- solutionMapping = rs.next();
- createResultElement(solutionMapping, results, doc);
- }
- createVariable(solutionMapping, head, doc);
- root.appendChild(results);
-
- return doc;
- }
-
- private void createResultElement(SolutionMapping solutionMap, Element results, Document doc) {
- Set<Variable> keys = solutionMap.keySet();
- Element result = doc.createElement("result");
- results.appendChild(result);
- for (Variable key : keys) {
- Element bindingElement = doc.createElement("binding");
- bindingElement.setAttribute("name", key.getName());
- bindingElement.appendChild(createValueElement(
- (Resource) solutionMap.get(key), doc));
- result.appendChild(bindingElement);
- }
- }
-
- private void createVariable(SolutionMapping solutionMap, Element head, Document doc) {
- if(solutionMap != null) {
- Set<Variable> keys = solutionMap.keySet();
- for (Variable key : keys) {
- Element varElement = doc.createElement("variable");
- varElement.setAttribute("name", key.getName());
- head.appendChild(varElement);
- }
- }
- }
-
- private Element createValueElement(Resource resource, Document doc) {
- Element value;
- if (resource instanceof UriRef) {
- value = doc.createElement("uri");
- value.appendChild(doc.createTextNode(((UriRef) resource)
- .getUnicodeString()));
- } else if (resource instanceof TypedLiteral) {
- value = doc.createElement("literal");
- value.appendChild(doc.createTextNode(((TypedLiteral) resource)
- .getLexicalForm()));
- value.setAttribute("datatype", (((TypedLiteral) resource)
- .getDataType().getUnicodeString()));
- } else if (resource instanceof PlainLiteral) {
- value = doc.createElement("literal");
- value.appendChild(doc.createTextNode(((PlainLiteral) resource)
- .getLexicalForm()));
- Language lang = ((PlainLiteral) resource).getLanguage();
- if (lang != null) {
- value.setAttribute("xml:lang", (lang.toString()));
- }
- } else {
- value = doc.createElement("bnode");
- value.appendChild(doc.createTextNode(((BNode) resource).toString()));
- }
- return value;
- }
+ private final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ Document toDocument(ResultSet rs) throws ParserConfigurationException {
+ final Document doc = dbf.newDocumentBuilder().newDocument();
+
+ // root element
+ Element root = doc.createElement("sparql");
+ root.setAttribute("xmlns", "http://www.w3.org/2005/sparql-results#");
+ doc.appendChild(root);
+ Element head = doc.createElement("head");
+ root.appendChild(head);
+
+ // result set
+ Element results = doc.createElement("results");
+ SolutionMapping solutionMapping = null;
+ while (rs.hasNext()) {
+ solutionMapping = rs.next();
+ createResultElement(solutionMapping, results, doc);
+ }
+ createVariable(solutionMapping, head, doc);
+ root.appendChild(results);
+
+ return doc;
+ }
+
+ private void createResultElement(SolutionMapping solutionMap, Element results, Document doc) {
+ Set<Variable> keys = solutionMap.keySet();
+ Element result = doc.createElement("result");
+ results.appendChild(result);
+ for (Variable key : keys) {
+ Element bindingElement = doc.createElement("binding");
+ bindingElement.setAttribute("name", key.getName());
+ bindingElement.appendChild(createValueElement(
+ (Resource) solutionMap.get(key), doc));
+ result.appendChild(bindingElement);
+ }
+ }
+
+ private void createVariable(SolutionMapping solutionMap, Element head, Document doc) {
+ if(solutionMap != null) {
+ Set<Variable> keys = solutionMap.keySet();
+ for (Variable key : keys) {
+ Element varElement = doc.createElement("variable");
+ varElement.setAttribute("name", key.getName());
+ head.appendChild(varElement);
+ }
+ }
+ }
+
+ private Element createValueElement(Resource resource, Document doc) {
+ Element value;
+ if (resource instanceof UriRef) {
+ value = doc.createElement("uri");
+ value.appendChild(doc.createTextNode(((UriRef) resource)
+ .getUnicodeString()));
+ } else if (resource instanceof TypedLiteral) {
+ value = doc.createElement("literal");
+ value.appendChild(doc.createTextNode(((TypedLiteral) resource)
+ .getLexicalForm()));
+ value.setAttribute("datatype", (((TypedLiteral) resource)
+ .getDataType().getUnicodeString()));
+ } else if (resource instanceof PlainLiteral) {
+ value = doc.createElement("literal");
+ value.appendChild(doc.createTextNode(((PlainLiteral) resource)
+ .getLexicalForm()));
+ Language lang = ((PlainLiteral) resource).getLanguage();
+ if (lang != null) {
+ value.setAttribute("xml:lang", (lang.toString()));
+ }
+ } else {
+ value = doc.createElement("bnode");
+ value.appendChild(doc.createTextNode(((BNode) resource).toString()));
+ }
+ return value;
+ }
}
Modified: incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetWriter.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetWriter.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetWriter.java Sun Dec 12 16:10:48 2010
@@ -31,40 +31,40 @@ import org.w3c.dom.Document;
@Produces({"application/sparql-results+xml", "application/xml", "text/xml"})
public class ResultSetWriter implements MessageBodyWriter<ResultSet> {
- public static final String ENCODING = "UTF-8";
+ public static final String ENCODING = "UTF-8";
- @Override
+ @Override
public long getSize(ResultSet resultSet, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return -1;
}
- @Override
+ @Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return ResultSet.class.isAssignableFrom(type);
}
- @Override
- public void writeTo(ResultSet resultSet, Class<?> type, Type genericType,
- Annotation[] annotations, MediaType mediaType,
- MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
- throws IOException, WebApplicationException {
+ @Override
+ public void writeTo(ResultSet resultSet, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
+ throws IOException, WebApplicationException {
try {
Document doc = new ResultSetToXml().toDocument(resultSet);
DOMSource domSource = new DOMSource(doc);
- StreamResult streamResult = new StreamResult(entityStream);
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer serializer = tf.newTransformer();
- serializer.setOutputProperty(OutputKeys.ENCODING,ENCODING);
- serializer.setOutputProperty(OutputKeys.INDENT,"yes");
- serializer.transform(domSource, streamResult);
- } catch(TransformerException te) {
- throw new IOException("TransformerException in writeTo()", te);
- } catch(ParserConfigurationException pce) {
- throw new IOException("Exception in ResultSetToXml.toDocument()", pce);
- }
+ StreamResult streamResult = new StreamResult(entityStream);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer serializer = tf.newTransformer();
+ serializer.setOutputProperty(OutputKeys.ENCODING,ENCODING);
+ serializer.setOutputProperty(OutputKeys.INDENT,"yes");
+ serializer.transform(domSource, streamResult);
+ } catch(TransformerException te) {
+ throw new IOException("TransformerException in writeTo()", te);
+ } catch(ParserConfigurationException pce) {
+ throw new IOException("Exception in ResultSetToXml.toDocument()", pce);
+ }
- entityStream.flush();
- }
+ entityStream.flush();
+ }
}
Modified: incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/JettyServerTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/JettyServerTest.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/JettyServerTest.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/JettyServerTest.java Sun Dec 12 16:10:48 2010
@@ -32,7 +32,6 @@ import org.apache.clerezza.rdf.core.seri
import org.apache.clerezza.rdf.jena.serializer.JenaSerializerProvider;
import org.apache.clerezza.rdf.rdfjson.serializer.RdfJsonSerializingProvider;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -316,4 +315,4 @@ public class JettyServerTest {
assertTrue(r.contains("{\"value\":\"http:\\/\\/dbpedia.org\\/resource\\/Bob_Marley\""));
}
-}
\ No newline at end of file
+}
Modified: incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProviderTest.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProviderTest.java (original)
+++ incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProviderTest.java Sun Dec 12 16:10:48 2010
@@ -25,160 +25,160 @@ import eu.iksproject.fise.servicesapi.rd
public class JsonLdSerializerProviderTest {
- private JsonLdSerializerProvider jsonldProvider;
- private String formatIdentifier = "application/json";
+ private JsonLdSerializerProvider jsonldProvider;
+ private String formatIdentifier = "application/json";
- @Before
- public void setup() {
+ @Before
+ public void setup() {
jsonldProvider = new JsonLdSerializerProvider();
- }
-
- @Test
- public void testWrongFormat() {
- String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived "
+ }
+
+ @Test
+ public void testWrongFormat() {
+ String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived "
+ "in New Zealand and worked at the University of Otago.";
- ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
+ ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
- OutputStream serializedGraph = new ByteArrayOutputStream();
- jsonldProvider.serialize(serializedGraph, ci.getMetadata(), "application/format+notsupported");
- }
-
- @Test
- public void testSingleSubjectSerializeNoNs() {
- String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived "
+ OutputStream serializedGraph = new ByteArrayOutputStream();
+ jsonldProvider.serialize(serializedGraph, ci.getMetadata(), "application/format+notsupported");
+ }
+
+ @Test
+ public void testSingleSubjectSerializeNoNs() {
+ String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived "
+ "in New Zealand and worked at the University of Otago.";
- ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
- getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+ ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
+ getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
- OutputStream serializedGraph = new ByteArrayOutputStream();
- jsonldProvider.setIndentation(0);
- jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
-
- String expected = "{\"@\":\"<urn:iks-project:fise:test:text-annotation:Person>\",\"a\":[\"<http:\\/\\/fise.iks-project.eu\\/ontology\\/Enhancement>\",\"<http:\\/\\/fise.iks-project.eu\\/ontology\\/TextAnnotation>\"],\"http:\\/\\/fise.iks-project.eu\\/ontology\\/end\":\"\\\"20\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/selected-text\":\"\\\"Patrick Marshall\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/selection-context\":\"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/start\":\"\\\"4\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/created\":\"\\\"2010-10-27T14:00:00+02:00\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#dateTime>\",\"http:
\\/\\/purl.org\\/dc\\/terms\\/creator\":\"<urn:iks-project:fise:test:dummyEngine>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/type\":\"<http:\\/\\/dbpedia.org\\/ontology\\/Person>\"}";
- String result = serializedGraph.toString();
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSingleSubjectSerializeNoNsWithIndent() {
- String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
-
- ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
- getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
-
- OutputStream serializedGraph = new ByteArrayOutputStream();
- jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
-
- String expected = "{\n \"@\": \"<urn:iks-project:fise:test:text-annotation:Person>\",\n \"a\": [\n \"<http:\\/\\/fise.iks-project.eu\\/ontology\\/Enhancement>\",\n \"<http:\\/\\/fise.iks-project.eu\\/ontology\\/TextAnnotation>\"\n ],\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/end\": \"\\\"20\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/selected-text\": \"\\\"Patrick Marshall\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/selection-context\": \"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/start\": \"\\\"4\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\n \"http:\\/\\/purl.org\\/dc\\/terms\\/created\": \"\\\"2010-10-27T14:00:00+02:00\\\"^^<http:\\/\
\/www.w3.org\\/2001\\/XMLSchema#dateTime>\",\n \"http:\\/\\/purl.org\\/dc\\/terms\\/creator\": \"<urn:iks-project:fise:test:dummyEngine>\",\n \"http:\\/\\/purl.org\\/dc\\/terms\\/type\": \"<http:\\/\\/dbpedia.org\\/ontology\\/Person>\"\n}";
- String result = serializedGraph.toString();
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSingleSubjectSerializeWithNs() {
- String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
-
- ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
- getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
-
- OutputStream serializedGraph = new ByteArrayOutputStream();
- Map<String, String> nsMap = new HashMap<String, String>();
- nsMap.put("http://fise.iks-project.eu/ontology/", "fise");
- nsMap.put("http://www.w3.org/2001/XMLSchema#", "xmlns");
- nsMap.put("http://dbpedia.org/ontology/", "dbpedia");
- nsMap.put("http://purl.org/dc/terms", "dcterms");
- jsonldProvider.setIndentation(0);
- jsonldProvider.setNamespacePrefixMap(nsMap);
- jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
-
- String expected = "{\"#\":{\"dbpedia\":\"http:\\/\\/dbpedia.org\\/ontology\\/\",\"dcterms\":\"http:\\/\\/purl.org\\/dc\\/terms\",\"fise\":\"http:\\/\\/fise.iks-project.eu\\/ontology\\/\",\"xmlns\":\"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#\"},\"@\":\"<urn:iks-project:fise:test:text-annotation:Person>\",\"a\":[\"<fise:Enhancement>\",\"<fise:TextAnnotation>\"],\"dcterms:\\/created\":\"\\\"2010-10-27T14:00:00+02:00\\\"^^<xmlns:dateTime>\",\"dcterms:\\/creator\":\"<urn:iks-project:fise:test:dummyEngine>\",\"dcterms:\\/type\":\"<dbpedia:Person>\",\"fise:end\":\"\\\"20\\\"^^<xmlns:int>\",\"fise:selected-text\":\"\\\"Patrick Marshall\\\"^^<xmlns:string>\",\"fise:selection-context\":\"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<xmlns:string>\",\"fise:start\":\"\\\"4\\\"^^<xmlns:int>\"}";
- String result = serializedGraph.toString();
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSingleSubjectSerializeWithNsWithIndent() {
- String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
-
- ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
- getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
-
- OutputStream serializedGraph = new ByteArrayOutputStream();
- Map<String, String> nsMap = new HashMap<String, String>();
- nsMap.put("http://fise.iks-project.eu/ontology/", "fise");
- nsMap.put("http://www.w3.org/2001/XMLSchema#", "xmlns");
- nsMap.put("http://dbpedia.org/ontology/", "dbpedia");
- nsMap.put("http://purl.org/dc/terms", "dcterms");
- jsonldProvider.setIndentation(4);
- jsonldProvider.setNamespacePrefixMap(nsMap);
- jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
-
- String expected = "{\n \"#\": {\n \"dbpedia\": \"http:\\/\\/dbpedia.org\\/ontology\\/\",\n \"dcterms\": \"http:\\/\\/purl.org\\/dc\\/terms\",\n \"fise\": \"http:\\/\\/fise.iks-project.eu\\/ontology\\/\",\n \"xmlns\": \"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#\"\n },\n \"@\": \"<urn:iks-project:fise:test:text-annotation:Person>\",\n \"a\": [\n \"<fise:Enhancement>\",\n \"<fise:TextAnnotation>\"\n ],\n \"dcterms:\\/created\": \"\\\"2010-10-27T14:00:00+02:00\\\"^^<xmlns:dateTime>\",\n \"dcterms:\\/creator\": \"<urn:iks-project:fise:test:dummyEngine>\",\n \"dcterms:\\/type\": \"<dbpedia:Person>\",\n \"fise:end\": \"\\\"20\\\"^^<xmlns:int>\",\n \"fise:selected-text\": \"\\\"Patrick Marshall\\\"^^<xmlns:string>\",\n \"fise:selection-context\": \"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<xmlns:string>\",\n \"fis
e:start\": \"\\\"4\\\"^^<xmlns:int>\"\n}";
- String result = serializedGraph.toString();
- Assert.assertEquals(expected, result);
- }
-
- private ContentItem getContentItem(final String id, final String text) {
- return new ContentItem() {
-
- SimpleMGraph metadata = new SimpleMGraph();
-
- public InputStream getStream() {
- return new ByteArrayInputStream(text.getBytes());
- }
-
- public String getMimeType() {
- return "text/plain";
- }
-
- public MGraph getMetadata() {
- return metadata;
- }
-
- public String getId() {
- return id;
- }
- };
- }
-
- private void getTextAnnotation(ContentItem ci, String annotationURNExtension, String namedEntity, String context, UriRef type) {
- String content;
- try {
- content = IOUtils.toString(ci.getStream());
- } catch (IOException e) {
- // should never happen anyway!
- content = "";
- }
- RdfEntityFactory factory = RdfEntityFactory.createInstance(ci.getMetadata());
- TextAnnotation testAnnotation = factory.getProxy(new UriRef("urn:iks-project:fise:test:text-annotation:" + annotationURNExtension), TextAnnotation.class);
- testAnnotation.setCreator(new UriRef("urn:iks-project:fise:test:dummyEngine"));
-
- Calendar myCal = Calendar.getInstance();
- myCal.set(2010, 9, 27, 12, 0, 0);
- myCal.set(Calendar.MILLISECOND, 0);
- myCal.setTimeZone(TimeZone.getTimeZone("Germany/Berlin"));
- testAnnotation.setCreated(myCal.getTime());
-
- testAnnotation.setSelectedText(namedEntity);
- testAnnotation.setSelectionContext(context);
- testAnnotation.getDcType().add(type);
- Integer start = content.indexOf(namedEntity);
- if (start < 0) { // if not found in the content set start to 42
- start = 42;
- }
- testAnnotation.setStart(start);
- testAnnotation.setEnd(start + namedEntity.length());
- }
-
- @SuppressWarnings("unused")
- private void toConsole(String result) {
- System.out.println(result);
- String s = result;
- s = s.replaceAll("\\\\", "\\\\\\\\");
- s = s.replace("\"", "\\\"");
- s = s.replace("\n", "\\n");
- System.out.println(s);
- }
+ OutputStream serializedGraph = new ByteArrayOutputStream();
+ jsonldProvider.setIndentation(0);
+ jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+ String expected = "{\"@\":\"<urn:iks-project:fise:test:text-annotation:Person>\",\"a\":[\"<http:\\/\\/fise.iks-project.eu\\/ontology\\/Enhancement>\",\"<http:\\/\\/fise.iks-project.eu\\/ontology\\/TextAnnotation>\"],\"http:\\/\\/fise.iks-project.eu\\/ontology\\/end\":\"\\\"20\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/selected-text\":\"\\\"Patrick Marshall\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/selection-context\":\"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/start\":\"\\\"4\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/created\":\"\\\"2010-10-27T14:00:00+02:00\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#dateTime>\",\
"http:\\/\\/purl.org\\/dc\\/terms\\/creator\":\"<urn:iks-project:fise:test:dummyEngine>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/type\":\"<http:\\/\\/dbpedia.org\\/ontology\\/Person>\"}";
+ String result = serializedGraph.toString();
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSingleSubjectSerializeNoNsWithIndent() {
+ String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
+
+ ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
+ getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+ OutputStream serializedGraph = new ByteArrayOutputStream();
+ jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+ String expected = "{\n \"@\": \"<urn:iks-project:fise:test:text-annotation:Person>\",\n \"a\": [\n \"<http:\\/\\/fise.iks-project.eu\\/ontology\\/Enhancement>\",\n \"<http:\\/\\/fise.iks-project.eu\\/ontology\\/TextAnnotation>\"\n ],\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/end\": \"\\\"20\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/selected-text\": \"\\\"Patrick Marshall\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/selection-context\": \"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\n \"http:\\/\\/fise.iks-project.eu\\/ontology\\/start\": \"\\\"4\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\n \"http:\\/\\/purl.org\\/dc\\/terms\\/created\": \"\\\"2010-10-27T14:00:00+02:00\\\"^^<htt
p:\\/\\/www.w3.org\\/2001\\/XMLSchema#dateTime>\",\n \"http:\\/\\/purl.org\\/dc\\/terms\\/creator\": \"<urn:iks-project:fise:test:dummyEngine>\",\n \"http:\\/\\/purl.org\\/dc\\/terms\\/type\": \"<http:\\/\\/dbpedia.org\\/ontology\\/Person>\"\n}";
+ String result = serializedGraph.toString();
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSingleSubjectSerializeWithNs() {
+ String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
+
+ ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
+ getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+ OutputStream serializedGraph = new ByteArrayOutputStream();
+ Map<String, String> nsMap = new HashMap<String, String>();
+ nsMap.put("http://fise.iks-project.eu/ontology/", "fise");
+ nsMap.put("http://www.w3.org/2001/XMLSchema#", "xmlns");
+ nsMap.put("http://dbpedia.org/ontology/", "dbpedia");
+ nsMap.put("http://purl.org/dc/terms", "dcterms");
+ jsonldProvider.setIndentation(0);
+ jsonldProvider.setNamespacePrefixMap(nsMap);
+ jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+ String expected = "{\"#\":{\"dbpedia\":\"http:\\/\\/dbpedia.org\\/ontology\\/\",\"dcterms\":\"http:\\/\\/purl.org\\/dc\\/terms\",\"fise\":\"http:\\/\\/fise.iks-project.eu\\/ontology\\/\",\"xmlns\":\"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#\"},\"@\":\"<urn:iks-project:fise:test:text-annotation:Person>\",\"a\":[\"<fise:Enhancement>\",\"<fise:TextAnnotation>\"],\"dcterms:\\/created\":\"\\\"2010-10-27T14:00:00+02:00\\\"^^<xmlns:dateTime>\",\"dcterms:\\/creator\":\"<urn:iks-project:fise:test:dummyEngine>\",\"dcterms:\\/type\":\"<dbpedia:Person>\",\"fise:end\":\"\\\"20\\\"^^<xmlns:int>\",\"fise:selected-text\":\"\\\"Patrick Marshall\\\"^^<xmlns:string>\",\"fise:selection-context\":\"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<xmlns:string>\",\"fise:start\":\"\\\"4\\\"^^<xmlns:int>\"}";
+ String result = serializedGraph.toString();
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSingleSubjectSerializeWithNsWithIndent() {
+ String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
+
+ ContentItem ci = getContentItem("urn:iks-project:fise:test:content-item:person", context);
+ getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+ OutputStream serializedGraph = new ByteArrayOutputStream();
+ Map<String, String> nsMap = new HashMap<String, String>();
+ nsMap.put("http://fise.iks-project.eu/ontology/", "fise");
+ nsMap.put("http://www.w3.org/2001/XMLSchema#", "xmlns");
+ nsMap.put("http://dbpedia.org/ontology/", "dbpedia");
+ nsMap.put("http://purl.org/dc/terms", "dcterms");
+ jsonldProvider.setIndentation(4);
+ jsonldProvider.setNamespacePrefixMap(nsMap);
+ jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+ String expected = "{\n \"#\": {\n \"dbpedia\": \"http:\\/\\/dbpedia.org\\/ontology\\/\",\n \"dcterms\": \"http:\\/\\/purl.org\\/dc\\/terms\",\n \"fise\": \"http:\\/\\/fise.iks-project.eu\\/ontology\\/\",\n \"xmlns\": \"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#\"\n },\n \"@\": \"<urn:iks-project:fise:test:text-annotation:Person>\",\n \"a\": [\n \"<fise:Enhancement>\",\n \"<fise:TextAnnotation>\"\n ],\n \"dcterms:\\/created\": \"\\\"2010-10-27T14:00:00+02:00\\\"^^<xmlns:dateTime>\",\n \"dcterms:\\/creator\": \"<urn:iks-project:fise:test:dummyEngine>\",\n \"dcterms:\\/type\": \"<dbpedia:Person>\",\n \"fise:end\": \"\\\"20\\\"^^<xmlns:int>\",\n \"fise:selected-text\": \"\\\"Patrick Marshall\\\"^^<xmlns:string>\",\n \"fise:selection-context\": \"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<xmlns:string>\",\n
\"fise:start\": \"\\\"4\\\"^^<xmlns:int>\"\n}";
+ String result = serializedGraph.toString();
+ Assert.assertEquals(expected, result);
+ }
+
+ private ContentItem getContentItem(final String id, final String text) {
+ return new ContentItem() {
+
+ SimpleMGraph metadata = new SimpleMGraph();
+
+ public InputStream getStream() {
+ return new ByteArrayInputStream(text.getBytes());
+ }
+
+ public String getMimeType() {
+ return "text/plain";
+ }
+
+ public MGraph getMetadata() {
+ return metadata;
+ }
+
+ public String getId() {
+ return id;
+ }
+ };
+ }
+
+ private void getTextAnnotation(ContentItem ci, String annotationURNExtension, String namedEntity, String context, UriRef type) {
+ String content;
+ try {
+ content = IOUtils.toString(ci.getStream());
+ } catch (IOException e) {
+ // should never happen anyway!
+ content = "";
+ }
+ RdfEntityFactory factory = RdfEntityFactory.createInstance(ci.getMetadata());
+ TextAnnotation testAnnotation = factory.getProxy(new UriRef("urn:iks-project:fise:test:text-annotation:" + annotationURNExtension), TextAnnotation.class);
+ testAnnotation.setCreator(new UriRef("urn:iks-project:fise:test:dummyEngine"));
+
+ Calendar myCal = Calendar.getInstance();
+ myCal.set(2010, 9, 27, 12, 0, 0);
+ myCal.set(Calendar.MILLISECOND, 0);
+ myCal.setTimeZone(TimeZone.getTimeZone("Germany/Berlin"));
+ testAnnotation.setCreated(myCal.getTime());
+
+ testAnnotation.setSelectedText(namedEntity);
+ testAnnotation.setSelectionContext(context);
+ testAnnotation.getDcType().add(type);
+ Integer start = content.indexOf(namedEntity);
+ if (start < 0) { // if not found in the content set start to 42
+ start = 42;
+ }
+ testAnnotation.setStart(start);
+ testAnnotation.setEnd(start + namedEntity.length());
+ }
+
+ @SuppressWarnings("unused")
+ private void toConsole(String result) {
+ System.out.println(result);
+ String s = result;
+ s = s.replaceAll("\\\\", "\\\\\\\\");
+ s = s.replace("\"", "\\\"");
+ s = s.replace("\n", "\\n");
+ System.out.println(s);
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/QueryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/QueryManager.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/QueryManager.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/QueryManager.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction;
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -48,125 +48,125 @@ import eu.iksproject.fise.interaction.ut
public class QueryManager implements EventListener {
- private String serverHost;
- private int serverPort;
- private String username;
- private String password;
-
- public QueryManager (String serverHost, int serverPort, String username, String password) {
- this.serverHost = serverHost;
- this.serverPort = serverPort;
- this.username = username;
- this.password = password;
- }
-
- public void eventOccurred(Event e) {
- if (e instanceof QueryEvent) {
- QueryEvent qe = (QueryEvent)e;
-
- String clerezzaResult = postData(qe.getSparqlQuery());
-
- if (clerezzaResult != null) {
- ClerezzaResultEvent cre = new ClerezzaResultEvent(clerezzaResult);
- EventManager.eventOccurred(cre);
- }
- }
- else if (e instanceof UploadFileEvent) {
- UploadFileEvent ufe = (UploadFileEvent)e;
-
- uploadFile(ufe.getFilename(), ufe.getUri());
- }
- else if (e instanceof ClerezzaServerInfoChangedEvent) {
- ClerezzaServerInfoChangedEvent csice = (ClerezzaServerInfoChangedEvent)e;
- this.serverHost = csice.getServerHost();
- this.serverPort = csice.getServerPort();
- this.username = csice.getUsername();
- this.password = csice.getPassword();
- }
-
- }
-
- private void uploadFile(String filename, String uri) {
- try {
- URL url = new URL("http://" + serverHost + ":" + serverPort + "/content");
- URLConnection conn = url.openConnection();
- ClientHttpRequest chr = new ClientHttpRequest(conn, username, password);
- chr.setParameter("uri", uri);
- chr.setParameter("content", new File(filename));
-
- String resultText = "";
- // Get the response
- BufferedReader rd = new BufferedReader(new InputStreamReader(chr.post()));
- String line;
- while ((line = rd.readLine()) != null) {
- // Process line...
- resultText += line;
- }
- rd.close();
- System.out.println(resultText);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private String postData (String query) {
- try {
- String resultText = "";
- // Construct data
- String data = URLEncoder.encode("query", "UTF-8") + "=" + URLEncoder.encode(query, "UTF-8");
-
- // Send data
- URL url = new URL("http://" + serverHost + ":" + serverPort + "/fise");
-
- URLConnection conn = url.openConnection();
- conn.setDoOutput(true);
- OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- wr.write(data);
- wr.flush();
-
- // Get the response
- BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String line;
- while ((line = rd.readLine()) != null) {
- // Process line...
- resultText += line;
- }
- wr.close();
- rd.close();
- return resultText;
- } catch (Exception e) {
- //e.printStackTrace();
- }
- return null;
- }
-
- public byte[] getBytesFromFile(File file) throws IOException {
- InputStream is = new FileInputStream(file);
- // Get the size of the file
- long length = file.length();
- // You cannot create an array using a long type.
- // It needs to be an int type.
- // Before converting to an int type, check
- // to ensure that file is not larger than Integer.MAX_VALUE.
-
- if (length > Integer.MAX_VALUE) {
- // File is too large
- }
- // Create the byte array to hold the data
- byte[] bytes = new byte[(int)length];
- // Read in the bytes
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
- offset += numRead;
- }
- // Ensure all the bytes have been read in
- if (offset < bytes.length) {
- throw new IOException("Could not completely read file " + file.getName());
- } // Close the input stream and return bytes
- is.close();
- return bytes;
- }
+ private String serverHost;
+ private int serverPort;
+ private String username;
+ private String password;
+
+ public QueryManager (String serverHost, int serverPort, String username, String password) {
+ this.serverHost = serverHost;
+ this.serverPort = serverPort;
+ this.username = username;
+ this.password = password;
+ }
+
+ public void eventOccurred(Event e) {
+ if (e instanceof QueryEvent) {
+ QueryEvent qe = (QueryEvent)e;
+
+ String clerezzaResult = postData(qe.getSparqlQuery());
+
+ if (clerezzaResult != null) {
+ ClerezzaResultEvent cre = new ClerezzaResultEvent(clerezzaResult);
+ EventManager.eventOccurred(cre);
+ }
+ }
+ else if (e instanceof UploadFileEvent) {
+ UploadFileEvent ufe = (UploadFileEvent)e;
+
+ uploadFile(ufe.getFilename(), ufe.getUri());
+ }
+ else if (e instanceof ClerezzaServerInfoChangedEvent) {
+ ClerezzaServerInfoChangedEvent csice = (ClerezzaServerInfoChangedEvent)e;
+ this.serverHost = csice.getServerHost();
+ this.serverPort = csice.getServerPort();
+ this.username = csice.getUsername();
+ this.password = csice.getPassword();
+ }
+
+ }
+
+ private void uploadFile(String filename, String uri) {
+ try {
+ URL url = new URL("http://" + serverHost + ":" + serverPort + "/content");
+ URLConnection conn = url.openConnection();
+ ClientHttpRequest chr = new ClientHttpRequest(conn, username, password);
+ chr.setParameter("uri", uri);
+ chr.setParameter("content", new File(filename));
+
+ String resultText = "";
+ // Get the response
+ BufferedReader rd = new BufferedReader(new InputStreamReader(chr.post()));
+ String line;
+ while ((line = rd.readLine()) != null) {
+ // Process line...
+ resultText += line;
+ }
+ rd.close();
+ System.out.println(resultText);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String postData (String query) {
+ try {
+ String resultText = "";
+ // Construct data
+ String data = URLEncoder.encode("query", "UTF-8") + "=" + URLEncoder.encode(query, "UTF-8");
+
+ // Send data
+ URL url = new URL("http://" + serverHost + ":" + serverPort + "/fise");
+
+ URLConnection conn = url.openConnection();
+ conn.setDoOutput(true);
+ OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
+ wr.write(data);
+ wr.flush();
+
+ // Get the response
+ BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ String line;
+ while ((line = rd.readLine()) != null) {
+ // Process line...
+ resultText += line;
+ }
+ wr.close();
+ rd.close();
+ return resultText;
+ } catch (Exception e) {
+ //e.printStackTrace();
+ }
+ return null;
+ }
+
+ public byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+ // Get the size of the file
+ long length = file.length();
+ // You cannot create an array using a long type.
+ // It needs to be an int type.
+ // Before converting to an int type, check
+ // to ensure that file is not larger than Integer.MAX_VALUE.
+
+ if (length > Integer.MAX_VALUE) {
+ // File is too large
+ }
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int)length];
+ // Read in the bytes
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
+ offset += numRead;
+ }
+ // Ensure all the bytes have been read in
+ if (offset < bytes.length) {
+ throw new IOException("Could not completely read file " + file.getName());
+ } // Close the input stream and return bytes
+ is.close();
+ return bytes;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/Start.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/Start.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/Start.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/Start.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction;
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -32,29 +32,29 @@ import eu.iksproject.fise.interaction.sp
import eu.iksproject.fise.interaction.speech.SpeechServer;
public class Start {
-
- public static final boolean USE_TTS = false;
- static final String INITIAL_CLEREZZA_SERVER_HOST = "localhost";
- static final int INITIAL_CLEREZZA_SERVER_PORT = 8080;
- static final String INITIAL_CLEREZZA_SERVER_USERNAME = "admin";
- static final String INITIAL_CLEREZZA_SERVER_PASSWORD = "admin";
-
- public static void main (String[] args) {
- Gui gui = new Gui(INITIAL_CLEREZZA_SERVER_HOST,
- INITIAL_CLEREZZA_SERVER_PORT,
- INITIAL_CLEREZZA_SERVER_USERNAME,
- INITIAL_CLEREZZA_SERVER_PASSWORD);
- SpeechServer speechServer = new SpeechServer();
- NL2Sparql nl2sparql = new NL2Sparql();
- QueryManager queryManager = new QueryManager(INITIAL_CLEREZZA_SERVER_HOST,
- INITIAL_CLEREZZA_SERVER_PORT,
- INITIAL_CLEREZZA_SERVER_USERNAME,
- INITIAL_CLEREZZA_SERVER_PASSWORD);
-
- EventManager.addEventListener(gui);
- EventManager.addEventListener(speechServer);
- EventManager.addEventListener(nl2sparql);
- EventManager.addEventListener(queryManager);
- }
+
+ public static final boolean USE_TTS = false;
+ static final String INITIAL_CLEREZZA_SERVER_HOST = "localhost";
+ static final int INITIAL_CLEREZZA_SERVER_PORT = 8080;
+ static final String INITIAL_CLEREZZA_SERVER_USERNAME = "admin";
+ static final String INITIAL_CLEREZZA_SERVER_PASSWORD = "admin";
+
+ public static void main (String[] args) {
+ Gui gui = new Gui(INITIAL_CLEREZZA_SERVER_HOST,
+ INITIAL_CLEREZZA_SERVER_PORT,
+ INITIAL_CLEREZZA_SERVER_USERNAME,
+ INITIAL_CLEREZZA_SERVER_PASSWORD);
+ SpeechServer speechServer = new SpeechServer();
+ NL2Sparql nl2sparql = new NL2Sparql();
+ QueryManager queryManager = new QueryManager(INITIAL_CLEREZZA_SERVER_HOST,
+ INITIAL_CLEREZZA_SERVER_PORT,
+ INITIAL_CLEREZZA_SERVER_USERNAME,
+ INITIAL_CLEREZZA_SERVER_PASSWORD);
+
+ EventManager.addEventListener(gui);
+ EventManager.addEventListener(speechServer);
+ EventManager.addEventListener(nl2sparql);
+ EventManager.addEventListener(queryManager);
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaResultEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaResultEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaResultEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaResultEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -28,13 +28,13 @@ package eu.iksproject.fise.interaction.e
public class ClerezzaResultEvent extends Event {
- private final String result;
-
- public ClerezzaResultEvent (String result) {
- this.result = result;
- }
-
- public String getData () {
- return result;
- }
+ private final String result;
+
+ public ClerezzaResultEvent (String result) {
+ this.result = result;
+ }
+
+ public String getData () {
+ return result;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaServerInfoChangedEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaServerInfoChangedEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaServerInfoChangedEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaServerInfoChangedEvent.java Sun Dec 12 16:10:48 2010
@@ -2,32 +2,32 @@ package eu.iksproject.fise.interaction.e
public class ClerezzaServerInfoChangedEvent extends Event {
- private final String serverHost;
- private final int serverPort;
- private final String username;
- private final String password;
-
- public ClerezzaServerInfoChangedEvent (String serverHost, int serverPort, String username, String password) {
- this.serverHost = serverHost;
- this.serverPort = serverPort;
- this.username = username;
- this.password = password;
- }
-
- public String getServerHost() {
- return serverHost;
- }
-
- public int getServerPort() {
- return serverPort;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword () {
- return password;
- }
+ private final String serverHost;
+ private final int serverPort;
+ private final String username;
+ private final String password;
+
+ public ClerezzaServerInfoChangedEvent (String serverHost, int serverPort, String username, String password) {
+ this.serverHost = serverHost;
+ this.serverPort = serverPort;
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getServerHost() {
+ return serverHost;
+ }
+
+ public int getServerPort() {
+ return serverPort;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword () {
+ return password;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/Event.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/Event.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/Event.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/Event.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventListener.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventListener.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventListener.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -27,7 +27,7 @@ package eu.iksproject.fise.interaction.e
*/
public interface EventListener {
-
- void eventOccurred (Event e);
+
+ void eventOccurred (Event e);
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventManager.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventManager.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventManager.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -31,27 +31,27 @@ import java.util.Set;
public class EventManager {
- private static final Set<EventListener> listeners = new HashSet<EventListener>();
+ private static final Set<EventListener> listeners = new HashSet<EventListener>();
- public static void eventOccurred (Event e) {
- synchronized (listeners) {
- for (EventListener el : listeners) {
- System.out.println("Send event " + e.getClass().getName() + " to " + el.getClass().getName());
- el.eventOccurred(e);
- }
- }
- }
-
- public static void addEventListener (EventListener el) {
- synchronized (listeners) {
- listeners.add(el);
- }
- }
-
- public static void removeEventListener (EventListener el) {
- synchronized (listeners) {
- listeners.remove(el);
- }
- }
+ public static void eventOccurred (Event e) {
+ synchronized (listeners) {
+ for (EventListener el : listeners) {
+ System.out.println("Send event " + e.getClass().getName() + " to " + el.getClass().getName());
+ el.eventOccurred(e);
+ }
+ }
+ }
+
+ public static void addEventListener (EventListener el) {
+ synchronized (listeners) {
+ listeners.add(el);
+ }
+ }
+
+ public static void removeEventListener (EventListener el) {
+ synchronized (listeners) {
+ listeners.remove(el);
+ }
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/NotUnderstoodEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/NotUnderstoodEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/NotUnderstoodEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/NotUnderstoodEvent.java Sun Dec 12 16:10:48 2010
@@ -1,5 +1,5 @@
package eu.iksproject.fise.interaction.event;
-public class NotUnderstoodEvent extends Event {
+public class NotUnderstoodEvent extends Event {
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/PlaybackAudioEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/PlaybackAudioEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/PlaybackAudioEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/PlaybackAudioEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -28,14 +28,14 @@ package eu.iksproject.fise.interaction.e
public class PlaybackAudioEvent extends Event {
- byte[] audioData;
+ byte[] audioData;
- public PlaybackAudioEvent (byte[] audioData) {
- this.audioData = audioData;
- }
+ public PlaybackAudioEvent (byte[] audioData) {
+ this.audioData = audioData;
+ }
- public byte[] getData () {
- return audioData;
- }
+ public byte[] getData () {
+ return audioData;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/QueryEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/QueryEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/QueryEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/QueryEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -28,20 +28,20 @@ package eu.iksproject.fise.interaction.e
public class QueryEvent extends Event {
- private String sparqlQuery;
- private String textQuery;
-
- public QueryEvent (String sparqlQuery, String textQuery) {
- this.sparqlQuery = sparqlQuery;
- this.textQuery = textQuery;
- }
-
- public String getSparqlQuery () {
- return sparqlQuery;
- }
-
- public String getTextQuery () {
- return textQuery;
- }
+ private String sparqlQuery;
+ private String textQuery;
+
+ public QueryEvent (String sparqlQuery, String textQuery) {
+ this.sparqlQuery = sparqlQuery;
+ this.textQuery = textQuery;
+ }
+
+ public String getSparqlQuery () {
+ return sparqlQuery;
+ }
+
+ public String getTextQuery () {
+ return textQuery;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecognizedSpeechEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecognizedSpeechEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecognizedSpeechEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecognizedSpeechEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -27,15 +27,15 @@ package eu.iksproject.fise.interaction.e
*/
public class RecognizedSpeechEvent extends Event {
-
- private String recognizedSpeech;
-
- public RecognizedSpeechEvent (String recognizedSpeech) {
- this.recognizedSpeech = recognizedSpeech;
- }
-
- public String getData() {
- return recognizedSpeech;
- }
+
+ private String recognizedSpeech;
+
+ public RecognizedSpeechEvent (String recognizedSpeech) {
+ this.recognizedSpeech = recognizedSpeech;
+ }
+
+ public String getData() {
+ return recognizedSpeech;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecordedAudioEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecordedAudioEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecordedAudioEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecordedAudioEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -27,15 +27,15 @@ package eu.iksproject.fise.interaction.e
*/
public class RecordedAudioEvent extends Event {
-
- byte[] audioData;
-
- public RecordedAudioEvent (byte[] audioData) {
- this.audioData = audioData;
- }
-
- public byte[] getData () {
- return audioData;
- }
+
+ byte[] audioData;
+
+ public RecordedAudioEvent (byte[] audioData) {
+ this.audioData = audioData;
+ }
+
+ public byte[] getData () {
+ return audioData;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/SparqlEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/SparqlEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/SparqlEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/SparqlEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -27,15 +27,15 @@ package eu.iksproject.fise.interaction.e
*/
public class SparqlEvent extends Event {
-
- private String sparqlQuery;
-
- public SparqlEvent (String sparqlQuery) {
- this.sparqlQuery = sparqlQuery;
- }
-
- public String getData() {
- return sparqlQuery;
- }
+
+ private String sparqlQuery;
+
+ public SparqlEvent (String sparqlQuery) {
+ this.sparqlQuery = sparqlQuery;
+ }
+
+ public String getData() {
+ return sparqlQuery;
+ }
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/TtsEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/TtsEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/TtsEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/TtsEvent.java Sun Dec 12 16:10:48 2010
@@ -5,21 +5,21 @@ package eu.iksproject.fise.interaction.e
* German Research Center for Artificial Intelligence (DFKI)
* Department of Intelligent User Interfaces
* Germany
- *
+ *
* http://www.dfki.de/web/forschung/iui
- *
+ *
* 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.
- *
+ *
* Authors:
* Sebastian Germesin
* Massimo Romanelli
@@ -28,14 +28,14 @@ package eu.iksproject.fise.interaction.e
public class TtsEvent extends Event {
- private String ttsText;
-
- public TtsEvent (String ttsText) {
- this.ttsText = ttsText;
- }
-
- public String getData() {
- return ttsText;
- }
-
+ private String ttsText;
+
+ public TtsEvent (String ttsText) {
+ this.ttsText = ttsText;
+ }
+
+ public String getData() {
+ return ttsText;
+ }
+
}
Modified: incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/UploadFileEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/UploadFileEvent.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/UploadFileEvent.java (original)
+++ incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/UploadFileEvent.java Sun Dec 12 16:10:48 2010
@@ -1,21 +1,21 @@
package eu.iksproject.fise.interaction.event;
public class UploadFileEvent extends Event {
-
- private final String filename;
- private final String uri;
-
- public UploadFileEvent (String filename, String uri) {
- this.filename = filename;
- this.uri = uri;
- }
-
- public String getFilename() {
- return filename;
- }
-
- public String getUri() {
- return uri;
- }
+
+ private final String filename;
+ private final String uri;
+
+ public UploadFileEvent (String filename, String uri) {
+ this.filename = filename;
+ this.uri = uri;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public String getUri() {
+ return uri;
+ }
}