Mentions légales du service

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

- implemented semi-deep cloning in BasicOntologyNetwork

- moved convertExtensions to Extensions
parent 00ddfb15
No related branches found
No related tags found
No related merge requests found
...@@ -218,6 +218,8 @@ public class BasicAlignment implements Alignment { ...@@ -218,6 +218,8 @@ public class BasicAlignment implements Alignment {
public Collection<String[]> getExtensions(){ return extensions.getValues(); } public Collection<String[]> getExtensions(){ return extensions.getValues(); }
public Extensions getExtensionsObject(){ return extensions; }
public void setExtensions( Extensions ext ){ extensions = ext; } public void setExtensions( Extensions ext ){ extensions = ext; }
public void setExtension( String uri, String label, String value ) { public void setExtension( String uri, String label, String value ) {
...@@ -667,25 +669,6 @@ public class BasicAlignment implements Alignment { ...@@ -667,25 +669,6 @@ public class BasicAlignment implements Alignment {
return result; return result;
} }
public Extensions convertExtension( String label, String method ) {
Extensions newext = (Extensions)extensions.clone();
String oldid = extensions.getExtension( Namespace.ALIGNMENT.uri, Annotations.ID );
if ( oldid != null && !oldid.equals("") ) {
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.DERIVEDFROM, oldid );
newext.unsetExtension( Namespace.ALIGNMENT.uri, Annotations.ID );
}
String pretty = getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY );
if ( pretty != null ){
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY, pretty+"/"+label );
};
if ( extensions.getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE ) != null ) {
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE,
extensions.getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE ) );
}
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.METHOD, method );
return newext;
}
/** /**
* A new alignment is created such that for * A new alignment is created such that for
* any pair (o, o', n, r) in O the resulting alignment will contain: * any pair (o, o', n, r) in O the resulting alignment will contain:
...@@ -699,7 +682,7 @@ public class BasicAlignment implements Alignment { ...@@ -699,7 +682,7 @@ public class BasicAlignment implements Alignment {
// We must inverse getType // We must inverse getType
result.setType( getType() ); result.setType( getType() );
result.setLevel( getLevel() ); result.setLevel( getLevel() );
result.setExtensions( convertExtension( "inverted", "http://exmo.inrialpes.fr/align/impl/BasicAlignment#inverse" ) ); result.setExtensions( extensions.convertExtension( "inverted", "http://exmo.inrialpes.fr/align/impl/BasicAlignment#inverse" ) );
//for ( Enumeration e = namespaces.getNames() ; e.hasMoreElements(); ){ //for ( Enumeration e = namespaces.getNames() ; e.hasMoreElements(); ){
// String label = (String)e.nextElement(); // String label = (String)e.nextElement();
for ( String label : namespaces.stringPropertyNames() ) { for ( String label : namespaces.stringPropertyNames() ) {
...@@ -743,7 +726,7 @@ public class BasicAlignment implements Alignment { ...@@ -743,7 +726,7 @@ public class BasicAlignment implements Alignment {
align.setLevel( getLevel() ); align.setLevel( getLevel() );
align.setFile1( getFile1() ); align.setFile1( getFile1() );
align.setFile2( getFile2() ); align.setFile2( getFile2() );
align.setExtensions( convertExtension( "cloned", this.getClass().getName()+"#clone" ) ); align.setExtensions( extensions.convertExtension( "cloned", this.getClass().getName()+"#clone" ) );
//for ( Enumeration e = namespaces.getNames() ; e.hasMoreElements(); ){ //for ( Enumeration e = namespaces.getNames() ; e.hasMoreElements(); ){
// String label = (String)e.nextElement(); // String label = (String)e.nextElement();
for ( String label : namespaces.stringPropertyNames() ) { for ( String label : namespaces.stringPropertyNames() ) {
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
package fr.inrialpes.exmo.align.impl; package fr.inrialpes.exmo.align.impl;
//import java.lang.Cloneable; // JE: what happens when I do a clone() ??
import java.lang.Iterable; import java.lang.Iterable;
import java.util.Collections; import java.util.Collections;
import java.util.Collection; import java.util.Collection;
...@@ -168,9 +167,23 @@ public class BasicOntologyNetwork implements OntologyNetwork { ...@@ -168,9 +167,23 @@ public class BasicOntologyNetwork implements OntologyNetwork {
/** /**
* Clone? * Clone does some deeper cloning
* It has the same content but a different id (no id indeed)
*/ */
//public BasicOntologyNetwork clone() {} public BasicOntologyNetwork clone() {
//public Object clone() {
BasicOntologyNetwork network = new BasicOntologyNetwork();
network.setExtensions( extensions.convertExtension( "cloned", this.getClass().getName()+"#clone" ) );
for ( URI onto : ontologies.keySet() ) network.addOntology( onto );
for ( Alignment al : alignments ) {
try {
network.addAlignment( al );
} catch (AlignmentException alex) {
logger.debug( "IGNORED Exception : should not happen {}", al );
}
}
return network;
}
/** /**
* Normalizes an ontology network for it to have exactly one alignment between each pair of ontologies. * Normalizes an ontology network for it to have exactly one alignment between each pair of ontologies.
......
...@@ -72,6 +72,25 @@ public class Extensions { ...@@ -72,6 +72,25 @@ public class Extensions {
return table.values(); return table.values();
} }
public Extensions convertExtension( String label, String method ) {
Extensions newext = (Extensions)clone();
String oldid = getExtension( Namespace.ALIGNMENT.uri, Annotations.ID );
if ( oldid != null && !oldid.equals("") ) {
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.DERIVEDFROM, oldid );
newext.unsetExtension( Namespace.ALIGNMENT.uri, Annotations.ID );
}
String pretty = getExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY );
if ( pretty != null ){
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PRETTY, pretty+"/"+label );
};
if ( getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE ) != null ) {
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE,
getExtension( Namespace.ALIGNMENT.uri, Annotations.PROVENANCE ) );
}
newext.setExtension( Namespace.ALIGNMENT.uri, Annotations.METHOD, method );
return newext;
}
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
public Object clone() { public Object clone() {
return new Extensions( (Hashtable<String,String[]>)table.clone() ); //[W:unchecked] return new Extensions( (Hashtable<String,String[]>)table.clone() ); //[W:unchecked]
......
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2003-2011, 2013 * Copyright (C) INRIA, 2003-2011, 2013-2014
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
...@@ -119,7 +119,7 @@ public class ObjectAlignment extends BasicAlignment { ...@@ -119,7 +119,7 @@ public class ObjectAlignment extends BasicAlignment {
align.setLevel( getLevel() ); align.setLevel( getLevel() );
align.setFile1( getFile1() ); align.setFile1( getFile1() );
align.setFile2( getFile2() ); align.setFile2( getFile2() );
align.setExtensions( convertExtension( "EDOALURIConverted", this.getClass().getName()+"#toURI" ) ); align.setExtensions( extensions.convertExtension( "EDOALURIConverted", this.getClass().getName()+"#toURI" ) );
for (Enumeration e = getElements(); e.hasMoreElements();) { for (Enumeration e = getElements(); e.hasMoreElements();) {
Cell c = (Cell)e.nextElement(); Cell c = (Cell)e.nextElement();
try { try {
...@@ -147,7 +147,7 @@ public class ObjectAlignment extends BasicAlignment { ...@@ -147,7 +147,7 @@ public class ObjectAlignment extends BasicAlignment {
} }
alignment.setType( al.getType() ); alignment.setType( al.getType() );
alignment.setLevel( al.getLevel() ); alignment.setLevel( al.getLevel() );
alignment.setExtensions( al.convertExtension( "ObjectURIConverted", "fr.inrialpes.exmo.align.ObjectAlignment#toObject" ) ); alignment.setExtensions( al.extensions.convertExtension( "ObjectURIConverted", "fr.inrialpes.exmo.align.ObjectAlignment#toObject" ) );
LoadedOntology<Object> o1 = (LoadedOntology<Object>)alignment.getOntologyObject1(); // [W:unchecked] LoadedOntology<Object> o1 = (LoadedOntology<Object>)alignment.getOntologyObject1(); // [W:unchecked]
LoadedOntology<Object> o2 = (LoadedOntology<Object>)alignment.getOntologyObject2(); // [W:unchecked] LoadedOntology<Object> o2 = (LoadedOntology<Object>)alignment.getOntologyObject2(); // [W:unchecked]
Object obj1 = null; Object obj1 = null;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* $Id$ * $Id$
* *
* Sourceforge version 1.6 - 2008 - was OMWGAlignment * Sourceforge version 1.6 - 2008 - was OMWGAlignment
* Copyright (C) INRIA, 2007-2013 * Copyright (C) INRIA, 2007-2014
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
...@@ -233,7 +233,7 @@ public class EDOALAlignment extends BasicAlignment { ...@@ -233,7 +233,7 @@ public class EDOALAlignment extends BasicAlignment {
align.setLevel( getLevel() ); align.setLevel( getLevel() );
align.setFile1( getFile1() ); align.setFile1( getFile1() );
align.setFile2( getFile2() ); align.setFile2( getFile2() );
align.setExtensions( convertExtension( "EDOALURIConverted", "http://exmo.inrialpes.fr/align/impl/edoal/EDOALAlignment#toURI" ) ); align.setExtensions( extensions.convertExtension( "EDOALURIConverted", "http://exmo.inrialpes.fr/align/impl/edoal/EDOALAlignment#toURI" ) );
for (Enumeration e = getElements(); e.hasMoreElements();) { for (Enumeration e = getElements(); e.hasMoreElements();) {
Cell c = (Cell)e.nextElement(); Cell c = (Cell)e.nextElement();
try { try {
...@@ -306,7 +306,7 @@ public class EDOALAlignment extends BasicAlignment { ...@@ -306,7 +306,7 @@ public class EDOALAlignment extends BasicAlignment {
*/ */
public void convertToEDOAL( BasicAlignment al ) throws AlignmentException { public void convertToEDOAL( BasicAlignment al ) throws AlignmentException {
setType( al.getType() ); setType( al.getType() );
setExtensions( al.convertExtension( "toEDOAL", "fr.inrialpes.exmo.align.edoal.EDOALAlignment#toEDOAL" ) ); setExtensions( al.getExtensionsObject().convertExtension( "toEDOAL", "fr.inrialpes.exmo.align.edoal.EDOALAlignment#toEDOAL" ) );
LoadedOntology<Object> o1 = (LoadedOntology<Object>)getOntologyObject1(); // [W:unchecked] LoadedOntology<Object> o1 = (LoadedOntology<Object>)getOntologyObject1(); // [W:unchecked]
LoadedOntology<Object> o2 = (LoadedOntology<Object>)getOntologyObject2(); // [W:unchecked] LoadedOntology<Object> o2 = (LoadedOntology<Object>)getOntologyObject2(); // [W:unchecked]
for ( Cell c : al ) { for ( Cell c : al ) {
...@@ -360,7 +360,7 @@ public class EDOALAlignment extends BasicAlignment { ...@@ -360,7 +360,7 @@ public class EDOALAlignment extends BasicAlignment {
align.setLevel( getLevel() ); align.setLevel( getLevel() );
align.setFile1( getFile1() ); align.setFile1( getFile1() );
align.setFile2( getFile2() ); align.setFile2( getFile2() );
align.setExtensions( convertExtension( "cloned", this.getClass().getName()+"#clone" ) ); align.setExtensions( extensions.convertExtension( "cloned", this.getClass().getName()+"#clone" ) );
try { try {
align.ingest( this ); align.ingest( this );
} catch (AlignmentException ex) { } catch (AlignmentException ex) {
......
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