helaba
Messages postés12Date d'inscriptionvendredi 10 décembre 2010StatutMembreDernière intervention 6 septembre 2013
-
23 mai 2012 à 13:00
NINA1989 -
23 août 2012 à 19:42
je voulais récupérer les instances de ma ontologie. voici le code:
class menu {
public static final String owlFile="file:///C:/Program Files/Protege_3.4.7/examples/Krs1.owl";
public static final String NL = System.getProperty("line.separator") ;
private JLabel label = new JLabel("Une ComboBox");
// Creation d'un modele d'ontologie pour une ontologie OWL-DL avec un resonneur RDFS
// Model m = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RDFS_INF);
Model m=ModelFactory.createMemModelMaker().createModel(null);
// Lecture du fichier OWL. Le Namespace de notre ontologie doit etre specifié
FileManager.get().readModel( m, owlFile );
// Construction de la requete
// String queryString = myOntologyPrefix + NL
// + had + NL
String queryString=
"PREFIX reuses: <http://www.owl-ontologies.com/reuses.owl#>"
+ "SELECT ?hasnamebesoin"
+ " WHERE "
+ "{"
+ "?Besoin reuses:hasnamebesoin ?hasnamebesoin."
+ " } ";
Query query = QueryFactory.create(queryString) ;
// // Affichage de la requete sur la sortie standard.
//query.serialize(new IndentedWriter(System.out,true)) ;
//System.out.println() ;
// Create a single execution of this query, apply to a model
// which is wrapped up as a Dataset
QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
// Execution de la requete
try {
// Pour l'instant nous nous limitons a des requetes de type SELECT
ResultSet rs = qexec.execSelect() ;
// Affichage des resultats
for ( ; rs.hasNext() ; ){
//System.out.print("");
JFrame frame = new JFrame("choix");
frame.setSize(600,600);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(SwingUtilities.getRoot(frame));
JDesktopPane desktop = new JDesktopPane();
QuerySolution rb = rs.nextSolution() ;
String y = rb.getLiteral("hasnamebesoin").getString();
//frame.addItem(rs.getString(y.toString()));
//System.out.print
frame.setLayout(new FlowLayout ());
Choice c = new Choice();
c.addItem(y.toString() + ";\n");
frame.add(c);
frame.show();
frame.pack();
}
}
finally{
qexec.close() ;
}
} }
ça marché mais le problème réside dont la génération de plusieurs fenêtres.
aidez moi SVP