package ons.solubility.rdf;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;

public class ConvertToRDF {
    
    private Model model;
    private int measurementsProcessed;
    
    public ConvertToRDF() {
        model = ModelFactory.createDefaultModel();
        measurementsProcessed = 0;
    }

    public void processStream(InputStream stream) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
        String header = reader.readLine();
        String line = reader.readLine();
        while (line != null) {
            createResource(line);
            line = reader.readLine();
        }
    }
    
    private void createResource(String line) {
        // create the resource
        String[] field = line.split(",");
        String url = ONS.NS;
        Resource measurement = model.createResource(url + measurementsProcessed);
        // FIXME: how can I set the rdf:type??
        measurement.addProperty(RDF.type, ONS.Measurement);
        measurement.addProperty(ONS.experiment, field[2]);
        measurementsProcessed++;
    }

    public void write() {
        model.write(System.out);
    }

    public static void main( String[] args ) throws Exception {
        ConvertToRDF convertor = new ConvertToRDF();
        InputStream stream = ConvertToRDF.class.getResourceAsStream("/data.csv");
        convertor.processStream(stream);
        convertor.write();
    }

}

@@ -288,48 +288,8 @@
 RDF;
-%0Aimport com.hp.hpl.jena.vocabulary.RDFS;
 %0A%0Apu
@@ -665,24 +665,26 @@
 ));%0A        
+/*
 String heade
@@ -687,16 +687,18 @@
 eader = 
+*/
 reader.r
@@ -1259,16 +1259,37 @@
 riment, 
+model.createResource(
 field%5B2%5D
@@ -1289,16 +1289,17 @@
 ield%5B2%5D)
+)
 ;%0A      
@@ -1376,26 +1376,177 @@
 del.
-write(System.out);
+setNsPrefix(%22ons%22, ONS.NS);%0A        try %7B%0A            model.write(System.out);%0A        %7D catch (Exception exception) %7B%0A            exception.printStackTrace();%0A        %7D
 %0A   

Use a 'ons' prefix; make experiments resources