diff --git a/html/relnotes.html b/html/relnotes.html index fcdf77a48f32865271a220f8a77c28ef2971aa0b..f361ca7489078f7dab8227c20de3137612f5b4ac 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -78,6 +78,7 @@ with a warning: <span style="color: green">Xerces 2.10</span>, <span style="color: green">log4j 1.2.16</span>, <span style="color: green">slf4j 1.6.4</span> (lib)</li--> +<li>Added <tt>EDOALAlignment.toEDOALAlignment()</tt> (edoal)</li> <li>Simplified <tt>TestGen</tt> options (cli)</li> <li>Fixed server initialisation error with new log4j (server)</li> <li>All documentation has now been revised in html and is not in the (outdated) manuals (html)</li> diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java index a237a1f44d9bf65d0247388aa9664349580b3ada..bfdff103785c21587175eadd1946a0f642914096 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/EDOALAlignment.java @@ -2,7 +2,7 @@ * $Id$ * * Sourceforge version 1.6 - 2008 - was OMWGAlignment - * Copyright (C) INRIA, 2007-2011 + * Copyright (C) INRIA, 2007-2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -42,6 +42,7 @@ import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.Namespace; import fr.inrialpes.exmo.align.impl.BasicAlignment; import fr.inrialpes.exmo.align.impl.URIAlignment; +import fr.inrialpes.exmo.align.impl.ObjectAlignment; import fr.inrialpes.exmo.align.impl.Extensions; import fr.inrialpes.exmo.align.parser.TypeCheckingVisitor; @@ -243,7 +244,18 @@ public class EDOALAlignment extends BasicAlignment { * convert an URI alignment into a corresponding EDOALAlignment * The same could be implemented for ObjectAlignent if necessary */ + // This works for any BasicAlignment but will return an empty + // alignment if they do not have proper URI dereferencing. + // It would be better to implement this for ObjectAlignment + // and to use return toEDOALAlignment( ObjectAlignment.toObjectAlignment( al ) ); + // for URIAlignment public static EDOALAlignment toEDOALAlignment( URIAlignment al ) throws AlignmentException { + return toEDOALAlignment( (BasicAlignment)al ); + } + public static EDOALAlignment toEDOALAlignment( ObjectAlignment al ) throws AlignmentException { + return toEDOALAlignment( (BasicAlignment)al ); + } + public static EDOALAlignment toEDOALAlignment( BasicAlignment al ) throws AlignmentException { EDOALAlignment alignment = new EDOALAlignment(); try { alignment.init( al.getFile1(), al.getFile2() ); @@ -255,32 +267,32 @@ public class EDOALAlignment extends BasicAlignment { } } alignment.setType( al.getType() ); - //alignment.setLevel( al.getLevel() ); // Should n't it be EDOAL level? alignment.setExtensions( al.convertExtension( "EDOALConverted", "fr.inrialpes.exmo.align.edoal.EDOALAlignment#toEDOAL" ) ); LoadedOntology<Object> o1 = (LoadedOntology<Object>)alignment.getOntologyObject1(); // [W:unchecked] LoadedOntology<Object> o2 = (LoadedOntology<Object>)alignment.getOntologyObject2(); // [W:unchecked] - try { - for ( Cell c : al ) { - // HERE THIS SHOULD BE CREATED AS THE CORRESPONDING ID DEPENDING ON THEIR TYPES... MAKE A FUNCTION + for ( Cell c : al ) { + try { Cell newc = alignment.addAlignCell( c.getId(), - getEntity( o1, c.getObject1AsURI(alignment) ), - getEntity( o2, c.getObject2AsURI(alignment) ), - c.getRelation(), - c.getStrength() ); + createEDOALExpression( o1, c.getObject1AsURI( al ) ), + createEDOALExpression( o2, c.getObject2AsURI( al ) ), + c.getRelation(), + c.getStrength() ); Collection<String[]> exts = c.getExtensions(); if ( exts != null ) { for ( String[] ext : exts ){ newc.setExtension( ext[0], ext[1], ext[2] ); } } + } catch ( AlignmentException aex ) { + aex.printStackTrace(); // continue to concert the rest + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Cannot dereference entity", owex ); } - } catch ( OntowrapException owex ) { - throw new AlignmentException( "Cannot dereference entity", owex ); } return alignment; } - static private Id getEntity( LoadedOntology<Object> o, URI u ) throws OntowrapException, AlignmentException { + private static Id createEDOALExpression( LoadedOntology<Object> o, URI u ) throws OntowrapException, AlignmentException { Object e = o.getEntity( u ); if ( o.isClass( e ) ) { return new ClassId( u ); @@ -293,10 +305,6 @@ public class EDOALAlignment extends BasicAlignment { } else throw new AlignmentException( "Cannot interpret URI" ); } - /** - * Returns the mappings of the EDOALAlignment - * @return The set of rules contained by the EDOALAlignment - */ /** * Generate a copy of this alignment object