From 27caeeb2ff1accc448b6ebc4aee09da56375288d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Mon, 1 Jun 2009 14:10:34 +0000 Subject: [PATCH] - updated to hierarchical storage of libraries - added pretty value management (server) - Corrected a bug when the server is launched without -S (server) --- build.xml | 44 +++--- html/relnotes.html | 19 ++- .../exmo/align/impl/Annotations.java | 3 +- .../exmo/align/impl/BasicAlignment.java | 12 +- .../impl/renderer/HTMLRendererVisitor.java | 8 +- .../align/service/AServProtocolManager.java | 64 +++++---- .../exmo/align/service/AlignmentId.java | 16 ++- .../exmo/align/service/AlignmentIds.java | 13 +- .../exmo/align/service/AlignmentService.java | 8 +- .../exmo/align/service/CacheImpl.java | 7 +- .../exmo/align/service/HTMLAServProfile.java | 125 +++++++++++------- 11 files changed, 207 insertions(+), 112 deletions(-) diff --git a/build.xml b/build.xml index b47a2455..bce786fd 100644 --- a/build.xml +++ b/build.xml @@ -14,22 +14,24 @@ <!-- tested --> <target name="usage" depends="init"> - <echo message="ant _target_ _options_"/> - <echo/> - <echo message="usage: this message"/> - <echo message="init: sets necessary variables"/> - <echo message="compile: incrementaly compiles sources"/> - <echo message="compileall: recompiles all sources"/> - <echo message="lint: compiles all sources with bug flags on"/> - <echo message="jar: archives compiled code"/> - <echo message="test: performs unit tests"/> - <echo message="zip: creates a new zip file"/> - <echo message="javadoc: generates documentation"/> - <echo message="release: releases a new version"/> - <echo message="svnbranch: copy the version under svn"/> - <echo message="clean: clean-up before release"/> - <echo/> - <echo message=" -Dversion=${version}"/> + <echo>ant _target_ _options_ + + usage: this message + init: sets necessary variables + upgrade: retrieve necessary libraries from other projects (local) + compile: incrementaly compiles sources + compileall: recompiles all sources + lint: compiles all sources with bug flags on + jar: archives compiled code + test: performs unit tests + zip: creates a new zip file + javadoc: generates documentation + release: releases a new version + svnbranch: copy the version under svn + clean: clean-up before release + + -Dversion=${version} + </echo> </target> <!-- tested --> @@ -54,6 +56,12 @@ </target> + <target name="upgrade"> + <copy file="../ontosim/lib/ontosim.jar" todir="lib/ontosim" + filtering="false"/> + <echo message="mappingapi is only updated from its directory"/> + </target> + <!-- tested --> <target name="compile" depends="init"> <echo message="Compiling..."/> @@ -122,7 +130,7 @@ <manifest> <attribute name="Built-Date" value="${TODAY}"/> <attribute name="Main-Class" value="fr.inrialpes.exmo.align.util.Procalign"/> - <attribute name="Class-Path" value="procalign.jar jwnl.jar"/> + <attribute name="Class-Path" value="procalign.jar jwnl/jwnl.jar"/> <attribute name="Implementation-Title" value="Alignment API WordNet support"/> <attribute name="Implementation-Version" value="${version}"/> </manifest> @@ -135,7 +143,7 @@ <manifest> <attribute name="Built-Date" value="${TODAY}"/> <attribute name="Main-Class" value="fr.inrialpes.exmo.align.service.AlignmentService"/> - <attribute name="Class-Path" value="procalign.jar alignwn.jar jade.jar iiop.jar http.jar mysql-connector-java-5.0.3-bin.jar servlet-api.jar jetty.jar jetty-util.jar"/> + <attribute name="Class-Path" value="procalign.jar alignwn.jar jade/jade.jar iiop.jar jade/http.jar jdbc/mysql-connector-java-5.0.3-bin.jar servlet/servlet-api.jar jetty/jetty.jar jetty/jetty-util.jar"/> <attribute name="Implementation-Title" value="Alignment server"/> <attribute name="Implementation-Version" value="${version}"/> </manifest> diff --git a/html/relnotes.html b/html/relnotes.html index ed81820e..c1d929c9 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -33,8 +33,6 @@ the main ruptures that will appear: support from OMWGAlignments which are currently based on Jena, (c) release of separated subpackages offering OWL API 1.0, OWL API 2.0, Jena 2.5, OLGraph and SKOS. (onto)</li> -<li>Addition of the notion of <tt>OntologyNetwork</tt> made of a set of - ontologies and alignments within the API.</li> <li>Creation of a different project, OntoSim, for supporting distances and similarities across ontologies. This project will adopt several parts of the current implementation part. It will have no impact on @@ -46,6 +44,7 @@ Other less radical changes include: <li>Implementation of <tt>Relation</tt> and <tt>Confidence</tt> interfaces </li> <li>Implement <tt>onto</tt> support in database store (server)</li> <li>Move <tt>OLgraphs</tt> as HeavyLoadedOntology (onto)</li> +<li>Integrate OWMG as part of the Alignment API code (impl)</li> <li>Implement database store for OMWG Language (server)</li> </ul> Currently the development and maintainance of 3 versions continue. @@ -58,8 +57,6 @@ Currently the development and maintainance of 3 versions continue. <li>Providing a <tt>DiffAlign( al1, al2 )</tt> operation and interface (util)</li> <li>Added get-aligned to interface (server)</li> -<li>Addition of the notion of <tt>OntologyNetwork</tt> made of a set of - ontologies and alignments within the API (api/impl/test).</li> <li>Improve HTML interface layout and usability (server)</li> <li>Implement metadata edition (server)</li> <li>Implement correspondence selection (server)</li> @@ -72,8 +69,16 @@ Currently the development and maintainance of 3 versions continue. <h2>Current SVN trunk version</h2> -<!--h2>Version 3.7/4.0 (95x): xx/09/2009 - Tring</h2--> -<!--h2>Version 3.7/4.0 (95x): xx/09/2009 - Rouquine carmélite</h2--> +<!--h2>Version 3.8/4.0/4.1 (1xxx): xx/09/2009 - Tring</h2--> +<!--h2>Version 3.7/4.0 (1xxx): xx/09/2009 - Rouquine carmélite</h2--> + +<p> +<ul compact="1"> +<li>Added pretty-printing of names in server (server)</li> +<li>Reorganised the lib directory hierarchically (build)</li> +<li>Corrected a bug when the server is launched without -S (server)</li> +</ul> +</p> <h2>Version 3.6 (988): 27/05/2009 - Sabai sabai</h2> @@ -89,6 +94,8 @@ If you want to stay with WordNet-2.0, you need to replace the jwnl.jar <ul compact="1"> <li><tt>tokenize</tt> has been moved from <tt>JWNLDistances</tt> to <tt>StringDistances</tt> (ling)</li> <li>Added REST interface to the HTML interface (server)</li> +<li>Addition of the notion of <tt>OntologyNetwork</tt> made of a set of + ontologies and alignments within the API (api/impl/test).</li> <li>Added new gap based (hardgap and propgap) methods in <tt>BasicAlignment.cut()</tt> (impl)</li> <li>Added new methods (Cosynonymy, Wu-Palmer) in JWNLDistances (ling)</li> <li>Added tests for ling and set noling as default in build (test)</li> diff --git a/src/fr/inrialpes/exmo/align/impl/Annotations.java b/src/fr/inrialpes/exmo/align/impl/Annotations.java index 5c99b4c8..8b3204d1 100644 --- a/src/fr/inrialpes/exmo/align/impl/Annotations.java +++ b/src/fr/inrialpes/exmo/align/impl/Annotations.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2008 + * Copyright (C) INRIA, 2008-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -26,6 +26,7 @@ public class Annotations { public static String METHOD = "method"; public static String TIME = "time"; public static String ID = "id"; + public static String PRETTY = "pretty"; /* Set to true for rejecting the use of deprecated (non deterministic) primitives */ public static boolean STRICT_IMPLEMENTATION = false; diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java index 030d1851..0a89a39e 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java @@ -646,11 +646,15 @@ public class BasicAlignment implements Alignment { for ( Object ext : ((BasicParameters)extensions).getValues() ){ result.setExtension( ((String[])ext)[0], ((String[])ext)[1], ((String[])ext)[2] ); } - String oldid = result.getExtension( Annotations.ALIGNNS, "id" ); + String oldid = result.getExtension( Annotations.ALIGNNS, Annotations.ID ); if ( oldid != null && !oldid.equals("") ) { result.setExtension( Annotations.ALIGNNS, "derivedFrom", oldid ); - result.getExtensions().unsetParameter( Annotations.ALIGNNS+"id" ); + result.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); } + String pretty = result.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pretty != null ){ + result.setExtension( Annotations.ALIGNNS, Annotations.PRETTY, pretty+"/inverted" ); + }; result.setExtension( Annotations.ALIGNNS, "method", "http://exmo.inrialpes.fr/align/impl/BasicAlignment#inverse" ); for ( Enumeration e = namespaces.getNames() ; e.hasMoreElements(); ){ String label = (String)e.nextElement(); @@ -696,10 +700,10 @@ public class BasicAlignment implements Alignment { for ( Object ext : ((BasicParameters)extensions).getValues() ){ align.setExtension( ((String[])ext)[0], ((String[])ext)[1], ((String[])ext)[2] ); } - String oldid = align.getExtension( Annotations.ALIGNNS, "id" ); + String oldid = align.getExtension( Annotations.ALIGNNS, Annotations.ID ); if ( oldid != null && !oldid.equals("") ) { align.setExtension( Annotations.ALIGNNS, "derivedFrom", oldid ); - align.getExtensions().unsetParameter( Annotations.ALIGNNS+"id" ); + align.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); } align.setExtension( Annotations.ALIGNNS, "method", this.getClass().getName()+"#clone" ); for ( Enumeration e = namespaces.getNames() ; e.hasMoreElements(); ){ diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java index 92d93ec0..d6d5946f 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java @@ -98,7 +98,13 @@ public class HTMLRendererVisitor implements AlignmentVisitor writer.print("\n xmlns:"+nslist.get(k)+"='"+k+"'"); } writer.print(">\n<head><title>Alignment</title></head>\n<body>\n"); - writer.print("<h1></h1>\n"); + String id = align.getExtension( Annotations.ALIGNNS, Annotations.ID ); + String pid = align.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) { + writer.print("<h1>"+id+"</h1>\n"); + } else { + writer.print("<h1>"+id+" ("+pid+")</h1>\n"); + } writer.print("<div typeof=\"align:Alignment\">\n"); writer.print("<h2>Alignment metadata</h2>\n"); writer.print("<table border=\"0\">\n"); diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 4f37bcc5..03e093e4 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -185,23 +185,29 @@ public class AServProtocolManager { file = (String)params.getParameter("filename"); if ( file != null && !file.equals("") ) name = "file://"+file; } - //if (debgug > 0) System.err.println("Preparing for "+name); - Alignment init = null; + //if ( debug > 0 ) System.err.println("Preparing for "+name); + Alignment al = null; try { - //if (debug > 0) System.err.println(" Parsing init"); + //if (debug > 0) System.err.println(" Parsing alignment"); AlignmentParser aparser = new AlignmentParser(0); - init = aparser.parse( name ); - //if (debug > 0) System.err.println(" Init parsed"); + al = aparser.parse( name ); + //if (debug > 0) System.err.println(" Alignment parsed"); } catch (Exception e) { return new UnreachableAlignment(newId(),mess,myId,mess.getSender(),name,(Parameters)null); } + // We preserve the pretty tag within the loaded ontology + String pretty = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pretty == null ) pretty = (String)params.getParameter("pretty"); + if ( pretty != null ) { + al.setExtension( Annotations.ALIGNNS, Annotations.PRETTY, pretty ); + } // register it - String id = alignmentCache.recordNewAlignment( init, true ); + String id = alignmentCache.recordNewAlignment( al, true ); // if the file has been uploaded: discard it - if ( init != null && file != null ) { + if ( al != null && al != null ) { // try unlink } - return new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); + return new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null,pretty); } // Implements: align @@ -269,9 +275,11 @@ public class AServProtocolManager { if ( alignments != null && params.getParameter("force") == null ) { for ( Iterator it = alignments.iterator(); it.hasNext() ; ){ Alignment al = ((Alignment)it.next()); - if ( al.getExtension( Annotations.ALIGNNS, Annotations.METHOD ).equals(method) ) - return new AlignmentId(newId(),mess,myId,mess.getSender(),al.getExtension( Annotations.ALIGNNS, Annotations.ID ),(Parameters)null); - + if ( al.getExtension( Annotations.ALIGNNS, Annotations.METHOD ).equals(method) ) { + return new AlignmentId(newId(),mess,myId,mess.getSender(), + al.getExtension( Annotations.ALIGNNS, Annotations.ID ),(Parameters)null, + al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ) ); + } } } return (Message)null; @@ -303,11 +311,12 @@ public class AServProtocolManager { return new ErrorMsg(newId(),mess,myId,mess.getSender(),"MalformedURI problem",(Parameters)null); }; //done below String msg = ""; - for( Iterator it = alignments.iterator(); it.hasNext(); ){ - msg += ((Alignment)it.next()).getExtension( Annotations.ALIGNNS, Annotations.ID ); - msg += " "; + String prettys = ""; + for ( Alignment al : alignments ) { + msg += al.getExtension( Annotations.ALIGNNS, Annotations.ID )+" "; + prettys += al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); } - return new AlignmentIds(newId(),mess,myId,mess.getSender(),msg,(Parameters)null); + return new AlignmentIds(newId(),mess,myId,mess.getSender(),msg,(Parameters)null,prettys); } // ABSOLUTELY NOT IMPLEMENTED @@ -430,7 +439,8 @@ public class AServProtocolManager { } // register by them // Could also be an AlreadyStoredAlignment error - return new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); + return new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null, + al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY )); } catch (Exception e) { return new UnknownAlignment(newId(),mess,myId,mess.getSender(),id,(Parameters)null); } @@ -487,8 +497,13 @@ public class AServProtocolManager { catch (AlignmentException e) { return new ErrorMsg(newId(),mess,myId,mess.getSender(),"dummy//",(Parameters)null); } + String pretty = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pretty != null ){ + al.setExtension( Annotations.ALIGNNS, Annotations.PRETTY, pretty+"/trimmed "+threshold ); + }; String newId = alignmentCache.recordNewAlignment( al, true ); - return new AlignmentId(newId(),mess,myId,mess.getSender(),newId,(Parameters)null); + return new AlignmentId(newId(),mess,myId,mess.getSender(),newId,(Parameters)null, + al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY )); } public Message harden( Message mess ){ @@ -512,7 +527,8 @@ public class AServProtocolManager { return new ErrorMsg(newId(),mess,myId,mess.getSender(),"dummy//",(Parameters)null); } String newId = alignmentCache.recordNewAlignment( al, true ); - return new AlignmentId(newId(),mess,myId,mess.getSender(),newId,(Parameters)null); + return new AlignmentId(newId(),mess,myId,mess.getSender(),newId,(Parameters)null, + al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY )); } public Message meet( Message mess ){ @@ -894,16 +910,15 @@ public class AServProtocolManager { java.lang.reflect.Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); AlignmentProcess aresult = (AlignmentProcess)alignmentConstructor.newInstance(mparams); try { - aresult.init( uri1, uri2 ); - long time = System.currentTimeMillis(); - aresult.align( init, params ); // add opts - long newTime = System.currentTimeMillis(); - aresult.setExtension( Annotations.ALIGNNS, Annotations.TIME, Long.toString(newTime - time) ); + aresult.setExtension( Annotations.ALIGNNS, Annotations.TIME, Long.toString(newTime - time) ); + String pretty = (String)params.getParameter( "pretty" ); + if ( pretty != null ) + aresult.setExtension( Annotations.ALIGNNS, Annotations.PRETTY, pretty ); } catch (AlignmentException e) { // The unreachability test has already been done // JE 15/1/2009: commented the unreachability test @@ -918,7 +933,8 @@ public class AServProtocolManager { } // ask to store A' alignmentCache.recordNewAlignment( id, aresult, true ); - result = new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); + result = new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null, + aresult.getExtension( Annotations.ALIGNNS, Annotations.PRETTY )); } catch (ClassNotFoundException e) { result = new RunTimeError(newId(),mess,myId,mess.getSender(),"Class not found: "+method,(Parameters)null); } catch (NoSuchMethodException e) { diff --git a/src/fr/inrialpes/exmo/align/service/AlignmentId.java b/src/fr/inrialpes/exmo/align/service/AlignmentId.java index 2b18a032..80fe7cad 100644 --- a/src/fr/inrialpes/exmo/align/service/AlignmentId.java +++ b/src/fr/inrialpes/exmo/align/service/AlignmentId.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2008 + * Copyright (C) INRIA, 2006-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -33,10 +33,16 @@ public class AlignmentId extends Success { public AlignmentId ( int surr, Message rep, String from, String to, String cont, Parameters param ) { super( surr, rep, from, to, cont, param ); } + public AlignmentId ( int surr, Message rep, String from, String to, String cont, Parameters param, String pretty ) { + super( surr, rep, from, to, cont, param ); + this.pretty = pretty; + } public String getPretty( String alid ) { - // getextension "pretty" - // if no pretty then - return alid; + if ( pretty == null ) { + return alid; + } else { + return alid+" ("+pretty+")"; + } }; public String HTMLString(){ return "Alignment ID: <a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+getContent()+"\">"+getPretty(getContent())+"</a> "; @@ -45,7 +51,7 @@ public class AlignmentId extends Success { return "Alignment ID: <a href=\"../rest/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+getContent()+"\">"+getPretty(getContent())+"</a> "; } public String RESTString(){ - return "<alid>"+content+"</alid>"; + return "<alid>"+getContent()+"</alid>"; } } diff --git a/src/fr/inrialpes/exmo/align/service/AlignmentIds.java b/src/fr/inrialpes/exmo/align/service/AlignmentIds.java index e0485e0d..a6eed356 100644 --- a/src/fr/inrialpes/exmo/align/service/AlignmentIds.java +++ b/src/fr/inrialpes/exmo/align/service/AlignmentIds.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2008 + * Copyright (C) INRIA, 2006-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -28,14 +28,23 @@ import org.semanticweb.owl.align.Parameters; public class AlignmentIds extends Success { + String pretty = null; + public AlignmentIds ( int surr, Message rep, String from, String to, String cont, Parameters param ) { super( surr, rep, from, to, cont, param ); } + public AlignmentIds ( int surr, Message rep, String from, String to, String cont, Parameters param, String pretty ) { + super( surr, rep, from, to, cont, param ); + this.pretty = pretty; + } public String HTMLString(){ String result = "Alignment Ids: <ul>"; String id[] = content.split(" "); + String pid[] = pretty.split("???"); for ( int i = id.length-1; i >= 0; i-- ){ - result += "<li><a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+id[i]+"\">"+id[i]+"</a></li>"; + result += "<li><a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+id[i]+"\">"; + if ( pid != null && !pid[i].equals("") ) result += " ("+pid[i]+")"; + result += "</a></li>"; } return result += "</ul>"; } diff --git a/src/fr/inrialpes/exmo/align/service/AlignmentService.java b/src/fr/inrialpes/exmo/align/service/AlignmentService.java index 5847aaad..a99d758f 100644 --- a/src/fr/inrialpes/exmo/align/service/AlignmentService.java +++ b/src/fr/inrialpes/exmo/align/service/AlignmentService.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2008 + * Copyright (C) INRIA, 2006-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -116,11 +116,11 @@ public class AlignmentService { // Connect database if( DBMS.equals("postgres") ) { - System.err.println("postgres"); + if ( debug > 0 ) System.err.println("postgres driver"); DBPORT = "5432"; connection = new DBServiceImpl( "org.postgresql.Driver" , "jdbc:postgresql", DBPORT ); } else { - System.err.println("mysql"); + if ( debug > 0 ) System.err.println("mysql driver"); DBPORT = "3306"; connection = new DBServiceImpl( "com.mysql.jdbc.Driver" , "jdbc:mysql", DBPORT ); } @@ -206,6 +206,8 @@ public class AlignmentService { public Parameters readParameters( String[] args ) { Parameters params = new BasicParameters(); + // Default values + params.setParameter( "host", HOST ); // Read parameters diff --git a/src/fr/inrialpes/exmo/align/service/CacheImpl.java b/src/fr/inrialpes/exmo/align/service/CacheImpl.java index 0ebc5213..54a78af5 100644 --- a/src/fr/inrialpes/exmo/align/service/CacheImpl.java +++ b/src/fr/inrialpes/exmo/align/service/CacheImpl.java @@ -2,7 +2,7 @@ * $Id$ * * Copyright (C) Seungkeun Lee, 2006 - * Copyright (C) INRIA Rhône-Alpes, 2006-2008 + * Copyright (C) INRIA, 2006-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -25,6 +25,7 @@ import java.util.Enumeration; import java.util.Iterator; import java.util.Hashtable; import java.util.Vector; +import java.util.Collection; import java.util.Set; import java.util.HashSet; import java.util.Date; @@ -198,6 +199,10 @@ public class CacheImpl { return alignmentTable.elements(); } + protected Collection<Alignment> alignments() { + return alignmentTable.values(); + } + protected void flushCache() {// throws AlignmentException for ( Alignment al : alignmentTable.values() ){ if ( al.getExtension( SVCNS, CACHED ) != "" diff --git a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java index 3b3e812b..465ffbb9 100644 --- a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java @@ -1,4 +1,4 @@ - /* +/* * $Id$ * * Copyright (C) INRIA, 2006-2009. @@ -401,29 +401,32 @@ public class HTMLAServProfile implements AlignmentServiceProfile { if ( perf.equals("listalignments") ){ msg = "<h1>Available alignments</h1><ul compact=\"1\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID ); - msg += "<li><a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+id+"\">"+id+"</a></li>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID ); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<li><a href=\"../html/retrieve?method=fr.inrialpes.exmo.align.impl.renderer.HTMLRendererVisitor&id="+id+"\">"+pid+"</a></li>"; } msg += "</ul>"; } else if ( perf.equals("listmethods") ){ msg = "<h1>Embedded classes</h1>\n<h2>Methods</h2><ul compact=\"1\">"; - for( Iterator it = manager.listmethods().iterator(); it.hasNext(); ) { - msg += "<li>"+it.next()+"</li>"; + for( String m : manager.listmethods() ) { + msg += "<li>"+m+"</li>"; } msg += "</ul>"; msg += "<h2>Renderers</h2><ul compact=\"1\">"; - for( Iterator it = manager.listrenderers().iterator(); it.hasNext(); ) { - msg += "<li>"+it.next()+"</li>"; + for( String m : manager.listrenderers() ) { + msg += "<li>"+m+"</li>"; } msg += "</ul>"; msg += "<h2>Services</h2><ul compact=\"1\">"; - for( Iterator it = manager.listservices().iterator(); it.hasNext(); ) { - msg += "<li>"+it.next()+"</li>"; + for( String m : manager.listservices() ) { + msg += "<li>"+m+"</li>"; } msg += "</ul>"; msg += "<h2>Evaluators</h2><ul compact=\"1\">"; - for( Iterator it = manager.listevaluators().iterator(); it.hasNext(); ) { - msg += "<li>"+it.next()+"</li>"; + for( String m : manager.listevaluators() ) { + msg += "<li>"+m+"</li>"; } msg += "</ul>"; } else if ( perf.equals("prmsqlquery") ){ @@ -494,7 +497,9 @@ public class HTMLAServProfile implements AlignmentServiceProfile { String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); params.setParameter("id", id); if ( !manager.storedAlignment( new Message(newId(),(Message)null,myId,serverId,"", params ) ) ){ - msg += "<option value=\""+id+"\">"+id+"</option>"; + String pid = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } } msg += "</select><br />"; @@ -525,11 +530,14 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg ="<h1>Trim alignments</h1><form action=\"cut\">"; msg += "Alignment id: <select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; if ( sel != null && sel.equals( id ) ){ - msg += "<option selected=\"1\" value=\""+id+"\">"+id+"</option>"; + msg += "<option selected=\"1\" value=\""+id+"\">"+pid+"</option>"; } else { - msg += "<option value=\""+id+"\">"+id+"</option>"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } } msg += "</select><br />"; @@ -550,8 +558,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg ="<h1>Inverse alignment</h1><form action=\"inv\">"; msg += "Alignment id: <select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br />"; msg += "<input type=\"submit\" name=\"action\" value=\"Invert\"/><br /></form>"; @@ -572,22 +583,25 @@ public class HTMLAServProfile implements AlignmentServiceProfile { String readonlyOnto = ""; //Ontologies from Cupboard may be already provided here. if((String)params.getParameter("restful") != null && ((String)params.getParameter("renderer")).equals("HTML") ){ - RESTOnto1 = (String)params.getParameter("onto1"); - RESTOnto2 = (String)params.getParameter("onto2"); - //if(RESTOnto1 != null && !RESTOnto1.equals("") && RESTOnto2 != null && !RESTOnto2.equals("")) - readonlyOnto = "readonly=\"readonly\""; - } - msg ="<h1>Match ontologies</h1><form action=\"match\">Ontology 1: <input type=\"text\" name=\"onto1\" size=\"80\" value="+RESTOnto1+ " " + readonlyOnto+"> (uri)<br />Ontology 2: <input type=\"text\" name=\"onto2\" size=\"80\" value="+RESTOnto2+ " " + readonlyOnto+ "> (uri)<br /><small>These are the URL of places where to find these ontologies. They must be reachable by the server (i.e., file:// URI are acceptable if they are on the server)</small><br /><!--input type=\"submit\" name=\"action\" value=\"Find\"/><br /-->Methods: <select name=\"method\">"; - for( Iterator it = manager.listmethods().iterator(); it.hasNext(); ) { - String id = (String)it.next(); + RESTOnto1 = (String)params.getParameter("onto1"); + RESTOnto2 = (String)params.getParameter("onto2"); + //if(RESTOnto1 != null && !RESTOnto1.equals("") && RESTOnto2 != null && !RESTOnto2.equals("")) + readonlyOnto = "readonly=\"readonly\""; + } + msg ="<h1>Match ontologies</h1><form action=\"match\">Ontology 1: <input type=\"text\" name=\"onto1\" size=\"80\" value="+RESTOnto1+" " +readonlyOnto+"> (uri)<br />Ontology 2: <input type=\"text\" name=\"onto2\" size=\"80\" value="+RESTOnto2+" "+readonlyOnto+ "> (uri)<br /><small>These are the URL of places where to find these ontologies. They must be reachable by the server (i.e., file:// URI are acceptable if they are on the server)</small><br /><!--input type=\"submit\" name=\"action\" value=\"Find\"/><br /-->Methods: <select name=\"method\">"; + for( String id : manager.listmethods() ) { msg += "<option value=\""+id+"\">"+id+"</option>"; } msg += "</select><br />Initial alignment id: <select name=\"id\"><option value=\"\" selected=\"1\"></option>"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br />"; + msg += "Pretty name: <input type=\"text\" name=\"pretty\" size=\"80\"/><br />"; msg += "<input type=\"submit\" name=\"action\" value=\"Match\"/>"; msg += " <input type=\"checkbox\" name=\"force\" /> Force <input type=\"checkbox\" name=\"async\" /> Asynchronous<br />"; msg += "Additional parameters:<br /><input type=\"text\" name=\"paramn1\" size=\"15\"/> = <input type=\"text\" name=\"paramv1\" size=\"65\"/><br /><input type=\"text\" name=\"paramn2\" size=\"15\"/> = <input type=\"text\" name=\"paramv2\" size=\"65\"/><br /><input type=\"text\" name=\"paramn3\" size=\"15\"/> = <input type=\"text\" name=\"paramv3\" size=\"65\"/><br /><input type=\"text\" name=\"paramn4\" size=\"15\"/> = <input type=\"text\" name=\"paramv4\" size=\"65\"/></form>"; @@ -614,17 +628,19 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg = "<h1>Retrieve alignment</h1><form action=\"retrieve\">"; msg += "Alignment id: <select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; if ( sel != null && sel.equals( id ) ){ - msg += "<option selected=\"1\" value=\""+id+"\">"+id+"</option>"; + msg += "<option selected=\"1\" value=\""+id+"\">"+pid+"</option>"; } else { - msg += "<option value=\""+id+"\">"+id+"</option>"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } } msg += "</select><br />"; msg += "Rendering: <select name=\"method\">"; - for( Iterator it = manager.listrenderers().iterator(); it.hasNext(); ) { - String id = (String)it.next(); + for( String id : manager.listrenderers() ) { msg += "<option value=\""+id+"\">"+id+"</option>"; } msg += "</select><br /><input type=\"submit\" value=\"Retrieve\"/></form>"; @@ -642,8 +658,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg = "<h1>Retrieve alignment metadata</h1><form action=\"metadata\">"; msg += "Alignment id: <select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br /><input type=\"submit\" value=\"Get metadata\"/></form>"; } else if ( perf.equals("metadata") ) { @@ -663,13 +682,14 @@ public class HTMLAServProfile implements AlignmentServiceProfile { // Alignment in HTML can be rendre or metadata+tuples } else if ( perf.equals("prmload") ) { // Should certainly be good to offer store as well - msg = "<h1>Load an alignment</h1><form action=\"load\">Alignment URL: <input type=\"text\" name=\"url\" size=\"80\"/> (uri)<br /><small>This is the URL of the place where to find this alignment. It must be reachable by the server (i.e., file:// URI is acceptable if it is on the server).</small><br /><input type=\"submit\" value=\"Load\"/></form>"; + msg = "<h1>Load an alignment</h1><form action=\"load\">Alignment URL: <input type=\"text\" name=\"url\" size=\"80\"/> (uri)<br /><small>This is the URL of the place where to find this alignment. It must be reachable by the server (i.e., file:// URI is acceptable if it is on the server).</small><br />Pretty name: <input type=\"text\" name=\"pretty\" size=\"80\"/><br /><input type=\"submit\" value=\"Load\"/></form>"; //msg += "Alignment file: <form ENCTYPE=\"text/xml; charset=utf-8\" action=\"loadfile\" method=\"POST\">"; msg += "Alignment file: <form enctype=\"multipart/form-data\" action=\"load\" method=\"POST\">"; - msg += " <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\""+MAX_FILE_SIZE+"\"/>"; + msg += "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\""+MAX_FILE_SIZE+"\"/>"; msg += "<input name=\"content\" type=\"file\" size=\"35\">"; msg += "<br /><small>NOTE: Max file size is "+(MAX_FILE_SIZE/1024)+"KB; this is experimental but works</small><br />"; - msg += " <input type=\"submit\" Value=\"Upload\">"; + msg += "Pretty name: <input type=\"text\" name=\"pretty\" size=\"80\"/><br />"; + msg += "<input type=\"submit\" Value=\"Upload\">"; msg += " </form>"; } else if ( perf.equals("load") ) { // load @@ -684,8 +704,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg = "<h1>Translate query</h1><form action=\"translate\">"; msg += "Alignment id: <select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br />"; msg += "SPARQL query:<br /> <textarea name=\"query\" rows=\"20\" cols=\"80\">PREFIX foaf: <http://xmlns.com/foaf/0.1/>\nSELECT *\nFROM <>\nWHERE {\n\n}</textarea> (SPARQL)<br /><small>A SPARQL query (PREFIX prefix: <uri> SELECT variables FROM <url> WHERE { triples })</small><br /><input type=\"submit\" value=\"Translate\"/></form>"; @@ -704,8 +727,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg = "<h1>Retrieve alignment metadata</h1><form action=\"metadata\">"; msg += "Alignment id: <select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br /><input type=\"submit\" value=\"Get metadata\"/></form>"; } else if ( perf.equals("metadata") ) { @@ -724,21 +750,26 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg += "Alignment to evaluate: "; msg += "<select name=\"id\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br />"; msg +="Reference alignment: "; msg += "<select name=\"ref\">"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); - msg += "<option value=\""+id+"\">"+id+"</option>"; + Alignment al = (Alignment)e.nextElement(); + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + msg += "<option value=\""+id+"\">"+pid+"</option>"; } msg += "</select><br />"; msg += "Evaluator: "; msg += "<select name=\"method\">"; - for( Iterator it = manager.listevaluators().iterator(); it.hasNext(); ) { - String id = (String)it.next(); + for( String id : manager.listevaluators() ) { msg += "<option value=\""+id+"\">"+id+"</option>"; } msg += "<br /><input type=\"submit\" name=\"action\" value=\"Evaluate\"/>\n"; -- GitLab