From 0cf58632d3727e43bdf6a5b196eb288758ebaf45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Fri, 16 May 2014 16:38:28 +0000 Subject: [PATCH] - implemented fix suggested by Luz Maria --- .../align/service/AServProtocolManager.java | 30 +++++++++---------- .../exmo/align/service/SQLCache.java | 2 +- .../exmo/align/service/VolatilCache.java | 19 +++++++----- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 19956142..f43ba22e 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -226,12 +226,12 @@ public class AServProtocolManager implements Service { public Set<Alignment> networkAlignmentUri(String uri) { OntologyNetwork noo = null; - try { - noo = alignmentCache.getOntologyNetwork(uri); - } catch (AlignmentException e) { - e.printStackTrace(); - } - return ((BasicOntologyNetwork) noo).getAlignments(); + try { + noo = alignmentCache.getOntologyNetwork(uri); + } catch (AlignmentException e) { + e.printStackTrace(); + } + return ((BasicOntologyNetwork) noo).getAlignments(); } public Collection<Alignment> alignments( URI uri1, URI uri2 ) { @@ -1221,25 +1221,23 @@ public class AServProtocolManager implements Service { try { noo = (BasicOntologyNetwork) BasicOntologyNetwork.read( name ); logger.trace(" Ontology network parsed"); - } catch (Exception e) { - return new UnreachableOntologyNetwork( params, newId(), serverId, name ); - } + } catch (Exception e) { + return new UnreachableOntologyNetwork( params, newId(), serverId, name ); + } // We preserve the pretty tag within the loaded ontology network String pretty = noo.getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ); if ( pretty == null ) pretty = params.getProperty("pretty"); if ( pretty != null && !pretty.equals("") ) { - noo.setExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY, pretty ); - } + noo.setExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY, pretty ); + } // register it String id = alignmentCache.recordNewNetwork( noo, true ); logger.debug(" Ontology network loaded, id: {} total ontologies: {} total alignments: {}",id, noo.getOntologies().size(),noo.getAlignments().size()); - //=== The alignment has the id of the source file (e.g. file:///path/FileName.rdf) - Set<Alignment> networkAlignments = networkAlignmentUri(id); - for (Alignment al : networkAlignments) { - String idAl = alignmentCache.recordNewAlignment( al, true ); + //=== The alignment has the id of the source file (e.g. file:///path/FileName.rdf) + for ( Alignment al : noo.getAlignments() ) { + alignmentCache.recordNewAlignment( al, true ); } - return new OntologyNetworkId( params, newId(), serverId, id ,pretty ); } diff --git a/src/fr/inrialpes/exmo/align/service/SQLCache.java b/src/fr/inrialpes/exmo/align/service/SQLCache.java index e70a881b..39086e6a 100644 --- a/src/fr/inrialpes/exmo/align/service/SQLCache.java +++ b/src/fr/inrialpes/exmo/align/service/SQLCache.java @@ -642,7 +642,7 @@ public class SQLCache extends VolatilCache implements Cache { storeAlignment( alid ); } query = "INSERT INTO networkalignment (network,align) VALUES (" - +qid+","+quote( alid )+");"; + +qid+","+quote( stripAlignmentUri( alid ) )+");"; st.executeUpdate(query); } // Store ontologies... diff --git a/src/fr/inrialpes/exmo/align/service/VolatilCache.java b/src/fr/inrialpes/exmo/align/service/VolatilCache.java index 26a5fd2d..89a88d05 100644 --- a/src/fr/inrialpes/exmo/align/service/VolatilCache.java +++ b/src/fr/inrialpes/exmo/align/service/VolatilCache.java @@ -57,12 +57,15 @@ import org.semanticweb.owl.align.AlignmentException; public class VolatilCache implements Cache { final static Logger logger = LoggerFactory.getLogger( VolatilCache.class ); - Hashtable<String,Alignment> alignmentTable = null; - Hashtable<String,Alignment> alignmentURITable = null; - Hashtable<URI,Set<Alignment>> ontologyTable = null; - Hashtable<URI,OntologyNetwork> onetworkTable = null; + private static Random rand; - String idprefix = null; + private Hashtable<String,Alignment> alignmentTable = null; + private Hashtable<URI,Set<Alignment>> ontologyTable = null; + private Hashtable<URI,OntologyNetwork> onetworkTable = null; + // JE: not sure of that one + protected Hashtable<String,Alignment> alignmentURITable = null; + + protected String idprefix = null; static protected final String SVCNS = Namespace.ALIGNSVC.getUriPrefix(); static protected final String CACHED = "cached"; @@ -71,11 +74,12 @@ public class VolatilCache implements Cache { static protected final String OURI1 = "ouri1"; static protected final String OURI2 = "ouri2"; static protected final String ONID = "onid/"; - + //********************************************************************** public VolatilCache() { resetTables(); + rand = new Random(System.currentTimeMillis()); } public void resetTables() { @@ -226,8 +230,9 @@ public class VolatilCache implements Cache { } private int randomNum() { - Random rand = new Random(System.currentTimeMillis()); + // We observe collisions! return Math.abs(rand.nextInt(1000)); + //return (int) (Math.abs(rand.nextInt(1000))+Math.random()*9); } /* -- GitLab