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

time zone support for export

parent 76ba58c6
...@@ -2,6 +2,7 @@ package de.sekmi.histream.export; ...@@ -2,6 +2,7 @@ package de.sekmi.histream.export;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
...@@ -35,6 +36,7 @@ public class TableExport { ...@@ -35,6 +36,7 @@ public class TableExport {
private ExportErrorHandler errorHandler; private ExportErrorHandler errorHandler;
private int patientCount; private int patientCount;
private int visitCount; private int visitCount;
private ZoneId zoneId;
public TableExport(ExportDescriptor desc){ public TableExport(ExportDescriptor desc){
this.desc = desc; this.desc = desc;
...@@ -61,6 +63,13 @@ public class TableExport { ...@@ -61,6 +63,13 @@ public class TableExport {
return xpath; return xpath;
} }
/**
* Set the zone id to use for timestamps
* @param zone
*/
public void setZoneId(ZoneId zoneId){
this.zoneId = zoneId;
}
/** /**
* Make sure, that any intersection between groups are empty. * Make sure, that any intersection between groups are empty.
* Overlapping group means concepts would get multiple classes * Overlapping group means concepts would get multiple classes
...@@ -126,6 +135,7 @@ public class TableExport { ...@@ -126,6 +135,7 @@ public class TableExport {
FragmentExporter fe = null; FragmentExporter fe = null;
try{ try{
fe = new FragmentExporter(createXPath(), desc, writer); fe = new FragmentExporter(createXPath(), desc, writer);
fe.setZoneId(zoneId);
fe.setErrorHandler(new ExportErrorHandler()); fe.setErrorHandler(new ExportErrorHandler());
Streams.transfer(supplier, fe); Streams.transfer(supplier, fe);
} catch (XMLStreamException | ParserConfigurationException e) { } catch (XMLStreamException | ParserConfigurationException e) {
......
...@@ -2,6 +2,7 @@ package de.sekmi.histream.export; ...@@ -2,6 +2,7 @@ package de.sekmi.histream.export;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.time.ZoneId;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
...@@ -35,7 +36,9 @@ public class TestExport { ...@@ -35,7 +36,9 @@ public class TestExport {
FileObservationProviderTest t = new FileObservationProviderTest(); FileObservationProviderTest t = new FileObservationProviderTest();
t.initializeObservationFactory(); t.initializeObservationFactory();
try( ObservationSupplier s = t.getExampleSupplier() ){ try( ObservationSupplier s = t.getExampleSupplier() ){
export.setZoneId(ZoneId.of("Asia/Shanghai"));
export.export(s, m); export.export(s, m);
export.setZoneId(null);
} }
// verify class lookup // verify class lookup
Assert.assertEquals("T:type:str", m.get(MemoryExportWriter.VISIT_TABLE, "byclass", 0)); Assert.assertEquals("T:type:str", m.get(MemoryExportWriter.VISIT_TABLE, "byclass", 0));
......
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