mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-20 11:10:00 +00:00
use persisted string representation when loading from mongodb
This commit is contained in:
1 parent
bcabc7b592
commit
f7a9c64ab8
2 files changed
+26
-3
No files matched your search
+1
-1
@@ -24,7 +24,7 @@ public class TrackFileImportDeviceIdentifierMongoHandler implements DeviceIdenti
|
||||
String trackName = (String) dbObject.get(Fields.TRACK_NAME.name());
|
||||
TimePoint uploaded = TrackFileImportDeviceIdentifierJsonHandler.
|
||||
loadTimePoint(dbObject.get(Fields.UPLOADED_MILLIS.name()));
|
||||
return new TrackFileImportDeviceIdentifierImpl(uuid, fileName, trackName, uploaded);
|
||||
return new TrackFileImportDeviceIdentifierImpl(uuid, stringRepresentation, fileName, trackName, uploaded);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+25
-2
@@ -15,6 +15,7 @@ public class TrackFileImportDeviceIdentifierImpl implements TrackFileImportDevic
|
||||
private final String fileName;
|
||||
private final String trackName;
|
||||
private final TimePoint timePoint;
|
||||
private final String stringRepresentation;
|
||||
|
||||
private static final ConcurrentMap<UUID, TrackFileImportDeviceIdentifier> cache = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -30,10 +31,18 @@ public class TrackFileImportDeviceIdentifierImpl implements TrackFileImportDevic
|
||||
}
|
||||
|
||||
public TrackFileImportDeviceIdentifierImpl(UUID id, String fileName, String trackName, TimePoint timePoint) {
|
||||
this(id, computeStringRepresentation(id, trackName, fileName, timePoint), fileName,
|
||||
trackName, timePoint);
|
||||
cache.put(id, this);
|
||||
}
|
||||
|
||||
public TrackFileImportDeviceIdentifierImpl(UUID id, String stringRepresentation, String fileName, String trackName,
|
||||
TimePoint timePoint) {
|
||||
this.id = id;
|
||||
this.fileName = fileName;
|
||||
this.trackName = trackName;
|
||||
this.timePoint = timePoint;
|
||||
this.stringRepresentation = stringRepresentation;
|
||||
cache.put(id, this);
|
||||
}
|
||||
|
||||
@@ -54,8 +63,7 @@ public class TrackFileImportDeviceIdentifierImpl implements TrackFileImportDevic
|
||||
|
||||
@Override
|
||||
public String getStringRepresentation() {
|
||||
return String.format("%s: %s\n @%s(uploaded %s)",
|
||||
id.toString(), trackName, fileName, timePoint);
|
||||
return stringRepresentation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,4 +100,19 @@ public class TrackFileImportDeviceIdentifierImpl implements TrackFileImportDevic
|
||||
}
|
||||
return (TrackFileImportDeviceIdentifier) deviceIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes unique string representation for this device identifier. This string representaion should be human
|
||||
* readable.
|
||||
*
|
||||
* @param id
|
||||
* @param fileName
|
||||
* @param trackName
|
||||
* @param timePoint
|
||||
* @return
|
||||
*/
|
||||
private static final String computeStringRepresentation(UUID id, String fileName, String trackName,
|
||||
TimePoint timePoint) {
|
||||
return String.format("%s: %s\n @%s(uploaded %s)", id.toString(), trackName, fileName, timePoint);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user