Search in sources :

Example 1 with KapuaPayload

use of org.eclipse.kapua.message.KapuaPayload in project kapua by eclipse.

the class DeviceLifeCycleServiceImpl method death.

@Override
public void death(KapuaId connectionId, KapuaDisconnectMessage message) throws KapuaException {
    KapuaPayload payload = message.getPayload();
    KapuaId scopeId = message.getScopeId();
    KapuaId deviceId = message.getDeviceId();
    // 
    // Device update
    KapuaLocator locator = KapuaLocator.getInstance();
    DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
    Device device = deviceRegistryService.find(scopeId, deviceId);
    // 
    // Event create
    DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
    DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
    DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, deviceId, message.getReceivedOn(), "DEATH");
    deviceEventCreator.setReceivedOn(message.getReceivedOn());
    // TODO check this change
    deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
    deviceEventCreator.setSentOn(message.getSentOn());
    KapuaPosition position = message.getPosition();
    if (position != null) {
        deviceEventCreator.setPosition(position);
    }
    deviceEventService.create(deviceEventCreator);
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) KapuaPosition(org.eclipse.kapua.message.KapuaPosition) Device(org.eclipse.kapua.service.device.registry.Device) KapuaPayload(org.eclipse.kapua.message.KapuaPayload) DeviceRegistryService(org.eclipse.kapua.service.device.registry.DeviceRegistryService) DeviceEventService(org.eclipse.kapua.service.device.registry.event.DeviceEventService) DeviceEventFactory(org.eclipse.kapua.service.device.registry.event.DeviceEventFactory) DeviceEventCreator(org.eclipse.kapua.service.device.registry.event.DeviceEventCreator) KapuaId(org.eclipse.kapua.model.id.KapuaId)

Example 2 with KapuaPayload

use of org.eclipse.kapua.message.KapuaPayload in project kapua by eclipse.

the class DeviceLifeCycleServiceImpl method missing.

@Override
public void missing(KapuaId connectionId, KapuaMissingMessage message) throws KapuaException {
    KapuaPayload payload = message.getPayload();
    KapuaId scopeId = message.getScopeId();
    KapuaId deviceId = message.getDeviceId();
    // 
    // Device update
    KapuaLocator locator = KapuaLocator.getInstance();
    DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
    Device device = deviceRegistryService.find(scopeId, deviceId);
    // 
    // Event create
    DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
    DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
    DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, device.getId(), message.getReceivedOn(), "MISSING");
    deviceEventCreator.setEventMessage(payload.toDisplayString());
    // TODO check this change
    deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
    deviceEventCreator.setSentOn(message.getReceivedOn());
    KapuaPosition position = message.getPosition();
    if (position != null) {
        deviceEventCreator.setPosition(position);
    }
    deviceEventService.create(deviceEventCreator);
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) KapuaPosition(org.eclipse.kapua.message.KapuaPosition) Device(org.eclipse.kapua.service.device.registry.Device) KapuaPayload(org.eclipse.kapua.message.KapuaPayload) DeviceRegistryService(org.eclipse.kapua.service.device.registry.DeviceRegistryService) DeviceEventService(org.eclipse.kapua.service.device.registry.event.DeviceEventService) DeviceEventFactory(org.eclipse.kapua.service.device.registry.event.DeviceEventFactory) DeviceEventCreator(org.eclipse.kapua.service.device.registry.event.DeviceEventCreator) KapuaId(org.eclipse.kapua.model.id.KapuaId)

Example 3 with KapuaPayload

use of org.eclipse.kapua.message.KapuaPayload in project kapua by eclipse.

the class DeviceLifeCycleServiceImpl method applications.

@Override
public void applications(KapuaId connectionId, KapuaAppsMessage message) throws KapuaException {
    KapuaPayload payload = message.getPayload();
    KapuaId scopeId = message.getScopeId();
    KapuaId deviceId = message.getDeviceId();
    // 
    // Device update
    KapuaLocator locator = KapuaLocator.getInstance();
    DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
    Device device = deviceRegistryService.find(scopeId, deviceId);
    // 
    // Event create
    DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
    DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
    DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, device.getId(), message.getReceivedOn(), "APPLICATION");
    deviceEventCreator.setEventMessage(payload.toDisplayString());
    // TODO check this change
    deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
    deviceEventCreator.setSentOn(message.getReceivedOn());
    KapuaPosition position = message.getPosition();
    if (position != null) {
        deviceEventCreator.setPosition(position);
    }
    deviceEventService.create(deviceEventCreator);
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) KapuaPosition(org.eclipse.kapua.message.KapuaPosition) Device(org.eclipse.kapua.service.device.registry.Device) KapuaPayload(org.eclipse.kapua.message.KapuaPayload) DeviceRegistryService(org.eclipse.kapua.service.device.registry.DeviceRegistryService) DeviceEventService(org.eclipse.kapua.service.device.registry.event.DeviceEventService) DeviceEventFactory(org.eclipse.kapua.service.device.registry.event.DeviceEventFactory) DeviceEventCreator(org.eclipse.kapua.service.device.registry.event.DeviceEventCreator) KapuaId(org.eclipse.kapua.model.id.KapuaId)

Aggregations

KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)3 KapuaPayload (org.eclipse.kapua.message.KapuaPayload)3 KapuaPosition (org.eclipse.kapua.message.KapuaPosition)3 KapuaId (org.eclipse.kapua.model.id.KapuaId)3 Device (org.eclipse.kapua.service.device.registry.Device)3 DeviceRegistryService (org.eclipse.kapua.service.device.registry.DeviceRegistryService)3 DeviceEventCreator (org.eclipse.kapua.service.device.registry.event.DeviceEventCreator)3 DeviceEventFactory (org.eclipse.kapua.service.device.registry.event.DeviceEventFactory)3 DeviceEventService (org.eclipse.kapua.service.device.registry.event.DeviceEventService)3