From 469afea96088d1017cb4a6354a8ddef40eb96666 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Fri, 23 Oct 2015 13:26:27 +0000
Subject: [PATCH] - Used intermediate RelationTransformer in renderers (impl)

---
 html/relnotes.html                            |   1 +
 .../renderer/COWLMappingRendererVisitor.java  |  76 +++-----
 .../renderer/OWLAxiomsRendererVisitor.java    | 129 ++------------
 .../impl/renderer/RelationTransformer.java    | 164 ++++++++++++++++++
 .../renderer/SEKTMappingRendererVisitor.java  |  34 ++--
 .../impl/renderer/SKOSRendererVisitor.java    |  44 ++---
 .../SPARQLConstructRendererVisitor.java       |  31 ++--
 .../impl/renderer/SWRLRendererVisitor.java    |  34 ++--
 .../impl/renderer/XSLTRendererVisitor.java    |  12 +-
 9 files changed, 271 insertions(+), 254 deletions(-)
 create mode 100644 src/fr/inrialpes/exmo/align/impl/renderer/RelationTransformer.java

diff --git a/html/relnotes.html b/html/relnotes.html
index d8cd1a04..fc3819bb 100644
--- a/html/relnotes.html
+++ b/html/relnotes.html
@@ -80,6 +80,7 @@ with a warning:
   and <tt>AlgebraRelation</tt> allowing for using algebras of
   relations in alignments (impl)</li>
 <li>Generalised the use of <tt>IndentedRendererVisitor</tt> in renderers (impl)</li>
+<li>Used intermediate <tt>RelationTransformer</tt> in renderers (impl)</li>
 <li>Added tutorial6 about data interlinking (tutorial)</li>
 <li>Introduced V5 marker for documenting anticipated API evolution (api)</li>
 <li>Upgraded to <span style="color: green">SLF4J 1.7.12</span> (lib)</li>
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java
index 5fcaff68..8b0ead23 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java
@@ -35,7 +35,6 @@ import org.semanticweb.owl.align.Relation;
 
 import fr.inrialpes.exmo.align.impl.ObjectAlignment;
 import fr.inrialpes.exmo.align.impl.URIAlignment;
-import fr.inrialpes.exmo.align.impl.rel.*;
 
 import fr.inrialpes.exmo.ontowrap.LoadedOntology;
 import fr.inrialpes.exmo.ontowrap.OntowrapException;
@@ -111,70 +110,41 @@ public class COWLMappingRendererVisitor extends IndentedRendererVisitor implemen
 	decreaseIndent();
 	indentedOutputln("</rdf:RDF>");
     }
+
     public void visit( Cell cell ) throws AlignmentException {
 	if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return;
 	// default behaviour
 	this.cell = cell;
+	String relationName = getRelationName( cell.getRelation() );
+	if ( relationName == null ) throw new AlignmentException( "Cannot render Relation "+cell.getRelation() );
 	indentedOutputln("<cowl:bridgeRule>");
 	increaseIndent();
-	cell.getRelation().accept( this );
-	decreaseIndent();
-	indentedOutputln("</cowl:bridgeRule>");
-    }
-    public void visit( EquivRelation rel ) throws AlignmentException {
-	    indentedOutputln("<cowl:Equivalent>");
+	indentedOutputln("<"+relationName+">");
 	increaseIndent();
-	    indentedOutputln("<cowl:source>");
-	    printObject(cell.getObject1(),onto1);
-	    indentedOutputln("</cowl:source>");
-	    indentedOutputln("<cowl:target>");
-	    printObject(cell.getObject2(),onto2);
-	    indentedOutputln("</cowl:target>");
+	indentedOutputln("<cowl:source>");
+	printObject(cell.getObject1(),onto1);
+	indentedOutputln("</cowl:source>");
+	indentedOutputln("<cowl:target>");
+	printObject(cell.getObject2(),onto2);
+	indentedOutputln("</cowl:target>");
 	decreaseIndent();
-	    indentedOutputln("</cowl:Equivalent>");
-    }
-
-    public void visit( SubsumeRelation rel ) throws AlignmentException {
-	    indentedOutputln("<cowl:Into>");
-	increaseIndent();
-	    indentedOutputln("<cowl:source>");
-	    printObject(cell.getObject1(),onto1);
-	    indentedOutputln("</cowl:source>");
-	    indentedOutputln("<cowl:target>");
-	    printObject(cell.getObject2(),onto2);
-	    indentedOutputln("</cowl:target>");
+	indentedOutputln("</"+relationName+">");
 	decreaseIndent();
-	    indentedOutputln("</cowl:Into>");
-    }
-    public void visit( SubsumedRelation rel ) throws AlignmentException {
-	    indentedOutputln("<cowl:Onto>");
-	increaseIndent();
-	    indentedOutputln("<cowl:source>");
-	    printObject(cell.getObject1(),onto1);
-	    indentedOutputln("</cowl:source>");
-	    indentedOutputln("<cowl:target>");
-	    printObject(cell.getObject2(),onto2);
-	    indentedOutputln("</cowl:target>");
-	decreaseIndent();
-	    indentedOutputln("</cowl:Onto>");
-    }
-    public void visit( IncompatRelation rel ) throws AlignmentException {
-	    indentedOutputln("<cowl:INCOMPATIBLE>");
-	increaseIndent();
-	    indentedOutputln("<cowl:source>");
-	    printObject(cell.getObject1(),onto1);
-	    indentedOutputln("</cowl:source>");
-	    indentedOutputln("<cowl:target>");
-	    printObject(cell.getObject2(),onto2);
-	    indentedOutputln("</cowl:target>");
-	decreaseIndent();
-	    indentedOutputln("</cowl:INCOMPATIBLE>");
+	indentedOutputln("</cowl:bridgeRule>");
     }
 
     public void visit( Relation rel ) throws AlignmentException {
-	if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return;
-	// default behaviour
-	throw new AlignmentException( "Cannot render generic Relation" );
+	throw new AlignmentException( "Cannot render generic relation "+rel );
+    }
+
+    public static String getRelationName( Relation rel ) throws AlignmentException {
+	if ( RelationTransformer.isEquivalence( rel ) ) return "cowl:Equivalent";
+	else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) return "cowl:Onto";
+	else if ( RelationTransformer.subsumesOrEqual( rel ) ) return "cowl:Into";
+	else if ( RelationTransformer.isDisjoint( rel ) ) return "cowl:INCOMPATIBLE";
+	// COWL?
+	// isInstanceOf(), hasInstance()
+	else return null;
     }
 
     public void printObject( Object ob, LoadedOntology<?> onto ) throws AlignmentException {
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java
index b643953d..9f40c7f2 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java
@@ -37,7 +37,6 @@ import fr.inrialpes.exmo.align.impl.Namespace;
 import fr.inrialpes.exmo.align.impl.Extensions;
 import fr.inrialpes.exmo.align.impl.ObjectAlignment;
 import fr.inrialpes.exmo.align.impl.URIAlignment;
-import fr.inrialpes.exmo.align.impl.rel.*;
 
 import fr.inrialpes.exmo.ontowrap.LoadedOntology;
 import fr.inrialpes.exmo.ontowrap.OntowrapException;
@@ -199,7 +198,7 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 	    increaseIndent();
 	    try {
 		Relation rel = cell.getRelation();
-		if ( rel instanceof SubsumeRelation || rel instanceof HasInstanceRelation ){
+		if ( RelationTransformer.canBeTranscribedInverted( rel ) ){
 		    u1 = onto2.getEntityURI( ob2 );
 		} else {
 		    u1 = onto1.getEntityURI( ob1 );
@@ -240,7 +239,7 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 	this.cell = cell;
 	toProcess = cell.getRelation();
 	increaseIndent();
-	if ( toProcess instanceof SubsumeRelation || toProcess instanceof HasInstanceRelation ) {
+	if ( RelationTransformer.canBeTranscribedInverted( toProcess ) ) {
 	    ((Expression)cell.getObject2()).accept( this );
 	} else {
 	    ((Expression)cell.getObject1()).accept( this );
@@ -248,103 +247,6 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 	decreaseIndent();
 	outputln();
     }
-
-    // This relation has a corresponding relation in OWL
-    public boolean canBeTranscribedDirectly( Relation rel ) {
-	return ( isEquivalence( rel ) 
-		 || isSubsumedOrEqual( rel ) 
-		 || isDisjoint( rel ) 
-		 || isInstanceOf( rel )) ;
-    }
-
-    // This relation is the converse of a relation in OWL
-    public boolean canBeTranscribedInverted( Relation rel ) {
-	return ( subsumesOrEqual( rel ) 
-		 || hasInstance( rel )) ;
-    }
-
-    // This relation is equivalence
-    public boolean isEquivalence( Relation rel ) {
-	return ( rel instanceof EquivRelation
-		 || ( rel instanceof A2AlgebraRelation && ((A2AlgebraRelation)rel).isIdRelation() )
-		 || ( rel instanceof A5AlgebraRelation && ((A5AlgebraRelation)rel).isIdRelation() )
-		 || ( rel instanceof A16AlgebraRelation && ((A16AlgebraRelation)rel).isIdRelation() )
-		 );
-    }
-
-    // This relation is subXOf
-    public boolean isSubsumedOrEqual( Relation rel ) {
-	try {
-	    return ( rel instanceof SubsumedRelation 
-		     || ( rel instanceof A5AlgebraRelation && 
-			  A5AlgebraRelation.createRelation( A5BaseRelation.SUBSUMED,  A5BaseRelation.EQUIV ).entails( (A5AlgebraRelation)rel ) )
-		     || ( rel instanceof A16AlgebraRelation &&
-			  A16AlgebraRelation.createRelation( A16BaseRelation.SUBSUMED, A16BaseRelation.EQ_N, A16BaseRelation.EQ_E, A16BaseRelation.EN ).entails( (A16AlgebraRelation)rel ) )
-		     );
-	} catch (AlignmentException aex) {
-	    logger.trace( "IGNORED Exception", aex );
-	    return false;
-	}
-    }
-
-    // This relation is superXOf
-    public boolean subsumesOrEqual( Relation rel ) {
-	try {
-	    return ( rel instanceof SubsumeRelation 
-		     || ( rel instanceof A5AlgebraRelation && 
-			  A5AlgebraRelation.createRelation( A5BaseRelation.SUBSUME, A5BaseRelation.EQUIV ).entails( (A5AlgebraRelation)rel ) )
-		     || ( rel instanceof A16AlgebraRelation &&
-			  A16AlgebraRelation.createRelation( A16BaseRelation.SUBSUME, A16BaseRelation.EQ_N, A16BaseRelation.EQ_E, A16BaseRelation.NE ).entails( (A16AlgebraRelation)rel ) )
-		     );
-	} catch (AlignmentException aex) {
-	    logger.trace( "IGNORED Exception", aex );
-	    return false;
-	}
-    }
-
-    // This relation is disjointFrom
-    public boolean isDisjoint( Relation rel ) {
-	try {
-	    return ( rel instanceof IncompatRelation 
-		     || ( rel instanceof A2AlgebraRelation &&
-			  A2AlgebraRelation.createRelation( A2BaseRelation.DIFF ).entails( (A2AlgebraRelation)rel ) )
-		     || ( rel instanceof A5AlgebraRelation && 
-			  A5AlgebraRelation.createRelation( A5BaseRelation.DISJOINT ).entails( (A5AlgebraRelation)rel ) )
-		     || ( rel instanceof A16AlgebraRelation && 
-			  A16AlgebraRelation.createRelation( A16BaseRelation.DISJOINT, A16BaseRelation.NOTEQ_I, A16BaseRelation.EQ_E, A16BaseRelation.NE, A16BaseRelation.EN ).entails( (A16AlgebraRelation)rel ) )
-		     );
-	} catch (AlignmentException aex) {
-	    logger.trace( "IGNORED Exception", aex );
-	    return false;
-	}
-    }
-
-    // This relation is isInstanceOf
-    public boolean isInstanceOf( Relation rel ) {
-	try {
-	    return ( rel instanceof InstanceOfRelation 
-		     || ( rel instanceof A16AlgebraRelation && 
-			  A16AlgebraRelation.createRelation( A16BaseRelation.ISA ).entails( (A16AlgebraRelation)rel ) )
-		     );
-	} catch (AlignmentException aex) {
-	    logger.trace( "IGNORED Exception", aex );
-	    return false;
-	}
-    }
-
-    // This relation is hasInstance
-    public boolean hasInstance( Relation rel ) {
-	try {
-	    return ( rel instanceof HasInstanceRelation 
-		     || ( rel instanceof A16AlgebraRelation && 
-			  A16AlgebraRelation.createRelation( A16BaseRelation.HAS ).entails( (A16AlgebraRelation)rel ) )
-		     );
-	} catch (AlignmentException aex) {
-	    logger.trace( "IGNORED Exception", aex );
-	    return false;
-	}
-    }
-
     // Classical dispatch
     // This is the previous code... which is the one which was used.
     // It should be reintroduced in the dispatch!
@@ -357,7 +259,7 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 	    if ( owlrel == null ) throw new AlignmentException( "Relation "+rel+" cannot apply to "+ob2 );
 	    indentedOutputln("<"+owlrel+">");
 	    increaseIndent();
-	    if ( rel instanceof HasInstanceRelation || rel instanceof SubsumeRelation ) {
+	    if ( RelationTransformer.canBeTranscribedInverted( rel ) ) {
 		((Expression)cell.getObject1()).accept( this );
 	    } else {
 		((Expression)ob2).accept( this );
@@ -406,9 +308,8 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
     /**
      * For EDOAL relation name depends on type of expressions
      */
-
     public String getRelationName( Relation rel, Object ob ) {
-	if ( isEquivalence( rel ) ) {
+	if ( RelationTransformer.isEquivalence( rel ) ) {
 	    if ( ob instanceof ClassExpression ) {
 		return "owl:equivalentClass";
 	    } else if ( ob instanceof PropertyExpression || ob instanceof RelationExpression ) {
@@ -416,29 +317,29 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 	    } else if ( ob instanceof InstanceExpression ) {
 		return "owl:sameAs";
 	    }
-	} else if ( isDisjoint( rel ) ) {
+	} else if ( RelationTransformer.isDisjoint( rel ) ) {
 	    if ( ob instanceof ClassExpression ) {
 		return "owl:disjointFrom";
 	    } else if ( ob instanceof InstanceExpression ) {
 		return "owl:differentFrom";
 	    }
-	} else if ( subsumesOrEqual( rel ) ) {
+	} else if ( RelationTransformer.subsumesOrEqual( rel ) ) {
 	    if ( ob instanceof ClassExpression ) {
 		return "owl:subClassOf";
 	    } else if ( ob instanceof PropertyExpression || ob instanceof RelationExpression ) {
 		return "owl:subPropertyOf";
 	    }
-	} else if ( isSubsumedOrEqual( rel ) ) {
+	} else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) {
 	    if ( ob instanceof ClassExpression ) {
 		return "owl:subClassOf";
 	    } else if ( ob instanceof PropertyExpression || ob instanceof RelationExpression ) {
 		return "owl:subPropertyOf";
 	    }
-	} else if ( isInstanceOf( rel ) ) {
+	} else if ( RelationTransformer.isInstanceOf( rel ) ) {
 	    if ( ob instanceof ClassExpression ) {
 		return "rdf:type";
 	    }
-	} else if ( hasInstance( rel ) ) {
+	} else if ( RelationTransformer.hasInstance( rel ) ) {
 	    if ( ob instanceof InstanceExpression ) {
 		return "rdf:type";
 	    }
@@ -452,7 +353,7 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 
     public String getRelationName( LoadedOntology<? extends Object> onto, Relation rel, Object ob ) {
 	try {
-	    if ( isEquivalence( rel ) ) {
+	    if ( RelationTransformer.isEquivalence( rel ) ) {
 		if ( onto.isClass( ob ) ) {
 		    return "owl:equivalentClass";
 		} else if ( onto.isProperty( ob ) ) {
@@ -460,29 +361,29 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements
 		} else if ( onto.isIndividual( ob ) ) {
 		    return "owl:sameAs";
 		}
-	    } else if ( subsumesOrEqual( rel ) ) {
+	    } else if ( RelationTransformer.subsumesOrEqual( rel ) ) {
 		if ( onto.isClass( ob ) ) {
 		    return "rdfs:subClassOf";
 		} else if ( onto.isProperty( ob ) ) {
 		    return "rdfs:subPropertyOf";
 		}
-	    } else if ( isSubsumedOrEqual( rel ) ) {
+	    } else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) {
 		if ( onto.isClass( ob ) ) {
 		    return "rdfs:subClassOf";
 		} else if ( onto.isProperty( ob ) ) {
 		    return "rdfs:subPropertyOf";
 		}
-	    } else if ( isDisjoint( rel ) ) {
+	    } else if ( RelationTransformer.isDisjoint( rel ) ) {
 		if ( onto.isClass( ob ) ) {
 		    return "rdfs:disjointFrom";
 		} else if ( onto.isIndividual( ob ) ) {
 		    return "owl:differentFrom";
 		}
-	    } else if ( isInstanceOf( rel ) ) {
+	    } else if ( RelationTransformer.isInstanceOf( rel ) ) {
 		if ( onto.isClass( ob ) ) {
 		    return "rdf:type";
 		}
-	    } else if ( hasInstance( rel ) ) {
+	    } else if ( RelationTransformer.hasInstance( rel ) ) {
 		if ( onto.isIndividual( ob ) ) {
 		    return "rdf:type";
 		}
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RelationTransformer.java b/src/fr/inrialpes/exmo/align/impl/renderer/RelationTransformer.java
new file mode 100644
index 00000000..d5e54585
--- /dev/null
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/RelationTransformer.java
@@ -0,0 +1,164 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) INRIA, 2003-2004, 2007-2015
+ *
+ * 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
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+package fr.inrialpes.exmo.align.impl.renderer; 
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.semanticweb.owl.align.AlignmentException;
+import org.semanticweb.owl.align.Relation;
+
+import fr.inrialpes.exmo.align.impl.rel.EquivRelation;
+import fr.inrialpes.exmo.align.impl.rel.SubsumeRelation;
+import fr.inrialpes.exmo.align.impl.rel.SubsumedRelation;
+import fr.inrialpes.exmo.align.impl.rel.IncompatRelation;
+import fr.inrialpes.exmo.align.impl.rel.InstanceOfRelation;
+import fr.inrialpes.exmo.align.impl.rel.HasInstanceRelation;
+
+import fr.inrialpes.exmo.align.impl.rel.A2AlgebraRelation;
+import fr.inrialpes.exmo.align.impl.rel.A5AlgebraRelation;
+import fr.inrialpes.exmo.align.impl.rel.A16AlgebraRelation;
+import fr.inrialpes.exmo.align.impl.rel.A2BaseRelation;
+import fr.inrialpes.exmo.align.impl.rel.A5BaseRelation;
+import fr.inrialpes.exmo.align.impl.rel.A16BaseRelation;
+
+/**
+ * This class categorises relations of the API implementation with respect to the
+ * category of their use by renderers.
+ *
+ * It is made for being used _statically_ by renderers to decise how to render a
+ * cell. In principle, this is the only thing that has to be modified when using
+ * different Relation implementations.
+ *
+ * @author Jérôme Euzenat
+ * @version $Id$ 
+ */
+
+public class RelationTransformer {
+    final static Logger logger = LoggerFactory.getLogger( OWLAxiomsRendererVisitor.class );
+
+    // Unused currently
+    final public static int EQUIV = 1;
+    final public static int SUBSUME = 2;
+    final public static int SUBSUMED = 3;
+    final public static int DISJOINT = 4;
+    final public static int OVERLAP = 5;
+    final public static int INSTANCEOF = 6;
+    final public static int HASINSTANCE = 7;
+
+    // This relation has a corresponding relation in OWL
+    public static boolean canBeTranscribedDirectly( Relation rel ) {
+	return ( isEquivalence( rel ) 
+		 || isSubsumedOrEqual( rel ) 
+		 || isDisjoint( rel ) 
+		 || isInstanceOf( rel )) ;
+    }
+
+    // This relation is the converse of a relation in OWL
+    public static boolean canBeTranscribedInverted( Relation rel ) {
+	return ( subsumesOrEqual( rel ) 
+		 || hasInstance( rel )) ;
+    }
+
+    // This relation is equivalence
+    public static boolean isEquivalence( Relation rel ) {
+	return ( rel instanceof EquivRelation
+		 || ( rel instanceof A2AlgebraRelation && ((A2AlgebraRelation)rel).isIdRelation() )
+		 || ( rel instanceof A5AlgebraRelation && ((A5AlgebraRelation)rel).isIdRelation() )
+		 || ( rel instanceof A16AlgebraRelation && ((A16AlgebraRelation)rel).isIdRelation() )
+		 );
+    }
+
+    // This relation is subXOf
+    public static boolean isSubsumedOrEqual( Relation rel ) {
+	try {
+	    return ( rel instanceof SubsumedRelation 
+		     || ( rel instanceof A5AlgebraRelation && 
+			  A5AlgebraRelation.createRelation( A5BaseRelation.SUBSUMED,  A5BaseRelation.EQUIV ).entails( (A5AlgebraRelation)rel ) )
+		     || ( rel instanceof A16AlgebraRelation &&
+			  A16AlgebraRelation.createRelation( A16BaseRelation.SUBSUMED, A16BaseRelation.EQ_N, A16BaseRelation.EQ_E, A16BaseRelation.EN ).entails( (A16AlgebraRelation)rel ) )
+		     );
+	} catch (AlignmentException aex) {
+	    logger.trace( "IGNORED Exception", aex );
+	    return false;
+	}
+    }
+
+    // This relation is superXOf
+    public static boolean subsumesOrEqual( Relation rel ) {
+	try {
+	    return ( rel instanceof SubsumeRelation 
+		     || ( rel instanceof A5AlgebraRelation && 
+			  A5AlgebraRelation.createRelation( A5BaseRelation.SUBSUME, A5BaseRelation.EQUIV ).entails( (A5AlgebraRelation)rel ) )
+		     || ( rel instanceof A16AlgebraRelation &&
+			  A16AlgebraRelation.createRelation( A16BaseRelation.SUBSUME, A16BaseRelation.EQ_N, A16BaseRelation.EQ_E, A16BaseRelation.NE ).entails( (A16AlgebraRelation)rel ) )
+		     );
+	} catch (AlignmentException aex) {
+	    logger.trace( "IGNORED Exception", aex );
+	    return false;
+	}
+    }
+
+    // This relation is disjointFrom
+    public static boolean isDisjoint( Relation rel ) {
+	try {
+	    return ( rel instanceof IncompatRelation 
+		     || ( rel instanceof A2AlgebraRelation &&
+			  A2AlgebraRelation.createRelation( A2BaseRelation.DIFF ).entails( (A2AlgebraRelation)rel ) )
+		     || ( rel instanceof A5AlgebraRelation && 
+			  A5AlgebraRelation.createRelation( A5BaseRelation.DISJOINT ).entails( (A5AlgebraRelation)rel ) )
+		     || ( rel instanceof A16AlgebraRelation && 
+			  A16AlgebraRelation.createRelation( A16BaseRelation.DISJOINT, A16BaseRelation.NOTEQ_I, A16BaseRelation.EQ_E, A16BaseRelation.NE, A16BaseRelation.EN ).entails( (A16AlgebraRelation)rel ) )
+		     );
+	} catch (AlignmentException aex) {
+	    logger.trace( "IGNORED Exception", aex );
+	    return false;
+	}
+    }
+
+    // This relation is isInstanceOf
+    public static boolean isInstanceOf( Relation rel ) {
+	try {
+	    return ( rel instanceof InstanceOfRelation 
+		     || ( rel instanceof A16AlgebraRelation && 
+			  A16AlgebraRelation.createRelation( A16BaseRelation.ISA ).entails( (A16AlgebraRelation)rel ) )
+		     );
+	} catch (AlignmentException aex) {
+	    logger.trace( "IGNORED Exception", aex );
+	    return false;
+	}
+    }
+
+    // This relation is hasInstance
+    public static boolean hasInstance( Relation rel ) {
+	try {
+	    return ( rel instanceof HasInstanceRelation 
+		     || ( rel instanceof A16AlgebraRelation && 
+			  A16AlgebraRelation.createRelation( A16BaseRelation.HAS ).entails( (A16AlgebraRelation)rel ) )
+		     );
+	} catch (AlignmentException aex) {
+	    logger.trace( "IGNORED Exception", aex );
+	    return false;
+	}
+    }
+
+
+}
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java
index d5502872..1034c7a5 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/SEKTMappingRendererVisitor.java
@@ -36,7 +36,6 @@ import org.semanticweb.owl.align.Relation;
 
 import fr.inrialpes.exmo.align.impl.ObjectAlignment;
 import fr.inrialpes.exmo.align.impl.URIAlignment;
-import fr.inrialpes.exmo.align.impl.rel.*;
 
 import fr.inrialpes.exmo.ontowrap.LoadedOntology;
 import fr.inrialpes.exmo.ontowrap.OntowrapException;
@@ -98,10 +97,12 @@ public class SEKTMappingRendererVisitor extends IndentedRendererVisitor implemen
 	Object ob1 = cell.getObject1();
 	Object ob2 = cell.getObject2();
 	try {
+	    String direction = getRelationDirection( cell.getRelation() );
+	    if ( direction == null ) throw new AlignmentException( "Cannot render relation "+cell.getRelation() );
 	    if ( onto1.isClass( ob1 ) ) {
 		indentedOutputln("classMapping( <\"#"+id+"\">");
 		increaseIndent();
-		cell.getRelation().accept( this );
+		indentedOutputln(direction);
 		indentedOutputln("<\""+onto1.getEntityURI( ob1 )+"\">");
 		indentedOutputln("<\""+onto2.getEntityURI( ob2 )+"\">");
 		decreaseIndent();
@@ -109,7 +110,7 @@ public class SEKTMappingRendererVisitor extends IndentedRendererVisitor implemen
 	    } else if ( onto1.isDataProperty( ob1 ) ) {
 		indentedOutputln("relationMapping( <\"#"+id+"\">");
 		increaseIndent();
-		cell.getRelation().accept( this );
+		indentedOutputln(direction);
 		indentedOutputln("<\""+onto1.getEntityURI( ob1 )+"\">");
 		indentedOutputln("<\""+onto2.getEntityURI( ob2 )+"\">");
 		decreaseIndent();
@@ -117,7 +118,7 @@ public class SEKTMappingRendererVisitor extends IndentedRendererVisitor implemen
 	    } else if ( onto1.isObjectProperty( ob1 ) ) {
 		indentedOutputln("attributeMapping( <\"#"+id+"\">");
 		increaseIndent();
-		cell.getRelation().accept( this );
+		indentedOutputln(direction);
 		indentedOutputln("<\""+onto1.getEntityURI( ob1 )+"\">");
 		indentedOutputln("<\""+onto2.getEntityURI( ob2 )+"\">");
 		decreaseIndent();
@@ -125,7 +126,7 @@ public class SEKTMappingRendererVisitor extends IndentedRendererVisitor implemen
 	    } else if ( onto1.isIndividual( ob1 ) ) {
 		indentedOutputln("instanceMapping( <\"#"+id+"\">");
 		increaseIndent();
-		cell.getRelation().accept( this );
+		indentedOutputln(direction);
 		indentedOutputln("<\""+onto1.getEntityURI( ob1 )+"\">");
 		indentedOutputln("<\""+onto2.getEntityURI( ob2 )+"\">");
 		decreaseIndent();
@@ -137,22 +138,21 @@ public class SEKTMappingRendererVisitor extends IndentedRendererVisitor implemen
 	}
     }
 
-    public void visit( EquivRelation rel ) throws AlignmentException {
-	indentedOutputln("bidirectional");
-    }
-    public void visit( SubsumeRelation rel ) throws AlignmentException {
-	indentedOutputln("unidirectional");
-    }
-    public void visit( SubsumedRelation rel ) throws AlignmentException {
-	indentedOutputln("unidirectional");
-    }
-    public void visit( IncompatRelation rel ) throws AlignmentException {
-	indentedOutputln("unidirectional");
+    public static String getRelationDirection( Relation rel ) throws AlignmentException {
+	// Not really semantically meaningfull
+	if ( RelationTransformer.isEquivalence( rel ) ) return "bidirectional";
+	else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) return "unidirectional";
+	else if ( RelationTransformer.subsumesOrEqual( rel ) ) return "unidirectional";
+	else if ( RelationTransformer.isDisjoint( rel ) ) return "unidirectional";
+	// COWL?
+	// isInstanceOf(), hasInstance()
+	else return null;
     }
+
     public void visit( Relation rel ) throws AlignmentException {
 	if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return;
 	// default behaviour
-	throw new AlignmentException( "Cannot render generic Relation" );
+	throw new AlignmentException( "Cannot render generic relation "+rel );
     }
 
 }
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java
index acec130c..7539390a 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java
@@ -34,7 +34,6 @@ import org.semanticweb.owl.align.AlignmentException;
 import org.semanticweb.owl.align.Cell;
 import org.semanticweb.owl.align.Relation;
 
-import fr.inrialpes.exmo.align.impl.rel.*;
 import fr.inrialpes.exmo.align.impl.ObjectAlignment;
 
 import fr.inrialpes.exmo.ontowrap.LoadedOntology;
@@ -126,37 +125,30 @@ public class SKOSRendererVisitor extends IndentedRendererVisitor implements Alig
 	    indentedOutputln("<skos:Concept rdf:about=\""+cell.getObject1AsURI( alignment )+"\">");
 	}
 	increaseIndent();
-	cell.getRelation().accept( this );
+	String relation = getRelationName( cell.getRelation() );
+	indentedOutputln("<"+relation+" rdf:resource=\""+getURI2()+"\"/>");
 	decreaseIndent();
 	indentedOutputln("</skos:Concept>\n");
     }
-    public void visit( EquivRelation rel ) throws AlignmentException {
-	if ( pre2008 ) {
-	    indentedOutputln("<skos:related rdf:resource=\""+getURI2()+"\"/>");
-	} else {
-	    indentedOutputln("<skos:exactMatch rdf:resource=\"" + getURI2() + "\"/>");
-	}
-    }
-    public void visit( SubsumeRelation rel ) throws AlignmentException {
-	if ( pre2008 ) {
-	    indentedOutputln("<skos:narrower rdf:resource=\""+getURI2()+"\"/>");
-	} else {
-	    indentedOutputln("<skos:narrowMatch rdf:resource=\""+getURI2()+"\"/>");
-	}
-    }
-    public void visit( SubsumedRelation rel ) throws AlignmentException {
-	if ( pre2008 ) {
-	    indentedOutputln("<skos:broader rdf:resource=\""+getURI2()+"\"/>");
-	} else {
-	    indentedOutputln("<skos:broadMatch rdf:resource=\""+getURI2()+"\"/>");
-	}
-    }
-    public void visit( IncompatRelation rel ) throws AlignmentException {
-	throw new AlignmentException("Cannot translate in SKOS"+rel);
+
+   public String getRelationName( Relation rel ) throws AlignmentException {
+       if ( pre2008 ) {
+	   if ( RelationTransformer.isEquivalence( rel ) ) return "skos:related";
+	   else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) return "skos:broader";
+	   else if ( RelationTransformer.subsumesOrEqual( rel ) ) return "skos:narrower";
+	   else rel.accept( this );
+       } else {
+	   if ( RelationTransformer.isEquivalence( rel ) ) return "skos:exactMatch";
+	   else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) return "skos:broadMatch";
+	   else if ( RelationTransformer.subsumesOrEqual( rel ) ) return "skos:narrowMatch";
+	   else rel.accept( this );
+       }
+       return null;
     }
+
     public void visit( Relation rel ) throws AlignmentException {
 	if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return;
 	// default behaviour
-	throw new AlignmentException( "Cannot render generic Relation" );
+	throw new AlignmentException( "Cannot render relation "+rel );
     }
 }
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java
index 95851c22..8af87380 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java
@@ -140,18 +140,18 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor
     }
 
     public void visit(Cell cell) throws AlignmentException {
-        if (subsumedInvocableMethod(this, cell, Cell.class)) {
-            return;
-        }
+        if (subsumedInvocableMethod(this, cell, Cell.class)) return;
         // default behaviour
         this.cell = cell;
         URI u1 = cell.getObject1AsURI(alignment);
         URI u2 = cell.getObject2AsURI(alignment);
-        if (edoal || (u1 != null && u2 != null)) {
-            generateConstruct(cell, (Expression) (cell.getObject1()), (Expression) (cell.getObject2()));
-            //if (!oneway) {
-            //    generateConstruct(cell, (Expression) (cell.getObject2()), (Expression) (cell.getObject1()));
-            //}
+	Relation rel = cell.getRelation();
+	if ( ( RelationTransformer.isEquivalence( rel ) || RelationTransformer.isSubsumedOrEqual( rel ) )
+	     && ( edoal || (u1 != null && u2 != null) ) ) {
+	    generateConstruct(cell, (Expression) (cell.getObject1()), (Expression) (cell.getObject2()));
+	    //if (!oneway) {
+	    //    generateConstruct(cell, (Expression) (cell.getObject2()), (Expression) (cell.getObject1()));
+	    //}
         }
     }
 
@@ -163,17 +163,10 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor
         // rel.write( writer );
     }
 
-    public void visit(final Linkkey linkkey) throws AlignmentException {
-        throw new AlignmentException("NOT IMPLEMENTED !");
-    }
-
-    public void visit(final LinkkeyEquals linkkeyEquals) throws AlignmentException {
-        throw new AlignmentException("NOT IMPLEMENTED !");
-    }
-
-    public void visit(final LinkkeyIntersects linkkeyIntersects) throws AlignmentException {
-        throw new AlignmentException("NOT IMPLEMENTED !");
-    }
+    // No use of Link keys with construct
+    public void visit(final Linkkey linkkey) {}
+    public void visit(final LinkkeyEquals linkkeyEquals) {}
+    public void visit(final LinkkeyIntersects linkkeyIntersects) {}
 
     protected void generateConstruct( Cell cell, Expression expr1, Expression expr2 ) throws AlignmentException {
         // Here the generation is dependent on global variables
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java
index d35ed074..6c4b62a3 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/SWRLRendererVisitor.java
@@ -35,7 +35,6 @@ import org.semanticweb.owl.align.Relation;
 
 import fr.inrialpes.exmo.align.impl.ObjectAlignment;
 import fr.inrialpes.exmo.align.impl.URIAlignment;
-import fr.inrialpes.exmo.align.impl.rel.*;
 
 import fr.inrialpes.exmo.ontowrap.LoadedOntology;
 import fr.inrialpes.exmo.ontowrap.OntowrapException;
@@ -112,23 +111,23 @@ public class SWRLRendererVisitor extends IndentedRendererVisitor implements Alig
 	if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return;
 	// default behaviour
 	this.cell = cell;
-	cell.getRelation().accept( this );
-    }
-
-    public void visit( EquivRelation rel ) throws AlignmentException {
 	Object ob1 = cell.getObject1();
 	Object ob2 = cell.getObject2();
-	generateImplication( ob1, ob2 );
-	generateImplication( ob2, ob1 );
+	Relation rel = cell.getRelation();
+	if ( RelationTransformer.isEquivalence( rel ) ) {
+	    generateImplication( ob1, ob2 );
+	    generateImplication( ob2, ob1 );
+	} else if ( RelationTransformer.isSubsumedOrEqual( rel ) ) {
+	    generateImplication( ob1, ob2 );
+	} else if ( RelationTransformer.subsumesOrEqual( rel ) ) {
+	    generateImplication( ob2, ob1 );
+	} else if ( RelationTransformer.isDisjoint( rel ) ) {
+	    generateIncompatibility( ob1, ob2 );
+	} else rel.accept( this );
+	// SWRL
+	// isInstanceOf(), hasInstance()
     }
 
-    public void visit( SubsumeRelation rel ) throws AlignmentException {
-	generateImplication( cell.getObject2(), cell.getObject1() );
-    };
-    public void visit( SubsumedRelation rel ) throws AlignmentException {
-	generateImplication( cell.getObject1(), cell.getObject2() );
-    };
-
     public void generateImplication( Object ob1, Object ob2 ) throws AlignmentException {
 	// JE: We should send warnings when dataproperties are mapped to individual properties and vice versa...
 	try {
@@ -204,10 +203,7 @@ public class SWRLRendererVisitor extends IndentedRendererVisitor implements Alig
 	}
     }
 
-    public void visit( IncompatRelation rel ) throws AlignmentException {
-	// JE: We should send warnings when dataproperties are mapped to individual properties and vice versa...
-	Object ob1 = cell.getObject1();
-	Object ob2 = cell.getObject2();
+    public void generateIncompatibility( Object ob1, Object ob2 ) throws AlignmentException {
 	try {
 	    URI uri1 = onto1.getEntityURI( ob1 );
 	    URI uri2 = onto2.getEntityURI( ob2 );
@@ -292,7 +288,7 @@ public class SWRLRendererVisitor extends IndentedRendererVisitor implements Alig
     public void visit( Relation rel ) throws AlignmentException {
 	if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return;
 	// default behaviour
-	throw new AlignmentException( "Cannot render generic Relation" );
+	throw new AlignmentException( "Cannot render relation "+rel );
     }
 
 }
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java
index 43b98040..f25ec415 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java
@@ -35,7 +35,6 @@ import org.semanticweb.owl.align.AlignmentException;
 import org.semanticweb.owl.align.Cell;
 import org.semanticweb.owl.align.Relation;
 
-import fr.inrialpes.exmo.align.impl.rel.*;
 import fr.inrialpes.exmo.align.impl.ObjectAlignment;
 
 import fr.inrialpes.exmo.ontowrap.LoadedOntology;
@@ -133,7 +132,11 @@ public class XSLTRendererVisitor extends IndentedRendererVisitor implements Alig
 	if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return;
 	// default behaviour
 	this.cell = cell;
-	cell.getRelation().accept( this );
+	Relation rel = cell.getRelation();
+	if ( RelationTransformer.isEquivalence( rel )
+	     || RelationTransformer.isSubsumedOrEqual( rel ) ) {
+	    generateTransformation( cell );
+	}
     }
 
     private void collectURIs ( Cell cell ) throws AlignmentException {
@@ -164,7 +167,7 @@ public class XSLTRendererVisitor extends IndentedRendererVisitor implements Alig
 	}
     }
 
-    public void visit( EquivRelation rel ) throws AlignmentException {
+    public void generateTransformation( Cell cell ) throws AlignmentException {
 	// The code is exactly the same for properties and classes
 	if ( onto1 != null ){
 	    try {
@@ -192,9 +195,6 @@ public class XSLTRendererVisitor extends IndentedRendererVisitor implements Alig
 	return namespaces.get(ns)+":"+u.getFragment();
     }
 
-    public void visit( SubsumeRelation rel ){};
-    public void visit( SubsumedRelation rel ){};
-    public void visit( IncompatRelation rel ){};
     public void visit( Relation rel ) throws AlignmentException {
 	if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return;
 	// default behaviour
-- 
GitLab