Generare new uuid for the event of an updated alarm

When an update is recieved for the existing alarm,
the event_log table rejects the insert request since
the event is already present in the table so, this
change creates a new uuid for the event by checking
for the uuid in the event_log table.

Test Cases:
PASS: Send an update for the existing alarm and verify
      a new event is created with different uuid

Closes bug:

Change-Id: I06fb43b35974ab81bd95979a7dfb3b3776aacd17
Signed-off-by: amantri <ayyappa.mantri@windriver.com>
This commit is contained in:
amantri 2023-12-11 11:45:19 -05:00
parent f8716aa344
commit 3fda8b7508

View File

@ -469,6 +469,20 @@ bool CFmDbAlarmOperation::get_all_history_alarms(CFmDBSession &sess, SFmAlarmDat
bool CFmDbAlarmOperation::add_alarm_history(CFmDBSession &sess,
SFmAlarmDataT &a, bool set){
std::string sql;
std::string query;
FM_DB_UT_NAME_VAL(query, FM_ALARM_COLUMN_UUID, a.uuid);
fm_db_util_build_sql_query((const char*)FM_EVENT_LOG_TABLE_NAME, query.c_str(), sql);
fm_db_result_t result;
if (sess.query(sql.c_str(), result)){
if (result.size() > 0){
FM_DEBUG_LOG("Generate new uuid (%s) for the event of an updated alarm\n");
fm_uuid_create(a.uuid);
}
}
if (set){
a.alarm_state = (a.alarm_state == FM_ALARM_STATE_CLEAR) ?
FM_ALARM_STATE_SET : a.alarm_state;
@ -509,7 +523,6 @@ bool CFmDbAlarmOperation::add_alarm_history(CFmDBSession &sess,
}
int id =0;
std::string sql;
if (false == fm_db_util_get_next_log_id(sess, id)) {
return false;