Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
histream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raphael
histream
Commits
8b7c3383
Commit
8b7c3383
authored
Sep 15, 2016
by
R.W.Majeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed using description for tooltip. Use readable path if no description is available.
parent
893dfbe6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
2 deletions
+102
-2
histream-i2b2/src/main/java/de/sekmi/histream/i2b2/ont/Import.java
...i2b2/src/main/java/de/sekmi/histream/i2b2/ont/Import.java
+47
-2
histream-i2b2/src/test/java/de/sekmi/histream/i2b2/ont/TestOntologyImport.java
...t/java/de/sekmi/histream/i2b2/ont/TestOntologyImport.java
+55
-0
No files found.
histream-i2b2/src/main/java/de/sekmi/histream/i2b2/ont/Import.java
View file @
8b7c3383
...
...
@@ -311,6 +311,49 @@ public class Import implements AutoCloseable{
}
return
xmlbuf
.
toString
();
}
/**
* Build a readable representation of a concept path.
* E.g. remove base path and namespace prefixes from path names
* @param path ontology path
* @return readable path
*/
public
String
readableConceptPath
(
String
path
){
if
(
path
.
startsWith
(
metaBase
)
){
path
=
path
.
substring
(
metaBase
.
length
());
}
StringBuilder
b
=
new
StringBuilder
();
int
pos
=
0
;
boolean
done
=
false
;
char
prefix_char
;
do
{
int
sep
=
path
.
indexOf
(
'\\'
,
pos
);
if
(
sep
==
-
1
){
done
=
true
;
sep
=
path
.
length
();
}
else
if
(
sep
==
path
.
length
()-
1
){
// empty backslash at end of path
done
=
true
;
}
// skip the http:// part of url prefixes
if
(
path
.
substring
(
pos
,
pos
+
7
).
equals
(
"http://"
)
){
// prefixes will end in #
prefix_char
=
'#'
;
pos
+=
7
;
}
else
{
// prefix will end in :
prefix_char
=
':'
;
}
// is there a prefix in the path segment?
int
pfx
=
path
.
indexOf
(
prefix_char
,
pos
);
if
(
pfx
!=
-
1
&&
pfx
<
sep
){
// prefix found, ignore the prefix
pos
=
pfx
+
1
;
}
b
.
append
(
'\\'
).
append
(
path
.
substring
(
pos
,
sep
));
pos
=
sep
+
1
;
}
while
(
!
done
);
return
b
.
toString
();
}
private
void
insertMeta
(
int
level
,
String
path_prefix
,
Concept
concept
,
boolean
accessRoot
)
throws
SQLException
,
OntologyException
{
insertMeta
.
setInt
(
1
,
level
);
String
label
=
concept
.
getPrefLabel
(
locale
);
...
...
@@ -399,8 +442,10 @@ public class Import implements AutoCloseable{
// c_tooltip
// try to use concept description
String
descr
=
concept
.
getDescription
(
locale
);
if
(
descr
==
null
)
descr
=
path
;
// use path if no description available
insertMeta
.
setString
(
9
,
path
);
if
(
descr
==
null
){
descr
=
readableConceptPath
(
path
);
// use path if no description available
}
insertMeta
.
setString
(
9
,
descr
);
// m_applied_path
insertMeta
.
setString
(
10
,
"@"
);
...
...
histream-i2b2/src/test/java/de/sekmi/histream/i2b2/ont/TestOntologyImport.java
0 → 100644
View file @
8b7c3383
package
de.sekmi.histream.i2b2.ont
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
de.sekmi.histream.i2b2.sql.VirtualConnection
;
public
class
TestOntologyImport
{
VirtualConnection
dbcData
;
VirtualConnection
dbcMeta
;
Import
imp
;
@Before
public
void
prepareVirtualConnections
()
throws
SQLException
{
dbcData
=
new
VirtualConnection
(
a
->
{}
);
dbcMeta
=
new
VirtualConnection
(
a
->
{}
);
Map
<
String
,
String
>
props
=
new
HashMap
<>();
// set preferences
props
.
put
(
"meta.basepath"
,
"\\i2b2\\"
);
props
.
put
(
"meta.sourcesystem_cd"
,
"test"
);
props
.
put
(
"meta.table"
,
"i2b2metadata.i2b2"
);
props
.
put
(
"meta.access"
,
"i2b2metadata.table_access"
);
props
.
put
(
"data.concept.table"
,
"i2b2crcdata.concepts"
);
props
.
put
(
"ont.language"
,
"en"
);
imp
=
new
Import
(
dbcMeta
,
dbcData
,
props
);
}
@After
public
void
closeVirtualConnections
()
throws
SQLException
{
imp
.
close
();
// dbcData.close();
// dbcMeta.close();
}
@Test
public
void
verifyReadablePath
(){
String
path
=
"\\i2b2\\asdf:First\\k23kskd:Second\\"
;
String
readable
=
imp
.
readableConceptPath
(
path
);
// there should be no prefixes
Assert
.
assertEquals
(-
1
,
readable
.
indexOf
(
':'
));
// print for debugging
System
.
out
.
println
(
readable
);
// second test with url prefixes
path
=
"\\i2b2\\http://lala/xyz#First\\asdf:Second"
;
String
readable2
=
imp
.
readableConceptPath
(
path
);
System
.
out
.
println
(
readable
);
Assert
.
assertEquals
(
readable
,
readable2
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment