Commit 749f63c1 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

First version with DB abstraction

parent a75853e6
......@@ -71,6 +71,7 @@ void Logger::_init(
m_udr_server = new _Logger("udr_server", m_sinks, ss.str().c_str());
m_udr_app = new _Logger("udr_app", m_sinks, ss.str().c_str());
m_udr_nrf = new _Logger("udr_nrf", m_sinks, ss.str().c_str());
m_udr_mysql = new _Logger("udr_mysql", m_sinks, ss.str().c_str());
}
//------------------------------------------------------------------------------
......
......@@ -87,6 +87,7 @@ class Logger {
static _Logger& config() { return *singleton().m_config; }
static _Logger& udr_server() { return *singleton().m_udr_server; }
static _Logger& udr_nrf() { return *singleton().m_udr_nrf; }
static _Logger& udr_mysql() { return *singleton().m_udr_mysql; }
private:
static Logger* m_singleton;
......@@ -109,6 +110,7 @@ class Logger {
_Logger* m_system;
_Logger* m_udr_server;
_Logger* m_udr_nrf;
_Logger* m_udr_mysql;
};
#endif
......@@ -139,7 +139,8 @@ bool cassandra_db::query_sdm_subscriptions(
//------------------------------------------------------------------------------
bool cassandra_db::query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai, std::string dnn) {
nlohmann::json& json_data, const oai::udr::model::Snssai&,
const std::string& dnn) {
return true;
}
......
......@@ -80,8 +80,8 @@ class cassandra_db : public database_wrapper<cassandra_db> {
bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai snssai = {},
std::string dnn = {});
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string& dnn = {});
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
......
......@@ -43,11 +43,6 @@ class database_wrapper : public database_wrapper_abstraction {
}
*/
/*
* Initialize a connection to the DB
* @param void
* @return true if successful, otherwise return false
*/
bool initialize() override {
Logger::udr_app().debug("Initialize from database_wrapper");
auto derived = static_cast<DerivedT*>(this);
......@@ -55,255 +50,126 @@ class database_wrapper : public database_wrapper_abstraction {
return true;
}
/*
* Close the connection established to the DB
* @param void
* @return true if successful, otherwise return false
*/
bool close_connection() override {
Logger::udr_app().debug("Initialize from database_wrapper");
auto derived = static_cast<DerivedT*>(this);
return derived->close_connection();
}
/*
* Insert a new item to the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool insert_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) override {
return true;
}
/*
* Query an item from the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data) override {
return true;
}
/*
* Update an item from the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) override {
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data) override {
return true;
}
/*
* Delete an item from the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
* @return true if successful, otherwise return false
*/
bool delete_authentication_subscription(const std::string& id) override {
return true;
}
/*
* Query an item from the DB for AccessandMobilitySubscriptionData
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string& ] serving_plmn_id: Serving PLMN ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) override {
return true;
}
/*
* Insert an item into DB for AMF3GPPAccessRegistration Context
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data) override {
const std::string& ue_id,
oai::udr::model::Amf3GppAccessRegistration& amf3GppAccessRegistration)
override {
return true;
}
/*
* Query for an item from the DB for AMF3GPPAccessRegistration
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @param [long code] code: HTTP response code
* @return true if successful, otherwise return false
*/
bool query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data) override {
return true;
}
/*
* Insert a new item into the DB for AuthenticationStatus
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool insert_authentication_status(
const std::string& ue_id, const nlohmann::json& json_data) override {
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data) override {
return true;
}
/*
* Delete an item from the DB for AuthenticationStatus
* @param [const std::string&] ue_id: UE Identity
* @return true if successful, otherwise return false
*/
bool delete_authentication_status(const std::string& ue_id) override {
return true;
}
/*
* Query for an item from the DB for AuthenticationStatus
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data) override {
return true;
}
/*
* Query an item from the DB for SDMSubscription
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] subs_id: subscription ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) override {
return true;
}
/*
* Delete an item from the DB for SDMSubscription
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] subs_id: subscription ID
* @return true if successful, otherwise return false
*/
bool delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id) override {
return true;
}
/*
* Update an item from the DB for SDMSubscription
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] subs_id: subscription ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) override {
return true;
}
/*
* Insert a new item into the DB for SDMSubscriptions
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool create_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) override {
const std::string& ue_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) override {
return true;
}
/*
* Query an item from the DB for SDMSubscriptions
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) override {
return true;
}
/*
* Query an item from the DB for SessionManagementSubscription
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] serving_plmn_id: Serving PLMN ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai snssai = {},
std::string dnn = {}) override {
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string& dnn = {}) override {
return true;
}
/*
* Insert an item into the DB for SMFRegistration
* @param [const std::string&] ue_id: UE Identity
* @param [const int32_t&] pdu_session_id: PDU Session ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data) override {
return true;
}
/*
* Delete an item from the DB for SMFRegistration
* @param [const std::string&] ue_id: UE Identity
* @param [const int32_t&] pdu_session_id: PDU Session ID
* @return true if successful, otherwise return false
*/
bool delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id) override {
return true;
}
/*
* Query an item from the DB SMFRegistration
* @param [const std::string&] ue_id: UE Identity
* @param [const int32_t&] pdu_session_id: PDU Session ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) override {
return true;
}
/*
* Query an item from the DB for a request to retrieve
* SMFRegistrationsCollection (SMFRegistrationsCollectionApiImpl)
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_smf_reg_list(
const std::string& ue_id, nlohmann::json& json_data) override {
return true;
}
/*
* Query an item from the DB for SMFSelectionSubscription
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] serving_plmn_id: Serving PLMN ID
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
bool query_smf_select_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) override {
......
......@@ -25,6 +25,12 @@
#include "Snssai.h"
#include "logger.hpp"
#include "Amf3GppAccessRegistration.h"
#include "AuthEvent.h"
#include "PatchItem.h"
#include "SdmSubscription.h"
#include "SmfRegistration.h"
#include <nlohmann/json.hpp>
namespace oai::udr::app {
......@@ -69,11 +75,15 @@ class database_wrapper_abstraction {
/*
* Update an item from the DB for the Authentication Subscription
* @param [const std::string&] id: UE Identity
* @param [const std::vector<oai::udr::model::PatchItem>&] patchItem:
* patchItem
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
virtual bool update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) = 0;
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data) = 0;
/*
* Delete an item from the DB for the Authentication Subscription
......@@ -96,11 +106,13 @@ class database_wrapper_abstraction {
/*
* Insert an item into DB for AMF3GPPAccessRegistration Context
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @param [oai::udr::model::Amf3GppAccessRegistration&]
* amf3GppAccessRegistration: Context to be stored
* @return true if successful, otherwise return false
*/
virtual bool create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data) = 0;
const std::string& ue_id, oai::udr::model::Amf3GppAccessRegistration&
amf3GppAccessRegistration) = 0;
/*
* Query for an item from the DB for AMF3GPPAccessRegistration
......@@ -115,11 +127,13 @@ class database_wrapper_abstraction {
/*
* Insert a new item into the DB for AuthenticationStatus
* @param [const std::string&] ue_id: UE Identity
* @param [const AuthEvent&] authEvent: Authentication Status data
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
virtual bool insert_authentication_status(
const std::string& ue_id, const nlohmann::json& json_data) = 0;
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data) = 0;
/*
* Delete an item from the DB for AuthenticationStatus
......@@ -161,21 +175,28 @@ class database_wrapper_abstraction {
* Update an item from the DB for SDMSubscription
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] subs_id: subscription ID
* @param [oai::udr::model::SdmSubscription&] sdmSubscription: Subscription
* information
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
virtual bool update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) = 0;
/*
* Insert a new item into the DB for SDMSubscriptions
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @param [oai::udr::model::SdmSubscription&] sdmSubscription: Subscription
* information
* @return true if successful, otherwise return false
*/
virtual bool create_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) = 0;
const std::string& ue_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) = 0;
/*
* Query an item from the DB for SDMSubscriptions
......@@ -191,22 +212,27 @@ class database_wrapper_abstraction {
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] serving_plmn_id: Serving PLMN ID
* @param [nlohmann::json&] json_data: Data in Json format
* @param [const oai::udr::model::Snssai&] snssai: SNSSAI
* @param [const std::string&] dnn: DNN
* @return true if successful, otherwise return false
*/
virtual bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai snssai = {},
std::string dnn = {}) = 0;
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string& dnn = {}) = 0;
/*
* Insert an item into the DB for SMFRegistration
* @param [const std::string&] ue_id: UE Identity
* @param [const int32_t&] pdu_session_id: PDU Session ID
* @param [const oai::udr::model::SmfRegistration&] smfRegistration: SMF
* Registration data
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
*/
virtual bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data) = 0;
/*
......@@ -230,8 +256,7 @@ class database_wrapper_abstraction {
nlohmann::json& json_data) = 0;
/*
* Query an item from the DB for a request to retrieve
* SMFRegistrationsCollection (SMFRegistrationsCollectionApiImpl)
* Query an item from the DB for SMFRegistrationsCollection
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] json_data: Data in Json format
* @return true if successful, otherwise return false
......
This diff is collapsed.
......@@ -23,6 +23,7 @@
#define MYSQL_DB_HPP
#include "database_wrapper.hpp"
#include "Amf3GppAccessRegistration.h"
#include <mysql/mysql.h>
namespace oai::udr::app {
......@@ -41,7 +42,9 @@ class mysql_db : public database_wrapper<mysql_db> {
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data);
bool update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data);
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data);
bool delete_authentication_subscription(const std::string& id);
bool query_am_data(
......@@ -49,13 +52,15 @@ class mysql_db : public database_wrapper<mysql_db> {
nlohmann::json& json_data);
bool create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data);
const std::string& ue_id,
oai::udr::model::Amf3GppAccessRegistration& amf3GppAccessRegistration);
bool query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data);
bool insert_authentication_status(
const std::string& ue_id, const nlohmann::json& json_data);
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data);
bool delete_authentication_status(const std::string& ue_id);
......@@ -71,21 +76,25 @@ class mysql_db : public database_wrapper<mysql_db> {
bool update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data);
bool create_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data);
const std::string& ue_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data);
bool query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data);
bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai snssai = {},
std::string dnn = {});
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string dnn = {});
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data);
bool delete_smf_context(
......
This diff is collapsed.
......@@ -243,13 +243,15 @@ class udr_app {
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] serving_plmn_id: Serving PLMN ID
* @param [nlohmann::json&] response_data: Response in Json format
* @param [const oai::udr::model::Snssai&] snssai: SNSSAI
* @param [const std::string&] dnn: DNN
* @param [long code] code: HTTP response code
* @return void
*/
void handle_query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& response_data, long& code,
oai::udr::model::Snssai snssai = {}, std::string dnn = {});
const oai::udr::model::Snssai& snssai = {}, const std::string& dnn = {});
/*
* Handle a request to create SMFRegistration (SMFRegistrationDocumentApiImpl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment