Skip to content

Commit

Permalink
Store json payload for action definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce committed Feb 3, 2016
1 parent e9db54b commit 381a0ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void addActionDefinition(String tenantId, ActionDefinition actionDefiniti

try {
session.execute(insertAction.bind(tenantId, actionDefinition.getActionPlugin(),
actionDefinition.getActionId(), actionDefinition.getProperties()));
actionDefinition.getActionId(), JsonUtil.toJson(actionDefinition)));
} catch (Exception e) {
msgLog.errorDatabaseException(e.getMessage());
throw e;
Expand Down Expand Up @@ -2601,7 +2601,7 @@ public void updateActionDefinition(String tenantId, ActionDefinition actionDefin
throw new RuntimeException("updateAction PreparedStatement is null");
}
try {
session.execute(updateAction.bind(actionDefinition.getProperties(), tenantId,
session.execute(updateAction.bind(JsonUtil.toJson(actionDefinition), tenantId,
actionDefinition.getActionPlugin(), actionDefinition.getActionId()));
} catch (Exception e) {
msgLog.errorDatabaseException(e.getMessage());
Expand Down Expand Up @@ -2717,8 +2717,7 @@ public ActionDefinition getActionDefinition(String tenantId, String actionPlugin
Iterator<Row> itAction = rsAction.iterator();
if (itAction.hasNext()) {
Row row = itAction.next();
actionDefinition = new ActionDefinition(tenantId, actionPlugin, actionId,
row.getMap("properties", String.class, String.class));
actionDefinition = JsonUtil.fromJson(row.getString("payload"), ActionDefinition.class);
}
} catch (Exception e) {
msgLog.errorDatabaseException(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public class CassStatement {
DELETE_TRIGGER = "DELETE FROM " + keyspace + ".triggers " + "WHERE tenantId = ? AND id = ? ";

INSERT_ACTION_DEFINITION = "INSERT INTO " + keyspace + ".actions_definitions "
+ "(tenantId, actionPlugin, actionId, properties) VALUES (?, ?, ?, ?) ";
+ "(tenantId, actionPlugin, actionId, payload) VALUES (?, ?, ?, ?) ";

INSERT_ACTION_HISTORY = "INSERT INTO " + keyspace + ".actions_history "
+ "(tenantId, actionPlugin, actionId, alertId, ctime, payload) VALUES (?, ?, ?, ?, ?, ?) " +
Expand Down Expand Up @@ -324,7 +324,7 @@ public class CassStatement {
INSERT_TRIGGER_ACTIONS = "INSERT INTO " + keyspace + ".triggers_actions "
+ "(tenantId, triggerId, actionPlugin, actionId, payload) VALUES (?, ?, ?, ?, ?) ";

SELECT_ACTION_DEFINITION = "SELECT properties FROM " + keyspace + ".actions_definitions "
SELECT_ACTION_DEFINITION = "SELECT payload FROM " + keyspace + ".actions_definitions "
+ "WHERE tenantId = ? AND actionPlugin = ? AND actionId = ? ";

SELECT_ACTION_HISTORY = "SELECT payload FROM " + keyspace + ".actions_history " +
Expand Down Expand Up @@ -510,7 +510,7 @@ public class CassStatement {
+ "firingMatch, memberOf, name, severity, source, tags, type "
+ "FROM " + keyspace + ".triggers WHERE tenantId = ? ";

UPDATE_ACTION_DEFINITION = "UPDATE " + keyspace + ".actions_definitions SET properties = ? "
UPDATE_ACTION_DEFINITION = "UPDATE " + keyspace + ".actions_definitions SET payload = ? "
+ "WHERE tenantId = ? AND actionPlugin = ? AND actionId = ? ";

UPDATE_ACTION_HISTORY = "UPDATE " + keyspace + ".actions_history " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CREATE TABLE ${keyspace}.actions_definitions (
tenantId text,
actionId text,
actionPlugin text,
properties map<text, text>,
payload text,
PRIMARY KEY (tenantId, actionPlugin, actionId)
);

Expand Down

0 comments on commit 381a0ee

Please sign in to comment.