Monday, October 15, 2012

load OWL file model in virtuoso

If you try save a model from OWL file in Virtuoso with class

VirtuosoUpdateFactory  or VirtuosoQueryExecutionFactory this fail.

http://answers.semanticweb.com/questions/10520/virtrdfinsert-examples
http://answers.semanticweb.com/questions/12513/graph-in-virtuoso

To load in virtuoso used VirtDataSource

    VirtDataSource vd = new VirtDataSource("jdbc:virtuoso://localhost:1111", "dba", "dba");

        ModelMaker maker = ModelFactory.createMemModelMaker();   
        Model m = maker.createModel(BASE, false);
               
        //load owl file in model M
        FileInputStream  fis = new FileInputStream (getClass().getClassLoader().getResource("file.owl").getFile());
        m.read(fis ,null);
        fis.close();

       
        //TODO: if exist BASE in virtuoso FAIL
        //to erase datas conductor SQL> RDF_GLOBAL_RESET ();
        Model m2 =vd.getNamedModel(BASE);
        if(m2 == null)
            vd.addNamedModel(BASE, m);

No comments:

Post a Comment