Strabon

changeset 860:2ee96133646a temporals

completed temporal relation tests.
ATTENTION: Changed "meets" operation to comply with the respective operation of Allen's interval algebra. The previous implementation used the "adjacent"
function of postgres temporal. Now, period A meets period B only if last(A)==first(B).
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Tue Jan 15 19:58:08 2013 +0200 (2013-01-15)
parents 6016672577e9
children 57f00dc6208e
files endpoint/WebContent/WEB-INF/connection.properties runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/QueryRewritingTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalRelationTests.java runtime/src/test/resources/temporal-periods.nq
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/connection.properties	Tue Jan 15 12:07:55 2013 +0200
     1.2 +++ b/endpoint/WebContent/WEB-INF/connection.properties	Tue Jan 15 19:58:08 2013 +0200
     1.3 @@ -1,6 +1,6 @@
     1.4  hostname=localhost
     1.5  port=5432
     1.6  dbengine=postgis
     1.7 -password=postgres
     1.8 -dbname=endpoint
     1.9 +password=p1r3as
    1.10 +dbname=test_noa
    1.11  username=postgres
     2.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/QueryRewritingTests.java	Tue Jan 15 12:07:55 2013 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,156 +0,0 @@
     2.4 -/**
     2.5 - * This Source Code Form is subject to the terms of the Mozilla Public
     2.6 - * License, v. 2.0. If a copy of the MPL was not distributed with this
     2.7 - * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     2.8 - * 
     2.9 - * Copyright (C) 2010, 2011, 2012, Pyravlos Team
    2.10 - * 
    2.11 - * http://www.strabon.di.uoa.gr/
    2.12 - */
    2.13 -package eu.earthobservatory.runtime.postgis.temporals;
    2.14 -
    2.15 -
    2.16 -
    2.17 -import static org.junit.Assert.assertEquals;
    2.18 -
    2.19 -import java.io.IOException;
    2.20 -import java.sql.SQLException;
    2.21 -import org.junit.AfterClass;
    2.22 -import org.junit.BeforeClass;
    2.23 -import org.junit.Test;
    2.24 -import org.openrdf.query.MalformedQueryException;
    2.25 -import org.openrdf.query.QueryEvaluationException;
    2.26 -import org.openrdf.query.TupleQueryResultHandlerException;
    2.27 -import org.openrdf.repository.RepositoryException;
    2.28 -import org.openrdf.rio.RDFHandlerException;
    2.29 -import org.openrdf.rio.RDFParseException;
    2.30 -
    2.31 -
    2.32 -import eu.earthobservatory.runtime.generaldb.*;
    2.33 -import eu.earthobservatory.runtime.postgis.temporals.TemplateTests;
    2.34 -
    2.35 -
    2.36 -/**
    2.37 - * A set of simple tests on query rewriting functionality 
    2.38 - * 
    2.39 - * @author Panayiotis Smeros <psmeros@di.uoa.gr>
    2.40 - */
    2.41 -public class QueryRewritingTests {
    2.42 -
    2.43 -	protected static Strabon strabon;
    2.44 -	
    2.45 -	protected static final String prefixes = 
    2.46 -		"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
    2.47 -		"PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> \n" +
    2.48 -		"PREFIX ex: <http://example.org/> \n" +
    2.49 -		"PREFIX xs: <http://www.w3.org/2001/XMLSchema#> \n" +
    2.50 -		"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n" +
    2.51 -		"PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n";
    2.52 -
    2.53 -	
    2.54 -	@BeforeClass
    2.55 -	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    2.56 -	{
    2.57 -		strabon = TemplateTests.beforeClass("/temporal-selection-tests.nq","NQUADS");
    2.58 -	}
    2.59 -	
    2.60 -	@AfterClass
    2.61 -	public static void afterClass() throws SQLException
    2.62 -	{
    2.63 -		TemplateTests.afterClass(strabon);
    2.64 -	}
    2.65 -	
    2.66 -	
    2.67 -	
    2.68 -	@Test
    2.69 -	public void testQueryRewriting1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
    2.70 -	{
    2.71 -	
    2.72 -		String query = 
    2.73 -			prefixes+
    2.74 -			"SELECT ?geo1 "+ 
    2.75 -			"WHERE { "+
    2.76 -				"?x strdf:hasGeometry ?geo1 . "+
    2.77 -				"?y strdf:hasGeometry ?geo2 . "+
    2.78 -				"FILTER(strdf:intersects(?geo1, ?geo2))."+
    2.79 -				"}";
    2.80 -		
    2.81 -		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");		
    2.82 -		assertEquals(1, querySplit.length);
    2.83 -	}
    2.84 -	
    2.85 -
    2.86 -	@Test
    2.87 -	public void testQueryRewriting2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
    2.88 -	{
    2.89 -	
    2.90 -		String query = 
    2.91 -			prefixes+
    2.92 -			"select ?geo ?s1 ?s2 " +
    2.93 -			"where {" +
    2.94 -			"?s1  ?p1 ?o1 ?t1 ." +
    2.95 -			" ?s2  ?p2 ?o2 ?t2 ." +
    2.96 -			"?x strdf:hasGeometry ?geo1 ." +
    2.97 -			"?y strdf:hasGeometry ?geo2." +
    2.98 -			"FILTER(strdf:intersects(?geo1,?geo2))." +
    2.99 -			"   FILTER(strdf:afterPeriod(?t1,?t2))}";	
   2.100 -		
   2.101 -		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");		
   2.102 -		assertEquals(3, querySplit.length);
   2.103 -	}
   2.104 -
   2.105 -
   2.106 -	@Test
   2.107 -	public void testQueryRewriting3() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   2.108 -	{
   2.109 -	
   2.110 -		String query = 
   2.111 -			prefixes+
   2.112 -			"select ?s1 " +
   2.113 -			"where { " +
   2.114 -			"?s1 ?p1 ?o1 ?t1 ." +
   2.115 -			"?s2 ?p2 ?o2 ?t2 ." +
   2.116 -			"?x1 <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#hasGeometry>    ?geo1. " +
   2.117 -			"?x2 <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#hasGeometry>    ?geo2. " +
   2.118 -			"FILTER(strdf:disjoint(?geo1,?geo2))" +
   2.119 -			"FILTER(strdf:afterPeriod(?t1, ?t2)).";
   2.120 -		
   2.121 -		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");		
   2.122 -		assertEquals(3, querySplit.length);
   2.123 -	}
   2.124 -	
   2.125 -	@Test
   2.126 -	public void testQueryRewriting4() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   2.127 -	{
   2.128 -	
   2.129 -		String query = 
   2.130 -			prefixes+
   2.131 -			"select distinct ?s1 ?s2 " +
   2.132 -			"where {" +
   2.133 -			"?s1 ?p1 ?ro1 ?o1 ." +
   2.134 -			"#?s2 ?p2 ?ro2 ?o2 . \n" +
   2.135 -			"FILTER(strdf:PeriodOverlaps(?o1, \"[2012-11-19 12:41:00+02, 2012-11-19 13:41:00.000001+02]\"^^<http://strdf.di.uoa.gr/ontology#validTime> ))" +
   2.136 -			"}";
   2.137 -		
   2.138 -		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");
   2.139 -		assertEquals(2, querySplit.length);
   2.140 -	}
   2.141 -	
   2.142 -	
   2.143 -	@Test
   2.144 -	public void testQueryRewriting5() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   2.145 -	{
   2.146 -	
   2.147 -		String query = 
   2.148 -			prefixes+
   2.149 -			"select distinct ?s1 ?s2 " +
   2.150 -			"where {" +
   2.151 -			"?s1 ?p1 ?ro1 ?o1 . " +
   2.152 -			"FILTER(strdf:PeriodOverlaps(?o1, \"[2012-11-19 12:41:00+02, 2012-11-19 13:41:00.000001+02]\"^^<http://strdf.di.uoa.gr/ontology#validTime>)) " +
   2.153 -			"#FILTER(strdf:PeriodOverlaps(?o1, \"Now\"^^<http://strdf.di.uoa.gr/ontology#validTime> )) \n " +
   2.154 -			"}";
   2.155 -		
   2.156 -		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");
   2.157 -		assertEquals(2, querySplit.length);
   2.158 -	}
   2.159 -}
     3.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalRelationTests.java	Tue Jan 15 12:07:55 2013 +0200
     3.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalRelationTests.java	Tue Jan 15 19:58:08 2013 +0200
     3.3 @@ -79,26 +79,50 @@
     3.4  	
     3.5  		String query = 
     3.6  			prefixes+
     3.7 -			"SELECT ?x1 "+ 
     3.8 +			"SELECT distinct ?x1 ?x2 "+ 
     3.9  			"WHERE { "+
    3.10  				"?x1 ?y1 ?z1 ?t1 . "+
    3.11  				"?x2 ?y2 ?z2 ?t2 . "+
    3.12 -				"FILTER(strdf:after(?t1, ?t2))."+
    3.13 +				"FILTER(strdf:after(?t1, ?t2) && str(?x1) != str(?x2))."+
    3.14  				"}";
    3.15  		
    3.16  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
    3.17  		
    3.18 -		for(String result: bindings)
    3.19 +		/*for(String result: bindings)
    3.20  		{
    3.21  			System.out.println(result.toString());
    3.22 -		}
    3.23 +		}*/
    3.24  		
    3.25 -		assertEquals(5, bindings.size());
    3.26 -		assertTrue(-1 < bindings.indexOf("[x1=http://example.org/item1]"));
    3.27 -		assertTrue(-1 < bindings.indexOf("[x1=http://example.org/item2]"));
    3.28 -		assertTrue(-1 < bindings.indexOf("[x1=http://example.org/item3]"));
    3.29 -		assertTrue(-1 < bindings.indexOf("[x1=http://example.org/item5]"));
    3.30 -		assertTrue(-1 < bindings.indexOf("[x1=http://example.org/item6]"));
    3.31 +		assertEquals(25, bindings.size());
    3.32 +		//assertTrue(-1 < bindings.indexOf(""));
    3.33 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item7]"));
    3.34 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item8]"));
    3.35 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item2]"));
    3.36 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item7]"));
    3.37 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item6]"));
    3.38 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item8]"));
    3.39 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item8]"));
    3.40 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item7]"));
    3.41 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item8]"));
    3.42 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item6]"));
    3.43 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item6]"));
    3.44 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item5]"));
    3.45 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item1]"));
    3.46 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
    3.47 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item3]"));
    3.48 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item1]"));
    3.49 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item8]"));
    3.50 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item3]"));
    3.51 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item1]"));
    3.52 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item3]"));
    3.53 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item7]"));
    3.54 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item2]"));
    3.55 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
    3.56 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item2]"));
    3.57 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item8]"));
    3.58 +		
    3.59 +		
    3.60 +
    3.61  	}
    3.62  	
    3.63  	@Test
    3.64 @@ -118,26 +142,39 @@
    3.65  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
    3.66  		//System.out.println(bindings.toString());
    3.67  		
    3.68 -		for(String result: bindings)
    3.69 +		/*for(String result: bindings)
    3.70  		{
    3.71  			System.out.println(result.toString());
    3.72 -		}
    3.73 +		}*/
    3.74  		
    3.75 -		assertEquals(14, bindings.size());
    3.76 +		assertEquals(25, bindings.size());
    3.77  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item5]"));
    3.78 +	
    3.79 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item4]"));
    3.80 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item6]"));
    3.81 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item5]"));
    3.82 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item7]"));
    3.83 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
    3.84 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item4]"));
    3.85 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item4]"));
    3.86  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item5]"));
    3.87 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item6]"));
    3.88 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item6]"));
    3.89 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item4]"));
    3.90 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item5]"));
    3.91  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item6]"));
    3.92 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item4]"));
    3.93  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
    3.94 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item5]"));
    3.95 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item4]"));
    3.96 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
    3.97 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item4]"));
    3.98 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item4]"));
    3.99 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item3]"));
   3.100 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item5]"));
   3.101 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item5]"));
   3.102 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item1]"));
   3.103  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item4]"));
   3.104 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item4]"));
   3.105 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item5]"));
   3.106 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item1]"));
   3.107 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item2]"));
   3.108 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item5]"));
   3.109  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item6]"));
   3.110 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item6]"));
   3.111 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item4]"));
   3.112  	}
   3.113  	
   3.114  	@Test
   3.115 @@ -154,12 +191,12 @@
   3.116  				"}";
   3.117  		
   3.118  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.119 -		assertEquals(18, bindings.size());
   3.120 +		assertEquals(31, bindings.size());
   3.121  		//assertTrue(-1 < bindings.indexOf(""));
   3.122 -		for(String result: bindings)
   3.123 +		/*for(String result: bindings)
   3.124  		{
   3.125  			System.out.println(result.toString());
   3.126 -		}
   3.127 +		}*/
   3.128  		
   3.129  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item1]"));
   3.130  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item2]"));
   3.131 @@ -179,6 +216,37 @@
   3.132  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item2]"));
   3.133  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item2]"));
   3.134  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item1]"));
   3.135 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item1]"));
   3.136 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item7]"));
   3.137 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item8]"));
   3.138 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item2]"));
   3.139 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item7]"));
   3.140 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item3]"));
   3.141 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
   3.142 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.143 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item6]"));
   3.144 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item8]"));
   3.145 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item8]"));
   3.146 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item7]"));
   3.147 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item8]"));
   3.148 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item6]"));
   3.149 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item8]"));
   3.150 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item7]"));
   3.151 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item5]"));
   3.152 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item7]"));
   3.153 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item2]"));
   3.154 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
   3.155 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item1]"));
   3.156 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.157 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item7]"));
   3.158 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item3]"));
   3.159 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item2]"));
   3.160 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item8]"));
   3.161 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item1]"));
   3.162 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.163 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item8]"));
   3.164 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item3]"));
   3.165 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
   3.166  	}
   3.167  	
   3.168  	@Test
   3.169 @@ -195,19 +263,28 @@
   3.170  				"}";
   3.171  		
   3.172  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.173 -		assertEquals(6, bindings.size());
   3.174 +		assertEquals(14, bindings.size());
   3.175  		//assertTrue(-1 < bindings.indexOf(""));
   3.176 -		for(String result: bindings)
   3.177 +		/*for(String result: bindings)
   3.178  		{
   3.179  			System.out.println(result.toString());
   3.180 -		}
   3.181 +		}*/
   3.182  		
   3.183  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.184 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item7]"));
   3.185 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
   3.186 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item3]"));
   3.187 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.188 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item7]"));
   3.189 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
   3.190 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item2]"));
   3.191 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.192 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item1]"));
   3.193 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item2]"));
   3.194 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item8]"));
   3.195 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.196  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
   3.197 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
   3.198 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
   3.199 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.200 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.201 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item7]"));
   3.202  	}
   3.203  	
   3.204  	@Test
   3.205 @@ -225,19 +302,28 @@
   3.206  		
   3.207  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.208  	
   3.209 -		assertEquals(6, bindings.size());
   3.210 +		assertEquals(14, bindings.size());
   3.211  		//assertTrue(-1 < bindings.indexOf(""));
   3.212 -		for(String result: bindings)
   3.213 +		/*for(String result: bindings)
   3.214  		{
   3.215  			System.out.println(result.toString());
   3.216 -		}
   3.217 +		}*/
   3.218  		
   3.219 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item8]"));
   3.220 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item7]"));
   3.221 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item3]"));
   3.222 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.223 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item7]"));
   3.224 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item1]"));
   3.225 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item2]"));
   3.226  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.227 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
   3.228 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.229  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
   3.230 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
   3.231 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item2]"));
   3.232  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
   3.233 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.234 -		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.235 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item7]"));
   3.236 +		
   3.237  	}
   3.238  	
   3.239  	@Test
   3.240 @@ -255,12 +341,12 @@
   3.241  		
   3.242  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.243  	
   3.244 -		assertEquals(6, bindings.size());
   3.245 +		assertEquals(8, bindings.size());
   3.246  		//assertTrue(-1 < bindings.indexOf(""));
   3.247 -		for(String result: bindings)
   3.248 +		/*for(String result: bindings)
   3.249  		{
   3.250  			System.out.println(result.toString());
   3.251 -		}
   3.252 +		}*/
   3.253  		
   3.254  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.255  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
   3.256 @@ -268,6 +354,8 @@
   3.257  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item1]"));
   3.258  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.259  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.260 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item7]"));
   3.261 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item8]"));
   3.262  		
   3.263  	}
   3.264  	@Test
   3.265 @@ -276,20 +364,21 @@
   3.266  	
   3.267  		String query = 
   3.268  			prefixes+
   3.269 -			"SELECT ?x1 ?x2 "+ 
   3.270 +			"SELECT distinct ?x1 ?x2 "+ 
   3.271  			"WHERE { "+
   3.272  				"?x1 ?y1 ?z1 ?t1 . "+
   3.273  				"?x2 ?y2 ?z2 ?t2 . "+
   3.274 -				"FILTER(strdf:adjacent(?t1, ?t2))."+
   3.275 +				"FILTER(strdf:adjacent(?t1, ?t2) && str(?x1) < str(?x2))."+
   3.276  				"}";
   3.277  		
   3.278  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.279 -		for(String result: bindings)
   3.280 +		/*for(String result: bindings)
   3.281  		{
   3.282  			System.out.println(result.toString());
   3.283 -		}
   3.284 -		//assertEquals(14, bindings.size());
   3.285 +		}*/
   3.286 +		assertEquals(1, bindings.size());
   3.287  		//assertTrue(-1 < bindings.indexOf(""));
   3.288 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item7]"));
   3.289  	}
   3.290  	
   3.291  	@Test
   3.292 @@ -298,20 +387,23 @@
   3.293  	
   3.294  		String query = 
   3.295  			prefixes+
   3.296 -			"SELECT ?x1 ?x2 "+ 
   3.297 +			"SELECT distinct ?x1 ?x2 "+ 
   3.298  			"WHERE { "+
   3.299  				"?x1 ?y1 ?z1 ?t1 . "+
   3.300  				"?x2 ?y2 ?z2 ?t2 . "+
   3.301 -				"FILTER(strdf:meets(?t1, ?t2))."+
   3.302 +				"FILTER(strdf:meets(?t1, ?t2) && ?x1 != ?x2)."+
   3.303  				"}";
   3.304  		
   3.305  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.306 -		for(String result: bindings)
   3.307 +		/*for(String result: bindings)
   3.308  		{
   3.309  			System.out.println(result.toString());
   3.310 -		}
   3.311 -		//assertEquals(14, bindings.size());
   3.312 +		}*/
   3.313 +		assertEquals(3, bindings.size());
   3.314  		//assertTrue(-1 < bindings.indexOf(""));
   3.315 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item3]"));
   3.316 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item1]"));
   3.317 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item2]"));
   3.318  	}
   3.319  	
   3.320  	@Test
   3.321 @@ -331,10 +423,10 @@
   3.322  
   3.323  		assertEquals(6, bindings.size());
   3.324  		//assertTrue(-1 < bindings.indexOf(""));
   3.325 -		for(String result: bindings)
   3.326 +		/*for(String result: bindings)
   3.327  		{
   3.328  			System.out.println(result.toString());
   3.329 -		}
   3.330 +		}*/
   3.331  		
   3.332  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.333  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
   3.334 @@ -360,16 +452,17 @@
   3.335  		
   3.336  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.337  		
   3.338 -		assertEquals(3, bindings.size());
   3.339 +		assertEquals(4, bindings.size());
   3.340  		//assertTrue(-1 < bindings.indexOf(""));
   3.341 -		for(String result: bindings)
   3.342 +		/*for(String result: bindings)
   3.343  		{
   3.344  			System.out.println(result.toString());
   3.345 -		}
   3.346 +		}*/
   3.347  		
   3.348  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item3]"));
   3.349  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item3]"));
   3.350  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item1;x1=http://example.org/item2]"));
   3.351 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item8]"));
   3.352  	}
   3.353  	
   3.354  	@Test
   3.355 @@ -388,10 +481,10 @@
   3.356  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.357  		//assertEquals(3, bindings.size());
   3.358  		//assertTrue(-1 < bindings.indexOf(""));
   3.359 -		for(String result: bindings)
   3.360 +		/*for(String result: bindings)
   3.361  		{
   3.362  			System.out.println(result.toString());
   3.363 -		}
   3.364 +		}*/
   3.365  		
   3.366  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item3;x1=http://example.org/item2]"));
   3.367  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item2;x1=http://example.org/item1]"));
   3.368 @@ -413,13 +506,12 @@
   3.369  		
   3.370  		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   3.371  		
   3.372 -		assertEquals(15, bindings.size());
   3.373 +		assertEquals(28, bindings.size());
   3.374  		//assertTrue(-1 < bindings.indexOf(""));
   3.375 -		for(String result: bindings)
   3.376 +		/*for(String result: bindings)
   3.377  		{
   3.378  			System.out.println(result.toString());
   3.379 -		}
   3.380 -		
   3.381 +		}*/
   3.382  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item1]"));
   3.383  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item1]"));
   3.384  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item5;x1=http://example.org/item2]"));
   3.385 @@ -435,7 +527,25 @@
   3.386  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item4]"));
   3.387  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item6;x1=http://example.org/item2]"));
   3.388  		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item2]"));
   3.389 -		
   3.390 -	}
   3.391 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item4;x1=http://example.org/item2]"));
   3.392 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item1]"));
   3.393 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item5]"));
   3.394 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item6]"));
   3.395 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item3]"));
   3.396 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item4]"));
   3.397 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item7]"));
   3.398 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item4]"));
   3.399 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item6]"));
   3.400 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item6]"));
   3.401 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item3]"));
   3.402 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item3]"));
   3.403 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item5]"));
   3.404 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item2]"));
   3.405 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item1]"));
   3.406 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item7;x1=http://example.org/item1]"));
   3.407 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item5]"));
   3.408 +		assertTrue(-1 < bindings.indexOf("[x2=http://example.org/item8;x1=http://example.org/item2]"));
   3.409 +
   3.410 +}
   3.411  }
   3.412  	
   3.413 \ No newline at end of file
     4.1 --- a/runtime/src/test/resources/temporal-periods.nq	Tue Jan 15 12:07:55 2013 +0200
     4.2 +++ b/runtime/src/test/resources/temporal-periods.nq	Tue Jan 15 19:58:08 2013 +0200
     4.3 @@ -11,3 +11,5 @@
     4.4  <http://example.org/item4> <http://example.org/value> "20"^^<http://www.w3.org/2001/XMLSchema#int> "2012-01-19T10:41:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
     4.5  <http://example.org/item5> <http://example.org/value> "20"^^<http://www.w3.org/2001/XMLSchema#int> "2012-01-19T11:41:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
     4.6  <http://example.org/item6> <http://example.org/value> "20"^^<http://www.w3.org/2001/XMLSchema#int> "2012-01-19T12:41:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
     4.7 +<http://example.org/item7> <http://example.org/id> "7"^^<http://www.w3.org/2001/XMLSchema#int> "[2012-11-19T13:41:00,2012-11-19T14:41:00]"^^<http://strdf.di.uoa.gr/ontology#period>.
     4.8 +<http://example.org/item8> <http://example.org/id> "8"^^<http://www.w3.org/2001/XMLSchema#int> "[2012-11-19T14:41:00.000001,2012-11-19T15:41:00]"^^<http://strdf.di.uoa.gr/ontology#period>.