Strabon

changeset 641:333e06b3e474

Some more changes to the maximum limit of results.
author Stella Giannakopoulou <sgian@di.uoa.gr>
date Wed Oct 17 20:02:55 2012 +0300 (2012-10-17)
parents 61c165c2e0b7
children 3135a083daa2
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Fri Oct 12 16:06:32 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Wed Oct 17 20:02:55 2012 +0300
     1.3 @@ -64,7 +64,7 @@
     1.4  		this.password = password;
     1.5  		this.checkForLockTable = checkForLockTable;
     1.6  		this.dbBackend = dbBackend;
     1.7 -		this.maxLimit = maxLimit;
     1.8 +		this.maxLimit = maxLimit;		
     1.9  		this.prefixes = prefixes;
    1.10  		this.entries = new ArrayList<StrabonBeanWrapperConfiguration>(args.size());
    1.11  		
    1.12 @@ -358,9 +358,10 @@
    1.13  		
    1.14  		if(max > 0)
    1.15  		{	
    1.16 -			Pattern limitPattern = Pattern.compile(".*limit \\d+", Pattern.DOTALL);							
    1.17 +			queryString = queryString.trim();		
    1.18 +			Pattern limitPattern = Pattern.compile(".*limit (\\d+)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
    1.19  			Matcher limitMatcher = limitPattern.matcher(queryString);
    1.20 -			
    1.21 +						
    1.22  			// check whether the query contains a limit clause
    1.23  			if(limitMatcher.matches())		
    1.24  			{								
    1.25 @@ -371,10 +372,9 @@
    1.26  				// if the initial limit is greater than the maximum, set it to the maximum
    1.27  				if(Integer.valueOf(rowsNumberMatcher.group()) > max)
    1.28  					limitedQuery = rowsNumberMatcher.replaceAll(String.valueOf(max));			
    1.29 -			}	
    1.30 +			}	 
    1.31  			else // add a limit to the query 
    1.32 -				limitedQuery = queryString+" limit "+max;
    1.33 -		
    1.34 +				limitedQuery = queryString+" limit "+max;		
    1.35  		}
    1.36  		return limitedQuery;
    1.37  	}