Added rule export/import

This commit is contained in:
M66B
2019-01-18 16:00:11 +00:00
parent 91ccd85c5b
commit c560cbc71d
3 changed files with 44 additions and 2 deletions

View File

@@ -198,4 +198,26 @@ public class EntityRule {
} else
return false;
}
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("name", name);
json.put("order", order);
json.put("enabled", enabled);
json.put("stop", stop);
json.put("condition", condition);
json.put("action", action);
return json;
}
public static EntityRule fromJSON(JSONObject json) throws JSONException {
EntityRule rule = new EntityRule();
rule.name = json.getString("name");
rule.order = json.getInt("order");
rule.enabled = json.getBoolean("enabled");
rule.stop = json.getBoolean("stop");
rule.condition = json.getString("condition");
rule.action = json.getString("action");
return rule;
}
}