From 9e82e981075267f761be5028565ecb6c6e9dd630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Wed, 25 Jul 2012 09:06:57 +0000 Subject: [PATCH] - implemented selection in alignment list --- html/relnotes.html | 2 + .../align/service/AServProtocolManager.java | 15 ++--- .../exmo/align/service/CacheImpl.java | 20 ++++-- .../exmo/align/service/HTMLAServProfile.java | 65 +++++++++++-------- .../exmo/align/service/WSAServProfile.java | 2 +- 5 files changed, 59 insertions(+), 45 deletions(-) diff --git a/html/relnotes.html b/html/relnotes.html index 060b2dd7..d862123f 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -67,6 +67,8 @@ with a warning: <!--h2>Version 4.5 (17xx): ??/??/2012 - Al pesto</h2--> <p><ul compact="1"> <!--li>Upgraded to <span style="color: green"></span> (lib)</li--> +<li>Added alignment selection per ontologies in list alignment interface (server)</li> +<li>Fixed a bug with subsumption statements in <tt>OWLAxiomsRendererVisitor</tt> (impl)</li> </ul></p> <h2>Version 4.4 (1754): 17/07/2012 - Casa Cirilo</h2> diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index f6e5f8e6..80ec35dd 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -192,15 +192,12 @@ public class AServProtocolManager { return alignmentCache.alignments(); } - public Collection<Alignment> alignments( String uri1, String uri2 ) { - if ( uri1 != null || uri2 != null ) { - try { - URI u1 = (uri1==null)?null:new URI( uri1 ); - URI u2 = (uri2==null)?null:new URI( uri2 ); - return alignmentCache.alignments( u1, u2 ); - } catch ( URISyntaxException usex ) {} // - } - return alignmentCache.alignments(); + public Collection<URI> ontologies() { + return alignmentCache.ontologies(); + } + + public Collection<Alignment> alignments( URI uri1, URI uri2 ) { + return alignmentCache.alignments( uri1, uri2 ); } public String query( String query ){ diff --git a/src/fr/inrialpes/exmo/align/service/CacheImpl.java b/src/fr/inrialpes/exmo/align/service/CacheImpl.java index 1fa55dc7..5925c7d5 100644 --- a/src/fr/inrialpes/exmo/align/service/CacheImpl.java +++ b/src/fr/inrialpes/exmo/align/service/CacheImpl.java @@ -191,22 +191,28 @@ public class CacheImpl { return alignmentTable.values(); } + protected Collection<URI> ontologies() { + return ontologyTable.keySet(); + } + protected Collection<Alignment> alignments( URI u1, URI u2 ) { Collection<Alignment> results = new HashSet<Alignment>(); if ( u1 != null ) { for ( Alignment al : ontologyTable.get( u1 ) ) { try { - if ( al.getOntology1URI().equals( u1 ) ) { - if ( u2 == null ) results.add( al ); - else if ( al.getOntology2URI().equals( u2 ) ) results.add( al ); - } + // if ( al.getOntology1URI().equals( u1 ) ) { + if ( u2 == null ) results.add( al ); + else if ( al.getOntology2URI().equals( u2 ) + || al.getOntology1URI().equals( u2 )) results.add( al ); + // } } catch (AlignmentException alex) {} // ignore } } else if ( u2 != null ) { for ( Alignment al : ontologyTable.get( u2 ) ) { - try { - if ( al.getOntology2URI().equals( u2 ) ) results.add( al ); - } catch (AlignmentException alex) {} // ignore + //try { + // if ( al.getOntology2URI().equals( u2 ) ) + results.add( al ); + //} catch (AlignmentException alex) {} // ignore } } else { results = alignmentTable.values(); } return results; diff --git a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java index d8457384..6e18cf2e 100644 --- a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java @@ -53,6 +53,8 @@ import java.util.Enumeration; import java.util.Iterator; import java.util.Map; +import java.net.URI; +import java.net.URISyntaxException; import java.net.Socket; import java.net.ServerSocket; import java.net.URLEncoder; @@ -474,40 +476,47 @@ public class HTMLAServProfile implements AlignmentServiceProfile { // REST get String msg = ""; if ( perf.equals("listalignments") ) { - String uri1 = params.getProperty("uri1"); - String uri2 = params.getProperty("uri2"); + URI uri1 = null; + String u1 = params.getProperty("uri1"); + try { + if ( u1 != null && !u1.equals("all") ) uri1 = new URI( u1 ); + } catch ( URISyntaxException usex ) {}; // take all + URI uri2 = null; + String u2 = params.getProperty("uri2"); + try { + if ( u2 != null && !u2.equals("all") ) uri2 = new URI( u2 ); + } catch ( URISyntaxException usex ) {}; // take all // Add two onto checklist + Collection<URI> ontologies = manager.ontologies(); msg = "<h1>Available alignments</h1><form action=\"listalignments\">"; - /* - msg += "Onto1: <select name=\"uri1\"><option value=\"all\" selected=\"1\">all</option>"; - for ( Alignment al : manager.alignments() ) { // onto - // I NEED TO GET THE ONTOLOGIES THERE... - String id = al.getExtension( Namespace.ALIGNMENT.uri, Annotations.ID); - params.setProperty("id", id); - if ( manager.storedAlignment( new Message(newId(),(Message)null,myId,serverId,"", params ) ) ){ - String pid = al.getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ); - if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; - msg += "<option value=\""+id+"\">"+pid+"</option>"; - } + msg += "Onto1: <select name=\"uri1\"><option value=\"all\""; + if ( uri1 == null ) msg += " selected=\"1\""; + msg += ">all</option>"; + for ( URI ont : ontologies ) { + msg += "<option"; + if ( ont.equals( uri1 ) ) msg += " selected =\"1\""; + msg += " value=\""+ont+"\">"+ont+"</option>"; //simplify } msg += "</select>"; - msg += "Onto2: <select name=\"uri2\"><option value=\"all\" selected=\"1\">all</option>"; - for ( Alignment al : manager.alignments() ) { // onto - String id = al.getExtension( Namespace.ALIGNMENT.uri, Annotations.ID); - params.setProperty("id", id); - if ( manager.storedAlignment( new Message(newId(),(Message)null,myId,serverId,"", params ) ) ){ - String pid = al.getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ); - if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; - msg += "<option value=\""+id+"\">"+pid+"</option>"; - } + msg += "Onto2: <select name=\"uri2\"><option value=\"all\""; + if ( uri2 == null ) msg += " selected=\"1\""; + msg += ">all</option>"; + for ( URI ont : ontologies ) { + msg += "<option"; + if ( ont.equals( uri2 ) ) msg += " selected =\"1\""; + msg += " value=\""+ont+"\">"+ont+"</option>"; //simplify } msg += "</select>"; - msg += " <input type=\"submit\" value=\"Update\"/></form><ul compact=\"1\">"; - if ( uri1 != null && uri1.equals("all") ) uri1 = null; - if ( uri2 != null && uri2.equals("all") ) uri2 = null; - //To be implemented - */ - for ( Alignment al : manager.alignments( uri1, uri2 ) ) { + msg += " <input type=\"submit\" value=\"Restrict\"/></form><ul compact=\"1\">"; + // would be better as a JavaScript which updates + Collection<Alignment> alignments = null; + if ( uri1 == null && uri2 == null ) { + alignments = manager.alignments(); + } else { + alignments = manager.alignments( uri1, uri2 ); + } + + for ( Alignment al : alignments ) { String id = al.getExtension( Namespace.ALIGNMENT.uri, Annotations.ID ); String pid = al.getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; diff --git a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java index 26fb853d..3bc3acab 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java @@ -192,7 +192,7 @@ public class WSAServProfile implements AlignmentServiceProfile { /** * HTTP protocol implementation * each call of the protocol is a direct URL - * and the answer is through the resulting page (RDF? SOAP? HTTP?) + * and the answer is through the resulting page (RDF? SOAP? HTTP? JSON?) * Not implemented yet * but reserved if appears useful */ -- GitLab