-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ issue #120 ] available datasets service
- Loading branch information
agazzarini
committed
Dec 11, 2015
1 parent
c5ddeb0
commit 092067c
Showing
11 changed files
with
374 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...c/main/java/org/gazzax/labs/solrdf/handler/search/ldf/AvailableDatasetsSearchHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.gazzax.labs.solrdf.handler.search.ldf; | ||
|
||
import org.apache.solr.common.params.ModifiableSolrParams; | ||
import org.apache.solr.handler.RequestHandlerBase; | ||
import org.apache.solr.request.SolrQueryRequest; | ||
import org.apache.solr.request.SolrRequestHandler; | ||
import org.apache.solr.response.SolrQueryResponse; | ||
import org.gazzax.labs.solrdf.Names; | ||
import org.gazzax.labs.solrdf.handler.search.Sparql11SearchHandler; | ||
|
||
public class AvailableDatasetsSearchHandler extends RequestHandlerBase { | ||
final static String SELECT_ALL_DATASETS = | ||
"CONSTRUCT { ?s ?p ?o } " | ||
+ "WHERE { " | ||
+ " ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/ns/void#Dataset> . " | ||
+ " ?s ?p ?o " | ||
+ "}"; | ||
|
||
@Override | ||
public void handleRequestBody(final SolrQueryRequest request, final SolrQueryResponse response) throws Exception { | ||
request.setParams( | ||
new ModifiableSolrParams(request.getParams()) | ||
.set(Names.QUERY, SELECT_ALL_DATASETS)); | ||
requestHandler(request).handleRequest(request, response); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Returns the available datasets within this SolRDF instance"; | ||
} | ||
|
||
@Override | ||
public String getSource() { | ||
return "https://github.com/agazzarini/SolRDF"; | ||
} | ||
|
||
/** | ||
* Returns the {@link SolrRequestHandler} associated with the given name. | ||
* | ||
* @param request the current Solr request. | ||
* @param name the {@link SolrRequestHandler} name. | ||
* @return the {@link SolrRequestHandler} associated with the given name. | ||
*/ | ||
SolrRequestHandler requestHandler(final SolrQueryRequest request) { | ||
return request.getCore().getRequestHandler(Sparql11SearchHandler.DEFAULT_SPARQL_QUERY_HANDLER_NAME); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...e/src/main/java/org/gazzax/labs/solrdf/handler/search/ldf/TriplePatternSearchHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.gazzax.labs.solrdf.handler.search.ldf; | ||
|
||
import org.apache.solr.handler.RequestHandlerBase; | ||
import org.apache.solr.request.SolrQueryRequest; | ||
import org.apache.solr.response.SolrQueryResponse; | ||
|
||
|
||
public class TriplePatternSearchHandler extends RequestHandlerBase { | ||
@Override | ||
public void handleRequestBody(final SolrQueryRequest request, final SolrQueryResponse response) throws Exception { | ||
|
||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
solrdf/solrdf-core/src/main/java/org/gazzax/labs/solrdf/handler/search/ldf/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Top level package for SolRDF Linked Data Fragments search request handlers. | ||
* | ||
* @see http://linkeddatafragments.org | ||
* @see http://data.linkeddatafragments.org | ||
* @see http://www.hydra-cg.com/spec/latest/triple-pattern-fragments | ||
* @see http://www.hydra-cg.com/spec/latest/linked-data-fragments | ||
*/ | ||
package org.gazzax.labs.solrdf.handler.search.ldf; |
2 changes: 1 addition & 1 deletion
2
.../handler/search/handler/package-info.java → ...s/solrdf/handler/search/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
* Top level package for SolRDF search request handlers. | ||
*/ | ||
package org.gazzax.labs.solrdf.handler.search.handler; | ||
package org.gazzax.labs.solrdf.handler.search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ests/src/test/java/org/gazzax/labs/solrdf/integration/ldf/LinkedDataFragments_ITCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* This Test case makes use of some examples from | ||
* | ||
* "Learning SPARQL - Querying and Updating with SPARQL 1.1" by Bob DuCharme | ||
* | ||
* Publisher: O'Reilly | ||
* Author: Bob DuCharme | ||
* ISBN: 978-1-449-37143-2 | ||
* http://www.learningsparql.com/ | ||
* http://shop.oreilly.com/product/0636920030829.do | ||
* | ||
* We warmly appreciate and thank the author and O'Reilly for such permission. | ||
* | ||
*/ | ||
package org.gazzax.labs.solrdf.integration.ldf; | ||
|
||
import static org.gazzax.labs.solrdf.MisteryGuest.misteryGuest; | ||
|
||
import java.io.File; | ||
|
||
import org.gazzax.labs.solrdf.integration.IntegrationTestSupertypeLayer; | ||
import org.junit.Test; | ||
|
||
import com.hp.hpl.jena.graph.NodeFactory; | ||
import com.hp.hpl.jena.rdf.model.Model; | ||
import com.hp.hpl.jena.rdf.model.ModelFactory; | ||
|
||
/** | ||
* Linked Data Fragments interface integration tests. | ||
* | ||
* Note: the SolRDF client is not yet ready from a full understanding of the LDF protocol perspective. | ||
* | ||
* @author Andrea Gazzarini | ||
* @since 1.0 | ||
*/ | ||
public class LinkedDataFragments_ITCase extends IntegrationTestSupertypeLayer { | ||
@Test | ||
public void availableDatasets() throws Exception { | ||
load(misteryGuest(null, "sample-datasets.nt")); | ||
Thread.sleep(10000000000000000L); | ||
final Model response = SOLRDF_CLIENT.ldf().availableDatasets(); | ||
final Model expectedResponse = ModelFactory.createDefaultModel().read( | ||
new File(examplesDirectory(), | ||
"available-datasets-expected-response.nt").toURI().toString()); | ||
|
||
assertTrue(response.isIsomorphicWith(expectedResponse)); | ||
} | ||
|
||
@Override | ||
protected String examplesDirectory() { | ||
return "src/test/resources/ldf"; | ||
} | ||
} |
Oops, something went wrong.