diff --git a/src/fr/inrialpes/exmo/align/impl/BasicCell.java b/src/fr/inrialpes/exmo/align/impl/BasicCell.java index c8b2952d792c3b1e20b95f6ee4d2c01f6265a13c..ee7a727d14cc94cbf258f3d713143dcdca370da4 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicCell.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicCell.java @@ -26,6 +26,7 @@ import java.util.Enumeration; import org.xml.sax.ContentHandler; +import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Cell; @@ -100,6 +101,9 @@ public class BasicCell implements Cell, Comparable<Cell> { * Use <tt>Ontology.getEntityURI( this )</tt> instead. */ public URI getObject1AsURI() throws AlignmentException { + return getObject1AsURI( null ); + } + public URI getObject1AsURI( Alignment al ) throws AlignmentException { if ( object1 instanceof URI ) { return (URI)object1; } else { @@ -114,6 +118,9 @@ public class BasicCell implements Cell, Comparable<Cell> { * Use <tt>Ontology.getEntityURI( this )</tt> instead. */ public URI getObject2AsURI() throws AlignmentException { + return getObject2AsURI( null ); + } + public URI getObject2AsURI( Alignment al ) throws AlignmentException { if ( object2 instanceof URI ) { return (URI)object2; } else { @@ -157,8 +164,8 @@ public class BasicCell implements Cell, Comparable<Cell> { for ( Object ext : ((BasicParameters)extensions).getValues() ){ result.setExtension( ((String[])ext)[0], ((String[])ext)[1], ((String[])ext)[2] ); } + result.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); } - result.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); // The sae should be done for the measure return result; } diff --git a/src/fr/inrialpes/exmo/align/impl/OWLAPICell.java b/src/fr/inrialpes/exmo/align/impl/OWLAPICell.java index 15997729156a202dcd44220da26d7b745fd80020..a01e9e2853d9a81ae70b64bfe6c2b6c628099836 100644 --- a/src/fr/inrialpes/exmo/align/impl/OWLAPICell.java +++ b/src/fr/inrialpes/exmo/align/impl/OWLAPICell.java @@ -33,6 +33,7 @@ import org.xml.sax.SAXException; import org.semanticweb.owl.model.OWLEntity; import org.semanticweb.owl.model.OWLException; +import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Cell; @@ -71,7 +72,7 @@ public class OWLAPICell extends ObjectCell { } // Only OWL - public URI getObject1AsURI() throws AlignmentException { + public URI getObject1AsURI( Alignment al ) throws AlignmentException { try { return ((OWLEntity)object1).getURI(); } catch (OWLException e) { @@ -80,7 +81,7 @@ public class OWLAPICell extends ObjectCell { } // Only OWL - public URI getObject2AsURI() throws AlignmentException { + public URI getObject2AsURI( Alignment al ) throws AlignmentException { try { return ((OWLEntity)object2).getURI(); } catch (OWLException e) { diff --git a/src/fr/inrialpes/exmo/align/impl/ObjectCell.java b/src/fr/inrialpes/exmo/align/impl/ObjectCell.java index a4033d5148e6a699521d50cc88a7853b24e4bb37..22dd5e89ef9f7aabaac6e86be451044feda07f8e 100644 --- a/src/fr/inrialpes/exmo/align/impl/ObjectCell.java +++ b/src/fr/inrialpes/exmo/align/impl/ObjectCell.java @@ -26,12 +26,16 @@ import java.util.Enumeration; import org.xml.sax.ContentHandler; +import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Parameters; +import fr.inrialpes.exmo.align.onto.LoadedOntology; +import fr.inrialpes.exmo.align.impl.BasicAlignment; + /** * Represents an ontology alignment correspondence. * @@ -72,20 +76,30 @@ public class ObjectCell extends BasicCell { } */ - public URI getObject1AsURI() throws AlignmentException { + public URI getObject1AsURI( Alignment al ) throws AlignmentException { + if ( al instanceof BasicAlignment ) { + Object ontology = ((BasicAlignment)al).getOntologyObject1(); + if ( ontology instanceof LoadedOntology ) { + return ((LoadedOntology)ontology).getEntityURI( object1 ); + } + }; if ( object1 instanceof URI ) { return (URI)object1; } else { - // TO BE DONE - return null; + throw new AlignmentException( "Cannot find URI for "+object1 ); } } - public URI getObject2AsURI() throws AlignmentException { - if ( object2 instanceof URI ) { + public URI getObject2AsURI( Alignment al ) throws AlignmentException { + if ( al instanceof BasicAlignment ) { + Object ontology = ((BasicAlignment)al).getOntologyObject2(); + if ( ontology instanceof LoadedOntology ) { + return ((LoadedOntology)ontology).getEntityURI( object2 ); + } + }; + if ( object2 instanceof URI ) { return (URI)object2; } else { - // TO BE DONE - return null; + throw new AlignmentException( "Cannot find URI for "+object2 ); } } public Cell inverse() throws AlignmentException { @@ -94,8 +108,8 @@ public class ObjectCell extends BasicCell { for ( Object ext : ((BasicParameters)extensions).getValues() ){ result.setExtension( ((String[])ext)[0], ((String[])ext)[1], ((String[])ext)[2] ); } + result.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); } - result.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); // The sae should be done for the measure return result; } diff --git a/src/fr/inrialpes/exmo/align/impl/URICell.java b/src/fr/inrialpes/exmo/align/impl/URICell.java index 482c51c9b53bf45785a1352b5ec2380d96721b14..550193b1c0020c94c86df96746aabf3c2b67b82a 100644 --- a/src/fr/inrialpes/exmo/align/impl/URICell.java +++ b/src/fr/inrialpes/exmo/align/impl/URICell.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2007 + * Copyright (C) INRIA Rhône-Alpes, 2007-2008 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -30,6 +30,7 @@ import java.net.URI; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; +import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Cell; @@ -75,8 +76,12 @@ public class URICell extends BasicCell { } } - public URI getObject1AsURI() throws AlignmentException { return (URI)object1; }; - public URI getObject2AsURI() throws AlignmentException { return (URI)object2; }; + public URI getObject1AsURI( Alignment al ) throws AlignmentException { + return (URI)object1; + }; + public URI getObject2AsURI( Alignment al ) throws AlignmentException { + return (URI)object2; + }; //public Object getObject1(){ return object1; }; //public Object getObject2(){ return object2; }; // We could check that the given values are URIs