diff --git a/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/TrackFileImportDeviceIdentifierMongoHandler.java b/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/TrackFileImportDeviceIdentifierMongoHandler.java index 861510296f1..a9b1e2cd8b5 100644 --- a/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/TrackFileImportDeviceIdentifierMongoHandler.java +++ b/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/TrackFileImportDeviceIdentifierMongoHandler.java @@ -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 diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/trackfiles/TrackFileImportDeviceIdentifierImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/trackfiles/TrackFileImportDeviceIdentifierImpl.java index 632d10b7a40..cacfb50771e 100644 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/trackfiles/TrackFileImportDeviceIdentifierImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/trackfiles/TrackFileImportDeviceIdentifierImpl.java @@ -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 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); + } }