load owl file java code using jena api -


i have code in package oopn.ontology

public class ontology {  private static ontology ontology = new ontology(); public static ontmodel ontologymodel; //this main of ontology model public static file ontologyfile; //this file of owl public static string ontologyfilepath; //this path of owl file public static jtree ontologymodeltree; public static int saveaction; public static string copiedtext; public static jtree tree;  private ontology() { }  public static ontology getinstance() {     return ontology; }  public void resetontology() {     ontologymodel = null;     ontologyfile = null;     ontologyfilepath = null;     ontologymodeltree = null; } 

then code create ontology model:

public ontmodel createontologymodelfromfile(string owlfile) {     inputstream in;     in = filemanager.get().open(owlfile); ontmodel model1 = modelfactory.createontologymodel(pelletreasonerfactory.the_spec); ontmodel model2 = modelfactory.createontologymodel(ontmodelspec.owl_mem); model1.read(in, ""); ontologymodel = model1;     return model1; } 

to open file have one:

file openontologyfile() {     jfilechooser filechooser;     file chosenfile;     filechooser = new jfilechooser(new file("mpasi.owl"));     filechooser.showopendialog(filechooser);     chosenfile = filechooser.getselectedfile();     if (chosenfile != null) {         //loadontologyfile(chosenfile);     } else {         joptionpane.showmessagedialog(filechooser, this);     }     //enablecontrols(true);     ontology.ontologyfilepath = chosenfile.getabsolutepath();     return chosenfile; } 

in main class one:

public class dss_mpasi extends javax.swing.jframe {  jfilechooser filedialog; public dss_mpasi() {     initcomponents();     if (ontology.ontologyfile != null) {         model tempmodel ;         if (ontology.ontologymodel == null) {             tempmodel = ontology.getinstance().createontologymodelfromfile(ontology.ontologyfilepath);         } else {             tempmodel = ontology.ontologymodel;         }         stringwriter writer = new stringwriter();         tempmodel.write(writer, "rdf/xml");                 }  } 

but still doesnt work... hope 1 can me make work?

consider replacing tempmodel = ontology.getinstance().createontologymodelfromfile(ontology.ontologyfilepath); this:

ontmodel tempmodel = modelfactory.createontologymodel(); filemanager.get().readmodel( tempmodel , ontology.ontologyfilepath); 

you might find selected answer on post useful purposes.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -