Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 1c371b38 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- Modified Cell interface so that object URIs can be found in a generic way

        -> solves a database storage bug
- Modified inverse() so that it works when no extensions are there
parent 90596d54
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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;
}
......
/*
* $Id$
*
* Copyright (C) INRIA Rhne-Alpes, 2007
* Copyright (C) INRIA Rhne-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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment