diff --git a/io.openems.backend.alerting/src/io/openems/backend/alerting/handler/OfflineEdgeHandler.java b/io.openems.backend.alerting/src/io/openems/backend/alerting/handler/OfflineEdgeHandler.java index bed59129c09..a40b932b82e 100644 --- a/io.openems.backend.alerting/src/io/openems/backend/alerting/handler/OfflineEdgeHandler.java +++ b/io.openems.backend.alerting/src/io/openems/backend/alerting/handler/OfflineEdgeHandler.java @@ -16,7 +16,7 @@ import io.openems.backend.alerting.scheduler.MessageSchedulerService; import io.openems.backend.alerting.scheduler.TimedExecutor; import io.openems.backend.alerting.scheduler.TimedExecutor.TimedTask; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.Mailer; import io.openems.backend.common.metadata.Metadata; @@ -175,7 +175,7 @@ protected OfflineEdgeMessage getEdgeMessage(Edge edge) { return null; } - private boolean shouldReceiveMail(Edge edge, AlertingSetting setting) { + private boolean shouldReceiveMail(Edge edge, UserAlertingSettings setting) { final var lastMailRecievedAt = setting.getLastNotification(); final var edgeOfflineSince = edge.getLastmessage(); diff --git a/io.openems.backend.alerting/src/io/openems/backend/alerting/message/OfflineEdgeMessage.java b/io.openems.backend.alerting/src/io/openems/backend/alerting/message/OfflineEdgeMessage.java index 623ca622388..4db099025d3 100644 --- a/io.openems.backend.alerting/src/io/openems/backend/alerting/message/OfflineEdgeMessage.java +++ b/io.openems.backend.alerting/src/io/openems/backend/alerting/message/OfflineEdgeMessage.java @@ -10,7 +10,7 @@ import com.google.gson.JsonPrimitive; import io.openems.backend.alerting.Message; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.common.utils.JsonUtils; public class OfflineEdgeMessage extends Message { @@ -18,9 +18,9 @@ public class OfflineEdgeMessage extends Message { public static final String TEMPLATE = "alerting_email"; private final ZonedDateTime offlineAt; - private final TreeMap> recipients; + private final TreeMap> recipients; - private OfflineEdgeMessage(String edgeId, ZonedDateTime offlineAt, TreeMap> map) { + private OfflineEdgeMessage(String edgeId, ZonedDateTime offlineAt, TreeMap> map) { super(edgeId); this.offlineAt = offlineAt; this.recipients = map; @@ -41,13 +41,13 @@ public ZonedDateTime getNotifyStamp() { * * @param setting of user to whom to send the mail to */ - public void addRecipient(AlertingSetting setting) { + public void addRecipient(UserAlertingSettings setting) { this.recipients.putIfAbsent(setting.getDelayTime(), new ArrayList<>()); var settings = this.recipients.get(setting.getDelayTime()); settings.add(setting); } - public List getCurrentRecipients() { + public List getCurrentRecipients() { return this.recipients.get(this.recipients.firstKey()); } @@ -84,7 +84,7 @@ public JsonObject getParams() { @Override public String toString() { - var rec = this.getCurrentRecipients().stream().map(AlertingSetting::getUserId).collect(Collectors.joining(",")); + var rec = this.getCurrentRecipients().stream().map(UserAlertingSettings::getUserId).collect(Collectors.joining(",")); return "OfflineEdgeMessage{for=" + this.getEdgeId() + ", to=[" + rec + "], at=" + this.getNotifyStamp() + "}"; } } diff --git a/io.openems.backend.alerting/test/io/openems/backend/alerting/Dummy.java b/io.openems.backend.alerting/test/io/openems/backend/alerting/Dummy.java index d53f32df1d2..661d35c37fc 100644 --- a/io.openems.backend.alerting/test/io/openems/backend/alerting/Dummy.java +++ b/io.openems.backend.alerting/test/io/openems/backend/alerting/Dummy.java @@ -20,7 +20,7 @@ import io.openems.backend.alerting.scheduler.MessageScheduler; import io.openems.backend.alerting.scheduler.MessageSchedulerService; import io.openems.backend.alerting.scheduler.MinuteTimer; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.Mailer; import io.openems.backend.common.test.DummyMetadata; @@ -83,7 +83,7 @@ public EventAdmin getEventAdmin() { public static class AlertingMetadataImpl extends SimpleMetadataImpl { private Collection edges; - private Map> alertingSettings; + private Map> alertingSettings; private Map sumStates = new HashMap<>(10); /** @@ -92,7 +92,7 @@ public static class AlertingMetadataImpl extends SimpleMetadataImpl { * @param edges to add * @param settings to add */ - public void initialize(Collection edges, Map> settings) { + public void initialize(Collection edges, Map> settings) { this.edges = edges; this.alertingSettings = settings; } @@ -113,7 +113,7 @@ public Collection getAllOfflineEdges() { } @Override - public List getUserAlertingSettings(String edgeId) { + public List getUserAlertingSettings(String edgeId) { return this.alertingSettings.get(edgeId); } @@ -125,7 +125,7 @@ public Collection getEdges() { return this.edges; } - public Map> getAlertingSettings() { + public Map> getAlertingSettings() { return this.alertingSettings; } } diff --git a/io.openems.backend.alerting/test/io/openems/backend/alerting/OfflineEdgeAlertingTest.java b/io.openems.backend.alerting/test/io/openems/backend/alerting/OfflineEdgeAlertingTest.java index 92bee5b633b..ce0417d6015 100644 --- a/io.openems.backend.alerting/test/io/openems/backend/alerting/OfflineEdgeAlertingTest.java +++ b/io.openems.backend.alerting/test/io/openems/backend/alerting/OfflineEdgeAlertingTest.java @@ -18,7 +18,7 @@ import io.openems.backend.alerting.Dummy.MailerImpl; import io.openems.backend.alerting.Dummy.TimeLeapMinuteTimer; import io.openems.backend.alerting.scheduler.Scheduler; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.common.event.EventBuilder; @@ -36,7 +36,7 @@ record SimpleAlertingSetting(String user, int delay) { private Scheduler scheduler; private HashMap edges; - private Map> settings; + private Map> settings; public TestEnvironment() { final var instant = Instant.now(); @@ -86,9 +86,9 @@ public void createEdge(int id, boolean online, ZonedDateTime lastMessage, Simple edge.setOnline(online); this.edges.put(id, edge); - var list = new ArrayList(5); + var list = new ArrayList(5); for (var set : settings) { - list.add(new AlertingSetting(id, set.user, null, lastMessage, set.delay)); + list.add(new UserAlertingSettings(id, set.user, null, lastMessage, set.delay)); } this.settings.put(edge.getId(), list); diff --git a/io.openems.backend.alerting/test/io/openems/backend/alerting/handler/TestOfflineEdgeHandler.java b/io.openems.backend.alerting/test/io/openems/backend/alerting/handler/TestOfflineEdgeHandler.java index 7ee5cd3eca6..65032f62208 100644 --- a/io.openems.backend.alerting/test/io/openems/backend/alerting/handler/TestOfflineEdgeHandler.java +++ b/io.openems.backend.alerting/test/io/openems/backend/alerting/handler/TestOfflineEdgeHandler.java @@ -22,7 +22,7 @@ import io.openems.backend.alerting.Dummy.SimpleMetadataImpl; import io.openems.backend.alerting.message.OfflineEdgeMessage; import io.openems.backend.alerting.scheduler.MinuteTimer; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.Metadata; import io.openems.backend.common.test.DummyMetadata; @@ -56,12 +56,12 @@ public void send() { final var timer = new MinuteTimer(Clock.systemUTC()); final var handler = new OfflineEdgeHandler(msgsch, timer, mailer, Utility.getTestMetadata(), 1); final var msg_1 = new OfflineEdgeMessage("1", ZonedDateTime.now().minusSeconds(1)); - msg_1.addRecipient(new AlertingSetting(1, "user1", null, null, 1)); - msg_1.addRecipient(new AlertingSetting(1, "user2", null, null, 2)); + msg_1.addRecipient(new UserAlertingSettings(1, "user1", null, null, 1)); + msg_1.addRecipient(new UserAlertingSettings(1, "user2", null, null, 2)); final var msg_2 = new OfflineEdgeMessage("Fail", ZonedDateTime.now().minusSeconds(2)); - msg_2.addRecipient(new AlertingSetting(2, "user1", null, null, 1)); - msg_2.addRecipient(new AlertingSetting(2, "user2", null, null, 2)); + msg_2.addRecipient(new UserAlertingSettings(2, "user1", null, null, 1)); + msg_2.addRecipient(new UserAlertingSettings(2, "user2", null, null, 2)); assertEquals(mailer.sentMails.size(), 0); var msgs = new ArrayList<>(List.of(msg_1, msg_2)); @@ -180,16 +180,16 @@ private static AlertingMetadataImpl getTestMetadata() { Utility.getTestEdge(metadata, "5", Utility.now.minusMonths(1), false), // Utility.getTestEdge(metadata, "6", null, false)); // - final Map> settings = Map.of(// + final Map> settings = Map.of(// "1", List.of(// - new AlertingSetting(1, "user1", null, Utility.now.minusDays(1), 1)), // + new UserAlertingSettings(1, "user1", null, Utility.now.minusDays(1), 1)), // "2", List.of(), // "3", List.of(// - new AlertingSetting(3, "user1", null, Utility.now.plusDays(1), 1), // - new AlertingSetting(3, "user2", null, Utility.now, 0)), // + new UserAlertingSettings(3, "user1", null, Utility.now.plusDays(1), 1), // + new UserAlertingSettings(3, "user2", null, Utility.now, 0)), // "4", List.of(// - new AlertingSetting(4, "edge2", null, Utility.now.minusDays(1), 1), // - new AlertingSetting(4, "edge3", null, Utility.now.minusDays(1), 2)) // + new UserAlertingSettings(4, "edge2", null, Utility.now.minusDays(1), 1), // + new UserAlertingSettings(4, "edge3", null, Utility.now.minusDays(1), 2)) // ); metadata.initialize(edges, settings); @@ -206,13 +206,13 @@ private static class ToManyMsgsMetadata extends DummyMetadata { private final ZonedDateTime now = ZonedDateTime.now(); private final ZonedDateTime yesterday = this.now.minusDays(1); - private List userList = List.of(// - new AlertingSetting(1, "user0", null, this.yesterday, 60), // - new AlertingSetting(1, "user1", null, this.yesterday, 15), // - new AlertingSetting(1, "user2", null, this.yesterday, 10), // - new AlertingSetting(1, "user3", null, this.yesterday, 30), // - new AlertingSetting(1, "user4", null, this.yesterday, 30), // - new AlertingSetting(1, "user5", null, this.yesterday, 1440)); + private List userList = List.of(// + new UserAlertingSettings(1, "user0", null, this.yesterday, 60), // + new UserAlertingSettings(1, "user1", null, this.yesterday, 15), // + new UserAlertingSettings(1, "user2", null, this.yesterday, 10), // + new UserAlertingSettings(1, "user3", null, this.yesterday, 30), // + new UserAlertingSettings(1, "user4", null, this.yesterday, 30), // + new UserAlertingSettings(1, "user5", null, this.yesterday, 1440)); @Override public boolean isInitialized() { @@ -231,7 +231,7 @@ public Collection getAllOfflineEdges() { } @Override - public List getUserAlertingSettings(String edgeId) { + public List getUserAlertingSettings(String edgeId) { return this.userList; } } @@ -256,11 +256,11 @@ public Collection getAllOfflineEdges() { } @Override - public List getUserAlertingSettings(String edgeId) { + public List getUserAlertingSettings(String edgeId) { return List.of(// - new AlertingSetting(0, "user0", null, this.yesterday, 60), // - new AlertingSetting(0, "user1", null, this.yesterday, 15), // - new AlertingSetting(0, "user2", null, this.yesterday, 0) // + new UserAlertingSettings(0, "user0", null, this.yesterday, 60), // + new UserAlertingSettings(0, "user1", null, this.yesterday, 15), // + new UserAlertingSettings(0, "user2", null, this.yesterday, 0) // ); } } diff --git a/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/request/SetUserAlertingConfigsRequest.java b/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/request/SetUserAlertingConfigsRequest.java index b3df7d16750..d8baffc979f 100644 --- a/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/request/SetUserAlertingConfigsRequest.java +++ b/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/request/SetUserAlertingConfigsRequest.java @@ -6,7 +6,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.common.exceptions.OpenemsError.OpenemsNamedException; import io.openems.common.jsonrpc.base.JsonrpcRequest; import io.openems.common.utils.JsonUtils; @@ -47,7 +47,7 @@ public static SetUserAlertingConfigsRequest from(JsonrpcRequest request) throws } private final String edgeId; - private final List userSettings = new ArrayList<>(); + private final List userSettings = new ArrayList<>(); private SetUserAlertingConfigsRequest(JsonrpcRequest request) throws OpenemsNamedException { super(request, SetUserAlertingConfigsRequest.METHOD); @@ -60,7 +60,7 @@ private SetUserAlertingConfigsRequest(JsonrpcRequest request) throws OpenemsName var userId = JsonUtils.getAsString(userJsonObject, "userId"); var timeToWait = JsonUtils.getAsInt(userJsonObject, "delayTime"); - this.userSettings.add(new AlertingSetting(userId, timeToWait)); + this.userSettings.add(new UserAlertingSettings(userId, timeToWait)); } catch (OpenemsNamedException e) { e.printStackTrace(); } @@ -81,7 +81,7 @@ public String getEdgeId() { * * @return list of {@link UserAlertingSetting} */ - public List getUserSettings() { + public List getUserSettings() { return this.userSettings; } @@ -93,7 +93,7 @@ public JsonObject getParams() { .build(); } - private JsonElement toJson(AlertingSetting setting) { + private JsonElement toJson(UserAlertingSettings setting) { return JsonUtils.buildJsonObject() // .addProperty("userId", setting.getUserId()) // .addProperty("delayTime", setting.getDelayTime()) // diff --git a/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/response/GetUserAlertingConfigsResponse.java b/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/response/GetUserAlertingConfigsResponse.java index 5e646060262..555c1c78b85 100644 --- a/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/response/GetUserAlertingConfigsResponse.java +++ b/io.openems.backend.common/src/io/openems/backend/common/jsonrpc/response/GetUserAlertingConfigsResponse.java @@ -6,7 +6,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.common.jsonrpc.base.JsonrpcResponseSuccess; import io.openems.common.session.Role; import io.openems.common.utils.JsonUtils; @@ -32,9 +32,9 @@ */ public class GetUserAlertingConfigsResponse extends JsonrpcResponseSuccess { - private final List settings; + private final List settings; - public GetUserAlertingConfigsResponse(UUID id, List settings) { + public GetUserAlertingConfigsResponse(UUID id, List settings) { super(id); this.settings = settings; } @@ -46,7 +46,7 @@ public JsonObject getResult() { .build(); } - private JsonElement toJson(AlertingSetting setting) { + private JsonElement toJson(UserAlertingSettings setting) { return JsonUtils.buildJsonObject() // .addProperty("userId", setting.getUserId()) // .add("role", setting.getUserRole().asJson()) // diff --git a/io.openems.backend.common/src/io/openems/backend/common/metadata/Metadata.java b/io.openems.backend.common/src/io/openems/backend/common/metadata/Metadata.java index 3a9ebbd01f8..0c37dc3e4ec 100644 --- a/io.openems.backend.common/src/io/openems/backend/common/metadata/Metadata.java +++ b/io.openems.backend.common/src/io/openems/backend/common/metadata/Metadata.java @@ -295,10 +295,10 @@ public static String activeStateChannelsToString( * * * @param edgeId the Edge ID - * @return List of {@link AlertingSetting} + * @return List of {@link UserAlertingSettings} * @throws OpenemsException on error */ - public List getUserAlertingSettings(String edgeId) throws OpenemsException; + public List getUserAlertingSettings(String edgeId) throws OpenemsException; /** * Gets the alerting settings for given edge id and userId. @@ -308,7 +308,7 @@ public static String activeStateChannelsToString( * @return List of {@link UserRoleDelayTime} * @throws OpenemsException on error */ - public AlertingSetting getUserAlertingSettings(String edgeId, String userId) throws OpenemsException; + public UserAlertingSettings getUserAlertingSettings(String edgeId, String userId) throws OpenemsException; /** * Sets the alerting settings for the given list of users. @@ -318,7 +318,7 @@ public static String activeStateChannelsToString( * @param users list of users to update * @throws OpenemsException on error */ - public void setUserAlertingSettings(User user, String edgeId, List users) throws OpenemsException; + public void setUserAlertingSettings(User user, String edgeId, List users) throws OpenemsException; /** * Returns an EventAdmin, used by Edge objects. diff --git a/io.openems.backend.common/src/io/openems/backend/common/metadata/AlertingSetting.java b/io.openems.backend.common/src/io/openems/backend/common/metadata/UserAlertingSettings.java similarity index 80% rename from io.openems.backend.common/src/io/openems/backend/common/metadata/AlertingSetting.java rename to io.openems.backend.common/src/io/openems/backend/common/metadata/UserAlertingSettings.java index 44fef162b57..4660a95b1b1 100644 --- a/io.openems.backend.common/src/io/openems/backend/common/metadata/AlertingSetting.java +++ b/io.openems.backend.common/src/io/openems/backend/common/metadata/UserAlertingSettings.java @@ -5,18 +5,18 @@ import io.openems.common.session.Role; -public class AlertingSetting { +public class UserAlertingSettings { private final int id; private final String userId; private final Role userRole; private final ZonedDateTime lastNotification; private final int delayTime; - public AlertingSetting(String userId, int delayTime) { + public UserAlertingSettings(String userId, int delayTime) { this(0, userId, null, null, delayTime); } - public AlertingSetting(int id, String userId, Role userRole, ZonedDateTime lastNotification, int delayTime) { + public UserAlertingSettings(int id, String userId, Role userRole, ZonedDateTime lastNotification, int delayTime) { this.id = id; this.userId = userId; this.userRole = userRole; @@ -57,7 +57,7 @@ public boolean equals(Object obj) { if (obj == null || this.getClass() != obj.getClass()) { return false; } - var other = (AlertingSetting) obj; + var other = (UserAlertingSettings) obj; return this.id == other.id; } } diff --git a/io.openems.backend.common/src/io/openems/backend/common/test/DummyMetadata.java b/io.openems.backend.common/src/io/openems/backend/common/test/DummyMetadata.java index 84c83b0bb93..479db9412fa 100644 --- a/io.openems.backend.common/src/io/openems/backend/common/test/DummyMetadata.java +++ b/io.openems.backend.common/src/io/openems/backend/common/test/DummyMetadata.java @@ -12,7 +12,7 @@ import com.google.gson.JsonObject; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.EdgeHandler; import io.openems.backend.common.metadata.Metadata; @@ -56,17 +56,17 @@ public Collection getAllOfflineEdges() { } @Override - public List getUserAlertingSettings(String edgeId) { + public List getUserAlertingSettings(String edgeId) { throw new UnsupportedOperationException("Unsupported by Dummy Class"); } @Override - public AlertingSetting getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { + public UserAlertingSettings getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { throw new UnsupportedOperationException("Unsupported by Dummy Class"); } @Override - public void setUserAlertingSettings(User user, String edgeId, List users) { + public void setUserAlertingSettings(User user, String edgeId, List users) { throw new UnsupportedOperationException("Unsupported by Dummy Class"); } diff --git a/io.openems.backend.metadata.dummy/src/io/openems/backend/metadata/dummy/MetadataDummy.java b/io.openems.backend.metadata.dummy/src/io/openems/backend/metadata/dummy/MetadataDummy.java index b775cbc93a1..160012a5177 100644 --- a/io.openems.backend.metadata.dummy/src/io/openems/backend/metadata/dummy/MetadataDummy.java +++ b/io.openems.backend.metadata.dummy/src/io/openems/backend/metadata/dummy/MetadataDummy.java @@ -31,7 +31,7 @@ import com.google.gson.JsonObject; import io.openems.backend.common.metadata.AbstractMetadata; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.EdgeHandler; import io.openems.backend.common.metadata.Metadata; @@ -273,17 +273,17 @@ public Optional getSerialNumberForEdge(Edge edge) { } @Override - public List getUserAlertingSettings(String edgeId) { + public List getUserAlertingSettings(String edgeId) { throw new UnsupportedOperationException("DummyMetadata.getUserAlertingSettings() is not implemented"); } @Override - public AlertingSetting getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { + public UserAlertingSettings getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { throw new UnsupportedOperationException("DummyMetadata.getUserAlertingSettings() is not implemented"); } @Override - public void setUserAlertingSettings(User user, String edgeId, List users) { + public void setUserAlertingSettings(User user, String edgeId, List users) { throw new UnsupportedOperationException("DummyMetadata.setUserAlertingSettings() is not implemented"); } diff --git a/io.openems.backend.metadata.file/src/io/openems/backend/metadata/file/MetadataFile.java b/io.openems.backend.metadata.file/src/io/openems/backend/metadata/file/MetadataFile.java index 968b56f1574..f196cdc9897 100644 --- a/io.openems.backend.metadata.file/src/io/openems/backend/metadata/file/MetadataFile.java +++ b/io.openems.backend.metadata.file/src/io/openems/backend/metadata/file/MetadataFile.java @@ -33,7 +33,7 @@ import com.google.gson.JsonObject; import io.openems.backend.common.metadata.AbstractMetadata; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.EdgeHandler; import io.openems.backend.common.metadata.Metadata; @@ -305,17 +305,17 @@ public Optional getSerialNumberForEdge(Edge edge) { } @Override - public List getUserAlertingSettings(String edgeId) { + public List getUserAlertingSettings(String edgeId) { throw new UnsupportedOperationException("FileMetadata.getUserAlertingSettings() is not implemented"); } @Override - public AlertingSetting getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { + public UserAlertingSettings getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { throw new UnsupportedOperationException("FileMetadata.getUserAlertingSettings() is not implemented"); } @Override - public void setUserAlertingSettings(User user, String edgeId, List users) { + public void setUserAlertingSettings(User user, String edgeId, List users) { throw new UnsupportedOperationException("FileMetadata.setUserAlertingSettings() is not implemented"); } diff --git a/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/MetadataOdoo.java b/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/MetadataOdoo.java index 58b67e5990a..3ce81cbeec3 100644 --- a/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/MetadataOdoo.java +++ b/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/MetadataOdoo.java @@ -35,7 +35,7 @@ import com.google.gson.JsonObject; import io.openems.backend.common.metadata.AbstractMetadata; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.AppCenterMetadata; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.EdgeHandler; @@ -500,17 +500,17 @@ public boolean isAppFree(// } @Override - public List getUserAlertingSettings(String edgeId) throws OpenemsException { + public List getUserAlertingSettings(String edgeId) throws OpenemsException { return this.odooHandler.getUserAlertingSettings(edgeId); } @Override - public AlertingSetting getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { + public UserAlertingSettings getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { return this.odooHandler.getUserAlertingSettings(edgeId, userId); } @Override - public void setUserAlertingSettings(User user, String edgeId, List users) throws OpenemsException { + public void setUserAlertingSettings(User user, String edgeId, List users) throws OpenemsException { this.odooHandler.setUserAlertingSettings((MyUser) user, edgeId, users); } diff --git a/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/odoo/OdooHandler.java b/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/odoo/OdooHandler.java index 7780e07fecc..9dc938d6f03 100644 --- a/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/odoo/OdooHandler.java +++ b/io.openems.backend.metadata.odoo/src/io/openems/backend/metadata/odoo/odoo/OdooHandler.java @@ -20,7 +20,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Edge; import io.openems.backend.common.metadata.EdgeUser; import io.openems.backend.common.metadata.User; @@ -1103,7 +1103,7 @@ public JsonObject getInstalledApps(String edgeId) throws OpenemsNamedException { * @return list of alerting settings * @throws OpenemsException on error */ - public List getUserAlertingSettings(String edgeId) throws OpenemsException { + public List getUserAlertingSettings(String edgeId) throws OpenemsException { return this.requestUserAlertingSettings(edgeId, null); } @@ -1112,15 +1112,15 @@ public List getUserAlertingSettings(String edgeId) throws Opene * * @param edgeId ID of Edge * @param userId ID of User - * @return {@link AlertingSetting} or {@link null} if no settings are stored + * @return {@link UserAlertingSettings} or {@link null} if no settings are stored * @throws OpenemsException on error */ - public AlertingSetting getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { + public UserAlertingSettings getUserAlertingSettings(String edgeId, String userId) throws OpenemsException { var settings = this.requestUserAlertingSettings(edgeId, userId); return settings.isEmpty() ? null : settings.get(0); } - private List requestUserAlertingSettings(String edgeId, String userId) throws OpenemsException { + private List requestUserAlertingSettings(String edgeId, String userId) throws OpenemsException { // Define Fields var edgeUserFields = new Field[] { // Field.EdgeDeviceUserRole.ID, // @@ -1152,7 +1152,7 @@ private List requestUserAlertingSettings(String edgeId, String usersMap.put(userIds[i], users[i]); } // create result list; - var result = new ArrayList(edgeUsers.length); + var result = new ArrayList(edgeUsers.length); for (var edgeUser : edgeUsers) { var userIdsArr = OdooUtils.getAs(Field.EdgeDeviceUserRole.USER_ODOO_ID, edgeUser, Object[].class); if (userIdsArr.length != 2) { @@ -1169,7 +1169,7 @@ private List requestUserAlertingSettings(String edgeId, String edgeUser, String.class, null); var lastNotification = OdooUtils.DateTime.stringToDateTime(lastNotificationStr); result.add( - new AlertingSetting(edgeUserId, login, Role.getRole(role), lastNotification, timeToWait)); + new UserAlertingSettings(edgeUserId, login, Role.getRole(role), lastNotification, timeToWait)); } } } @@ -1184,7 +1184,7 @@ private List requestUserAlertingSettings(String edgeId, String * @param userAlertingSettings list of users * @throws OpenemsException on error */ - public void setUserAlertingSettings(MyUser user, String edgeId, List userAlertingSettings) + public void setUserAlertingSettings(MyUser user, String edgeId, List userAlertingSettings) throws OpenemsException { // search edge by id var edgeIds = OdooUtils.search(this.credentials, Field.EdgeDevice.ODOO_MODEL, diff --git a/io.openems.backend.uiwebsocket/src/io/openems/backend/uiwebsocket/impl/OnRequest.java b/io.openems.backend.uiwebsocket/src/io/openems/backend/uiwebsocket/impl/OnRequest.java index 286c4018509..04bd5549a4c 100644 --- a/io.openems.backend.uiwebsocket/src/io/openems/backend/uiwebsocket/impl/OnRequest.java +++ b/io.openems.backend.uiwebsocket/src/io/openems/backend/uiwebsocket/impl/OnRequest.java @@ -22,7 +22,7 @@ import io.openems.backend.common.jsonrpc.response.AddEdgeToUserResponse; import io.openems.backend.common.jsonrpc.response.GetUserAlertingConfigsResponse; import io.openems.backend.common.jsonrpc.response.GetUserInformationResponse; -import io.openems.backend.common.metadata.AlertingSetting; +import io.openems.backend.common.metadata.UserAlertingSettings; import io.openems.backend.common.metadata.Metadata.GenericSystemLog; import io.openems.backend.common.metadata.User; import io.openems.common.exceptions.OpenemsError; @@ -503,7 +503,7 @@ private CompletableFuture handleGetSetupProtocolD private CompletableFuture handleGetUserAlertingConfigsRequest(User user, GetUserAlertingConfigsRequest request) throws OpenemsException { var edgeId = request.getEdgeId(); - List users; + List users; if (userIsAdmin(user, edgeId)) { users = this.parent.metadata.getUserAlertingSettings(edgeId);