From 1799d12e7aa6b502383b41547dc9bd073cb61be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Mon, 12 Jul 2010 19:46:06 +0000 Subject: [PATCH] - implemented Diff in interface --- .../align/service/AServProtocolManager.java | 23 ++++++------------- .../exmo/align/service/EvalResult.java | 13 +++++++---- .../exmo/align/service/HTMLAServProfile.java | 6 +++-- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 27493a8d..d95e4770 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -29,6 +29,7 @@ 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.util.DiffAlign; +import fr.inrialpes.exmo.align.impl.eval.DiffEvaluator; import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontowrap.Ontology; @@ -615,24 +616,14 @@ public class AServProtocolManager { } catch (Exception e) { return new UnknownAlignment(newId(),mess,myId,mess.getSender(),"unknown/Alignment/"+id2,(Properties)null); } - // Set the comparison method - // Should be rewritted with diff -- no choice - /* - DiffAlign eval = new DiffAlign( al1, al2 ); - // Compare it - try { eval.eval( params ); } - catch (AlignmentException e) { + try { + DiffEvaluator diff = new DiffEvaluator( al1, al2 ); + diff.eval( params ); + // This will only work with HTML + return new EvalResult(newId(),mess,myId,mess.getSender(),diff.HTMLString(),(Properties)null); + } catch (AlignmentException e) { return new ErrorMsg(newId(),mess,myId,mess.getSender(),"dummy//",(Properties)null); } - // Return it, not easy - StringWriter sw = new StringWriter(); - try { - eval.write( new PrintWriter( sw ) ); - } catch (IOException ioex) {}; // never occurs - // Should not be alignment evaluation results... - return new EvaluationId(newId(),mess,myId,mess.getSender(),sw.toString(),(Properties)null); - */ - return new ErrorMsg(newId(),mess,myId,mess.getSender(),"Not yet implented",(Properties)null); } /** diff --git a/src/fr/inrialpes/exmo/align/service/EvalResult.java b/src/fr/inrialpes/exmo/align/service/EvalResult.java index 5f67f255..e3ccea30 100644 --- a/src/fr/inrialpes/exmo/align/service/EvalResult.java +++ b/src/fr/inrialpes/exmo/align/service/EvalResult.java @@ -32,11 +32,16 @@ public class EvalResult extends Success { super( surr, rep, from, to, cont, param ); } public String HTMLString(){ - String results = "Alignment method: "+getContent()+"\n<ul>\n"; - for ( String key : getParameters().stringPropertyNames() ) { - results += "<li>"+key+" : "+getParameters().getProperty( key )+"</li>\n"; + String results = ""; + if ( getParameters() == null ) { + results += getContent(); + } else { + results += "Alignment method: "+getContent()+"\n<ul>\n"; + for ( String key : getParameters().stringPropertyNames() ) { + results += "<li>"+key+" : "+getParameters().getProperty( key )+"</li>\n"; + } + results += "</ul>\n"; } - results += "</ul>\n"; return results; } public String RESTString(){ diff --git a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java index 30a27c10..77c74013 100644 --- a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java @@ -196,8 +196,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { // e.g., it uses /tmp and keeps the files filter.doFilter( request, dummyResponse, new Chain() ); // Extract parameters from response + if ( request.getAttribute("pretty") != null ) + params.setProperty( "pretty", request.getAttribute("pretty").toString() ); if ( request.getAttribute("content") != null ) params.setProperty( "filename", request.getAttribute("content").toString() ); + //System.err.println( " >>>> Read: "+params.getProperty( "pretty" ) ); filter.destroy(); } else if ( mimetype != null && mimetype.startsWith("text/xml") ) { // Most likely Web service request (REST through POST) @@ -778,8 +781,6 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else { msg = "<h1>Evaluation results</h1>"; msg += displayAnswer( answer, params ); - // This should be nice here to provide the oportunity to diff them - // This needs to pass arguments... and to get them on the other side. } } else if ( perf.equals("saveeval") ) { } else if ( perf.equals("prmgrpeval") ) { @@ -828,6 +829,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg += "<form action=\"prmstore\"><button title=\"Persistently store an alignent in this server\" type=\"submit\" >Store alignment</button></form>"; msg += "<form action=\"prmretrieve\"><button title=\"Render an alignment in a particular format\" type=\"submit\">Render alignment</button></form>"; msg += "<form action=\"prmeval\"><button title=\"Evaluation of an alignment\" type=\"submit\">Evaluate alignment</button></form>"; + msg += "<form action=\"prmdiff\"><button title=\"Compare two alignments\" type=\"submit\">Compare alignment</button></form>"; msg += "<form action=\"../admin/\"><button style=\"background-color: lightpink;\" title=\"Server management functions\" type=\"submit\">Server management</button></form>"; } else { msg = "Cannot understand command "+perf; -- GitLab