Loading src/automation/src/main/java/eu/teraflow/automation/AutomationService.java +2 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,6 @@ import io.smallrye.mutiny.Uni; public interface AutomationService { Uni<Device> addDevice(String deviceId); Uni<Device> deleteDevice(String deviceId); } src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java +22 −0 Original line number Diff line number Diff line Loading @@ -80,4 +80,26 @@ public class AutomationServiceImpl implements AutomationService { return deserializedDeviceUni; } @Override public Uni<Device> deleteDevice(String deviceId) { final var deserializedDeviceUni = contextService.getDevice(deviceId); deserializedDeviceUni .subscribe() .with( device -> { final var id = deviceId; LOGGER.infof("Retrieved %s", device); final var empty = deviceService.deleteDevice(device.getDeviceId()); empty .subscribe() .with(emptyMessage -> LOGGER.infof("Device [%s] has been deleted.\n", id)); }); return deserializedDeviceUni; } } src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java +4 −1 Original line number Diff line number Diff line Loading @@ -73,9 +73,12 @@ public class ContextSubscriber { LOGGER.infof("Received %s for device [%s]", event, deviceId); automationService.addDevice(deviceEvent.getDeviceId()); break; case REMOVE: LOGGER.infof("Received %s for device [%s]", event, deviceId); automationService.deleteDevice(deviceEvent.getDeviceId()); break; case UPDATE: case REMOVE: case UNDEFINED: logWarningMessage(event, deviceId, eventType); break; Loading src/automation/src/main/java/eu/teraflow/automation/Serializer.java +12 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import eu.teraflow.automation.context.model.DeviceConfig; import eu.teraflow.automation.context.model.DeviceDriverEnum; import eu.teraflow.automation.context.model.DeviceEvent; import eu.teraflow.automation.context.model.DeviceOperationalStatus; import eu.teraflow.automation.context.model.Empty; import eu.teraflow.automation.context.model.EndPoint; import eu.teraflow.automation.context.model.EndPointId; import eu.teraflow.automation.context.model.Event; Loading Loading @@ -920,6 +921,17 @@ public class Serializer { deviceEndPoints); } public ContextOuterClass.Empty serializeEmpty(Empty empty) { final var builder = ContextOuterClass.Empty.newBuilder(); return builder.build(); } public Empty deserializeEmpty(ContextOuterClass.Empty serializedEmpty) { return new Empty(); } public Uuid serializeUuid(String uuid) { return Uuid.newBuilder().setUuid(uuid).build(); } Loading src/automation/src/main/java/eu/teraflow/automation/context/model/Empty.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package eu.teraflow.automation.context.model; public class Empty { public Empty() { // Empty constructor to represent the Empty rpc message of context service } } Loading
src/automation/src/main/java/eu/teraflow/automation/AutomationService.java +2 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,6 @@ import io.smallrye.mutiny.Uni; public interface AutomationService { Uni<Device> addDevice(String deviceId); Uni<Device> deleteDevice(String deviceId); }
src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java +22 −0 Original line number Diff line number Diff line Loading @@ -80,4 +80,26 @@ public class AutomationServiceImpl implements AutomationService { return deserializedDeviceUni; } @Override public Uni<Device> deleteDevice(String deviceId) { final var deserializedDeviceUni = contextService.getDevice(deviceId); deserializedDeviceUni .subscribe() .with( device -> { final var id = deviceId; LOGGER.infof("Retrieved %s", device); final var empty = deviceService.deleteDevice(device.getDeviceId()); empty .subscribe() .with(emptyMessage -> LOGGER.infof("Device [%s] has been deleted.\n", id)); }); return deserializedDeviceUni; } }
src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java +4 −1 Original line number Diff line number Diff line Loading @@ -73,9 +73,12 @@ public class ContextSubscriber { LOGGER.infof("Received %s for device [%s]", event, deviceId); automationService.addDevice(deviceEvent.getDeviceId()); break; case REMOVE: LOGGER.infof("Received %s for device [%s]", event, deviceId); automationService.deleteDevice(deviceEvent.getDeviceId()); break; case UPDATE: case REMOVE: case UNDEFINED: logWarningMessage(event, deviceId, eventType); break; Loading
src/automation/src/main/java/eu/teraflow/automation/Serializer.java +12 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import eu.teraflow.automation.context.model.DeviceConfig; import eu.teraflow.automation.context.model.DeviceDriverEnum; import eu.teraflow.automation.context.model.DeviceEvent; import eu.teraflow.automation.context.model.DeviceOperationalStatus; import eu.teraflow.automation.context.model.Empty; import eu.teraflow.automation.context.model.EndPoint; import eu.teraflow.automation.context.model.EndPointId; import eu.teraflow.automation.context.model.Event; Loading Loading @@ -920,6 +921,17 @@ public class Serializer { deviceEndPoints); } public ContextOuterClass.Empty serializeEmpty(Empty empty) { final var builder = ContextOuterClass.Empty.newBuilder(); return builder.build(); } public Empty deserializeEmpty(ContextOuterClass.Empty serializedEmpty) { return new Empty(); } public Uuid serializeUuid(String uuid) { return Uuid.newBuilder().setUuid(uuid).build(); } Loading
src/automation/src/main/java/eu/teraflow/automation/context/model/Empty.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package eu.teraflow.automation.context.model; public class Empty { public Empty() { // Empty constructor to represent the Empty rpc message of context service } }