Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Add asset attribute for action

Mica Hallin056d640535e8
diff --git a/console/android/src/main/java/org/openremote/android/service/AlertAction.java b/console/android/src/main/java/org/openremote/android/service/AlertAction.java
index 63cdf6ddb..5d9dd685b 100644
--- a/console/android/src/main/java/org/openremote/android/service/AlertAction.java
+++ b/console/android/src/main/java/org/openremote/android/service/AlertAction.java
@@ -1,9 +1,38 @@
package org.openremote.android.service;
-public class AlertAction {
+import java.io.Serializable;
+
+public class AlertAction implements Serializable {
private AlertNotification.ActionType type;
private String title;
+ private String assetId;
+ private String attributeName;
+ private String rawJson;
+
+ public String getAssetId() {
+ return assetId;
+ }
+
+ public void setAssetId(String assetId) {
+ this.assetId = assetId;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public void setAttributeName(String attributeName) {
+ this.attributeName = attributeName;
+ }
+
+ public String getRawJson() {
+ return rawJson;
+ }
+
+ public void setRawJson(String rawJson) {
+ this.rawJson = rawJson;
+ }
public AlertAction() {
}
diff --git a/model/src/main/java/org/openremote/model/notification/AlertAction.java b/model/src/main/java/org/openremote/model/notification/AlertAction.java
index ea7e6572f..7813b5839 100644
--- a/model/src/main/java/org/openremote/model/notification/AlertAction.java
+++ b/model/src/main/java/org/openremote/model/notification/AlertAction.java
@@ -13,6 +13,31 @@ public class AlertAction {
}
+ public AlertAction(String title, ActionType type,String assetId, String attributeName, String rawJson) {
+ this();
+ setTitle(title);
+ setType(type);
+ setAssetId(assetId);
+ setAttributeName(attributeName);
+ setRawJson(rawJson);
+ }
+
+ private void setRawJson(String rawJson) {
+ if (rawJson != null) {
+ jsonObject.put("rawJson", Json.create(rawJson));
+ } else if (jsonObject.hasKey("rawJson")) {
+ jsonObject.remove("rawJson");
+ }
+ }
+
+ private void setAttributeName(String attributeName) {
+ if (attributeName != null) {
+ jsonObject.put("attributeName", Json.create(attributeName));
+ } else if (jsonObject.hasKey("attributeName")) {
+ jsonObject.remove("attributeName");
+ }
+ }
+
public String getTitle() {
if (jsonObject.hasKey("title")) {
return jsonObject.getString("title");
@@ -48,4 +73,12 @@ public class AlertAction {
public JsonObject getValue() {
return jsonObject;
}
+
+ public void setAssetId(String assetId) {
+ if (assetId != null) {
+ jsonObject.put("assetId", Json.create(assetId));
+ } else if (jsonObject.hasKey("assetId")) {
+ jsonObject.remove("assetId");
+ }
+ }
}
diff --git a/model/src/main/java/org/openremote/model/notification/AlertNotification.java b/model/src/main/java/org/openremote/model/notification/AlertNotification.java
index 129ac3b28..ca924c032 100644
--- a/model/src/main/java/org/openremote/model/notification/AlertNotification.java
+++ b/model/src/main/java/org/openremote/model/notification/AlertNotification.java
@@ -77,6 +77,7 @@ public class AlertNotification {
}
public JsonArray getActions() {
+
return actions;
}