001 /** 002 * OntoBride library 003 * Departamento de Ingeniería del Software e Inteligencia Artificial 004 * Universidad Complutense de Madrid 005 * 006 * Licensed under the terms of the GNU Library or Lesser General Public License (LGPL) 007 * 008 * @author Juan A. Recio García 009 * 010 * This software is a subproject of the jCOLIBRI framework 011 * http://sourceforge.net/projects/jcolibri-cbr/ 012 * http://gaia.fdi.ucm.es/projects/jcolibri/ 013 * 014 * File: Test5.java 015 * 26/02/2007 016 */ 017 package es.ucm.fdi.gaia.ontobridge.test; 018 019 import java.util.ArrayList; 020 import java.util.Iterator; 021 022 import es.ucm.fdi.gaia.ontobridge.OntoBridge; 023 import es.ucm.fdi.gaia.ontobridge.OntologyDocument; 024 import es.ucm.fdi.gaia.ontobridge.test.gui.PnlInstancesTree; 025 026 /** 027 * File used for testing the library using the GAIA photos ontology. 028 * Shows a graphical representation of an instance. 029 * 030 * @author Juan A. Recio Garcia 031 */ 032 public class Test5 { 033 034 public static void main(String args[]) 035 { 036 OntoBridge ob = new OntoBridge(); 037 ob.initWithPelletReasoner(); 038 039 OntologyDocument mainOnto = new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/fotos.owl","file:test/fotos.owl"); 040 ArrayList<OntologyDocument> subOntologies = new ArrayList<OntologyDocument>(); 041 042 ob.loadOntology(mainOnto, subOntologies, false); 043 ob.createClass("Vacaciones"); 044 ob.setSubClass("Vacaciones", "Foto"); 045 ob.createInstance("Vacaciones", "fotov1"); 046 ob.createOntProperty("fotov1", "aparecePersona", "Ana"); 047 ob.createDataTypeProperty("fotov1", "urlfoto", "file://c:/fotosvacaciones/fotov1.jpg"); 048 ob.createDataTypeProperty("fotov1", "fecha", "2007-02-25", "http://www.w3.org/2001/XMLSchema#date"); 049 050 Iterator<String> fotos = ob.listInstances("Foto"); 051 while(fotos.hasNext()) 052 { 053 String instance = fotos.next(); 054 System.out.println(instance); 055 ArrayList<String> properties = new ArrayList<String>(); 056 ArrayList<String> values = new ArrayList<String>(); 057 ob.listInstancePropertiesValues(instance, properties, values); 058 for(int i=0; i<properties.size(); i++) 059 System.out.println(properties.get(i)+" --> "+ values.get(i)); 060 } 061 062 063 javax.swing.JFrame window = new javax.swing.JFrame(mainOnto.getURL() + "#Foto_1"); 064 PnlInstancesTree tree = new PnlInstancesTree(ob, "Foto_1"); 065 window.getContentPane().add(tree); 066 window.pack(); 067 window.setSize(600, 600); 068 window.setVisible(true); 069 070 //ob.save("newonto.owl"); 071 } 072 }