Search in sources :

Example 36 with QuerySolution

use of org.apache.jena.query.QuerySolution in project jena by apache.

the class SouthPFTest method testExecEvaluated.

/**
 * Test of execEvaluated method, of class SouthPF.
 */
@Test
public void testExecEvaluated() {
    Dataset dataset = SpatialIndexTestData.createTestDataset();
    String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + "    ?subj spatial:south(48.857487 2.373047) .\n" + "}ORDER by ?subj";
    List<Resource> result = new ArrayList<>();
    try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
        ResultSet rs = qe.execSelect();
        while (rs.hasNext()) {
            QuerySolution qs = rs.nextSolution();
            Resource feature = qs.getResource("subj");
            result.add(feature);
        }
    }
    List<Resource> expResult = Arrays.asList(SpatialIndexTestData.AUCKLAND_FEATURE, SpatialIndexTestData.HONOLULU_FEATURE, SpatialIndexTestData.NEW_YORK_FEATURE, SpatialIndexTestData.PERTH_FEATURE);
    assertEquals(expResult, result);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 37 with QuerySolution

use of org.apache.jena.query.QuerySolution in project jena by apache.

the class WestPFTest method testExecEvaluated.

/**
 * Test of execEvaluated method, of class WestPF.
 */
@Test
public void testExecEvaluated() {
    Dataset dataset = SpatialIndexTestData.createTestDataset();
    String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + "    ?subj spatial:west(48.857487 2.373047) .\n" + "}ORDER by ?subj";
    List<Resource> result = new ArrayList<>();
    try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
        ResultSet rs = qe.execSelect();
        while (rs.hasNext()) {
            QuerySolution qs = rs.nextSolution();
            Resource feature = qs.getResource("subj");
            result.add(feature);
        }
    }
    List<Resource> expResult = Arrays.asList(SpatialIndexTestData.HONOLULU_FEATURE, SpatialIndexTestData.LONDON_FEATURE, SpatialIndexTestData.NEW_YORK_FEATURE);
    assertEquals(expResult, result);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 38 with QuerySolution

use of org.apache.jena.query.QuerySolution in project jena by apache.

the class NearbyPFTest method testExecEvaluated.

/**
 * Test of execEvaluated method, of class NearbyPF.
 */
@Test
public void testExecEvaluated() {
    Dataset dataset = SpatialIndexTestData.createTestDataset();
    String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + "    ?subj spatial:nearby(48.857487 2.373047 350) .\n" + "}ORDER by ?subj";
    List<Resource> result = new ArrayList<>();
    try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
        ResultSet rs = qe.execSelect();
        while (rs.hasNext()) {
            QuerySolution qs = rs.nextSolution();
            Resource feature = qs.getResource("subj");
            result.add(feature);
        }
    }
    List<Resource> expResult = Arrays.asList(SpatialIndexTestData.LONDON_FEATURE);
    assertEquals(expResult, result);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 39 with QuerySolution

use of org.apache.jena.query.QuerySolution in project jena by apache.

the class IntersectBoxPFTest method testExecEvaluated.

/**
 * Test of execEvaluated method, of class IntersectBox.
 */
@Test
public void testExecEvaluated() {
    Dataset dataset = SpatialIndexTestData.createTestDataset();
    String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + "    ?subj spatial:intersectBox(51.4 -0.13 51.6 -0.12) .\n" + "}ORDER by ?subj";
    List<Resource> result = new ArrayList<>();
    try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
        ResultSet rs = qe.execSelect();
        while (rs.hasNext()) {
            QuerySolution qs = rs.nextSolution();
            Resource feature = qs.getResource("subj");
            result.add(feature);
        }
    }
    List<Resource> expResult = Arrays.asList(SpatialIndexTestData.LONDON_FEATURE);
    assertEquals(expResult, result);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Example 40 with QuerySolution

use of org.apache.jena.query.QuerySolution in project jena by apache.

the class WithinBoxPFTest method testExecEvaluated.

/**
 * Test of execEvaluated method, of class WithinBoxPF.
 */
@Test
public void testExecEvaluated() {
    Dataset dataset = SpatialIndexTestData.createTestDataset();
    String query = "PREFIX spatial: <http://jena.apache.org/spatial#>\n" + "\n" + "SELECT ?subj\n" + "WHERE{\n" + "    ?subj spatial:withinBox(51.4 -0.13 51.6 -0.12) .\n" + "}ORDER by ?subj";
    List<Resource> result = new ArrayList<>();
    try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
        ResultSet rs = qe.execSelect();
        while (rs.hasNext()) {
            QuerySolution qs = rs.nextSolution();
            Resource feature = qs.getResource("subj");
            result.add(feature);
        }
    }
    List<Resource> expResult = Arrays.asList(SpatialIndexTestData.LONDON_FEATURE);
    assertEquals(expResult, result);
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution) Test(org.junit.Test)

Aggregations

QuerySolution (org.apache.jena.query.QuerySolution)129 ResultSet (org.apache.jena.query.ResultSet)106 QueryExecution (org.apache.jena.query.QueryExecution)99 Test (org.junit.Test)71 ArrayList (java.util.ArrayList)70 Query (org.apache.jena.query.Query)47 Dataset (org.apache.jena.query.Dataset)44 Resource (org.apache.jena.rdf.model.Resource)43 Literal (org.apache.jena.rdf.model.Literal)22 RDFNode (org.apache.jena.rdf.model.RDFNode)21 Model (org.apache.jena.rdf.model.Model)15 HashMap (java.util.HashMap)7 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)6 Extractor (infoeval.main.WikiData.Extractor)4 IOException (java.io.IOException)4 Node (org.apache.jena.graph.Node)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 Date (java.sql.Date)3 SimpleDateFormat (java.text.SimpleDateFormat)3 LinkedList (java.util.LinkedList)3