mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 20:13:52 +00:00
added placeholder identifier and ping identifier
This commit is contained in:
1 parent
dea531e6d0
commit
335e090ebc
14 files changed
+255
-21
No files matched your search
+14
@@ -0,0 +1,14 @@
|
||||
package com.sap.sailing.domain.racelog.tracking;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A device identifier used to identify a non-existent, virtual device, which is used only once as an
|
||||
* identifier to add a single fix to a track (i.e. pinging the location of that track's item).
|
||||
*
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface PingDeviceIdentifier extends DeviceIdentifier {
|
||||
UUID getId();
|
||||
}
|
||||
+2
@@ -52,6 +52,8 @@ public class Activator implements BundleActivator {
|
||||
registrations.add(context.registerService(DeviceIdentifierMongoHandler.class, new SmartphoneImeiMongoHandlerImpl(), getDict(SmartphoneImeiIdentifier.TYPE)));
|
||||
registrations.add(context.registerService(DeviceIdentifierJsonHandler.class, new SmartphoneImeiJsonHandlerImpl(), getDict(SmartphoneImeiIdentifier.TYPE)));
|
||||
|
||||
registrations.add(context.registerService(DeviceIdentifierMongoHandler.class, new PingDeviceMongoHandlerImpl(), getDict(PingDeviceIdentifierImpl.TYPE)));
|
||||
|
||||
registerGPSFixJsonService(context, new GPSFixJsonDeserializer(), new GPSFixJsonSerializer(), GPSFixJsonDeserializer.TYPE);
|
||||
registerGPSFixJsonService(context, new GPSFixMovingJsonDeserializer(), new GPSFixMovingJsonSerializer(), GPSFixMovingJsonDeserializer.TYPE);
|
||||
registerGPSFixJsonService(context, new GPSFixNmeaDTOJsonDeserializer(), new GPSFixNmeaDTOJsonSerializer(), GPSFixNmeaDTOJsonDeserializer.TYPE);
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.impl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.base.IsManagedBySharedDomainFactory;
|
||||
import com.sap.sailing.domain.base.SharedDomainFactory;
|
||||
import com.sap.sailing.domain.racelog.tracking.PingDeviceIdentifier;
|
||||
|
||||
public class PingDeviceIdentifierImpl implements PingDeviceIdentifier {
|
||||
private static final long serialVersionUID = -4049961972156611640L;
|
||||
|
||||
public static final String TYPE = "PING";
|
||||
|
||||
private final UUID id;
|
||||
|
||||
public PingDeviceIdentifierImpl() {
|
||||
this.id = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public PingDeviceIdentifierImpl(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifierType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsManagedBySharedDomainFactory resolve(SharedDomainFactory domainFactory) {
|
||||
//No resolving necessary, only relevant on the creating server
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringRepresentation() {
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.impl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelog.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelog.tracking.PingDeviceIdentifier;
|
||||
|
||||
public class PingDeviceMongoHandlerImpl implements DeviceIdentifierMongoHandler {
|
||||
private PingDeviceIdentifier castIdentifier(DeviceIdentifier identifier) throws TransformationException {
|
||||
if (!(identifier instanceof PingDeviceIdentifier))
|
||||
throw new TransformationException("Expected a PingDeviceIdentifier, got instead: " + identifier);
|
||||
return (PingDeviceIdentifier) identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object transformForth(DeviceIdentifier deviceIdentifier) throws TransformationException {
|
||||
return castIdentifier(deviceIdentifier).getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceIdentifier transformBack(Object input) {
|
||||
return new PingDeviceIdentifierImpl(UUID.fromString((String) input));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user