deal with null timepoints in device mapping events

This commit is contained in:
Fredrik Teschke committed 2014-03-16 17:00:21 +01:00
1 parent 53ef9027c9
commit cbe875af35
2 files changed
+9 -5

No files matched your search

@@ -204,7 +204,9 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
}
private TimePoint loadTimePoint(DBObject object, FieldNames field) {
return new MillisecondsTimePoint(((Number) object.get(field.name())).longValue());
Object loaded = object.get(field.name());
if (loaded == null) return null;
return new MillisecondsTimePoint(((Number) loaded).longValue());
}
/**
@@ -811,10 +811,12 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
e.printStackTrace();
}
result.put(FieldNames.DEVICE_ID.name(), deviceId);
TimePoint from = event.getFrom() == null ? new MillisecondsTimePoint(Long.MIN_VALUE) : event.getFrom();
TimePoint to = event.getTo() == null ? new MillisecondsTimePoint(Long.MAX_VALUE) : event.getTo();
storeTimePoint(from, result, FieldNames.RACE_LOG_FROM);
storeTimePoint(to, result, FieldNames.RACE_LOG_TO);
if (event.getFrom() != null) {
storeTimePoint(event.getFrom(), result, FieldNames.RACE_LOG_FROM);
}
if (event.getTo() != null) {
storeTimePoint(event.getTo(), result, FieldNames.RACE_LOG_TO);
}
}
private Object storeRaceLogDeviceCompetitorMappingEvent(DeviceCompetitorMappingEvent event) {