Commit 5a0e07a1 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

allow specification of scheme for i2b2 ontology

parent 1fafc9d4
...@@ -194,7 +194,11 @@ public class Store implements Ontology, Plugin { ...@@ -194,7 +194,11 @@ public class Store implements Ontology, Plugin {
@Override @Override
public Concept[] getTopConcepts(String scheme)throws OntologyException{ public Concept[] getTopConcepts(String scheme)throws OntologyException{
return getRelatedConcepts(repo.getValueFactory().createURI(scheme), SKOS.HAS_TOP_CONCEPT); URI schemeURI = null;
if( scheme != null ){
schemeURI = repo.getValueFactory().createURI(scheme);
}
return getRelatedConcepts(schemeURI, SKOS.HAS_TOP_CONCEPT);
} }
private Concept[] getRelatedConcepts(Resource subject, URI predicate)throws OntologyException{ private Concept[] getRelatedConcepts(Resource subject, URI predicate)throws OntologyException{
RepositoryResult<Statement> rr; RepositoryResult<Statement> rr;
......
...@@ -52,6 +52,7 @@ public class Import implements AutoCloseable{ ...@@ -52,6 +52,7 @@ public class Import implements AutoCloseable{
private int insertConceptCount; private int insertConceptCount;
private String sourceId; private String sourceId;
private String scheme;
private Timestamp sourceTimestamp; private Timestamp sourceTimestamp;
/** /**
...@@ -65,7 +66,8 @@ public class Import implements AutoCloseable{ ...@@ -65,7 +66,8 @@ public class Import implements AutoCloseable{
* Use {@code meta.sourcesystem_cd} for the source system. * Use {@code meta.sourcesystem_cd} for the source system.
* {@code jdbc.host}, {@code jdbc.port}, {@code jdbc.database} are used to construct the connect string. * {@code jdbc.host}, {@code jdbc.port}, {@code jdbc.database} are used to construct the connect string.
* Any other parameters starting with {@code jdbc.} are also passed to {@link DriverManager#getConnection(String, Properties)}. * Any other parameters starting with {@code jdbc.} are also passed to {@link DriverManager#getConnection(String, Properties)}.
* * <p>
* More parameters: {@code ont.language} and {@code ont.scheme}.
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws SQLException * @throws SQLException
*/ */
...@@ -121,6 +123,10 @@ public class Import implements AutoCloseable{ ...@@ -121,6 +123,10 @@ public class Import implements AutoCloseable{
}else{ }else{
locale = Locale.forLanguageTag(config.get("ont.language")); locale = Locale.forLanguageTag(config.get("ont.language"));
} }
// parse scheme
if( config.get("ont.language") != null ){
this.scheme = config.get("ont.scheme");
}
// parse base path // parse base path
String base = config.get("meta.basepath"); String base = config.get("meta.basepath");
...@@ -135,7 +141,9 @@ public class Import implements AutoCloseable{ ...@@ -135,7 +141,9 @@ public class Import implements AutoCloseable{
base_level = 0; base_level = 0;
} }
Concept[] concepts = ontology.getTopConcepts(); Concept[] concepts = ontology.getTopConcepts(this.scheme);
for( Concept c : concepts ){ for( Concept c : concepts ){
insertMeta(base_level, base, c, true); insertMeta(base_level, base, c, true);
} }
...@@ -248,13 +256,18 @@ public class Import implements AutoCloseable{ ...@@ -248,13 +256,18 @@ public class Import implements AutoCloseable{
if( label == null ){ if( label == null ){
// no label for language, try to get neutral label // no label for language, try to get neutral label
label = concept.getPrefLabel(null); label = concept.getPrefLabel(null);
path_part = label;
if( label == null ){ if( label == null ){
// concept does not have a label // concept does not have a label
path_part = Integer.toHexString(concept.hashCode());
label = concept.toString(); label = concept.toString();
path_part = label;//Integer.toHexString(concept.hashCode());
log.warning("Missing prefLabel for concept "+concept+" substituted with hashCode:"+label); log.warning("Missing prefLabel for concept "+concept+" substituted with hashCode:"+label);
} }
} }
// TODO find better way to generate path_part
path_part = Integer.toHexString(label.hashCode());
// use hashcode
String path = path_prefix + path_part+"\\"; String path = path_prefix + path_part+"\\";
insertMeta.setString(2, path); insertMeta.setString(2, path);
insertMeta.setString(3, label); insertMeta.setString(3, label);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment