Strabon

changeset 685:68f4e9215b28 temporals

Added a regex to spot quadruples.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Fri Nov 02 18:25:39 2012 +0200 (2012-11-02)
parents 6438a594cf66
children 13e41acf4964
files runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java
line diff
     1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Fri Oct 26 18:41:15 2012 +0300
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Fri Nov 02 18:25:39 2012 +0200
     1.3 @@ -6,6 +6,8 @@
     1.4   * Copyright (C) 2010, 2011, 2012, Pyravlos Team
     1.5   * 
     1.6   * http://www.strabon.di.uoa.gr/
     1.7 + * 
     1.8 + * @author Panayiotis Smeros <psmeros@di.uoa.gr>
     1.9   */
    1.10  package eu.earthobservatory.runtime.generaldb;
    1.11  
    1.12 @@ -22,6 +24,8 @@
    1.13  import java.util.ArrayList;
    1.14  import java.util.Collection;
    1.15  import java.util.Iterator;
    1.16 +import java.util.regex.Matcher;
    1.17 +import java.util.regex.Pattern;
    1.18  
    1.19  import org.openrdf.model.Statement;
    1.20  import org.openrdf.model.URI;
    1.21 @@ -215,7 +219,7 @@
    1.22  	throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException {
    1.23  		boolean status = true;
    1.24  		
    1.25 -		logger.info("[Strabon.query] Executing query: {}", queryString);
    1.26 +		logger.info("[Strabon.query] Executing query: \n{}", queryString);
    1.27  		
    1.28  		// check for null stream
    1.29  		if (out == null) {
    1.30 @@ -226,6 +230,7 @@
    1.31  		
    1.32  		TupleQuery tupleQuery = null;
    1.33  		try {
    1.34 +			queryString = convertQueryToSparql(queryString);
    1.35  			tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    1.36  			
    1.37  		} catch (RepositoryException e) {
    1.38 @@ -271,6 +276,29 @@
    1.39  		return status;
    1.40  	}
    1.41  
    1.42 +	private String convertQueryToSparql(String queryString) {
    1.43 +		
    1.44 +		//TODO
    1.45 +		String newQueryString="";
    1.46 +		
    1.47 +		// check whether the query contains quadtruples
    1.48 +		String REGEX = ".*\\{.*([[a-z][A-Z][?/<>^#]]+(\\s)+){3}(\\s)*[.}(.})]?.*\\}.*";
    1.49 +		Pattern limitPattern = Pattern.compile(REGEX, Pattern.DOTALL);							
    1.50 +		Matcher limitMatcher = limitPattern.matcher(queryString);
    1.51 +		
    1.52 +		if(limitMatcher.matches())		
    1.53 +		{
    1.54 +			logger.info("\n\nQUADRUPLE SPOTTED\n\n");
    1.55 +		}
    1.56 +		else
    1.57 +		{
    1.58 +			logger.info("\n\nQUADRUPLE NOT SPOTTED\n\n");
    1.59 +			newQueryString=queryString;
    1.60 +		}
    1.61 +		return newQueryString;
    1.62 +	}
    1.63 +
    1.64 +
    1.65  	public void update(String updateString, SailRepositoryConnection con) throws MalformedQueryException 
    1.66  	{
    1.67  		Update update = null;