Strabon

changeset 1161:1d3afe469324 temporals

fixed bug that is encountered when the fourth element of nquads is not a literal
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Thu May 09 14:46:55 2013 +0300 (2013-05-09)
parents e6f71db0955e
children bae12a2322e4
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	Wed May 08 20:51:29 2013 +0300
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu May 09 14:46:55 2013 +0300
     1.3 @@ -603,6 +603,8 @@
     1.4  						 
     1.5  			Collection<Statement> statements = translator.translate(in, baseURI);
     1.6  			Iterator iterator = statements.iterator();
     1.7 +			Resource newContext = null;
     1.8 +			
     1.9  			for(Statement st: statements)
    1.10  			{
    1.11  				if(st.getContext() == null)
    1.12 @@ -615,19 +617,27 @@
    1.13  				{
    1.14  					String cont = st.getContext().toString();
    1.15  					 String validPeriod= cont;
    1.16 -					 if(!cont.contains(","))
    1.17 +					 if(!cont.contains("\"")) //the fourth element is not a literal
    1.18  					 {
    1.19 -						 int i = cont.indexOf('"')+1;
    1.20 -						 int j = cont.lastIndexOf('"');
    1.21 -						 validPeriod = "\"[" + cont.substring(i,j) + "," + cont.substring(i,j) + "]\"^^<"+TemporalConstants.PERIOD; 				 
    1.22 -					 }	 
    1.23 -					try {
    1.24 -						Resource newContext = new NQuadsParser().createValidTimeURI(validPeriod);
    1.25 -						con.add(st.getSubject(), st.getPredicate(), st.getObject(), newContext);
    1.26 -					} catch (ParseException e) {
    1.27 -						logger.error(this.getClass().toString()+": error when constructing the new context");
    1.28 -						e.printStackTrace();
    1.29 -					}
    1.30 +						 newContext = st.getContext();
    1.31 +					 }
    1.32 +					 else
    1.33 +					 {
    1.34 +						 if(!cont.contains(","))
    1.35 +						 {
    1.36 +							 int i = cont.indexOf('"')+1;
    1.37 +							 int j = cont.lastIndexOf('"');
    1.38 +							 validPeriod = "\"[" + cont.substring(i,j) + "," + cont.substring(i,j) + "]\"^^<"+TemporalConstants.PERIOD; 				 
    1.39 +						 }	 
    1.40 +						try {
    1.41 +							 newContext = new NQuadsParser().createValidTimeURI(validPeriod);
    1.42 +						} catch (ParseException e) {
    1.43 +							logger.error(this.getClass().toString()+": error when constructing the new context");
    1.44 +							e.printStackTrace();
    1.45 +						}
    1.46 +					 }
    1.47 +						
    1.48 +					 con.add(st.getSubject(), st.getPredicate(), st.getObject(), newContext);
    1.49  		
    1.50  				}
    1.51  			}