diff --git a/client/IDSBrowser/IDS Browser/src/META-INF/jdoconfig.xml b/client/IDSBrowser/IDS Browser/src/META-INF/jdoconfig.xml
new file mode 100644
index 0000000..9966473
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/src/META-INF/jdoconfig.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/client/IDSBrowser/IDS Browser/src/META-INF/persistence.xml b/client/IDSBrowser/IDS Browser/src/META-INF/persistence.xml
new file mode 100644
index 0000000..55dc331
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/src/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ org.datanucleus.api.jpa.PersistenceProviderImpl
+
+
+
+
+
+
+
diff --git a/client/IDSBrowser/IDS Browser/src/log4j.properties b/client/IDSBrowser/IDS Browser/src/log4j.properties
new file mode 100644
index 0000000..d9c3edc
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/src/log4j.properties
@@ -0,0 +1,24 @@
+# A default log4j configuration for log4j users.
+#
+# To use this configuration, deploy it into your application's WEB-INF/classes
+# directory. You are also encouraged to edit it as you like.
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+# tighten logging on the DataNucleus Categories
+log4j.category.DataNucleus.JDO=WARN, A1
+log4j.category.DataNucleus.Persistence=WARN, A1
+log4j.category.DataNucleus.Cache=WARN, A1
+log4j.category.DataNucleus.MetaData=WARN, A1
+log4j.category.DataNucleus.General=WARN, A1
+log4j.category.DataNucleus.Utility=WARN, A1
+log4j.category.DataNucleus.Transaction=WARN, A1
+log4j.category.DataNucleus.Datastore=WARN, A1
+log4j.category.DataNucleus.ClassLoading=WARN, A1
+log4j.category.DataNucleus.Plugin=WARN, A1
+log4j.category.DataNucleus.ValueGeneration=WARN, A1
+log4j.category.DataNucleus.Enhancer=WARN, A1
+log4j.category.DataNucleus.SchemaTool=WARN, A1
diff --git a/client/IDSBrowser/IDS Browser/src/nl/vu/idsbrowser/IDS_BrowserServlet.java b/client/IDSBrowser/IDS Browser/src/nl/vu/idsbrowser/IDS_BrowserServlet.java
new file mode 100644
index 0000000..99b482f
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/src/nl/vu/idsbrowser/IDS_BrowserServlet.java
@@ -0,0 +1,13 @@
+package nl.vu.idsbrowser;
+
+import java.io.IOException;
+import javax.servlet.http.*;
+
+@SuppressWarnings("serial")
+public class IDS_BrowserServlet extends HttpServlet {
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+ resp.setContentType("text/plain");
+ resp.getWriter().println("Hello, world");
+ }
+}
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/appengine-web.xml b/client/IDSBrowser/IDS Browser/war/WEB-INF/appengine-web.xml
new file mode 100644
index 0000000..538db0d
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/war/WEB-INF/appengine-web.xml
@@ -0,0 +1,31 @@
+
+
+
+ 1
+
+
+ true
+
+
+
+
+
+
+
+
+
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.1.jar b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.1.jar
new file mode 100644
index 0000000..b7638fa
Binary files /dev/null and b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.1.jar differ
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-api-labs.jar b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-api-labs.jar
new file mode 100644
index 0000000..f46d67a
Binary files /dev/null and b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-api-labs.jar differ
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-endpoints.jar b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-endpoints.jar
new file mode 100644
index 0000000..683aaa6
Binary files /dev/null and b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-endpoints.jar differ
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-jsr107cache-1.7.1.jar b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-jsr107cache-1.7.1.jar
new file mode 100644
index 0000000..8e3c4b7
Binary files /dev/null and b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/appengine-jsr107cache-1.7.1.jar differ
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/jsr107cache-1.1.jar b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/jsr107cache-1.1.jar
new file mode 100644
index 0000000..a94aa31
Binary files /dev/null and b/client/IDSBrowser/IDS Browser/war/WEB-INF/lib/jsr107cache-1.1.jar differ
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/logging.properties b/client/IDSBrowser/IDS Browser/war/WEB-INF/logging.properties
new file mode 100644
index 0000000..a172066
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/war/WEB-INF/logging.properties
@@ -0,0 +1,13 @@
+# A default java.util.logging configuration.
+# (All App Engine logging is through java.util.logging by default).
+#
+# To use this configuration, copy it into your application's WEB-INF
+# folder and add the following to your appengine-web.xml:
+#
+#
+#
+#
+#
+
+# Set the default logging level for all loggers to WARNING
+.level = WARNING
diff --git a/client/IDSBrowser/IDS Browser/war/WEB-INF/web.xml b/client/IDSBrowser/IDS Browser/war/WEB-INF/web.xml
new file mode 100644
index 0000000..826a88f
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/war/WEB-INF/web.xml
@@ -0,0 +1,25 @@
+
+
+ IDS_Browser
+ nl.vu.idsbrowser.IDS_BrowserServlet
+
+
+ IDS_Browser
+ /ids_browser
+
+
+ index.html
+
+
+ SystemServiceServlet
+ com.google.api.server.spi.SystemServiceServlet
+
+ services
+
+
+
+
+ SystemServiceServlet
+ /_ah/spi/*
+
+
\ No newline at end of file
diff --git a/client/IDSBrowser/IDS Browser/war/favicon.ico b/client/IDSBrowser/IDS Browser/war/favicon.ico
new file mode 100644
index 0000000..0062ab4
Binary files /dev/null and b/client/IDSBrowser/IDS Browser/war/favicon.ico differ
diff --git a/client/IDSBrowser/IDS Browser/war/index.html b/client/IDSBrowser/IDS Browser/war/index.html
new file mode 100644
index 0000000..0b32a68
--- /dev/null
+++ b/client/IDSBrowser/IDS Browser/war/index.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+ Hello App Engine
+
+
+
+ Hello App Engine!
+
+
+
+
diff --git a/server/IDSWrapper/src/uk/ac/ids/data/DataSet.java b/server/IDSWrapper/src/uk/ac/ids/data/DataSet.java
index 32939f0..b785368 100644
--- a/server/IDSWrapper/src/uk/ac/ids/data/DataSet.java
+++ b/server/IDSWrapper/src/uk/ac/ids/data/DataSet.java
@@ -222,11 +222,14 @@ public void applyLinkers(String hostIdentifier, Graph targetGraph,
.getValue();
}
}
- if (paramValueKey.startsWith("#"))
- params.put(paramKey,
- keyValuePairs.get(paramValueKey).get(0));
- else
+ if (paramValueKey.startsWith("#")) {
+ ArrayList values = keyValuePairs
+ .get(paramValueKey);
+ if (values != null)
+ params.put(paramKey, values.get(0));
+ } else {
params.put(paramKey, paramValueKey);
+ }
}
}
}
@@ -251,12 +254,8 @@ public void applyLinkers(String hostIdentifier, Graph targetGraph,
targetGraph.add(resource, linkerPredicate, ref);
}
}
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ logger.warning("Exception in DataSet");
}
}
}
diff --git a/server/IDSWrapper/src/uk/ac/ids/resources/GenericResource.java b/server/IDSWrapper/src/uk/ac/ids/resources/GenericResource.java
index b9f28ba..8bcb79a 100644
--- a/server/IDSWrapper/src/uk/ac/ids/resources/GenericResource.java
+++ b/server/IDSWrapper/src/uk/ac/ids/resources/GenericResource.java
@@ -1,10 +1,9 @@
package uk.ac.ids.resources;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -16,28 +15,25 @@
import org.restlet.data.Status;
import org.restlet.ext.freemarker.TemplateRepresentation;
import org.restlet.ext.rdf.Graph;
+import org.restlet.ext.rdf.Link;
import org.restlet.ext.rdf.Literal;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;
+import org.restlet.util.Triple;
import uk.ac.ids.Main;
import uk.ac.ids.data.Namespaces;
import uk.ac.ids.data.Parameters;
import uk.ac.ids.linker.LinkerParameters;
-import uk.ac.ids.linker.impl.DBpedia;
import uk.ac.ids.linker.impl.IATI;
import uk.ac.ids.linker.impl.Lexvo;
import uk.ac.ids.linker.impl.ThemeChildren;
+import uk.ac.ids.util.DataHarvester;
import uk.ac.ids.vocabulary.OWL;
import uk.ac.ids.vocabulary.RDFS;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-
// http://wiki.restlet.org/docs_2.1/13-restlet/28-restlet/270-restlet/245-restlet.html
/**
@@ -98,7 +94,18 @@ protected void doInit() throws ResourceException {
resource = new Reference(getRequest().getOriginalRef().toUri());
// Load the key-values pairs from the JSON API
- loadKeyValuePairs();
+ try {
+ DataHarvester d = new DataHarvester();
+ String query = getApplication().getDataSet(datasetName)
+ .getPatternFor(resourceType);
+ d.setURL(new URL(query.replace("{id}", resourceID)));
+ String api_key = Parameters.getInstance().get(Parameters.API_KEY);
+ d.setKey(api_key);
+ d.setRoot(getApplication().getDataSet(datasetName).getResultRoot(
+ resourceType));
+ keyValuePairs = d.getKeyValuePairs();
+ } catch (Exception e) {
+ }
// Process them
for (Entry> keyValuePair : keyValuePairs
@@ -185,9 +192,9 @@ else if (getApplication().getDataSet(datasetName)
}
// Look for linking services and apply them
- getApplication().getDataSet(datasetName).applyLinkers(getRequest().getOriginalRef()
- .getHostIdentifier(), graph, resource,
- resourceType, keyValuePairs, vocabNS);
+ getApplication().getDataSet(datasetName).applyLinkers(
+ getRequest().getOriginalRef().getHostIdentifier(), graph,
+ resource, resourceType, keyValuePairs, vocabNS);
// Link Theme to IATI
if (resourceType.equals("theme")) {
@@ -232,80 +239,52 @@ public Main getApplication() {
return (Main) super.getApplication();
}
- /**
- * Load the key values pairs from the JSON API
+ /*
+ * private void loadKeyValuePairs() { try { // Compose the URL String query
+ * = getApplication().getDataSet(datasetName) .getPatternFor(resourceType);
+ * URL url = new URL(query.replace("{id}", resourceID));
+ * logger.info("Query " + url);
+ *
+ * // Get the API key String api_key =
+ * Parameters.getInstance().get(Parameters.API_KEY);
+ *
+ * // Issue the API request StringBuffer response = new StringBuffer();
+ * HttpURLConnection connection = (HttpURLConnection) url .openConnection();
+ * connection.setRequestProperty("Token-Guid", api_key); BufferedReader
+ * reader = new BufferedReader(new InputStreamReader(
+ * connection.getInputStream())); String line; while ((line =
+ * reader.readLine()) != null) { response.append(line); } reader.close();
+ * logger.info("Response " + response.toString());
+ *
+ * // Parse the response JsonParser parser = new JsonParser(); JsonElement
+ * element = parser.parse(response.toString()); if (!element.isJsonObject())
+ * return; logger.info("a:" + element.toString());
+ *
+ * // Check if there is a specific root to use String root =
+ * getApplication().getDataSet(datasetName) .getResultRoot(resourceType);
+ * logger.info("Get root " + root);
+ *
+ * if (root != null) element = ((JsonObject) element).get(root); if
+ * (!element.isJsonObject()) return; logger.info("b:" + element.toString());
+ *
+ * for (Entry entry : ((JsonObject) element)
+ * .entrySet()) { logger.info(entry.toString());
+ *
+ * // Ignore the objects if (entry.getValue().isJsonObject()) continue;
+ *
+ * // Prepare the list of values ArrayList values = new
+ * ArrayList();
+ *
+ * // Store all the entries of the array if (entry.getValue().isJsonArray())
+ * for (JsonElement v : (JsonArray) entry.getValue()) if
+ * (v.isJsonPrimitive()) values.add(v.getAsString());
+ *
+ * // Store the single value if (entry.getValue().isJsonPrimitive())
+ * values.add(entry.getValue().getAsString());
+ *
+ * // Store the keyValuePairs.put("#" + entry.getKey(), values); } } catch
+ * (Exception e) { e.printStackTrace(); } }
*/
- private void loadKeyValuePairs() {
- try {
- // Compose the URL
- String query = getApplication().getDataSet(datasetName)
- .getPatternFor(resourceType);
- URL url = new URL(query.replace("{id}", resourceID));
- logger.info("Query " + url);
-
- // Get the API key
- String api_key = Parameters.getInstance().get(Parameters.API_KEY);
-
- // Issue the API request
- StringBuffer response = new StringBuffer();
- HttpURLConnection connection = (HttpURLConnection) url
- .openConnection();
- connection.setRequestProperty("Token-Guid", api_key);
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- connection.getInputStream()));
- String line;
- while ((line = reader.readLine()) != null) {
- response.append(line);
- }
- reader.close();
- logger.info("Response " + response.toString());
-
- // Parse the response
- JsonParser parser = new JsonParser();
- JsonElement element = parser.parse(response.toString());
- if (!element.isJsonObject())
- return;
- logger.info("a:" + element.toString());
-
- // Check if there is a specific root to use
- String root = getApplication().getDataSet(datasetName)
- .getResultRoot(resourceType);
- logger.info("Get root " + root);
-
- if (root != null)
- element = ((JsonObject) element).get(root);
- if (!element.isJsonObject())
- return;
- logger.info("b:" + element.toString());
-
- for (Entry entry : ((JsonObject) element)
- .entrySet()) {
- logger.info(entry.toString());
-
- // Ignore the objects
- if (entry.getValue().isJsonObject())
- continue;
-
- // Prepare the list of values
- ArrayList values = new ArrayList();
-
- // Store all the entries of the array
- if (entry.getValue().isJsonArray())
- for (JsonElement v : (JsonArray) entry.getValue())
- if (v.isJsonPrimitive())
- values.add(v.getAsString());
-
- // Store the single value
- if (entry.getValue().isJsonPrimitive())
- values.add(entry.getValue().getAsString());
-
- // Store the
- keyValuePairs.put("#" + entry.getKey(), values);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
/**
* Returns an HTML representation of the resource
@@ -323,9 +302,20 @@ public Representation toHTML() {
namespaces.register(ns.toString(), datasetName + ":");
}
+ // Sort the triples
+ List triples = new ArrayList();
+ for (Link t : graph)
+ triples.add(t);
+ Collections.sort(triples, new Comparator() {
+ public int compare(Link a, Link b) {
+ return a.getTypeRef().toString()
+ .compareTo(b.getTypeRef().toString());
+ }
+ });
+
Map map = new HashMap();
map.put("resource", resource);
- map.put("triples", graph);
+ map.put("triples", triples);
map.put("ns", namespaces);
return new TemplateRepresentation("resource.html", getApplication()
diff --git a/server/IDSWrapper/src/uk/ac/ids/util/DataHarvester.java b/server/IDSWrapper/src/uk/ac/ids/util/DataHarvester.java
index d4fe32e..e2de143 100644
--- a/server/IDSWrapper/src/uk/ac/ids/util/DataHarvester.java
+++ b/server/IDSWrapper/src/uk/ac/ids/util/DataHarvester.java
@@ -5,6 +5,7 @@
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -17,14 +18,17 @@
public class DataHarvester {
// Logger instance
- protected static final Logger logger = Logger
- .getLogger(DataHarvester.class.getName());
-
+ protected static final Logger logger = Logger.getLogger(DataHarvester.class
+ .getName());
+
// The URL to query
private URL url = null;
-
+
// The API key to use
private String api_key = null;
+
+ // The resultRoot
+ private String resultRoot = null;
/**
* @param url
@@ -32,27 +36,26 @@ public class DataHarvester {
public void setURL(URL url) {
this.url = url;
}
-
+
/**
* @param key
*/
public void setKey(String api_key) {
this.api_key = api_key;
}
-
+
/**
* @return
- * @throws IOException
+ * @throws IOException
*/
- public Map getKeyValuePairs() throws IOException {
- Map results= new HashMap();
+ public Map> getKeyValuePairs() throws IOException {
+ Map> results = new HashMap>();
logger.info("Query " + url);
-
+
// Issue the API request
StringBuffer response = new StringBuffer();
- HttpURLConnection connection = (HttpURLConnection) url
- .openConnection();
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if (api_key != null)
connection.setRequestProperty("Token-Guid", api_key);
BufferedReader reader = new BufferedReader(new InputStreamReader(
@@ -77,39 +80,53 @@ public Map getKeyValuePairs() throws IOException {
* @param element
* @param results
*/
- private void parseElement(String root, JsonElement element, Map results) {
+ private void parseElement(String root, JsonElement element,
+ Map> results) {
if (element.isJsonObject()) {
JsonObject obj = element.getAsJsonObject();
for (Entry entry : obj.entrySet()) {
String newRoot = root + entry.getKey() + ".";
parseElement(newRoot, entry.getValue(), results);
- }
+ }
}
-
+
else if (element.isJsonArray()) {
JsonArray array = element.getAsJsonArray();
- for (int i=0; i < array.size(); i++) {
- JsonElement v = array.get(i);
- String newRoot = root + i + ".";
- parseElement(newRoot, v, results);
+ if (array.size() < 2) {
+ // TODO: Find a better model for verbose descriptions, just cut now
+ for (int i = 0; i < array.size(); i++) {
+ JsonElement v = array.get(i);
+ String newRoot = root + i + ".";
+ parseElement(newRoot, v, results);
+ }
}
}
-
+
else if (element.isJsonPrimitive()) {
- String key = root.substring(0, root.length()-1);
- if (results.containsKey(key))
- logger.info("Overwrite " + key);
- results.put(key, element.getAsString());
+ String key = "#" + root.substring(0, root.length() - 1);
+ if (resultRoot != null)
+ key = key.replace(resultRoot + ".", "");
+ ArrayList list = null;
+ if (results.containsKey(key)) {
+ list = results.get(key);
+ } else {
+ list = new ArrayList();
+ results.put(key, list);
+ }
+ list.add(element.getAsString());
}
}
-
-
+
public static void main(String[] args) throws IOException {
DataHarvester d = new DataHarvester();
- d.setURL(new URL("http://oipa.openaidsearch.org//api/v2/activities/41AAA-00043782/?format=json"));
- Map r = d.getKeyValuePairs();
- for (Entry e : r.entrySet())
+ d.setURL(new URL(
+ "http://oipa.openaidsearch.org//api/v2/activities/41AAA-00043782/?format=json"));
+ Map> r = d.getKeyValuePairs();
+ for (Entry> e : r.entrySet())
System.out.println(e.getKey() + " = " + e.getValue());
}
-}
+ public void setRoot(String resultRoot) {
+ this.resultRoot = resultRoot;
+ }
+}
diff --git a/server/IDSWrapper/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.2.1.jar b/server/IDSWrapper/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.3.jar
similarity index 93%
rename from server/IDSWrapper/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.2.1.jar
rename to server/IDSWrapper/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.3.jar
index 3f7e294..7bf1ecb 100644
Binary files a/server/IDSWrapper/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.2.1.jar and b/server/IDSWrapper/war/WEB-INF/lib/appengine-api-1.0-sdk-1.7.3.jar differ
diff --git a/server/IDSWrapper/war/WEB-INF/lib/appengine-api-labs.jar b/server/IDSWrapper/war/WEB-INF/lib/appengine-api-labs.jar
index 5ee1e4d..302649a 100644
Binary files a/server/IDSWrapper/war/WEB-INF/lib/appengine-api-labs.jar and b/server/IDSWrapper/war/WEB-INF/lib/appengine-api-labs.jar differ
diff --git a/server/IDSWrapper/war/WEB-INF/lib/appengine-endpoints.jar b/server/IDSWrapper/war/WEB-INF/lib/appengine-endpoints.jar
index e061c35..0128e2e 100644
Binary files a/server/IDSWrapper/war/WEB-INF/lib/appengine-endpoints.jar and b/server/IDSWrapper/war/WEB-INF/lib/appengine-endpoints.jar differ
diff --git a/server/IDSWrapper/war/WEB-INF/lib/appengine-jsr107cache-1.7.2.1.jar b/server/IDSWrapper/war/WEB-INF/lib/appengine-jsr107cache-1.7.3.jar
similarity index 73%
rename from server/IDSWrapper/war/WEB-INF/lib/appengine-jsr107cache-1.7.2.1.jar
rename to server/IDSWrapper/war/WEB-INF/lib/appengine-jsr107cache-1.7.3.jar
index cb17b2f..487690f 100644
Binary files a/server/IDSWrapper/war/WEB-INF/lib/appengine-jsr107cache-1.7.2.1.jar and b/server/IDSWrapper/war/WEB-INF/lib/appengine-jsr107cache-1.7.3.jar differ