mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
fix bug #1740: create new DBObject instead of enriching in DeviceIdentifierPersistenceHandler
This commit is contained in:
1 parent
b48bae009d
commit
23a8cc8214
2 files changed
+8
-14
No files matched your search
+2
-10
@@ -4,14 +4,6 @@ import com.mongodb.DBObject;
|
||||
import com.sap.sailing.domain.devices.DeviceIdentifier;
|
||||
|
||||
public interface DeviceIdentifierPersistenceHandler {
|
||||
/**
|
||||
* Enrich the base object with the necessary data for this specific
|
||||
* device identifier type.
|
||||
* @param base
|
||||
* @param deviceIdentifiers
|
||||
* @return
|
||||
*/
|
||||
DBObject enrichDBObject(DBObject base, DeviceIdentifier deviceIdentifier) throws IllegalArgumentException;
|
||||
|
||||
DeviceIdentifier loadFromDBObject(DBObject input);
|
||||
DBObject store(DeviceIdentifier deviceIdentifier) throws IllegalArgumentException;
|
||||
DeviceIdentifier load(DBObject input);
|
||||
}
|
||||
+6
-4
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.smartphoneadapter.impl;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import com.sap.sailing.domain.devices.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.devices.SmartphoneImeiIdentifier;
|
||||
@@ -11,19 +12,20 @@ public class SmartphoneImeiHandlerImpl implements DeviceIdentifierPersistenceHan
|
||||
public static final String FIELD_IMEI = "imei";
|
||||
|
||||
@Override
|
||||
public DBObject enrichDBObject(DBObject base, DeviceIdentifier deviceIdentifier) throws IllegalArgumentException {
|
||||
public DBObject store(DeviceIdentifier deviceIdentifier) throws IllegalArgumentException {
|
||||
if (!(deviceIdentifier instanceof SmartphoneImeiIdentifier)) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Unexpected device identifier of type %s while trying to persist smartphone IMEI identifier",
|
||||
deviceIdentifier.getClass().getName()));
|
||||
}
|
||||
DBObject result = new BasicDBObject();
|
||||
SmartphoneImeiIdentifier imeiIdentifier = (SmartphoneImeiIdentifier) deviceIdentifier;
|
||||
base.put(FIELD_IMEI, imeiIdentifier.getImei());
|
||||
return base;
|
||||
result.put(FIELD_IMEI, imeiIdentifier.getImei());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmartphoneImeiIdentifier loadFromDBObject(DBObject input) {
|
||||
public SmartphoneImeiIdentifier load(DBObject input) {
|
||||
return new SmartphoneImeiIdentifier((String) input.get(FIELD_IMEI));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user