Strabon

changeset 744:0aeaab276850 temporals

Comments can be everywhere! (believe me)
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Wed Nov 28 19:14:11 2012 +0200 (2012-11-28)
parents c9cf73b38b54
children 565907aa0e93
files runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/QueryRewritingTests.java
line diff
     1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Wed Nov 28 17:51:08 2012 +0200
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Wed Nov 28 19:14:11 2012 +0200
     1.3 @@ -295,11 +295,12 @@
     1.4  			graphVariable+="_";
     1.5  			
     1.6  			//remove comments from query
     1.7 -			String REGEX = "((^(\\s)*#)|((\\s)*#)).*$";
     1.8 +			queryString=queryString.replaceAll("\\.#", ".\n#");
     1.9 +		    String REGEX = "((^(\\s)*#)|((\\s)+#)).*$";
    1.10  			Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);							
    1.11  			Matcher matcher = pattern.matcher(queryString);
    1.12  			String oldQueryString=matcher.replaceAll("");
    1.13 -					
    1.14 +			
    1.15  			//check whether the query contains quadruples	
    1.16  			String Word="((\\w)|(\\p{InGreek}))+";
    1.17  			String URI="(<([\\S])*>)|("+Word+":"+Word+")";
     2.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/QueryRewritingTests.java	Wed Nov 28 17:51:08 2012 +0200
     2.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/QueryRewritingTests.java	Wed Nov 28 19:14:11 2012 +0200
     2.3 @@ -125,11 +125,30 @@
     2.4  	
     2.5  		String query = 
     2.6  			prefixes+
     2.7 -			"select distinct ?s1 ?s2" +
     2.8 +			"select distinct ?s1 ?s2 " +
     2.9  			"where {" +
    2.10  			"?s1 ?p1 ?ro1 ?o1 ." +
    2.11 -			"#?s2 ?p2 ?ro2 ?o2 ." +
    2.12 -			"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.13 +			"#?s2 ?p2 ?ro2 ?o2 . \n" +
    2.14 +			"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.15 +			"}";
    2.16 +		
    2.17 +		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");
    2.18 +		assertEquals(2, querySplit.length);
    2.19 +	}
    2.20 +	
    2.21 +	
    2.22 +	@Test
    2.23 +	public void testQueryRewriting5() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
    2.24 +	{
    2.25 +	
    2.26 +		String query = 
    2.27 +			prefixes+
    2.28 +			"select distinct ?s1 ?s2 " +
    2.29 +			"where {" +
    2.30 +			"?s1 ?p1 ?ro1 ?o1 . " +
    2.31 +			"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.32 +			"#FILTER(strdf:PeriodOverlaps(?o1, \"Now\"^^<http://strdf.di.uoa.gr/ontology#validTime> )) \n " +
    2.33 +			"}";
    2.34  		
    2.35  		String [] querySplit=strabon.queryRewriting(query).split("GRAPH");
    2.36  		assertEquals(2, querySplit.length);