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
b2ad31fc
Commit
b2ad31fc
authored
Aug 21, 2015
by
R.W.Majeed
Browse files
Changed configuration to include meta source element with timestamp.
parent
b4859a26
Changes
5
Hide whitespace changes
Inline
Side-by-side
histream-import/src/main/java/de/sekmi/histream/etl/config/DataSource.java
View file @
b2ad31fc
...
...
@@ -31,6 +31,7 @@ public class DataSource {
@XmlElement
(
name
=
"wide-table"
)
WideTable
[]
wideTables
;
public
Meta
getMeta
(){
return
meta
;}
public
PatientTable
getPatientTable
(){
return
patientTable
;
...
...
histream-import/src/main/java/de/sekmi/histream/etl/config/Meta.java
View file @
b2ad31fc
package
de.sekmi.histream.etl.config
;
import
java.time.Instant
;
import
java.util.Calendar
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
public
class
Meta
{
@XmlElement
(
name
=
"source-id"
)
String
sourceId
;
import
de.sekmi.histream.ext.ExternalSourceType
;
public
class
Meta
{
@XmlElement
Source
source
;
@XmlElement
(
name
=
"etl-strategy"
)
String
etlStrategy
;
public
static
class
Source
implements
ExternalSourceType
{
@XmlAttribute
String
id
;
@XmlAttribute
Calendar
timestamp
;
@Override
public
String
getSourceId
()
{
return
id
;}
@Override
public
Instant
getSourceTimestamp
()
{
return
timestamp
.
toInstant
();
}
@Override
public
void
setSourceId
(
String
arg0
)
{
this
.
id
=
arg0
;}
@Override
public
void
setSourceTimestamp
(
Instant
instant
)
{
this
.
timestamp
=
Calendar
.
getInstance
();
this
.
timestamp
.
setTimeInMillis
(
instant
.
toEpochMilli
());
}
}
protected
Meta
(){
}
public
Meta
(
String
etlStrategy
,
String
sourceId
,
Calendar
sourceTimestamp
){
this
.
etlStrategy
=
etlStrategy
;
this
.
source
=
new
Source
();
this
.
source
.
timestamp
=
sourceTimestamp
;
this
.
source
.
id
=
sourceId
;
}
public
Source
getSource
(){
return
this
.
source
;
}
}
histream-import/src/main/java/de/sekmi/histream/etl/config/TableSource.java
View file @
b2ad31fc
...
...
@@ -16,4 +16,5 @@ import de.sekmi.histream.etl.RowSupplier;
@XmlSeeAlso
({
FileSource
.
class
,
SQLSource
.
class
})
public
abstract
class
TableSource
{
public
abstract
RowSupplier
rows
()
throws
IOException
;
// TODO allow table sources to specify timestamp
}
\ No newline at end of file
histream-import/src/test/java/de/sekmi/histream/etl/config/TestMarshall.java
View file @
b2ad31fc
...
...
@@ -4,6 +4,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.Calendar
;
import
javax.xml.bind.JAXB
;
...
...
@@ -21,7 +22,7 @@ public class TestMarshall {
DataSource
ds
=
JAXB
.
unmarshal
(
in
,
DataSource
.
class
);
Assert
.
assertNotNull
(
ds
.
meta
);
Assert
.
assertEquals
(
"replace-source"
,
ds
.
meta
.
etlStrategy
);
Assert
.
assertEquals
(
"test-1"
,
ds
.
meta
.
source
I
d
);
Assert
.
assertEquals
(
"test-1"
,
ds
.
meta
.
source
.
i
d
);
// patient table
Assert
.
assertNotNull
(
ds
.
patientTable
);
Assert
.
assertNotNull
(
ds
.
patientTable
.
source
);
...
...
@@ -57,9 +58,7 @@ public class TestMarshall {
@Test
public
void
testMarshal
()
throws
MalformedURLException
{
DataSource
s
=
new
DataSource
();
s
.
meta
=
new
Meta
();
s
.
meta
.
sourceId
=
"SID"
;
s
.
meta
.
etlStrategy
=
"replace-source"
;
s
.
meta
=
new
Meta
(
"replace-source"
,
"SID"
,
Calendar
.
getInstance
());
s
.
xmlSources
=
new
XmlSource
[
1
];
s
.
xmlSources
[
0
]
=
new
XmlSource
();
s
.
xmlSources
[
0
].
url
=
new
URL
(
"http://lala"
);
...
...
histream-import/src/test/resources/test-1-datasource.xml
View file @
b2ad31fc
...
...
@@ -2,7 +2,7 @@
<datasource
version=
"1.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
>
<meta>
<etl-strategy>
replace-source
</etl-strategy>
<source
-id>
test-1
</source-id
>
<source
timestamp=
"2015-04-21T08:58:00"
id=
"test-1"
/
>
</meta>
<!-- erstmal weglassen -->
<transformations>
...
...
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