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

Changed configuration to include meta source element with timestamp.

parent b4859a26
......@@ -31,6 +31,7 @@ public class DataSource {
@XmlElement(name="wide-table")
WideTable[] wideTables;
public Meta getMeta(){return meta;}
public PatientTable getPatientTable(){
return patientTable;
......
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;
}
}
......@@ -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
......@@ -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.sourceId);
Assert.assertEquals("test-1",ds.meta.source.id);
// 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");
......
......@@ -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>
......
Markdown is supported
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