You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by fc...@apache.org on 2011/12/06 18:30:09 UTC
svn commit: r1211042 - in /incubator/stanbol/trunk: factstore/
factstore/factstore/src/main/java/org/apache/stanbol/factstore/derby/
factstore/factstore/src/main/java/org/apache/stanbol/factstore/model/
integration-tests/src/test/java/org/apache/stanbo...
Author: fchrist
Date: Tue Dec 6 17:30:08 2011
New Revision: 1211042
URL: http://svn.apache.org/viewvc?rev=1211042&view=rev
Log:
STANBOL-237 Fixed query with multiple results
Modified:
incubator/stanbol/trunk/factstore/README.md
incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/derby/DerbyFactStore.java
incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/model/FactResultSet.java
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/factstore/FactStoreTest.java
Modified: incubator/stanbol/trunk/factstore/README.md
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/factstore/README.md?rev=1211042&r1=1211041&r2=1211042&view=diff
==============================================================================
--- incubator/stanbol/trunk/factstore/README.md (original)
+++ incubator/stanbol/trunk/factstore/README.md Tue Dec 6 17:30:08 2011
@@ -1,17 +1,19 @@
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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.
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
# Apache Stanbol FactStore
@@ -22,7 +24,9 @@ store relations between N participating
## Documentation
-To get the latest documentation you should start your copy of Apache Stanbol and navigate your browser to http://localhost:8080/factstore. There you will find more information and the documentation of the FactStore's REST API.
+To get the latest documentation you should start your copy of Apache Stanbol
+and navigate your browser to http://localhost:8080/factstore. There you will
+find more information and the documentation of the FactStore's REST API.
## Example
@@ -69,7 +73,9 @@ Now to PUT the `worksFor` fact schema we
curl http://localhost:8080/factstore/facts/http%3A%2F%2Ffactschema.org%2FworksFor -T worksFor.json
-After creating the fact schema we can store the fact that John Doe works for Winzigweich by POSTing it to the FactStore. The fact is specified in JSON-LD syntax. The `@profile` defines the fact schema where this fact belongs to.
+After creating the fact schema we can store the fact that John Doe works for
+Winzigweich by POSTing it to the FactStore. The fact is specified in JSON-LD
+syntax. The `@profile` defines the fact schema where this fact belongs to.
{
"@profile" : "http://factschema.org/worksFor",
@@ -82,4 +88,6 @@ Now we can POST this fact, e.g. stored i
curl -d @fact.json -H "Content-Type: application/json" http://localhost:8080/factstore/facts
-On success this will return a 201 (Created) and the URI of the newly created fact in the location header of the response. To retrieve a fact you can GET it from the returned URI.
+On success this will return a 201 (Created) and the URI of the newly created
+fact in the location header of the response. To retrieve a fact you can GET it
+from the returned URI.
Modified: incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/derby/DerbyFactStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/derby/DerbyFactStore.java?rev=1211042&r1=1211041&r2=1211042&view=diff
==============================================================================
--- incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/derby/DerbyFactStore.java (original)
+++ incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/derby/DerbyFactStore.java Tue Dec 6 17:30:08 2011
@@ -419,6 +419,9 @@ public class DerbyFactStore implements F
firstRole = false;
}
selectBuilder.append(" FROM " + factSchemaB64 + " WHERE id=?");
+
+ // TODO Load the context, too
+
ps = con.prepareStatement(selectBuilder.toString());
ps.setInt(1, factId);
rs = ps.executeQuery();
@@ -637,8 +640,7 @@ public class DerbyFactStore implements F
// from here on we have valid data
- String factSchemaB64 = Base64.encodeBase64URLSafeString(query
- .getFromSchemaURN().getBytes());
+ String factSchemaB64 = Base64.encodeBase64URLSafeString(query.getFromSchemaURN().getBytes());
StringBuilder querySql = new StringBuilder("SELECT ");
@@ -667,6 +669,7 @@ public class DerbyFactStore implements F
}
querySql.append(')');
+ // TODO load context, too
logger.info("performing query {}", querySql);
@@ -732,8 +735,7 @@ public class DerbyFactStore implements F
FactSchema schema = this.loadFactSchema(query.getFromSchemaURN(), con);
if (schema == null) {
- throw new Exception("Fact schema " + query.getFromSchemaURN()
- + " does not exist.");
+ throw new Exception("Fact schema " + query.getFromSchemaURN() + " does not exist.");
}
StringBuilder unknownRoles = new StringBuilder();
Modified: incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/model/FactResultSet.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/model/FactResultSet.java?rev=1211042&r1=1211041&r2=1211042&view=diff
==============================================================================
--- incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/model/FactResultSet.java (original)
+++ incubator/stanbol/trunk/factstore/factstore/src/main/java/org/apache/stanbol/factstore/model/FactResultSet.java Tue Dec 6 17:30:08 2011
@@ -52,8 +52,11 @@ public class FactResultSet {
public String toJSON() {
JsonLd root = new JsonLd();
if (rows != null && !rows.isEmpty()) {
+ int rowCount = 0;
for (FactResult result : rows) {
+ rowCount++;
JsonLdResource subject = new JsonLdResource();
+ subject.setSubject(String.valueOf(rowCount));
for (int i = 0; i < header.size(); i++) {
subject.putProperty(header.get(i), result.getValues().get(i));
}
Modified: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/factstore/FactStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/factstore/FactStoreTest.java?rev=1211042&r1=1211041&r2=1211042&view=diff
==============================================================================
--- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/factstore/FactStoreTest.java (original)
+++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/factstore/FactStoreTest.java Tue Dec 6 17:30:08 2011
@@ -300,7 +300,7 @@ public class FactStoreTest extends Stanb
.withHeader("Content-Type", "application/json")
.withHeader("Accept", "application/json");
- String expected = "{\"person\":\"http://upb.de/persons/bnagel\"}";
+ String expected = "{\"@subject\":\"1\",\"person\":\"http://upb.de/persons/bnagel\"}";
String actual = executor.execute(q).assertStatus(200).getContent();
Assert.assertEquals(expected, actual);
}