Strabon

changeset 1304:96d5038efff4 temporals

Fixed a bug in storing from endpoint.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Wed Dec 11 17:18:40 2013 +0200 (2013-12-11)
parents b3766e94a88d
children edc19e1061da
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Tue Dec 03 14:49:20 2013 +0200
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Wed Dec 11 17:18:40 2013 +0200
     1.3 @@ -356,66 +356,19 @@
     1.4  			throw new RepositoryException("Could not connect to Strabon.");
     1.5  		}
     1.6  
     1.7 -		SailRepositoryConnection conn = strabon.getSailRepoConnection();
     1.8 -
     1.9 -			URL source=null;
    1.10  		if (url) {
    1.11 -				source = new URL(src);
    1.12 +			URL source = new URL(src);
    1.13  			if (source.getProtocol().equalsIgnoreCase(FILE_PROTOCOL)) {
    1.14  				// it would be a security issue if we read from the server's filesystem
    1.15  				throw new IllegalArgumentException("The protocol of the URL should be one of http or ftp.");
    1.16  			}
    1.17 -				
    1.18 -			if(!format.equals(RDFFormat.NQUADS.toString()))
    1.19 -			{
    1.20 -				if (url) {				
    1.21 -					conn.add(source, "", RDFFormat.NQUADS, new Resource[1]);
    1.22 -	
    1.23 -				} else {
    1.24 -					conn.add(new StringReader(src), "", RDFFormat.NQUADS, new Resource[1]);
    1.25 -				}			
    1.26 -			}
    1.27 -			else
    1.28 -			{
    1.29 -				InputStream in=null;
    1.30 -				if (url) {				
    1.31 -					in= source.openStream();
    1.32 -				} else {
    1.33 -					in= new ByteArrayInputStream(src.getBytes());
    1.34 -				}
    1.35 -				//ByteArrayInputStream in = new ByteArrayInputStream();
    1.36 -				NQuadsTranslator translator = new NQuadsTranslator(conn);
    1.37 -							 
    1.38 -				Collection<Statement> statements = translator.translate(in, "");
    1.39 -				for(Statement st: statements)
    1.40 -				{
    1.41 -					String cont = st.getContext().toString();
    1.42 -					 String validPeriod= cont;
    1.43 -					 if(!cont.contains(","))
    1.44 -					 {
    1.45 -						 int i = cont.indexOf('"')+1;
    1.46 -						 int j = cont.lastIndexOf('"');
    1.47 -						 validPeriod = "\"[" + cont.substring(i,j) + "," + cont.substring(i,j) + "]\"^^<"+TemporalConstants.PERIOD; 
    1.48 -						 //validPeriod = cont.replace("]",","+cont.substring(i, j)+"]");		 
    1.49 -					 }
    1.50 -					 
    1.51 -					try {
    1.52 -						Resource newContext = new NQuadsParser().createValidTimeURI(validPeriod);
    1.53 -						conn.add(st.getSubject(), st.getPredicate(), st.getObject(), newContext);
    1.54 -					} catch (ParseException e) {
    1.55 -						logger.error(this.getClass().toString()+": error when constructing the new context");
    1.56 -						e.printStackTrace();
    1.57 -					}
    1.58 -		
    1.59 -				}
    1.60  		}
    1.61  
    1.62  		strabon.storeInRepo(src, null, context, format, inference);
    1.63  		
    1.64  		logger.info("[StrabonEndpoint] STORE was successful.");
    1.65 -		}
    1.66 +		
    1.67  		return true;
    1.68 -	
    1.69  	}
    1.70  	
    1.71  
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Tue Dec 03 14:49:20 2013 +0200
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Wed Dec 11 17:18:40 2013 +0200
     2.3 @@ -475,7 +475,7 @@
     2.4  		} else if(format.equalsIgnoreCase("TURTLE") || format.equals(RDFFormat.TURTLE.getName())) {
     2.5  			realFormat =  RDFFormat.TURTLE;
     2.6  			
     2.7 -		}else if(format.equalsIgnoreCase("NQUADS")) {
     2.8 +		}else if(format.equalsIgnoreCase("NQUADS") || format.equals(RDFFormat.NQUADS.getName())) {
     2.9  			realFormat =  RDFFormat.NQUADS;
    2.10  		} 
    2.11  		else {