marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [4/4] git commit: MARMOTTA-556: added hydra controls
Date Tue, 28 Oct 2014 09:16:14 GMT
MARMOTTA-556: added hydra controls


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/b8d297a7
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/b8d297a7
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/b8d297a7

Branch: refs/heads/MARMOTTA-556
Commit: b8d297a79016717710eadb2781e72ef0e685074b
Parents: 718c304
Author: Sergio Fernández <wikier@apache.org>
Authored: Tue Oct 28 10:15:56 2014 +0100
Committer: Sergio Fernández <wikier@apache.org>
Committed: Tue Oct 28 10:15:56 2014 +0100

----------------------------------------------------------------------
 .../platform/ldf/services/LdfServiceImpl.java   | 29 ++++++++++++++++----
 .../ldf/webservices/LdfWebServiceTest.java      |  8 ------
 2 files changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/b8d297a7/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java
b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java
index f776e03..576560a 100644
--- a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java
+++ b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java
@@ -24,12 +24,12 @@ import org.apache.marmotta.commons.vocabulary.XSD;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
 import org.apache.marmotta.platform.ldf.api.LdfService;
 import org.apache.marmotta.platform.ldf.vocab.HYDRA;
+import org.apache.marmotta.platform.ldf.vocab.RDF;
 import org.apache.marmotta.platform.ldf.vocab.SSD;
 import org.apache.marmotta.platform.ldf.vocab.VOID;
 import org.openrdf.model.*;
 import org.openrdf.model.impl.TreeModel;
 import org.openrdf.model.impl.ValueFactoryImpl;
-import org.openrdf.model.vocabulary.RDF;
 import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
 import org.openrdf.repository.RepositoryResult;
@@ -166,8 +166,8 @@ public class LdfServiceImpl implements LdfService {
 
             //and add ldf metadata
             URI dataset = vf.createURI(UriBuilder.fromUri(uri).replaceQuery(null).build().toASCIIString());
-            model.add(dataset, RDF.TYPE, VOID.Dataset);
-            model.add(dataset, RDF.TYPE, HYDRA.Collection);
+            model.add(dataset, RDF.type, VOID.Dataset);
+            model.add(dataset, RDF.type, HYDRA.Collection);
             if (context != null) {
                 model.add(dataset, VOID.inDataset, context);
                 model.add(dataset, SSD.namedGraph, context);
@@ -175,11 +175,13 @@ public class LdfServiceImpl implements LdfService {
 
             Resource fragment = vf.createBNode(String.format("fragment-%tFT%<tH-%<tM-%<tS.%<tL",
new Date()));
             model.add(dataset, VOID.subset, fragment);
-            model.add(fragment, RDF.TYPE, HYDRA.Collection);
+            model.add(fragment, RDF.type, HYDRA.Collection);
             if (offset != 0 && limit != size) {
-                model.add(fragment, RDF.TYPE, HYDRA.PagedCollection);
+                model.add(fragment, RDF.type, HYDRA.PagedCollection);
             }
             model.add(fragment, VOID.triples, vf.createLiteral(Integer.toString(filteredStatements.size()),
XSD.Integer));
+
+            //and add hydra controls
             model.add(fragment, HYDRA.totalItems, vf.createLiteral(Integer.toString(filteredStatements.size()),
XSD.Integer));
             model.add(fragment, HYDRA.itemsPerPage, vf.createLiteral(Integer.toString(LdfService.PAGE_SIZE),
XSD.Integer));
             model.add(fragment, HYDRA.firstPage, vf.createURI(UriBuilder.fromUri(uri).queryParam("page",
1).build().toASCIIString()));
@@ -189,7 +191,22 @@ public class LdfServiceImpl implements LdfService {
             if (offset + limit < statements.size()) {
                 model.add(fragment, HYDRA.nextPage, vf.createURI(UriBuilder.fromUri(uri).queryParam("page",
page+1).build().toASCIIString()));
             }
-            //TODO: hydra controls
+            Resource triplePattern = vf.createBNode("triplePattern");
+            model.add(dataset, HYDRA.search, triplePattern);
+            model.add(triplePattern, HYDRA.template, vf.createLiteral(dataset.stringValue()
+ "{?subject,predicate,object}"));
+            Resource subjectMapping = vf.createBNode("subjectMapping");
+            model.add(triplePattern, HYDRA.mapping, subjectMapping);
+            model.add(subjectMapping, HYDRA.variable, vf.createLiteral("subject"));
+            model.add(subjectMapping, HYDRA.property, RDF.subject);
+            Resource predicateMapping = vf.createBNode("predicateMapping");
+            model.add(triplePattern, HYDRA.mapping, predicateMapping);
+            model.add(predicateMapping, HYDRA.variable, vf.createLiteral("predicate"));
+            model.add(predicateMapping, HYDRA.property, RDF.predicate);
+            Resource objectMapping = vf.createBNode("objectMapping");
+            model.add(triplePattern, HYDRA.mapping, objectMapping);
+            model.add(objectMapping, HYDRA.variable, vf.createLiteral("object"));
+            model.add(objectMapping, HYDRA.property, RDF.object);
+
 
             return model;
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b8d297a7/platform/marmotta-ldf/src/test/java/org/apache/marmotta/platform/ldf/webservices/LdfWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldf/src/test/java/org/apache/marmotta/platform/ldf/webservices/LdfWebServiceTest.java
b/platform/marmotta-ldf/src/test/java/org/apache/marmotta/platform/ldf/webservices/LdfWebServiceTest.java
index d37d6e0..c42c17f 100644
--- a/platform/marmotta-ldf/src/test/java/org/apache/marmotta/platform/ldf/webservices/LdfWebServiceTest.java
+++ b/platform/marmotta-ldf/src/test/java/org/apache/marmotta/platform/ldf/webservices/LdfWebServiceTest.java
@@ -1,22 +1,14 @@
 package org.apache.marmotta.platform.ldf.webservices;
 
 import com.jayway.restassured.RestAssured;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.importer.ImportService;
-import org.apache.marmotta.platform.core.api.prefix.PrefixService;
-import org.apache.marmotta.platform.core.api.triplestore.ContextService;
 import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
 import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
-import org.apache.marmotta.platform.core.webservices.io.ImportWebService;
-import org.apache.marmotta.platform.core.webservices.prefix.PrefixWebService;
-import org.apache.marmotta.platform.core.webservices.triplestore.ContextWebService;
 import org.junit.AfterClass;
-import org.junit.Assume;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.openrdf.model.URI;
 import org.openrdf.model.impl.ValueFactoryImpl;
 
 import java.io.IOException;


Mime
View raw message