100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Added convenience methods for notifications creation
Eric Bariauxc9a39a5cdf15
diff --git a/manager/server/src/main/resources/demo/rules/DemoApartmentNotificationWhenAlarm.drl b/manager/server/src/main/resources/demo/rules/DemoApartmentNotificationWhenAlarm.drlindex 7c4b2ddc4..aea7431cf 100644--- a/manager/server/src/main/resources/demo/rules/DemoApartmentNotificationWhenAlarm.drl+++ b/manager/server/src/main/resources/demo/rules/DemoApartmentNotificationWhenAlarm.drl@@ -14,14 +14,9 @@ when$residence : AssetState(type == AssetType.RESIDENCE, attributeName == "alarmEnabled", valueAsBoolean == true)$room : AssetState(parentId == $residence.id, type == AssetType.ROOM, attributeName == "presenceDetected", valueAsBoolean == true)then- AlertNotification alert = new AlertNotification();- alert.setTitle("Alert Title");- alert.setMessage("Alert Message");- alert.setAppUrl("Deep Url");- AlertAction alertAction = new AlertAction();- alertAction.setTitle("ACTION1");- alertAction.setActionType(ActionType.LINK);- alert.addAction(alertAction);+ AlertNotification alert = new AlertNotification("Alert Title", "Alert Message");+ alert.addLinkAction("Link", "#/Veilig");+ alert.addActuatorAction("Disarm", "assetId", "alarmEnabled", "value");users.query()diff --git a/model/src/main/java/org/openremote/model/notification/AlertNotification.java b/model/src/main/java/org/openremote/model/notification/AlertNotification.javaindex adc28b3c9..35796a2fa 100644--- a/model/src/main/java/org/openremote/model/notification/AlertNotification.java+++ b/model/src/main/java/org/openremote/model/notification/AlertNotification.java@@ -43,6 +43,14 @@ public class AlertNotification {@Enumerated(EnumType.STRING)private DeliveryStatus deliveryStatus;+ public AlertNotification() {+ }++ public AlertNotification(String title, String message) {+ this.title = title;+ this.message = message;+ }+/* Actuator */public Long getId() {@@ -81,6 +89,20 @@ public class AlertNotification {this.actions.set(this.actions.length(), action.getObjectValue());}+ public void addLinkAction(String title, String url) {+ AlertAction action = new AlertAction();+ action.setActionType(ActionType.LINK);+ action.setTitle(title);+ // TODO: this is currenly on notification, should be on action, but must update console to support that+ setAppUrl(url);+ addAction(action);+ }++ public void addActuatorAction(String title, String assetId, String attributeName, String rawJson ) {+ AlertAction action = new AlertAction(title, ActionType.ACTUATOR, assetId, attributeName, rawJson);+ addAction(action);+ }+public String getAppUrl() {return appUrl;}