Strabon

changeset 652:0c88d7c2a066 temporals

made some more changes to the QuadRDFHandler and added the period datatype and datatype function validation so that it can be used in the literal manager, as soon as the schema will be extended with a periodvalues table
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Wed Oct 24 11:42:23 2012 +0300 (2012-10-24)
parents 3b6d6674f0aa
children 413e2e0f4b4b
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/NQuadsTranslator.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/QuadRDFHandler.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java	Tue Oct 23 20:07:07 2012 +0300
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java	Wed Oct 24 11:42:23 2012 +0300
     1.3 @@ -43,7 +43,7 @@
     1.4  	 * in the model stRDF and query language stSPARQL
     1.5  	 */
     1.6  	public static final String GML						= stRDF + "GML";
     1.7 -	public static final String validTime                = stRDF + "validTime";
     1.8 +	public static final String PERIOD                = stRDF + "validTime";
     1.9  
    1.10  	/**
    1.11  	 * 
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java	Tue Oct 23 20:07:07 2012 +0300
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java	Wed Oct 24 11:42:23 2012 +0300
     2.3 @@ -114,6 +114,21 @@
     2.4  	}
     2.5  	
     2.6  	/**
     2.7 +	 * Checks whether the supplied datatype is actually a GML literal.
     2.8 +	 * 
     2.9 +	 * @param datatype
    2.10 +	 * @return
    2.11 +	 */
    2.12 +	public static boolean isPeriodDatatype(URI datatype)
    2.13 +	{
    2.14 +		if(datatype == null) {
    2.15 +			return false;
    2.16 +		}
    2.17 +	
    2.18 +		return GeoConstants.PERIOD.equals(datatype.stringValue());
    2.19 +	}
    2.20 +	
    2.21 +	/**
    2.22  	 * Checks whether the supplied datatype is actually a SemiLinearPointSet literal.
    2.23  	 * 
    2.24  	 * @param datatype
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/NQuadsTranslator.java	Tue Oct 23 20:07:07 2012 +0300
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/NQuadsTranslator.java	Wed Oct 24 11:42:23 2012 +0300
     3.3 @@ -11,8 +11,8 @@
     3.4  import org.openrdf.rio.RDFParseException;
     3.5  import org.openrdf.rio.helpers.StatementCollector;
     3.6  
     3.7 -import net.fortytwo.sesametools.nquads.NQuadsParser;
     3.8 -import net.fortytwo.sesametools.nquads.NQuadsFormat;
     3.9 +//import net.fortytwo.sesametools.nquads.NQuadsParser;
    3.10 +//import net.fortytwo.sesametools.nquads.NQuadsFormat;
    3.11  
    3.12  public class NQuadsTranslator {
    3.13  	
     4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/QuadRDFHandler.java	Tue Oct 23 20:07:07 2012 +0300
     4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/QuadRDFHandler.java	Wed Oct 24 11:42:23 2012 +0300
     4.3 @@ -36,9 +36,19 @@
     4.4  	            //super.handleStatement(st);
     4.5  	            if(st.getContext().toString().contains("^^<http://strdf.di.uoa.gr/ontology#validTime>"))
     4.6  	         	{	System.out.println("THIS IS A VALID TIME LITERAL");
     4.7 -	         		String validTimeLiteral = st.getContext().toString();
     4.8 -						String triple = st.getContext().toString() + " <http://strdf.di.uoa.gr/ontology#hasValidTime> "+ st.getContext().toString()+ " .\n" ;
     4.9 +	         	    NQuadsParser parser = new NQuadsParser();
    4.10 +	         		try {
    4.11 +					 Resource graph = parser.createValidTimeURI(st.getContext().toString());
    4.12 +					 String triple = graph.toString() + " <http://strdf.di.uoa.gr/ontology#hasValidTime> "+ st.getContext().toString()+ " .\n" ;
    4.13  					    triples.append(triple);
    4.14 +					} catch (RDFParseException e) {
    4.15 +						// TODO Auto-generated catch block
    4.16 +						e.printStackTrace();
    4.17 +					} catch (ParseException e) {
    4.18 +						// TODO Auto-generated catch block
    4.19 +						e.printStackTrace();
    4.20 +					}
    4.21 +	
    4.22  	         	}
    4.23  	            super.handleStatement(st);
    4.24  	        }
     5.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Tue Oct 23 20:07:07 2012 +0300
     5.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Wed Oct 24 11:42:23 2012 +0300
     5.3 @@ -378,7 +378,7 @@
     5.4  			NQuadsTranslator translator = new NQuadsTranslator();
     5.5  		//	 final ByteArrayInputStream bais = new ByteArrayInputStream(i);
     5.6  			 final ByteArrayInputStream bais = new ByteArrayInputStream(
     5.7 -			            "<http://www.v/dat/4b> <http://www.w3.org/20/ica#dtend> <http://sin/value/2> \"lala\" ."
     5.8 +			            "<http://www.v/dat/4b> <http://www.w3.org/20/ica#dtend> <http://sin/value/2> \"[2005-01-01 00:00:00+01,2006-01-01 00:00:00+01]\"^^<http://strdf.di.uoa.gr/ontology#validTime> ."
     5.9  			            .getBytes()
    5.10  			        );
    5.11  			Collection<Statement> statements = translator.translate(bais, baseURI);
    5.12 @@ -389,8 +389,9 @@
    5.13  				con1.add(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext());
    5.14  				System.out.println("STATEMENT: "+st.toString());
    5.15  				System.out.println("CONTEXT: "+st.getContext().toString());
    5.16 -				return; //there is no point continuing in this method. Or maybe there is for geosparql reasoning
    5.17  			}
    5.18 +			StringReader quadGraphReader = new StringReader(translator.getHandledTriples().toString());
    5.19 +			con1.add(quadGraphReader, "", RDFFormat.NTRIPLES);
    5.20  			return;
    5.21  		}
    5.22