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

JAXB annotations

parent f49346d4
......@@ -2,31 +2,53 @@ package de.sekmi.histream.impl;
import java.time.Instant;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import de.sekmi.histream.ext.ExternalSourceType;
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class ExternalSourceImpl implements ExternalSourceType {
protected Instant sourceTimestamp;
protected String sourceId;
private Instant timestamp;
private String id;
public static class Adapter extends XmlAdapter<String, Instant>{
@Override
public Instant unmarshal(String v) throws Exception {
return javax.xml.bind.DatatypeConverter.parseDateTime(v).toInstant();
}
@Override
public String marshal(Instant v) throws Exception {
return v.toString();
}
}
@XmlAttribute(name="timestamp")
@XmlJavaTypeAdapter(Adapter.class)
@Override
public Instant getSourceTimestamp() {
return sourceTimestamp;
return timestamp;
}
@Override
public void setSourceTimestamp(Instant instant) {
this.sourceTimestamp = instant;
this.timestamp = instant;
}
@XmlAttribute(name="id")
@Override
public String getSourceId() {
return sourceId;
return id;
}
@Override
public void setSourceId(String sourceSystemId) {
this.sourceId = sourceSystemId;
this.id = sourceSystemId;
}
}
......@@ -42,11 +42,11 @@ public class Meta {
break;
case ObservationSupplier.META_SOURCE_ID:
if( source == null )source = new ExternalSourceImpl();
source.sourceId = value;
source.setSourceId(value);
break;
case ObservationSupplier.META_SOURCE_TIMESTAMP:
if( source == null )source = new ExternalSourceImpl();
source.sourceTimestamp = javax.xml.bind.DatatypeConverter.parseDateTime(value).toInstant();
source.setSourceTimestamp(javax.xml.bind.DatatypeConverter.parseDateTime(value).toInstant());
break;
}
}
......
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