Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Raphael
histream
Commits
2221723e
Commit
2221723e
authored
Aug 04, 2015
by
rwm
Browse files
column types for integer and decimal
parent
8ed00085
Changes
6
Hide whitespace changes
Inline
Side-by-side
histream-import/src/main/java/de/sekmi/histream/etl/config/Column.java
View file @
2221723e
...
@@ -18,7 +18,7 @@ import de.sekmi.histream.etl.ParseException;
...
@@ -18,7 +18,7 @@ import de.sekmi.histream.etl.ParseException;
*
*
*/
*/
@XmlTransient
@XmlTransient
@XmlSeeAlso
({
StringColumn
.
class
})
@XmlSeeAlso
({
StringColumn
.
class
,
IntegerColumn
.
class
,
DateTimeColumn
.
class
,
DecimalColumn
.
class
})
public
abstract
class
Column
<
T
>
{
public
abstract
class
Column
<
T
>
{
protected
Column
(){
protected
Column
(){
}
}
...
...
histream-import/src/main/java/de/sekmi/histream/etl/config/DecimalColumn.java
0 → 100644
View file @
2221723e
package
de.sekmi.histream.etl.config
;
import
java.math.BigDecimal
;
import
javax.xml.bind.annotation.XmlType
;
import
de.sekmi.histream.etl.ParseException
;
@XmlType
(
name
=
"decimal"
)
public
class
DecimalColumn
extends
Column
<
BigDecimal
>{
@Override
public
BigDecimal
valueOf
(
Object
input
)
throws
ParseException
{
Object
value
=
preprocessValue
(
input
);
if
(
value
==
null
){
return
null
;
}
else
if
(
value
instanceof
String
){
// TODO: use decimalformat for parsing
return
new
BigDecimal
((
String
)
value
);
}
else
if
(
value
instanceof
BigDecimal
){
return
(
BigDecimal
)
value
;
}
else
{
throw
new
ParseException
(
"Invalid type for decimal column: "
+
value
.
getClass
().
getName
());
}
}
}
histream-import/src/main/java/de/sekmi/histream/etl/config/IntegerColumn.java
0 → 100644
View file @
2221723e
package
de.sekmi.histream.etl.config
;
import
javax.xml.bind.annotation.XmlType
;
import
de.sekmi.histream.etl.ParseException
;
@XmlType
(
name
=
"integer"
)
public
class
IntegerColumn
extends
Column
<
Long
>
{
@Override
public
Long
valueOf
(
Object
input
)
throws
ParseException
{
input
=
preprocessValue
(
input
);
if
(
input
==
null
){
return
null
;
}
else
if
(
input
instanceof
String
){
// TODO: use integerformat for parsing
return
Long
.
parseLong
((
String
)
input
);
}
else
if
(
input
instanceof
Integer
){
return
new
Long
((
Integer
)
input
);
}
else
if
(
input
instanceof
Long
){
return
(
Long
)
input
;
}
else
{
throw
new
ParseException
(
"Unsupported input type "
+
input
.
getClass
().
getName
());
}
}
}
histream-import/src/main/java/de/sekmi/histream/etl/config/StringColumn.java
View file @
2221723e
package
de.sekmi.histream.etl.config
;
package
de.sekmi.histream.etl.config
;
import
javax.xml.bind.annotation.XmlType
;
import
de.sekmi.histream.etl.ParseException
;
import
de.sekmi.histream.etl.ParseException
;
@XmlType
(
name
=
"string"
)
public
class
StringColumn
extends
Column
<
String
>{
public
class
StringColumn
extends
Column
<
String
>{
public
StringColumn
(
String
name
)
{
public
StringColumn
(
String
name
)
{
...
...
histream-import/src/test/java/de/sekmi/histream/etl/config/TestReadTables.java
View file @
2221723e
...
@@ -2,6 +2,7 @@ package de.sekmi.histream.etl.config;
...
@@ -2,6 +2,7 @@ package de.sekmi.histream.etl.config;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.time.temporal.ChronoField
;
import
java.time.temporal.ChronoField
;
import
javax.xml.bind.JAXB
;
import
javax.xml.bind.JAXB
;
...
@@ -59,8 +60,8 @@ public class TestReadTables {
...
@@ -59,8 +60,8 @@ public class TestReadTables {
Assert
.
assertTrue
(
r
.
getFacts
().
size
()
>
0
);
Assert
.
assertTrue
(
r
.
getFacts
().
size
()
>
0
);
Observation
o
=
r
.
getFacts
().
get
(
0
);
Observation
o
=
r
.
getFacts
().
get
(
0
);
Assert
.
assertEquals
(
"natrium"
,
o
.
getConceptId
());
Assert
.
assertEquals
(
"natrium"
,
o
.
getConceptId
());
Assert
.
assertEquals
(
Value
.
Type
.
Text
,
o
.
getValue
().
getType
());
Assert
.
assertEquals
(
Value
.
Type
.
Numeric
,
o
.
getValue
().
getType
());
Assert
.
assertEquals
(
"
124
"
,
o
.
getValue
().
get
String
Value
());
Assert
.
assertEquals
(
BigDecimal
.
valueOf
(
124
)
,
o
.
getValue
().
get
Numeric
Value
());
}
}
}
}
}
}
histream-import/src/test/resources/test-1-datasource.xml
View file @
2221723e
...
@@ -33,8 +33,8 @@
...
@@ -33,8 +33,8 @@
<birthdate
format=
"d.M.u"
>
geburtsdatum
</birthdate>
<birthdate
format=
"d.M.u"
>
geburtsdatum
</birthdate>
<deathdate
format=
"d.M.u"
>
verstorben
</deathdate>
<deathdate
format=
"d.M.u"
>
verstorben
</deathdate>
<gender>
geschlecht
</gender>
<gender>
geschlecht
</gender>
<ignore
xsi:type=
"string
Column
"
>
ignoriert1
</ignore>
<ignore
xsi:type=
"string"
>
ignoriert1
</ignore>
<ignore
xsi:type=
"string
Column
"
>
patfakt1
</ignore>
<ignore
xsi:type=
"string"
>
patfakt1
</ignore>
</idat>
</idat>
</patient-table>
</patient-table>
<!-- optional -->
<!-- optional -->
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
<mdat>
<mdat>
<!-- in/out code -->
<!-- in/out code -->
<concept
id=
"weight"
>
<concept
id=
"weight"
>
<value
xsi:type=
"string
Column
"
>
gewicht
</value>
<value
xsi:type=
"string"
>
gewicht
</value>
<start>
start
</start>
<start>
start
</start>
</concept>
</concept>
</mdat>
</mdat>
...
@@ -71,11 +71,11 @@
...
@@ -71,11 +71,11 @@
<mdat>
<mdat>
<concept
id=
"natrium"
>
<concept
id=
"natrium"
>
<!-- TODO implement numeric columns -->
<!-- TODO implement numeric columns -->
<value
xsi:type=
"
stringColumn
"
>
na
</value>
<value
xsi:type=
"
decimal
"
>
na
</value>
<start
format=
"d.M.u[ H[:m[:s]]]"
>
zeitpunkt
</start>
<start
format=
"d.M.u[ H[:m[:s]]]"
>
zeitpunkt
</start>
<unit
constant-value=
"mmol/l"
/>
<unit
constant-value=
"mmol/l"
/>
<modifier
id=
"other"
>
<modifier
id=
"other"
>
<value
xsi:type=
"string
Column
"
constant-value=
""
/>
<value
xsi:type=
"string"
constant-value=
""
/>
</modifier>
</modifier>
</concept>
</concept>
</mdat>
</mdat>
...
...
Write
Preview
Supports
Markdown
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