Loading src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java +9 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package eu.teraflow.automation; import eu.teraflow.automation.context.ContextService; import eu.teraflow.automation.context.model.Event; import eu.teraflow.automation.context.model.EventTypeEnum; import io.quarkus.runtime.StartupEvent; import java.time.Duration; import javax.enterprise.context.ApplicationScoped; Loading Loading @@ -75,11 +77,7 @@ public class ContextSubscriber { case UPDATE: case REMOVE: case UNDEFINED: { LOGGER.warnf( "Received %s for device [%s]. [%s] event handling is not yet implemented, ignoring...", event, deviceId, eventType); } logWarningMessage(event, deviceId, eventType); break; } }); Loading @@ -94,4 +92,10 @@ public class ContextSubscriber { LOGGER.info("Not subscribing to Context service for device events..."); } } private void logWarningMessage(Event event, String deviceId, EventTypeEnum eventType) { LOGGER.warnf( "Received %s for device [%s]. [%s] event handling is not yet implemented, ignoring...", event, deviceId, eventType); } } src/automation/src/main/java/eu/teraflow/automation/Serializer.java +13 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import context.ContextOuterClass.ConfigRule_Custom; import context.ContextOuterClass.ContextId; import context.ContextOuterClass.DeviceId; import context.ContextOuterClass.DeviceOperationalStatusEnum; import context.ContextOuterClass.Location.LocationCase; import context.ContextOuterClass.Uuid; import eu.teraflow.automation.acl.AclAction; import eu.teraflow.automation.acl.AclEntry; Loading Loading @@ -833,12 +834,14 @@ public class Serializer { final var serializedEndPointId = serialize(endPointId); final var serializedKpiSampleTypes = kpiSampleTypes.stream().map(this::serialize).collect(Collectors.toList()); if (endPointLocation != null) { final var serializedEndPointLocation = serialize(endPointLocation); builder.setEndpointLocation(serializedEndPointLocation); } builder.setEndpointId(serializedEndPointId); builder.setEndpointType(endPointType); builder.addAllKpiSampleTypes(serializedKpiSampleTypes); builder.setEndpointLocation(serializedEndPointLocation); return builder.build(); } Loading @@ -852,9 +855,15 @@ public class Serializer { final var endPointId = deserialize(serializedEndPointId); final var kpiSampleTypes = serializedKpiSampleTypes.stream().map(this::deserialize).collect(Collectors.toList()); if (serializedEndPointLocation.getLocationCase() != LocationCase.LOCATION_NOT_SET) { final var endPointLocation = deserialize(serializedEndPointLocation); return new EndPoint.EndPointBuilder(endPointId, endPointType, kpiSampleTypes) .location(endPointLocation) .build(); } return new EndPoint(endPointId, endPointType, kpiSampleTypes, endPointLocation); return new EndPoint.EndPointBuilder(endPointId, endPointType, kpiSampleTypes).build(); } public ContextOuterClass.Device serialize(Device device) { Loading src/automation/src/main/java/eu/teraflow/automation/acl/AclRuleSet.java +7 −6 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package eu.teraflow.automation.acl; import eu.teraflow.automation.common.Util; import java.util.List; import java.util.stream.Collectors; public class AclRuleSet { Loading Loading @@ -64,10 +64,11 @@ public class AclRuleSet { public String toString() { return String.format( "%s:{name:\"%s\", type:\"%s\", description:\"%s\", userId:\"%s\", [%s]}", getClass().getSimpleName(), name, type.toString(), description, userId, toString(entries)); } private static <T> String toString(List<T> list) { return list.stream().map(T::toString).collect(Collectors.joining(", ")); getClass().getSimpleName(), name, type.toString(), description, userId, Util.toString(entries)); } } src/automation/src/main/java/eu/teraflow/automation/common/Util.java 0 → 100644 +29 −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.common; import java.util.List; import java.util.stream.Collectors; public class Util { private Util() {} public static <T> String toString(List<T> list) { return list.stream().map(T::toString).collect(Collectors.joining(", ")); } } src/automation/src/main/java/eu/teraflow/automation/context/model/Device.java +3 −7 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package eu.teraflow.automation.context.model; import eu.teraflow.automation.common.Util; import java.util.List; import java.util.stream.Collectors; public class Device { Loading Loading @@ -102,11 +102,7 @@ public class Device { deviceType, deviceConfig, deviceOperationalStatus.toString(), toString(deviceDrivers), toString(endPoints)); } private static <T> String toString(List<T> list) { return list.stream().map(T::toString).collect(Collectors.joining(", ")); Util.toString(deviceDrivers), Util.toString(endPoints)); } } Loading
src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java +9 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package eu.teraflow.automation; import eu.teraflow.automation.context.ContextService; import eu.teraflow.automation.context.model.Event; import eu.teraflow.automation.context.model.EventTypeEnum; import io.quarkus.runtime.StartupEvent; import java.time.Duration; import javax.enterprise.context.ApplicationScoped; Loading Loading @@ -75,11 +77,7 @@ public class ContextSubscriber { case UPDATE: case REMOVE: case UNDEFINED: { LOGGER.warnf( "Received %s for device [%s]. [%s] event handling is not yet implemented, ignoring...", event, deviceId, eventType); } logWarningMessage(event, deviceId, eventType); break; } }); Loading @@ -94,4 +92,10 @@ public class ContextSubscriber { LOGGER.info("Not subscribing to Context service for device events..."); } } private void logWarningMessage(Event event, String deviceId, EventTypeEnum eventType) { LOGGER.warnf( "Received %s for device [%s]. [%s] event handling is not yet implemented, ignoring...", event, deviceId, eventType); } }
src/automation/src/main/java/eu/teraflow/automation/Serializer.java +13 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import context.ContextOuterClass.ConfigRule_Custom; import context.ContextOuterClass.ContextId; import context.ContextOuterClass.DeviceId; import context.ContextOuterClass.DeviceOperationalStatusEnum; import context.ContextOuterClass.Location.LocationCase; import context.ContextOuterClass.Uuid; import eu.teraflow.automation.acl.AclAction; import eu.teraflow.automation.acl.AclEntry; Loading Loading @@ -833,12 +834,14 @@ public class Serializer { final var serializedEndPointId = serialize(endPointId); final var serializedKpiSampleTypes = kpiSampleTypes.stream().map(this::serialize).collect(Collectors.toList()); if (endPointLocation != null) { final var serializedEndPointLocation = serialize(endPointLocation); builder.setEndpointLocation(serializedEndPointLocation); } builder.setEndpointId(serializedEndPointId); builder.setEndpointType(endPointType); builder.addAllKpiSampleTypes(serializedKpiSampleTypes); builder.setEndpointLocation(serializedEndPointLocation); return builder.build(); } Loading @@ -852,9 +855,15 @@ public class Serializer { final var endPointId = deserialize(serializedEndPointId); final var kpiSampleTypes = serializedKpiSampleTypes.stream().map(this::deserialize).collect(Collectors.toList()); if (serializedEndPointLocation.getLocationCase() != LocationCase.LOCATION_NOT_SET) { final var endPointLocation = deserialize(serializedEndPointLocation); return new EndPoint.EndPointBuilder(endPointId, endPointType, kpiSampleTypes) .location(endPointLocation) .build(); } return new EndPoint(endPointId, endPointType, kpiSampleTypes, endPointLocation); return new EndPoint.EndPointBuilder(endPointId, endPointType, kpiSampleTypes).build(); } public ContextOuterClass.Device serialize(Device device) { Loading
src/automation/src/main/java/eu/teraflow/automation/acl/AclRuleSet.java +7 −6 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package eu.teraflow.automation.acl; import eu.teraflow.automation.common.Util; import java.util.List; import java.util.stream.Collectors; public class AclRuleSet { Loading Loading @@ -64,10 +64,11 @@ public class AclRuleSet { public String toString() { return String.format( "%s:{name:\"%s\", type:\"%s\", description:\"%s\", userId:\"%s\", [%s]}", getClass().getSimpleName(), name, type.toString(), description, userId, toString(entries)); } private static <T> String toString(List<T> list) { return list.stream().map(T::toString).collect(Collectors.joining(", ")); getClass().getSimpleName(), name, type.toString(), description, userId, Util.toString(entries)); } }
src/automation/src/main/java/eu/teraflow/automation/common/Util.java 0 → 100644 +29 −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.common; import java.util.List; import java.util.stream.Collectors; public class Util { private Util() {} public static <T> String toString(List<T> list) { return list.stream().map(T::toString).collect(Collectors.joining(", ")); } }
src/automation/src/main/java/eu/teraflow/automation/context/model/Device.java +3 −7 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package eu.teraflow.automation.context.model; import eu.teraflow.automation.common.Util; import java.util.List; import java.util.stream.Collectors; public class Device { Loading Loading @@ -102,11 +102,7 @@ public class Device { deviceType, deviceConfig, deviceOperationalStatus.toString(), toString(deviceDrivers), toString(endPoints)); } private static <T> String toString(List<T> list) { return list.stream().map(T::toString).collect(Collectors.joining(", ")); Util.toString(deviceDrivers), Util.toString(endPoints)); } }