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: Test1.java
015     * 22/11/2006
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    
025    /**
026     * File used for testing the library using the GAIA restaurants ontology.
027     * http://gaia.fdi.ucm.es/ontologies/
028     * 
029     * @author Juan A. Recio Garcia
030     */
031    public class Test1 {
032    
033            public static void main(String args[]) 
034            {
035                    OntoBridge ob = new OntoBridge();
036                    ob.initWithPelletReasoner();
037                    
038                    OntologyDocument mainOnto = new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/restaurant.owl","file:test/restaurant.owl");
039                    
040                    ArrayList<OntologyDocument> subOntologies = new ArrayList<OntologyDocument>();
041                    subOntologies.add(new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/calendar.owl","file:test/calendar.owl"));
042                    subOntologies.add(new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/price.owl","file:test/price.owl"));
043                    subOntologies.add(new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/address.owl","file:test/address.owl"));
044                    subOntologies.add(new OntologyDocument("http://gaia.fdi.ucm.es/ontologies/contact-details.owl","file:test/contact-details.owl"));
045                    
046                    ob.loadOntology(mainOnto, subOntologies, false);
047                    
048                    System.out.println("\nALL CLASSES (no anonymous)");
049                    for(Iterator<String> iter = ob.listAllClasses(); iter.hasNext();)
050                            System.out.println(iter.next());
051                    
052                    System.out.println("\nHIERARCHY ROOT CLASSES (no anonymous)");
053                    for(Iterator<String> iter = ob.listRootClasses(); iter.hasNext();)
054                            System.out.println(iter.next());
055                    
056                    System.out.println("\nDIRECT SUBCLASSES OF http://gaia.fdi.ucm.es/ontologies/restaurant.owl#Facility");
057                    for(Iterator<String> iter = ob.listSubClasses("http://gaia.fdi.ucm.es/ontologies/restaurant.owl#Facility", true); iter.hasNext();)
058                            System.out.println(iter.next());
059                    
060                    System.out.println("\nDIRECT AND INDIRECT SUBCLASSES OF http://gaia.fdi.ucm.es/ontologies/restaurant.owl#Facility");
061                    for(Iterator<String> iter = ob.listSubClasses("http://gaia.fdi.ucm.es/ontologies/restaurant.owl#Facility", false); iter.hasNext();)
062                            System.out.println(iter.next());
063                    
064                    System.out.println("\nDIRECT SUPERCLASSES OF http://gaia.fdi.ucm.es/ontologies/restaurant.owl#ChildrenMeal");
065                    for(Iterator<String> iter = ob.listSuperClasses("http://gaia.fdi.ucm.es/ontologies/restaurant.owl#ChildrenMeal", true); iter.hasNext();)
066                            System.out.println(iter.next());
067                    
068                    System.out.println("\nDIRECT AND INDIRECT SUBCLASSES OF http://gaia.fdi.ucm.es/ontologies/restaurant.owl#ChildrenMeal");
069                    for(Iterator<String> iter = ob.listSuperClasses("ChildrenMeal", false); iter.hasNext();)
070                            System.out.println(iter.next());
071                    
072                    System.out.println("\nIs Children Meal subclass of Facility?");
073                    System.out.println(ob.isSubClassOf("ChildrenMeal", "Facility"));
074                    
075                    System.out.println("\nIs Restaurant_2 instance of Facility?");
076                    System.out.println(ob.isInstanceOf("Restaurant_2", "Facility"));
077                    
078                    System.out.println("\nProperties applicable to Restaurant");
079                    for(Iterator<String> iter = ob.listProperties("Restaurant"); iter.hasNext();)
080                            System.out.println(iter.next());
081                    
082                    System.out.println("\nSpecific properties for Restaurant (they have Restaurant as domain)");
083                    for(Iterator<String> iter = ob.listSpecificProperties("Restaurant"); iter.hasNext();)
084                            System.out.println(iter.next());
085                    
086                    System.out.println("\nRANGE OF openingPeriods");
087                    for(Iterator<String> iter = ob.listPropertyRange("openingPeriods"); iter.hasNext();)
088                            System.out.println(iter.next());
089                    
090                    System.out.println("\nINSTANCES OF Restaurant");
091                    for(Iterator<String> iter = ob.listInstances("Restaurant"); iter.hasNext();)
092                            System.out.println(iter.next());
093                    
094                    System.out.println("\nVALUE OF Restaurant_1 --> openingPeriods");
095                    for(Iterator<String> iter = ob.listPropertyValue("Restaurant_1", "openingPeriods"); iter.hasNext();)
096                            System.out.println(iter.next());
097                    
098                    System.out.println("\nIs valid?");
099                    System.out.println(ob.isValid(false));
100                    
101                    System.out.println("\nValidation messages");
102                    for(Iterator<String> iter = ob.validate(); iter.hasNext();)
103                            System.out.println(iter.next());
104                    
105                    System.out.println("\nWhiteWine declared belonging clases");
106                    for(Iterator<String> iter = ob.listBelongingClasses("WhiteWine"); iter.hasNext();)
107                            System.out.println(iter.next());
108    
109                    System.out.println("\nWhiteWine direct (not inferred) declared belonging clases");
110                    for(Iterator<String> iter = ob.listDeclaredBelongingClasses("WhiteWine"); iter.hasNext();)
111                            System.out.println(iter.next());
112    
113            }
114    }