Generare new uuid for the event of an alarm update

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, if exist, it
raises a new event by generating a new uuid.

Test Cases:
PASS: Send an update for the existing alarm and verify
      a new event is created with different uuid
PASS: Send multiple consecutive alarm updates and
      verify new events are raised for each update
      with unique uuid and timestamps.

Closes bug: 2046374

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 80ac610755
1 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2014-2018 Wind River Systems, Inc.
// Copyright (c) 2014-2023 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
@ -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 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;