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

Constants for Meta strings

parent 3ef9354e
......@@ -37,35 +37,36 @@ import java.util.function.Supplier;
*
*/
public interface ObservationSupplier extends Supplier<Observation>, AutoCloseable{
/**
* Retrieve meta information for this supply of observations.
* <p>
* Possible keys are source.id, source.timestamp, etl.strategy, order.grouped, order.sorted
* <dl>
* <dt>source.id</dt>
* <dd>ID for the source which provides the observations
*
* <dt>source.timestamp</dt>
* <dd>Timestamp when the source data was extracted/downloaded/queried</dd>
*
* <dt>etl.strategy</dt>
* <dd>Strategy how to handle imported data.
/**
* ID for the source which provides the observations
*/
public static final String META_SOURCE_ID = "source.id";
/**
* Timestamp when the source data was extracted/downloaded/queried
*/
public static final String META_SOURCE_TIMESTAMP = "source.timestamp";
/**
* Strategy how to handle imported data.
* {@code replace-source} will drop any previous imports
* with the same {@code source.id}, {@code replace-visit} will
* delete any previous data with the same patient+visit combination.
* </dd>
*
* <dt>order.grouped</dt>
* <dd>If set to true, guarantees that all facts belonging to the same
*/
public static final String META_ETL_STRATEGY = "etl.strategy";
/**
* If set to true, guarantees that all facts belonging to the same
* patient+visit combination are provided en bloc.
* </dd>
*
* <dt>order.sorted</dt>
* <dd>If set to true, guarantees that all facts within the same
*/
public static final String META_ORDER_GROUPED = "order.grouped";
/**
* If set to true, guarantees that all facts within the same
* patient+visit combination occur in ascending order of start timestamp.
* </dd>
* </dl>
*/
public static final String META_ORDER_SORTED = "order.sorted";
/**
* Retrieve meta information for this supply of observations.
* For possible keys see {@link #META_ETL_STRATEGY} ...
* @param key meta key
* @return value for the meta key
*/
......
......@@ -93,16 +93,16 @@ public class JAXBObservationSupplier extends AbstractObservationParser implement
if( reader.getLocalName().equals("etl") ){
String etlStrategy = reader.getAttributeValue(null, "strategy");
// TODO use constants for etl.strategy, etc.
if( etlStrategy != null )setMeta("etl.strategy", etlStrategy);
if( etlStrategy != null )setMeta(ObservationSupplier.META_ETL_STRATEGY, etlStrategy);
reader.nextTag();
// should be end element
reader.nextTag();
}
if( reader.getLocalName().equals("source") ){
String sourceTimestamp = reader.getAttributeValue(null, "timestamp");
setMeta("source.timestamp", sourceTimestamp);
setMeta(ObservationSupplier.META_SOURCE_TIMESTAMP, sourceTimestamp);
String sourceId = reader.getAttributeValue(null, "id");
setMeta("source.id", sourceId);
setMeta(ObservationSupplier.META_SOURCE_ID, sourceId);
// will be set automatically by setMeta
//setSourceId(sourceId);
//setSourceTimestamp(parseSourceTimestamp(sourceTimestamp));
......
......@@ -30,6 +30,7 @@ import de.sekmi.histream.AbnormalFlag;
import de.sekmi.histream.DateTimeAccuracy;
import de.sekmi.histream.Modifier;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ObservationSupplier;
import de.sekmi.histream.Value;
import de.sekmi.histream.Value.Type;
import de.sekmi.histream.ext.Patient;
......@@ -204,8 +205,8 @@ class XMLObservationParser extends AbstractObservationParser{
}
protected void parseSource(AttributeAccessor atts){
setMeta("source.timestamp", atts.getValue("timestamp"));
setMeta("source.id", atts.getValue("id"));
setMeta(ObservationSupplier.META_SOURCE_TIMESTAMP, atts.getValue("timestamp"));
setMeta(ObservationSupplier.META_SOURCE_ID, atts.getValue("id"));
}
protected void parseEncounter(AttributeAccessor atts){
encounterStart = DateTimeAccuracy.parsePartialIso8601(atts.getValue("start"));
......
......@@ -81,7 +81,7 @@ public class XMLObservationSupplier extends XMLObservationParser implements Obse
if( reader.getLocalName().equals("etl") ){
String etlStrategy = reader.getAttributeValue(null, "strategy");
// TODO use constants for etl.strategy, etc.
if( etlStrategy != null )setMeta("etl.strategy", etlStrategy);
if( etlStrategy != null )setMeta(ObservationSupplier.META_ETL_STRATEGY, etlStrategy);
reader.nextTag();
// should be end element
reader.nextTag();
......
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