Strabon

changeset 1151:c8f4ebc124a2 temporals

added HashTable to ensure that the constructed graph variables in the update and select clause that correspond to the same temporal literal are the same
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Wed May 08 13:28:42 2013 +0300 (2013-05-08)
parents dc7f1c630fb5
children b23c7794ecba
files runtime/src/main/java/eu/earthobservatory/runtime/generaldb/utils.java
line diff
     1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/utils.java	Wed May 08 12:07:51 2013 +0300
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/utils.java	Wed May 08 13:28:42 2013 +0300
     1.3 @@ -1,5 +1,6 @@
     1.4  package eu.earthobservatory.runtime.generaldb;
     1.5  
     1.6 +import java.util.Hashtable;
     1.7  import java.util.regex.Matcher;
     1.8  import java.util.regex.Pattern;
     1.9  
    1.10 @@ -17,6 +18,8 @@
    1.11  		int numOfQuadruples=0;
    1.12  		int startIndex=0;
    1.13  		
    1.14 +		Hashtable< String, String> periodsAndGraphs = new Hashtable<String, String>();
    1.15 +		
    1.16  		StringBuffer whereClauses = new StringBuffer(2048);
    1.17  		NQuadsParser parser = new NQuadsParser();
    1.18  		
    1.19 @@ -107,19 +110,38 @@
    1.20  					i=5;
    1.21  	
    1.22  				}
    1.23 -				else if(isVar(token[3]) && inWhere==false) //the fourth element is a temporal variable in an update clause
    1.24 +				else
    1.25  				{
    1.26 +					String tgraph=null;
    1.27  					//String addedPattern = graphVariable+numOfQuadruples+ " <http://strdf.di.uoa.gr/ontology#hasValidTime>"+ token[3];
    1.28 -					newQueryString+="\n GRAPH "+graphVariable+numOfQuadruples+" { " +token[0]+" "+token[1]+" "+token[2]+" .}\n";
    1.29 -					i=5;
    1.30 +					if(periodsAndGraphs.containsKey(token[3]))
    1.31 +					{
    1.32 +						tgraph = periodsAndGraphs.get(token[3]);
    1.33 +						System.out.println("no need to make an insert to the hashTable");
    1.34 +
    1.35 +					}
    1.36 +					else
    1.37 +					{
    1.38 +						tgraph = graphVariable + numOfQuadruples;
    1.39 +						periodsAndGraphs.put(token[3], tgraph);
    1.40 +						System.out.println("just inserted to hashTable: tvar: "+token[3]+" and tgraph: "+tgraph);
    1.41 +					}
    1.42 +					
    1.43 +					if(inWhere == false)
    1.44 +					{
    1.45 +						newQueryString+="\n GRAPH "+tgraph+ "{ " +token[0]+" "+token[1]+" "+token[2]+" .}\n";
    1.46 +						i=5;
    1.47 +				
    1.48 +					}
    1.49 +					else
    1.50 +					{
    1.51 +				
    1.52 +						newQueryString+="\n GRAPH "+tgraph+" { " +token[0]+" "+token[1]+" "+token[2]+" .}\n";
    1.53 +						newQueryString+=tgraph+" <http://strdf.di.uoa.gr/ontology#hasValidTime>";
    1.54 +						i=3;
    1.55 +					
    1.56 +					}
    1.57  				}
    1.58 -				else if(isVar(token[3]) && inWhere==true) //temporal variable in where clause
    1.59 -				{
    1.60 -					newQueryString+="\n GRAPH "+graphVariable+numOfQuadruples+" { " +token[0]+" "+token[1]+" "+token[2]+" .}\n";
    1.61 -					newQueryString+=graphVariable+numOfQuadruples+" <http://strdf.di.uoa.gr/ontology#hasValidTime>";
    1.62 -					i=3;
    1.63 -				}
    1.64 -				
    1.65  				
    1.66  				//add the rest tokens
    1.67  				while( i<token.length)