diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 6c3486d93210131097e02526667a6104b2af15a8..61e5245910a8e2066c4047db1d367abeb66a8e9c 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -1418,8 +1418,8 @@ public List<Message> alignonet( Properties params ) { } - /* TO VERIFY - public Message alignonet( Properties params ) { + // TO VERIFY + public Message alignonet2( Properties params ) { //parameters: onID, method, reflexive, symmetric OntologyNetwork noo = null; @@ -1435,6 +1435,7 @@ public List<Message> alignonet( Properties params ) { } catch (AlignmentException e1) { return new UnknownOntologyNetwork( params, newId(), serverId,id ); } + logger.debug(" Before Network alignments results, id: {} total ontologies: {} total alignments: {}",id, noo.getOntologies().size(),noo.getAlignments().size()); try { ((BasicOntologyNetwork) noo).match(method, reflexive, symmetric); @@ -1448,7 +1449,32 @@ public List<Message> alignonet( Properties params ) { } - */ + + public Message trimonet( Properties params ) { + + //parameters: onID, method, reflexive, symmetric + OntologyNetwork noo = null; + OntologyNetwork nooClone = null; + String id = params.getProperty("id"); + String method = params.getProperty("type"); + double threshold = Double.parseDouble(params.getProperty("threshold")); + + try { + noo = alignmentCache.getOntologyNetwork( id ); + //nooClone = (OntologyNetwork) ((Hashtable<URI, OntologyNetwork>) noo)).clone(); + } catch (AlignmentException e1) { + return new UnknownOntologyNetwork( params, newId(), serverId,id ); + } + + try { + ((BasicOntologyNetwork) noo).trim(method, threshold); + } catch (AlignmentException e) { + return new ErrorMsg( params, newId(), serverId,"Network alignment error" ); + } + return new OntologyNetworkId( params, newId(), serverId, id, + ((BasicOntologyNetwork) noo).getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY )); + } + public Message listNetworkOntology( Properties params ) { //not UsED?? String result = ""; diff --git a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java index fddd19dde055686e8c55669019bd25998a4291c7..ee2fdec4b3578ed12285b6f6aea9a1ae8566cae9 100644 --- a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java @@ -349,9 +349,38 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg += "</select><br />"; msg += "<br /><input type=\"submit\" value=\"Store\"/></form>"; + } else if ( perf.equals("prmtrimonet") ){ + + String sel = params.getProperty("id"); + msg ="<h1>Trim networks</h1><form action=\"trimonet\">"; + msg += "Network: <select name=\"id\">"; + for ( OntologyNetwork on : manager.ontologyNetworks() ) { + String id = ((BasicOntologyNetwork)on).getExtension( Namespace.ALIGNMENT.uri, Annotations.ID ); //TODO eliminate BasicOntologyNetwork + String pid = ((BasicOntologyNetwork)on).getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ); //TODO eliminate BasicOntologyNetwork + if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; + if ( sel != null && sel.equals( id ) ){ + msg += "<option selected=\"1\" value=\""+id+"\">"+pid+"</option>"; + } else { msg += "<option value=\""+id+"\">"+pid+"</option>";} + } + msg += "</select><br />"; + msg += "Type: <select name=\"type\"><option value=\"hard\">hard</option><option value=\"perc\">perc</option><option value=\"best\">best</option><option value=\"span\">span</option><option value=\"prop\">prop</option></select><br />Threshold: <input type=\"text\" name=\"threshold\" size=\"4\"/> <small>A value between 0. and 1. with 2 digits</small><br /><input type=\"submit\" name=\"action\" value=\"Trim\"/><br /></form>"; + + } else if ( perf.equals("trimonet") ){ + Message answer = manager.trimonet( params ); + if ( answer instanceof ErrorMsg ) { + System.out.println("answer error "); + msg = testErrorMessages( answer, params, eSource ); + } else { + msg ="<h1>Trimed network</h1><form action=\"trimonet\">"; + msg += "<a href=\"" + answer.getContent() +"\">" + answer.getContent() + "</a>"; + + System.out.println("answer: "+ answer.getContent()); + } + } else if ( perf.equals("prmmatchonet") ){ msg = "<h1>Match an ontology network</h1><form action=\"matchonet\">"; + msg += "<h2><font color=\"red\">(not implemented yet)</font></h2>"; msg += "Network: <select name=\"id\">"; String sel = params.getProperty("id"); for ( OntologyNetwork on : manager.ontologyNetworks() ) { @@ -385,7 +414,8 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( perf.equals("matchonet") ) { - // DO MATCHING + // DO MATCHING version 1 + List<Message> answer = manager.alignonet( params ); msg = "<h1>Network Alignments results</h1>"; Iterator<Message> it = answer.iterator(); @@ -396,11 +426,12 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } msg += "</ul>"; - /* + + // DO MATCHING - String idON = params.getProperty("id"); +/* String idON = params.getProperty("id"); logger.debug("Matching network {}", idON); - Message answer = manager.alignonet( params ); + Message answer = manager.alignonet2( params ); if ( answer instanceof ErrorMsg ) { msg = testErrorMessages( answer, params, eSource ); } else { @@ -420,7 +451,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } msg += "</ul>"; } - */ + */ } else if ( perf.equals("prmretreiveonet") ){ @@ -456,6 +487,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( perf.equals("prmcloseonet") ){ msg = "<h1>Close an ontology network</h1><form action=\"matchonet\">"; + msg += "<h2><font color=\"red\">(not implemented yet)</font></h2>"; msg += "Network: <select name=\"id\">"; String sel = params.getProperty("id"); for ( OntologyNetwork on : manager.ontologyNetworks() ) { @@ -472,7 +504,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg += "<input type=\"submit\" name=\"action\" value=\"Compose\"/> "; msg += "<input type=\"checkbox\" name=\"new\" /> New "; - } else if ( perf.equals("prmresetonet") ){ + } else if ( perf.equals("prmnormalizeonet") ){ } else if ( perf.equals("") ) { msg = "<h1>Ontology Network commands</h1>"; @@ -480,10 +512,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { // msg += "<form action=\"prmlistonet\"><button title=\"List networks stored in the server\" type=\"submit\">Available networks</button></form>"; msg += "<form action=\"prmloadonet\"><button title=\"Load a network from a valid source\" type=\"submit\">Load a network</button></form>"; msg += "<form action=\"prmstoreonet\"><button title=\"Store a network in the server\" type=\"submit\">Store network</button></form>"; + msg += "<form action=\"prmtrimonet\"><button title=\"Trim a network\" type=\"submit\">Trim network</button></form>"; msg += "<form action=\"prmmatchonet\"><button title=\"Match an ontology network\" type=\"submit\">Match network </button></form>"; msg += "<form action=\"prmretreiveonet\"><button title=\"Render an ontology network in a particular format\" type=\"submit\">Render network</button></form>"; msg += "<form action=\"prmcloseonet\"><button title=\"Close an ontology network\" type=\"submit\">Close network</button></form>"; - msg += "<form action=\"prmresetonet\"><button title=\"Reset an ontology network\" type=\"submit\">Reset network</button></form>"; + msg += "<form action=\"prmnormalizeonet\"><button title=\"Normalize an ontology network\" type=\"submit\">Reset network</button></form>"; msg += "<form action=\"../html/\"><button style=\"background-color: lightpink;\" title=\"Back to user menu\" type=\"submit\">User interface</button></form>"; } else { msg = "Cannot understand: "+perf; diff --git a/src/fr/inrialpes/exmo/align/service/SQLCache.java b/src/fr/inrialpes/exmo/align/service/SQLCache.java index 39086e6a8cc850f2f38354b0bc3d1718ddba6f3b..4379a3839165f2b244db24da4255cd1965188de6 100644 --- a/src/fr/inrialpes/exmo/align/service/SQLCache.java +++ b/src/fr/inrialpes/exmo/align/service/SQLCache.java @@ -585,18 +585,21 @@ public class SQLCache extends VolatilCache implements Cache { // Do not add transaction here: this is handled by caller public void recordOntology( Statement st, URI uri, URI file, Ontology onto ) throws SQLException { - String sfile = ""; + // modify to use queryStatement.setNull for sformalism and sformuri String suri = uri.toString(); + String sfile = ""; if ( file != null ) sfile = file.toString(); + String sformuri = "NULL"; String query = "SELECT * FROM ontology WHERE uri="+quote(suri)+";"; ResultSet res = st.executeQuery(query); if ( !res.next() ) { - logger.debug( "Recording ontology {} with file {}", suri, sfile ); + logger.debug( "Recording ontology {} with file {} formalism {} formURI {}", suri, sfile, onto.getFormalism(), onto.getFormURI() ); if ( onto != null ) { + if ( onto.getFormURI() != null ) sformuri = onto.getFormURI().toString(); query = "INSERT INTO ontology " + "(uri, file, formname, formuri) " + - "VALUES ("+ quote(suri)+","+quote(sfile)+","+quote(onto.getFormalism())+","+quote(onto.getFormURI().toString())+")"; + "VALUES ("+ quote(suri)+","+quote(sfile)+","+quote(onto.getFormalism())+","+quote(sformuri)+")"; } else { query = "INSERT INTO ontology " + "(uri, file) " + @@ -604,9 +607,12 @@ public class SQLCache extends VolatilCache implements Cache { } st.executeUpdate(query); } else { + String sformname = ""; + if ( res.getString("formname") != null ) sformname = res.getString("formname"); if ( onto != null && res.getString("formname").equals("") ) { // JE: checktest logger.debug( "Updating ontology {} with formalism {}", suri, onto.getFormalism() ); - query = "UPDATE ontology SET formname="+quote(onto.getFormalism())+", formuri="+quote(onto.getFormURI().toString())+" WHERE uri="+quote(suri)+";"; + if ( onto.getFormURI() != null ) sformuri = onto.getFormURI().toString(); + query = "UPDATE ontology SET formname="+quote(onto.getFormalism())+", formuri="+quote(sformuri)+" WHERE uri="+quote(suri)+";"; st.executeUpdate(query); } } diff --git a/src/fr/inrialpes/exmo/align/service/VolatilCache.java b/src/fr/inrialpes/exmo/align/service/VolatilCache.java index 89a88d053b8d6fd75df15a76492d21e20579d4f4..792005d6c63080b32e5e92e209b1fb56aaa69782 100644 --- a/src/fr/inrialpes/exmo/align/service/VolatilCache.java +++ b/src/fr/inrialpes/exmo/align/service/VolatilCache.java @@ -231,8 +231,7 @@ public class VolatilCache implements Cache { private int randomNum() { // We observe collisions! - return Math.abs(rand.nextInt(1000)); - //return (int) (Math.abs(rand.nextInt(1000))+Math.random()*9); + return Math.abs(rand.nextInt(10000)); } /*