Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 316a2219 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- implemented match() on BasicOntologyNetwork

parent 4554eb5f
No related branches found
No related tags found
No related merge requests found
......@@ -31,8 +31,10 @@ import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Properties;
import java.net.URI;
import java.net.URISyntaxException;
import java.lang.reflect.Constructor;
import java.io.PrintWriter;
import java.io.InputStream;
......@@ -56,6 +58,7 @@ import fr.inrialpes.exmo.align.parser.AlignmentParser;
import fr.inrialpes.exmo.align.impl.Namespace;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentProcess;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.OntologyNetwork;
......@@ -236,7 +239,7 @@ public class BasicOntologyNetwork implements OntologyNetwork {
* public void match( Class<? extends AlignmentProcess> method, boolean reflexive ) throws AlignmentException {
}
*/
public void match( String method, boolean reflexive, boolean symmetric) throws AlignmentException {
public void match( String method, boolean reflexive, boolean symmetric, Properties params ) throws AlignmentException {
for ( OntologyTriple ot1 : ontologies.values() ) {
for ( OntologyTriple ot2 : ontologies.values() ) {
if ( ( ot1 == ot2 && reflexive )
......@@ -246,13 +249,27 @@ public class BasicOntologyNetwork implements OntologyNetwork {
for ( Alignment al : als ) {
remAlignment( al );
}
// Create the alignment process
//AlignmentProcess ap = ...
// Match
//ap.init( ot1.onto, ot2.onto );
//ap.align( init, (Properties)null );
// replace
//addAlignment( ap );
// Create the alignment process
AlignmentProcess ap = null;
try {
// Create alignment object
Class<?> alignmentClass = Class.forName( method );
Class[] cparams = {};
Constructor alignmentConstructor = alignmentClass.getConstructor(cparams);
Object[] mparams = {};
ap = (AlignmentProcess)alignmentConstructor.newInstance( mparams );
ap.init( ot1.onto, ot2.onto );
} catch ( Exception ex ) {
logger.error( "Cannot create alignment {}", method );
throw new AlignmentException( "Cannot create alignment "+method, ex );
}
// Compute alignment
long time = System.currentTimeMillis();
ap.align( init, params ); // or params?
long newTime = System.currentTimeMillis();
ap.setExtension( Namespace.ALIGNMENT.uri, Annotations.TIME, Long.toString(newTime - time) );
// replace
addAlignment( ap );
}
}
}
......
......@@ -1377,9 +1377,7 @@ public class AServProtocolManager implements Service {
}
public List<Message> alignonet( Properties params ) {
public List<Message> alignonet( Properties params ) {
List<Message> result = new ArrayList<>();
//not finished
//parameters: onID, method, reflexive, symmetric
......@@ -1412,9 +1410,7 @@ public List<Message> alignonet( Properties params ) {
}
}
}
return result;
}
......@@ -1431,22 +1427,21 @@ public List<Message> alignonet( Properties params ) {
if (params.getProperty("symmetric") != null) symmetric = true;
try {
noo = alignmentCache.getOntologyNetwork( id );
} catch (AlignmentException e1) {
return new UnknownOntologyNetwork( params, newId(), serverId,id );
}
noo = alignmentCache.getOntologyNetwork( id );
} 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);
} catch (AlignmentException e) {
((BasicOntologyNetwork)noo).match( method, reflexive, symmetric, params );
} catch (AlignmentException e) {
return new ErrorMsg( params, newId(), serverId,"Network alignment error" );
}
logger.debug(" Network alignments results, id: {} total ontologies: {} total alignments: {}",id, noo.getOntologies().size(),noo.getAlignments().size());
return new OntologyNetworkId( params, newId(), serverId, id,
((BasicOntologyNetwork) noo).getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ));
((BasicOntologyNetwork) noo).getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY ));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment