diff --git a/build.xml b/build.xml index 10ed0390e42759abf687252cd96d990f2156e07f..0f2c0b409112c29923febf8ba86d694d657dc50f 100644 --- a/build.xml +++ b/build.xml @@ -11,6 +11,7 @@ <echo message="init: sets necessary variables"/> <echo message="compile: incrementaly compiles sources"/> <echo message="compileall: recompiles all sources"/> + <echo message="lint: compiles all sources with bug flags on"/> <echo message="jar: archives compiled code"/> <echo message="test: performs unit tests [nyi]"/> <echo message="zip: creates a new zip file"/> @@ -104,6 +105,7 @@ </manifest> <fileset dir="classes" includes="org/ivml/**/*.class"/> <fileset dir="classes" includes="fr/inrialpes/exmo/align/util/**/*.class"/> + <fileset dir="classes" includes="fr/inrialpes/exmo/align/onto/**/*.class"/> <fileset dir="classes" includes="fr/inrialpes/exmo/align/parser/**/*.class"/> <fileset dir="classes" includes="fr/inrialpes/exmo/align/impl/**/*.class"/> <fileset dir="classes" includes="LICENSE.TXT"/> diff --git a/html/relnotes.html b/html/relnotes.html index 4942418bb8a98397e1e6fca62ea41a2a0e5d29f8..59134f5c21e65bc7e3d9628dda63ead1183fb5e8 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -22,6 +22,7 @@ <li>Restructuring language dependent alignments (impl)</li> <li>Implementing database store for OMWG Language (server)</li> <li>Replacing <tt>Parameters</tt> with Java <tt>Property</tt> (api/impl)</li> +<li>Implement debug options with log4j</li> <li>Use more for-each Java 1.5 construct</li> </ul></p> @@ -30,6 +31,7 @@ <!--h2>Version 3.3 (): xx/yy/2008 - O sole mio</h2--> <p><ul compact="1"> +<li>Added an abstract ontology interface (impl)</li> <li>Passed to Java 1.5 generics [incl. API modif] (dev/api)</li> <li>Passed all code through lint (dev)</li> </ul></p> diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java index 90738ec7ea39d50ee08c7ddcf027f2b39c7b7546..a51155bb567342a6de7a2e63590ca26f9c8cf359 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java @@ -41,6 +41,9 @@ import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Parameters; +import fr.inrialpes.exmo.align.onto.Ontology; +import fr.inrialpes.exmo.align.onto.BasicOntology; + /** * Represents a basic ontology alignment, i.e., a fully functionnal alignment * for wich the type of aligned objects is not known. @@ -61,8 +64,8 @@ public class BasicAlignment implements Alignment { visitor.visit(this); } - protected Ontology onto1 = null; - protected Ontology onto2 = null; + protected Ontology<Object> onto1 = null; + protected Ontology<Object> onto2 = null; protected int debug = 0; @@ -80,26 +83,21 @@ public class BasicAlignment implements Alignment { protected Parameters namespaces = null; - /** - * This is the URI of the place from which the ontology has been loaded! - * This is NOT the Ontology URI which can be obtained by - * getOntology1URI() - */ - public BasicAlignment() { hash1 = new Hashtable<Object,Set<Cell>>(); hash2 = new Hashtable<Object,Set<Cell>>(); extensions = new BasicParameters(); namespaces = new BasicParameters(); if ( this instanceof AlignmentProcess ) setExtension( Annotations.ALIGNNS, Annotations.METHOD, getClass().getName() ); - onto1 = new Ontology(); - onto2 = new Ontology(); + onto1 = new BasicOntology<Object>(); + onto2 = new BasicOntology<Object>(); } public void init( Object onto1, Object onto2, Object cache ) throws AlignmentException { + // JE: Onto I am not sure this works if ( onto1 instanceof Ontology ) { - this.onto1 = (Ontology)onto1; - this.onto2 = (Ontology)onto2; + this.onto1 = (Ontology<Object>)onto1; + this.onto2 = (Ontology<Object>)onto2; } else { this.onto1.setOntology( onto1 ); this.onto2.setOntology( onto2 ); @@ -139,22 +137,12 @@ public class BasicAlignment implements Alignment { return onto2; }; - public URI getOntology1URI() throws AlignmentException { - Object ontology = onto1.getOntology(); - if ( ontology != null && ontology instanceof URI ) { - return (URI)ontology; - } else { - throw new AlignmentException( "Cannot find URI for "+onto1 ); - } + public URI getOntology1URI() { + return onto1.getURI(); }; - public URI getOntology2URI() throws AlignmentException { - Object ontology = onto2.getOntology(); - if ( ontology != null && ontology instanceof URI ) { - return (URI)ontology; - } else { - throw new AlignmentException( "Cannot find URI for "+onto2 ); - } + public URI getOntology2URI() { + return onto2.getURI(); }; public void setOntology1(Object ontology) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java index c605b49d031f4d4117c0f7dd589a3b7e0c71323d..e2e2a6cb71e4d52c07c2743ac6c89db1469cf249 100644 --- a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java @@ -35,11 +35,6 @@ import org.xml.sax.SAXException; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLEntity; import org.semanticweb.owl.model.OWLException; -import org.semanticweb.owl.util.OWLManager; -import org.semanticweb.owl.util.OWLConnection; -import org.semanticweb.owl.io.owl_rdf.OWLRDFParser; -import org.semanticweb.owl.io.owl_rdf.OWLConsumer; -import org.semanticweb.owl.io.owl_rdf.OWLRDFErrorHandler; import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; @@ -48,6 +43,11 @@ import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Parameters; +import fr.inrialpes.exmo.align.onto.OntologyFactory; +import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.Ontology; +import fr.inrialpes.exmo.align.onto.LoadedOntology; + /** * Represents an OWL ontology alignment. An ontology comprises a number of * collections. Each ontology has a number of classes, properties and @@ -72,34 +72,13 @@ public class OWLAPIAlignment extends BasicAlignment { OntologyCache cache = null; if ( ontologies instanceof OntologyCache ) cache = (OntologyCache)ontologies; else cache = (OntologyCache)null; + // JE: why should this happen now? Never? if ( (o1 instanceof OWLOntology && o2 instanceof OWLOntology) || (o1 instanceof Ontology && o2 instanceof Ontology) ){ super.init( o1, o2, ontologies ); } else if ( o1 instanceof URI && o2 instanceof URI ) { - // The URI is set below - setFile1( (URI)o1 ); - setFile2( (URI)o2 ); - // JE: newOnto --- - ((Ontology)onto1).setFormalism( "OWL1.0" ); - ((Ontology)onto2).setFormalism( "OWL1.0" ); - // JE: newOnto --- - try { - URI u = new URI("http://www.w3.org/2002/07/owl#"); - ((Ontology)onto1).setFormURI( u ); - ((Ontology)onto2).setFormURI( u ); - } catch (Exception e) {}; // does not happen - try { - super.init( loadOntology( (URI)o1, cache ), - loadOntology( (URI)o2, cache ) ); - // Not sure it should be here or in super.init() - onto1.setURI( ((OWLOntology)(onto1.getOntology())).getLogicalURI() ); - onto2.setURI( ((OWLOntology)(onto2.getOntology())).getLogicalURI() ); - } catch (OWLException e) { - throw new AlignmentException( "Cannot load ontologies", e ); - } catch (SAXException e) { - throw new AlignmentException( "Cannot load ontologies", e ); - } - // We should set the URI to that of the ontologies + super.init( loadOntology( (URI)o1, cache ), + loadOntology( (URI)o2, cache ) ); } else { throw new AlignmentException("arguments must be OWLOntology or URI"); }; @@ -119,50 +98,9 @@ public class OWLAPIAlignment extends BasicAlignment { } } - // JE: --- post-3.1 - public URI getOntology1URI() //throws AlignmentException -{ - //try { - // JE: OWMG1 - //return ((OWLOntology)(onto1.getOntology())).getLogicalURI(); - return onto1.getURI(); - //} catch ( OWLException e ) { - //throw new AlignmentException( "URI conversion error for "+onto1, e ); - //} - }; + public URI getOntology1URI() { return onto1.getURI(); }; - // JE: --- post-3.1 - public URI getOntology2URI() //throws AlignmentException - { - //try { - // JE: OWMG1 - //return ((OWLOntology)(onto2.getOntology())).getLogicalURI(); - return onto2.getURI(); - //} catch ( OWLException e ) { - //throw new AlignmentException( "URI conversion error for "+onto2, e ); - //} - }; - - // JE: --- post-3.1 - //public void setOntology1(Object ontology) throws AlignmentException { - //if ( ontology instanceof OWLOntology ){ - //super.setOntology1( ontology ); - //onto1.setOntology( ontology ); - //} else { - //throw new AlignmentException("arguments must be OWLOntology"); - //}; - //}; - - // JE: --- post-3.1 - //public void setOntology2(Object ontology) throws AlignmentException { - // JE: tonewOnto - //if ( ontology instanceof OWLOntology ){ - //super.setOntology2( ontology ); - //onto2.setOntology( ontology ); - //} else { - //throw new AlignmentException("arguments must be OWLOntology"); - //}; - //}; + public URI getOntology2URI() { return onto2.getURI(); }; /** Cell methods **/ public Cell addAlignCell(String id, Object ob1, Object ob2, Relation relation, double measure, Parameters extensions ) throws AlignmentException { @@ -285,9 +223,6 @@ public class OWLAPIAlignment extends BasicAlignment { // Here it becomes necessary to load OWL static public OWLAPIAlignment toOWLAPIAlignment( URIAlignment al, OntologyCache ontologies ) throws AlignmentException, SAXException, OWLException { OWLAPIAlignment alignment = new OWLAPIAlignment(); - //alignment.setFile1( al.getFile1() ); - //alignment.setFile2( al.getFile2() ); - //System.err.println( "TOA: " + al.getFile1()+ " -- " + al.getFile2()); alignment.init( al.getFile1(), al.getFile2(), ontologies ); alignment.setType( al.getType() ); alignment.setLevel( al.getLevel() ); @@ -311,7 +246,14 @@ public class OWLAPIAlignment extends BasicAlignment { return alignment; } - // JE: newOnto --- + private static LoadedOntology loadOntology( URI ref, OntologyCache ontologies ) { + OntologyFactory factory = OntologyFactory.newInstance(); + LoadedOntology onto = factory.loadOntology( ref ); + if ( ontologies != null ) ontologies.recordOntology( ref, onto ); + return onto; + } + + // JE: newOnto --- Onto: should be discarded private static OWLEntity getEntity( OWLOntology ontology, URI uri ) throws OWLException, SAXException { OWLEntity result = (OWLEntity)ontology.getClass( uri ); if ( result == null ) result = (OWLEntity)ontology.getDataProperty( uri ); @@ -320,8 +262,9 @@ public class OWLAPIAlignment extends BasicAlignment { return result; } - // JE: newOnto --- + // JE: newOnto --- Onto: should be discarded /** Can be used for loading the ontology if it is not available **/ + /* //private static OWLOntology loadOntology( URI ref, Hashtable ontologies ) throws SAXException, OWLException { private static OWLOntology loadOntology( URI ref, OntologyCache ontologies ) throws SAXException, OWLException { if ( (ontologies != null) && ( ontologies.getOntology( ref ) != null ) ) { @@ -355,6 +298,6 @@ public class OWLAPIAlignment extends BasicAlignment { return parsedOnt; } } - + */ } diff --git a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java index a7fe1b87c2609dc82860d10eab98085077d48d8d..77f28707ec6800930c44f0b0a589e0c6b36eb930 100644 --- a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java @@ -44,6 +44,8 @@ import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Parameters; +import fr.inrialpes.exmo.align.onto.Ontology; + /** * Represents an ontology alignment relating entities identified by their URIs * @@ -53,8 +55,6 @@ import org.semanticweb.owl.align.Parameters; public class URIAlignment extends BasicAlignment { - public URIAlignment() {} - // JE: OMWG1, not sure it works... public void init(Object o1, Object o2) throws AlignmentException { if ( o1 instanceof Ontology && o2 instanceof Ontology ){ diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java index dba5a84bf9c772182c01d38d25adcdcb308ad247..7ac511a0399cbc9753858fa109d98a6d2ae1616c 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java @@ -60,12 +60,12 @@ public class HTMLRendererVisitor implements AlignmentVisitor writer.print("<h1></h1>\n"); writer.print("<h2>Alignment metadata</h2>\n"); writer.print("<table border=\"0\">\n"); - writer.print("<tr><td>uri1</td><td>"+align.getOntology1URI().toString()+"</td></tr>\n" ); - writer.print("<tr><td>uri2</td><td>"+align.getOntology2URI().toString()+"</td></tr>\n" ); + writer.print("<tr><td>uri1</td><td>"+align.getOntology1URI()+"</td></tr>\n" ); + writer.print("<tr><td>uri2</td><td>"+align.getOntology2URI()+"</td></tr>\n" ); if ( align.getFile1() != null ) - writer.print("<tr><td>ontofile1</td><td><a href=\""+align.getFile1().toString()+"\">"+align.getFile1().toString()+"</a></td></tr>\n" ); + writer.print("<tr><td>ontofile1</td><td><a href=\""+align.getFile1()+"\">"+align.getFile1()+"</a></td></tr>\n" ); if ( align.getFile2() != null ) - writer.print("<tr><td>ontofile2</td><td><a href=\""+align.getFile2().toString()+"\">"+align.getFile2().toString()+"</a></td></tr>\n" ); + writer.print("<tr><td>ontofile2</td><td><a href=\""+align.getFile2()+"\">"+align.getFile2()+"</a></td></tr>\n" ); writer.print("<tr><td>level</td><td>"+align.getLevel()+"</td></tr>\n" ); writer.print("<tr><td>type</td><td>"+align.getType()+"</td></tr>\n" ); // Get the keys of the parameter diff --git a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java index 0640f4982ba9fcc4b6c0058d84032dc5f0fff378..e638a0151876159964215eaff0cc9903c3e5941f 100644 --- a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java +++ b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java @@ -51,7 +51,9 @@ import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.Parameters; -import fr.inrialpes.exmo.align.impl.Ontology; +import fr.inrialpes.exmo.align.onto.Ontology; +import fr.inrialpes.exmo.align.onto.LoadedOntology; +import fr.inrialpes.exmo.align.onto.BasicOntology; import fr.inrialpes.exmo.align.impl.URIAlignment; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.Annotations; @@ -67,8 +69,6 @@ import fr.inrialpes.exmo.align.impl.Annotations; public class AlignmentParser extends DefaultHandler { - private static String ALIGNNS = "http://knowledgeweb.semanticweb.org/heterogeneity/alignment#"; - /** * level of debug/warning information */ @@ -231,7 +231,7 @@ public class AlignmentParser extends DefaultHandler { System.err.println("startElement AlignmentParser : " + pName); parselevel++; if( namespaceURI.equals("http://knowledgeweb.semanticweb.org/heterogeneity/alignment") - || namespaceURI.equals(ALIGNNS) ) { + || namespaceURI.equals(Annotations.ALIGNNS) ) { if (pName.equals("relation")) { } else if (pName.equals("semantics")) { } else if (pName.equals("measure")) { @@ -282,7 +282,8 @@ public class AlignmentParser extends DefaultHandler { } else if (pName.equals("Ontology")) { if ( atts.getValue("rdf:about") != null && !atts.getValue("rdf:about").equals("") ) { try { - curronto.setOntology( new URI( atts.getValue("rdf:about") ) ); + // JE: Onto + //curronto.setOntology( new URI( atts.getValue("rdf:about") ) ); curronto.setURI( new URI( atts.getValue("rdf:about") ) ); } catch (URISyntaxException e) { throw new SAXException("onto2: malformed URI"); @@ -299,8 +300,9 @@ public class AlignmentParser extends DefaultHandler { } else if (pName.equals("xml")) { } else if (pName.equals("Alignment")) { alignment = new URIAlignment(); - onto1 = new Ontology(); - onto2 = new Ontology(); + onto1 = ((URIAlignment)alignment).getOntologyObject1(); + onto2 = ((URIAlignment)alignment).getOntologyObject2(); + System.err.println(">>>>>>> "+onto1); if ( atts.getValue("rdf:about") != null && !atts.getValue("rdf:about").equals("") ) { alignment.setExtension( Annotations.ALIGNNS, Annotations.ID, atts.getValue("rdf:about") ); }; @@ -367,7 +369,7 @@ public class AlignmentParser extends DefaultHandler { if(debugMode > 2) System.err.println("endElement AlignmentParser : " + pName); if( namespaceURI.equals("http://knowledgeweb.semanticweb.org/heterogeneity/alignment") - || namespaceURI.equals(ALIGNNS) ) { + || namespaceURI.equals(Annotations.ALIGNNS) ) { try { if (pName.equals("relation")) { relation = content; @@ -398,20 +400,22 @@ public class AlignmentParser extends DefaultHandler { if ( extensions != null ) cell.setExtensions( extensions ); } else if (pName.equals("map")) { } else if (pName.equals("uri1")) { - if ( onto1.getOntology() == null ){ + if ( onto1.getURI() == null ){//JE: Onto try { URI u = new URI( content ); - onto1.setOntology( u ); + // JE: Onto + //onto1.setOntology( u ); onto1.setURI( u ); } catch (URISyntaxException e) { throw new SAXException("uri1: malformed URI"); } } } else if (pName.equals("uri2")) { - if ( onto2.getOntology() == null ){ + if ( onto2.getURI() == null ){//JE: Onto try { URI u = new URI( content ); - onto2.setOntology( u ); + // JE: Onto + //onto2.setOntology( u ); onto2.setURI( u ); } catch (URISyntaxException e) { throw new SAXException("uri2: malformed URI"); diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 9c171cb123f3b90e7801f736e040c132b1131f58..c2dcc6f8fdfd71e4e78fc92b0fccd5e22209a76f 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -25,7 +25,10 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser; import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.BasicAlignment; -import fr.inrialpes.exmo.align.impl.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyFactory; +import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.Ontology; +import fr.inrialpes.exmo.align.onto.LoadedOntology; import org.semanticweb.owl.align.Parameters; import org.semanticweb.owl.align.Alignment; @@ -33,14 +36,6 @@ import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.AlignmentException; -import org.semanticweb.owl.util.OWLManager; -import org.semanticweb.owl.model.OWLOntology; -import org.semanticweb.owl.model.OWLException; -import org.semanticweb.owl.io.owl_rdf.OWLRDFParser; -import org.semanticweb.owl.io.owl_rdf.OWLRDFErrorHandler; -import org.semanticweb.owl.io.ParserException; - -import org.xml.sax.SAXException; import java.sql.SQLException; import java.lang.ClassNotFoundException; @@ -88,7 +83,6 @@ public class AServProtocolManager { Set<String> services = null; OntologyCache loadedOntologies = null; - OWLRDFErrorHandler handler = null; Hashtable<String,Directory> directories = null; // This should be stored somewhere @@ -113,20 +107,6 @@ public class AServProtocolManager { methods.remove("fr.inrialpes.exmo.align.impl.DistanceAlignment"); // this one is generic services = implementations( "fr.inrialpes.exmo.align.service.AlignmentServiceProfile" ); loadedOntologies = new OntologyCache(); - handler = new OWLRDFErrorHandler() { - public void owlFullConstruct(int code, String message) - throws SAXException { - } - public void owlFullConstruct(int code, String message, Object o) - throws SAXException { - } - public void error(String message) throws SAXException { - throw new SAXException(message.toString()); - } - public void warning(String message) throws SAXException { - System.err.println("WARNING: " + message); - } - }; } public void close() { @@ -235,8 +215,8 @@ public class AServProtocolManager { // find and access o, o' URI uri1 = null; URI uri2 = null; - OWLOntology onto1 = null; - OWLOntology onto2 = null; + Ontology onto1 = null; + Ontology onto2 = null; try { uri1 = new URI((String)params.getParameter("onto1")); uri2 = new URI((String)params.getParameter("onto2")); @@ -249,13 +229,7 @@ public class AServProtocolManager { return new UnreachableOntology(newId(),mess,myId,mess.getSender(),(String)params.getParameter("onto2"),(Parameters)null); } // Try to retrieve first - Set alignments = null; - try { - // This is OWLAPI specific but there is no other way... - alignments = alignmentCache.getAlignments( onto1.getLogicalURI(), onto2.getLogicalURI() ); - } catch (OWLException e) { - // Unexpected OWLException! - } + Set alignments = alignmentCache.getAlignments( onto1.getURI(), onto2.getURI() ); if ( alignments != null && params.getParameter("force") == null ) { for ( Iterator it = alignments.iterator(); it.hasNext() ; ){ Alignment al = ((Alignment)it.next()); @@ -380,24 +354,25 @@ public class AServProtocolManager { public Message store( Message mess ){ String id = mess.getContent(); try { - alignmentCache.storeAlignment( id ); - } catch (Exception e) { - return new UnknownAlignment(newId(),mess,myId,mess.getSender(),id,(Parameters)null); - } - // Retrieve the alignment - Alignment al = null; - try { al = alignmentCache.getAlignment( id ); + Alignment al = alignmentCache.getAlignment( id ); + // Be sure it is not already stored + if ( !alignmentCache.isAlignmentStored( al ) ){ + alignmentCache.storeAlignment( id ); + // Retrieve the alignment again + al = alignmentCache.getAlignment( id ); + // for all directories... + for ( Directory d : directories.values() ){ + // Declare the alignment in the directory + try { d.register( al ); } + catch (AServException e) { e.printStackTrace(); }// ignore + } + } + // register by them + // Could also be an AlreadyStoredAlignment error + return new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); } catch (Exception e) { return new UnknownAlignment(newId(),mess,myId,mess.getSender(),id,(Parameters)null); } - // for all directories... - for ( Directory d : directories.values() ){ - // Declare the alignment in the directory - try { d.register( al ); } - catch (AServException e) { e.printStackTrace(); }// ignore - } - // register by them - return new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); } /* @@ -573,24 +548,21 @@ public class AServProtocolManager { * Utilities: reaching and loading ontologies *********************************************************************/ - public OWLOntology reachable( URI uri ){ + public LoadedOntology reachable( URI uri ){ try { return loadOntology( uri ); } catch (Exception e) { e.printStackTrace(); - return (OWLOntology)null; + return null; } } - public OWLOntology loadOntology( URI uri ) throws ParserException, OWLException { + public LoadedOntology loadOntology( URI uri ) { // Test if not loaded... - OWLOntology parsedOnt = null; - OWLRDFParser parser = new OWLRDFParser(); - parser.setOWLRDFErrorHandler(handler); - parser.setConnection(OWLManager.getOWLConnection()); - parsedOnt = parser.parseOntology( uri ); + OntologyFactory factory = OntologyFactory.newInstance(); + LoadedOntology onto = factory.loadOntology( uri ); if ( loadedOntologies != null ) - loadedOntologies.recordOntology( uri, parsedOnt ); - return parsedOnt; + loadedOntologies.recordOntology( uri, onto ); + return onto; } /********************************************************************* @@ -748,8 +720,6 @@ public class AServProtocolManager { // find and access o, o' URI uri1 = null; URI uri2 = null; - OWLOntology onto1 = null; - OWLOntology onto2 = null; try { uri1 = new URI((String)params.getParameter("onto1")); @@ -811,7 +781,6 @@ public class AServProtocolManager { } catch (AlignmentException e) { result = new NonConformParameters(newId(),mess,myId,mess.getSender(),"nonconform/params/",(Parameters)null); } - // JE: In non OWL-API-based version, here unload ontologies loadedOntologies.clear(); // not always necessary result = new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); } diff --git a/src/fr/inrialpes/exmo/align/service/CacheImpl.java b/src/fr/inrialpes/exmo/align/service/CacheImpl.java index 9a538f45f08b75f38bd830303a7e084fecb41002..ed58e2bc074fb11714b98abd2037845a8ae1f4b3 100644 --- a/src/fr/inrialpes/exmo/align/service/CacheImpl.java +++ b/src/fr/inrialpes/exmo/align/service/CacheImpl.java @@ -127,16 +127,6 @@ public class CacheImpl { * loads the alignment descriptions from the database and put them in the * alignmentTable hashtable * index them under the ontology URIs - * - * Beware, the Alignment API has two attributes: - * onto1 is the OWLOntology object - * uri1 is the URI object from which loading the ontologies - * In the database we store: - * owlontology1 the URI string of the ontology - * file1 the URI string from which loading the ontologies - * uri1 which should be the same as the last one... - * Since alignments are indexed by the URI of the ontologies, we use - * the "ouri1" temporary extension to contain this URI. */ private void loadAlignments( boolean force ) throws SQLException { String query = null; @@ -169,6 +159,16 @@ public class CacheImpl { /** * loads the description of alignments from the database and set them * in an alignment object + * + * Beware, the Alignment API has two attributes: + * onto1 is the OWLOntology object + * uri1 is the URI object from which loading the ontologies + * In the database we store: + * owlontology1 the URI string of the ontology + * file1 the URI string from which loading the ontologies + * uri1 which should be the same as the last one... + * Since alignments are indexed by the URI of the ontologies, we use + * the "ouri1" temporary extension to contain this URI. */ protected Alignment retrieveDescription( String id ){ String query; @@ -176,7 +176,7 @@ public class CacheImpl { String tag; String value; - Alignment result = new URIAlignment(); + URIAlignment result = new URIAlignment(); try { Statement st = (Statement) conn.createStatement(); @@ -187,6 +187,8 @@ public class CacheImpl { // Either uri1 or file1 result.setFile1( new URI( rs.getString("file1") ) ); result.setFile2( new URI( rs.getString("file2") ) ); + result.getOntologyObject1().setURI( new URI(rs.getString("owlontology1")) ); + result.getOntologyObject2().setURI( new URI(rs.getString("owlontology2")) ); result.setExtension( SVCNS, OURI1, rs.getString("owlontology1") ); result.setExtension( SVCNS, OURI2, rs.getString("owlontology2") ); result.setLevel(rs.getString("level")); @@ -428,6 +430,13 @@ public class CacheImpl { } } + public boolean isAlignmentStored( Alignment alignment ) { + if ( alignment.getExtension( SVCNS, STORED ) != null && + !alignment.getExtension( SVCNS, STORED ).equals("") ) + return false; + else return true; + } + public void storeAlignment( String id ) throws Exception { String query = null; Alignment alignment = getAlignment( id ); diff --git a/src/fr/inrialpes/exmo/align/service/OysterDirectory.java b/src/fr/inrialpes/exmo/align/service/OysterDirectory.java index 5bb6a0a640902557844af697abbddff221d8bd99..dbbd5882e35c08b6973eb08ddfd4b6850502e7b1 100644 --- a/src/fr/inrialpes/exmo/align/service/OysterDirectory.java +++ b/src/fr/inrialpes/exmo/align/service/OysterDirectory.java @@ -27,7 +27,8 @@ import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import fr.inrialpes.exmo.align.impl.Annotations; -import fr.inrialpes.exmo.align.impl.Ontology; + +import fr.inrialpes.exmo.align.onto.Ontology; import org.neon_toolkit.registry.api.Oyster2Manager; import org.neon_toolkit.registry.api.Oyster2Connection; diff --git a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java index 479f688782bdb1edcdb9a0a62bf13af59e8b970a..3a5b7274903a1bef214b73caac306ae620fe6b22 100644 --- a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java @@ -33,10 +33,11 @@ import org.semanticweb.owl.align.Parameters; import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.impl.OWLAPIAlignment; import fr.inrialpes.exmo.align.impl.URIAlignment; import fr.inrialpes.exmo.align.impl.eval.ExtPREvaluator; +import fr.inrialpes.exmo.align.parser.AlignmentParser; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.File; import java.io.PrintStream; @@ -52,8 +53,6 @@ import org.xml.sax.SAXException; import gnu.getopt.LongOpt; import gnu.getopt.Getopt; -import fr.inrialpes.exmo.align.parser.AlignmentParser; - /** A basic class for synthesizing the results of a set of alignments provided by different algorithms. The output is a table showing various generalisations of precision and recall for each test and for each algorithm. diff --git a/src/fr/inrialpes/exmo/align/util/GenTriangle.java b/src/fr/inrialpes/exmo/align/util/GenTriangle.java index fec1d3c832948c30536e48b7a1193dfefefc6cf5..bf6cece475084279c0eb33d61c5b6940d5378c8b 100644 --- a/src/fr/inrialpes/exmo/align/util/GenTriangle.java +++ b/src/fr/inrialpes/exmo/align/util/GenTriangle.java @@ -31,8 +31,8 @@ import org.semanticweb.owl.align.Parameters; import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.File; import java.io.PrintStream; diff --git a/src/fr/inrialpes/exmo/align/util/GroupAlign.java b/src/fr/inrialpes/exmo/align/util/GroupAlign.java index a2d69a11db828e78f7222ba513ec8ec8a338c1f2..c9e699d4ff5c47e1236239e2258ba0fca3eea12c 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupAlign.java +++ b/src/fr/inrialpes/exmo/align/util/GroupAlign.java @@ -38,8 +38,8 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.parser.AlignmentParser; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.File; import java.io.FileOutputStream; diff --git a/src/fr/inrialpes/exmo/align/util/GroupEval.java b/src/fr/inrialpes/exmo/align/util/GroupEval.java index ac9c5f95c3f082f8f434ba5b864a262eca4ff43f..1fab84473ea6de216397eeaa23ea965812a4bb58 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/GroupEval.java @@ -31,8 +31,8 @@ import org.semanticweb.owl.align.Parameters; import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.File; import java.io.PrintStream; diff --git a/src/fr/inrialpes/exmo/align/util/GroupOutput.java b/src/fr/inrialpes/exmo/align/util/GroupOutput.java index fa3751b0282fd4d7317b101864d49dba6347d4f2..dbf7e80ac56822797e255c6140e4e6e8a441e9dd 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/util/GroupOutput.java @@ -33,8 +33,8 @@ import org.semanticweb.owl.align.Parameters; import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.File; import java.io.FileOutputStream; diff --git a/src/fr/inrialpes/exmo/align/util/ParserPrinter.java b/src/fr/inrialpes/exmo/align/util/ParserPrinter.java index 611689551b434a57a10df2b38665a9477ac485e4..09fe449c104535c02af6f7c16bd8786708ab7ea2 100644 --- a/src/fr/inrialpes/exmo/align/util/ParserPrinter.java +++ b/src/fr/inrialpes/exmo/align/util/ParserPrinter.java @@ -33,8 +33,8 @@ import org.semanticweb.owl.align.AlignmentException; import fr.inrialpes.exmo.align.impl.renderer.RDFRendererVisitor; import fr.inrialpes.exmo.align.impl.OWLAPIAlignment; -import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.impl.URIAlignment; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.OutputStream; import java.io.FileOutputStream; diff --git a/src/fr/inrialpes/exmo/align/util/Procalign.java b/src/fr/inrialpes/exmo/align/util/Procalign.java index c507f707b1197e1ed6e1240542ff315798cbc59d..0613657a50e58bf0af142f82722bc7ca9c819125 100644 --- a/src/fr/inrialpes/exmo/align/util/Procalign.java +++ b/src/fr/inrialpes/exmo/align/util/Procalign.java @@ -34,7 +34,7 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.OutputStream; import java.io.FileOutputStream; @@ -218,7 +218,7 @@ public class Procalign { System.exit(0); } - if (debug > 0) System.err.println(" Handler set"); + if (debug > 0) System.err.println(" Ready"); try { if (initName != null) {