From a84dce4905e83c5470d505c600381c229a732613 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Sun, 24 Mar 2013 17:17:45 +0000
Subject: [PATCH] - revised Tutorial 4 with new IDDL interface (and other
 things)

---
 html/tutorial/tutorial4/MyApp.java | 41 ++++++++++--------------------
 html/tutorial/tutorial4/index.html | 33 ++++++++++++------------
 2 files changed, 30 insertions(+), 44 deletions(-)

diff --git a/html/tutorial/tutorial4/MyApp.java b/html/tutorial/tutorial4/MyApp.java
index d1d11913..86122233 100644
--- a/html/tutorial/tutorial4/MyApp.java
+++ b/html/tutorial/tutorial4/MyApp.java
@@ -65,6 +65,7 @@ import org.semanticweb.HermiT.Reasoner;
 
 // IDDL
 import fr.paris8.iut.info.iddl.IDDLReasoner;
+import fr.paris8.iut.info.iddl.IDDLException;
 import fr.paris8.iut.info.iddl.conf.Semantics;
 
 // SAX standard classes
@@ -90,6 +91,7 @@ import javax.xml.xpath.XPathConstants;
 
 // Java standard classes
 import java.util.Set;
+import java.util.ArrayList;
 import java.util.Properties;
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -120,10 +122,14 @@ public class MyApp {
     String RESTServ = "http://aserv.inrialpes.fr/rest/";
 
     public static void main( String[] args ) {
-	new MyApp().run( args );
+	try {
+	    new MyApp().run( args );
+	} catch ( Exception ex ) {
+	    ex.printStackTrace();
+	}
     }
 
-    public void run( String[] args ) {
+    public void run( String[] args ) throws IDDLException {
 	String myId = "Test";
 	Alignment al = null;
 	URI uri1 = null;
@@ -303,20 +309,17 @@ public class MyApp {
 	OWLClass person = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#Person" ) );   
 	OWLClass student = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#Student" ) );   
 	Set<OWLNamedIndividual> instances  = reasoner.getInstances( estud, false ).getFlattened();
-	System.err.println("OWLReasoner(Merged): There are "+instances.size()+" students "+clname(estud));
+	System.err.println("OWLReasoner(Merged): There are "+instances.size()+" students ("+clname(estud)+")");
 
 	testOWLReasonerSubClass( manager, reasoner, estud, person );
 	testOWLReasonerSubClass( manager, reasoner, estud, student );
 
 	// (Sol3) reasoning with distributed semantics (IDDL)
 	// test consistency of aligned ontologies
-	IDDLReasoner dreasoner = new IDDLReasoner( Semantics.DL );
-	dreasoner.addOntology( uri1 );
-	dreasoner.addOntology( uri2 );
-	// Apparently, here, it has correctly loaded ontologies
-	dreasoner.addAlignment( al );
-	// Apparently, here, it bugs (print and error instead of raising it)
-	// becasu it cannot find stuff related by URIs (same below)
+	ArrayList<Alignment> allist = new ArrayList<Alignment>();
+	allist.add( al );
+	IDDLReasoner dreasoner = new IDDLReasoner( allist, Semantics.DL );
+	// Try Semantics.IDDL instead!
 	if ( dreasoner.isConsistent() ) {
 	    System.out.println( "IDDL: the alignment network is consistent");
 	    testIDDLSubClass( dreasoner, uri1, uri2, estud, person );
@@ -324,22 +327,6 @@ public class MyApp {
          } else {
 	    System.out.println( "IDDL: the alignment network is inconsistent");
 	}
-
-	/* ORIGINAL IDDL... IDEAL
-	// (Sol3) reasoning with distributed semantics (IDDL)
-	// test consistency of aligned ontologies
-	IDDLReasoner dreasoner = new IDDLReasoner( Semantics.DL );
-	dreasoner.addOntology( uri1 );
-	dreasoner.addOntology( uri2 );
-	dreasoner.addAlignment( al );
-	if ( dreasoner.isConsistent() ) {
-	    System.out.println( "IDDL: the alignment network is consistent");
-	    testIDDLSubClass( dreasoner, uri1, uri2, estud, person );
-	    testIDDLSubClass( dreasoner, uri1, uri2, estud, student );
-         } else {
-	    System.out.println( "IDDL: the alignment network is inconsistent");
-	    }
-	*/
     }
 
     private String clname( OWLClassExpression cl ) {
@@ -355,7 +342,7 @@ public class MyApp {
 	}
     }
 
-    public void testIDDLSubClass( IDDLReasoner dreasoner, URI onto1, URI onto2, OWLClassExpression d1, OWLClassExpression d2 ) {
+    public void testIDDLSubClass( IDDLReasoner dreasoner, URI onto1, URI onto2, OWLClassExpression d1, OWLClassExpression d2 ) throws IDDLException {
 	Alignment al2 = new ObjectAlignment();
 	try {
 	    al2.init( onto1, onto2 );
diff --git a/html/tutorial/tutorial4/index.html b/html/tutorial/tutorial4/index.html
index 14e46c29..ad813bcc 100644
--- a/html/tutorial/tutorial4/index.html
+++ b/html/tutorial/tutorial4/index.html
@@ -96,7 +96,7 @@ how this could be achieved.
 <p>For that purpose, you have to develop a program in Java. 
 We first define the CLASSPATH because a lot of external software is required
 <div class="terminal">
-$ setenv CLASSPATH ../../../lib/align.jar:../../../lib/procalign.jar:../../../lib/jena/jena.jar:../../../lib/jena/arq.jar:../../../lib/iddl/iddl.jar:../../../lib/hermit/HermiT.jar:../../../lib/ontosim/ontosim.jar:../../../lib/log4j/commons-logging.jar:../../../lib/log4j/log4j.jar:../../../lib/xerces/xercesImpl.jar:../../../lib/jena/iri.jar:../../../lib/jena/icu4j_3_4.jar:../../../lib/jena/concurrent.jar:../../../lib/xsdlib/relaxngDatatype.jar:../../../lib/xsdlib/xsdlib.jar:results
+$ setenv CLASSPATH ../../../lib/align.jar:../../../lib/procalign.jar:../../../lib/jena/jena.jar:../../../lib/jena/arq.jar:../../../lib/iddl/iddl.jar:../../../lib/hermit/hermit.jar:../../../lib/ontosim/ontosim.jar:../../../lib/log4j/commons-logging.jar:../../../lib/log4j/log4j.jar:../../../lib/xerces/xercesImpl.jar:../../../lib/jena/iri.jar:../../../lib/jena/icu4j_3_4.jar:../../../lib/jena/concurrent.jar:../../../lib/xsdlib/relaxngDatatype.jar:../../../lib/xsdlib/xsdlib.jar:results
 </div>
 The list of jars is long, but at least it is explicit and you
 should be safe with this one.
@@ -131,9 +131,9 @@ and, if none is found, computes one.
 </p>
 <div class="button">
   <input type="button" onclick="show('qu0')" value="Various variables"/>
-  <input type="button" onclick="show('qu1')" value="Show solution 1"/>
-  <input type="button" onclick="show('qu2')" value="Show solution 2"/>
-  <input type="button" onclick="show('qu3')" value="Show solution 3"/>
+  <input type="button" onclick="show('qu1')" value="Show server searching"/>
+  <input type="button" onclick="show('qu2')" value="Show local matching"/>
+  <input type="button" onclick="show('qu3')" value="Show server matching"/>
   <input type="button" onclick="hide('qu0');hide('qu1');hide('qu2');hide('qu3');" value="Hide solutions"/>
 </div>
 <div class="explain" id="qu0">
@@ -204,7 +204,7 @@ if ( alset.getLength() == 0 ) {
   the alignment server.</p>
 </div>
 <div class="button">
-  <input type="button" onclick="show('qu4')" value="Show solution"/>
+  <input type="button" onclick="show('qu4')" value="Show how to store on server"/>
   <input type="button" onclick="hide('qu4');" value="Hide solution"/>
 </div>
 <div class="explain" id="qu4"><p>Not ready yet (but not difficult)</p>
@@ -212,7 +212,7 @@ if ( alset.getLength() == 0 ) {
 </pre>
 </div>
 
-<h2>Manipulate the data</h2>
+<h2>Manipulating data</h2>
 
 <p>
 Again, this is either:
@@ -226,7 +226,7 @@ This can be done with the alignment API support.
 </p>
 
 <div class="button">
-  <input type="button" onclick="show('qu5')" value="Show solution 1"/>
+  <input type="button" onclick="show('qu5')" value="Show generating OWL"/>
   <!--input type="button" onclick="show('qu6')" value="Show solution 2"/-->
   <input type="button" onclick="hide('qu5');hide('qu6');" value="Hide solutions"/>
 </div>
@@ -249,7 +249,7 @@ writer.close();
 </pre>
 </div>
 
-<h2>Generate the answers</h2>
+<h2>Generating answers</h2>
 
 <p>
 This can be done in three ways:
@@ -269,9 +269,9 @@ ontologies instead of the merged one.
 </p>
 </p>
 <div class="button">
-  <input type="button" onclick="show('qu7')" value="Show solution 1"/>
-  <input type="button" onclick="show('qu8')" value="Show solution 2"/>
-  <!--input type="button" onclick="show('qu9')" value="Show solution 3"/-->
+  <input type="button" onclick="show('qu7')" value="Show SPARQL solution"/>
+  <input type="button" onclick="show('qu8')" value="Show HermiT solution"/>
+  <input type="button" onclick="show('qu9')" value="Show IDDL solution"/>
   <input type="button" onclick="hide('qu7');hide('qu8');hide('qu9');" value="Hide solutions"/>
 </div>
 <div class="explain" id="qu7">
@@ -327,7 +327,7 @@ OWLClass estud = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://al
 OWLClass person = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#Person" ) );   
 OWLClass student = manager.getOWLDataFactory().getOWLClass( IRI.create( "http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#Student" ) );   
 Set&lt;OWLNamedIndividual> instances  = reasoner.getInstances( estud, false ).getFlattened();
-System.err.println("OWLReasoner(Merged): There are "+instances.size()+" students "+clname(estud));
+System.err.println("OWLReasoner(Merged): There are "+instances.size()+" students ("+clname(estud)+")");
 </div>
 <p>Some subsumption tests:</p>
 <div class="java">
@@ -353,10 +353,9 @@ public void testOWLReasonerSubClass( OWLOntologyManager manager, OWLReasoner rea
 <div class="explain" id="qu9">
 <p>Load the two ontologies and the alignment in the IDDL reasoner:</p>
 <div class="java">
-	IDDLReasoner dreasoner = new IDDLReasoner( Semantics.DL );
-	dreasoner.addOntology( uri1 );
-	dreasoner.addOntology( uri2 );
-	dreasoner.addAlignment( al );
+	ArrayList<Alignment> allist = new ArrayList<Alignment>();
+	allist.add( al );
+	IDDLReasoner dreasoner = new IDDLReasoner( allist, Semantics.DL );
 </div>
 <p>Test consistency and check if a particular correspondence is a consequence:</p>
 <div class="java">
@@ -397,7 +396,7 @@ The results for these execution are, for SPARQL:
 </pre>
 for OWLReasoner:
 <pre>
-OWLReasoner(Merged): There are 47 students http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#Estudiante
+OWLReasoner(Merged): There are 47 students (Estudiante)
 OWLReasoner(Merged): Estudiante is not necessarily subclass of Person
 OWLReasoner(Merged): Estudiante is subclass of Student
 </pre>
-- 
GitLab