Commit 0031f439 authored by yangjian's avatar yangjian

update SDMSubscriptions

parent c71cd9ff
/** /**
* Nudr_DataRepository API OpenAPI file * Nudr_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* *
* The version of the OpenAPI document: 2.1.2 * The version of the OpenAPI document: 2.1.2
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech * https://openapi-generator.tech
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/* /*
* SDMSubscriptionsCollectionApi.h * SDMSubscriptionsCollectionApi.h
* *
* *
*/ */
#ifndef SDMSubscriptionsCollectionApi_H_ #ifndef SDMSubscriptionsCollectionApi_H_
...@@ -56,17 +56,17 @@ private: ...@@ -56,17 +56,17 @@ private:
/// Create individual sdm subscription /// Create individual sdm subscription
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// ///
/// </remarks> /// </remarks>
/// <param name="ueId">UE ID</param> /// <param name="ueId">UE ID</param>
/// <param name="sdmSubscription"></param> /// <param name="sdmSubscription"></param>
virtual void create_sdm_subscriptions(const std::string &ueId, const SdmSubscription &sdmSubscription, Pistache::Http::ResponseWriter &response) = 0; virtual void create_sdm_subscriptions(const std::string &ueId, SdmSubscription &sdmSubscription, Pistache::Http::ResponseWriter &response) = 0;
/// <summary> /// <summary>
/// Retrieves the sdm subscriptions of a UE /// Retrieves the sdm subscriptions of a UE
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// ///
/// </remarks> /// </remarks>
/// <param name="ueId">UE id</param> /// <param name="ueId">UE id</param>
/// <param name="supportedFeatures">Supported Features (optional, default to &quot;&quot;)</param> /// <param name="supportedFeatures">Supported Features (optional, default to &quot;&quot;)</param>
......
...@@ -210,42 +210,42 @@ void SDMSubscriptionDocumentApiImpl::updatesdmsubscriptions(const std::string &u ...@@ -210,42 +210,42 @@ void SDMSubscriptionDocumentApiImpl::updatesdmsubscriptions(const std::string &u
{ {
nlohmann::json MonitoredResourceUris_json(sdmSubscription.getMonitoredResourceUris()); nlohmann::json MonitoredResourceUris_json(sdmSubscription.getMonitoredResourceUris());
query="update SdmSubscriptions set nfInstanceId='"+sdmSubscription.getNfInstanceId()+"',"+ \ query="update SdmSubscriptions set nfInstanceId='"+sdmSubscription.getNfInstanceId()+"'"+ \
(sdmSubscription.implicitUnsubscribeIsSet()?(sdmSubscription.isImplicitUnsubscribe()?"implicitUnsubscribe=1,":"implicitUnsubscribe=0,"):"")+ \ (sdmSubscription.implicitUnsubscribeIsSet()?(sdmSubscription.isImplicitUnsubscribe()?",implicitUnsubscribe=1":",implicitUnsubscribe=0"):"")+ \
(sdmSubscription.expiresIsSet()?"expires='"+sdmSubscription.getExpires()+"',":"")+ \ (sdmSubscription.expiresIsSet()?",expires='"+sdmSubscription.getExpires()+"'":"")+ \
"callbackReference='"+sdmSubscription.getCallbackReference()+"',"+ \ ",callbackReference='"+sdmSubscription.getCallbackReference()+"'"+ \
(sdmSubscription.dnnIsSet()?"dnn='"+sdmSubscription.getDnn()+"',":"")+ \ (sdmSubscription.dnnIsSet()?",dnn='"+sdmSubscription.getDnn()+"'":"")+ \
(sdmSubscription.subscriptionIdIsSet()?"subscriptionId='"+sdmSubscription.getSubscriptionId()+"',":"")+ \ (sdmSubscription.subscriptionIdIsSet()?",subscriptionId='"+sdmSubscription.getSubscriptionId()+"'":"")+ \
(sdmSubscription.immediateReportIsSet()?(sdmSubscription.isImmediateReport()?"immediateReport=1,":"immediateReport=0,"):"")+ \ (sdmSubscription.immediateReportIsSet()?(sdmSubscription.isImmediateReport()?",immediateReport=1":",immediateReport=0"):"")+ \
(sdmSubscription.supportedFeaturesIsSet()?"supportedFeatures='"+sdmSubscription.getSupportedFeatures()+"',":""); (sdmSubscription.supportedFeaturesIsSet()?",supportedFeatures='"+sdmSubscription.getSupportedFeatures()+"'":"");
if(sdmSubscription.amfServiceNameIsSet()) if(sdmSubscription.amfServiceNameIsSet())
{ {
to_json(j,sdmSubscription.getAmfServiceName()); to_json(j,sdmSubscription.getAmfServiceName());
query += "amfServiceName='"+j.dump()+"',"; query += ",amfServiceName='"+j.dump()+"'";
} }
if(sdmSubscription.singleNssaiIsSet()) if(sdmSubscription.singleNssaiIsSet())
{ {
to_json(j,sdmSubscription.getSingleNssai()); to_json(j,sdmSubscription.getSingleNssai());
query += "singleNssai='"+j.dump()+"',"; query += ",singleNssai='"+j.dump()+"'";
} }
if(sdmSubscription.plmnIdIsSet()) if(sdmSubscription.plmnIdIsSet())
{ {
to_json(j,sdmSubscription.getPlmnId()); to_json(j,sdmSubscription.getPlmnId());
query += "plmnId='"+j.dump()+"',"; query += ",plmnId='"+j.dump()+"'";
} }
if(sdmSubscription.reportIsSet()) if(sdmSubscription.reportIsSet())
{ {
to_json(j,sdmSubscription.getReport()); to_json(j,sdmSubscription.getReport());
query += "report='"+j.dump()+"',"; query += ",report='"+j.dump()+"'";
} }
if(sdmSubscription.contextInfoIsSet()) if(sdmSubscription.contextInfoIsSet())
{ {
to_json(j,sdmSubscription.getContextInfo()); to_json(j,sdmSubscription.getContextInfo());
query += "contextInfo='"+j.dump()+"',"; query += ",contextInfo='"+j.dump()+"'";
} }
query += "monitoredResourceUris='"+MonitoredResourceUris_json.dump()+"'"; query += ",monitoredResourceUris='"+MonitoredResourceUris_json.dump()+"'";
query += " where ueid="+ueId+" AND subsId="+subsId; query += " where ueid="+ueId+" AND subsId="+subsId;
} }
......
/** /**
* Nudr_DataRepository API OpenAPI file * Nudr_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* *
* The version of the OpenAPI document: 2.1.2 * The version of the OpenAPI document: 2.1.2
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech * https://openapi-generator.tech
...@@ -19,22 +19,222 @@ namespace api { ...@@ -19,22 +19,222 @@ namespace api {
using namespace org::openapitools::server::model; using namespace org::openapitools::server::model;
SDMSubscriptionsCollectionApiImpl::SDMSubscriptionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr) SDMSubscriptionsCollectionApiImpl::SDMSubscriptionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr,MYSQL *mysql)
: SDMSubscriptionsCollectionApi(rtr) : SDMSubscriptionsCollectionApi(rtr)
{ } {
mysql_WitcommUDRDB = mysql;
void SDMSubscriptionsCollectionApiImpl::create_sdm_subscriptions(const std::string &ueId, const SdmSubscription &sdmSubscription, Pistache::Http::ResponseWriter &response) { }
//response.send(Pistache::Http::Code::Ok, "Do some magic\n");
void SDMSubscriptionsCollectionApiImpl::create_sdm_subscriptions(const std::string &ueId, SdmSubscription &sdmSubscription, Pistache::Http::ResponseWriter &response) {
/************************ test ************************/ MYSQL_RES *res = NULL;
nlohmann::json j; MYSQL_ROW row;
to_json(j,sdmSubscription); nlohmann::json j;
response.send(Pistache::Http::Code::Created, j.dump());
//response.send(Pistache::Http::Code::Ok, "Do some magic hello\n"); int32_t subsId = 0;
/******************************************************/ int32_t count = 0;
std::string query = "SELECT subsId from SdmSubscriptions WHERE ueid="+ueId;
if (mysql_real_query(mysql_WitcommUDRDB,query.c_str(), (unsigned long)query.size()))
{
std::cout << "mysql_real_query failure!" << std::endl;
return;
}
res = mysql_store_result(mysql_WitcommUDRDB);
if(res == NULL)
{
std::cout << "mysql_store_result failure!" << std::endl;
return;
}
while(row = mysql_fetch_row(res))
{
count ++;
if(strcmp(row[0], std::to_string(count).c_str()))
{
subsId = count;
break;
}
}
mysql_free_result(res);
//****** add query *******
query="insert into SdmSubscriptions set ueid="+ueId+ \
",nfInstanceId='"+sdmSubscription.getNfInstanceId()+"'"+ \
(sdmSubscription.implicitUnsubscribeIsSet()?(sdmSubscription.isImplicitUnsubscribe()?",implicitUnsubscribe=1":",implicitUnsubscribe=0"):"")+ \
(sdmSubscription.expiresIsSet()?",expires='"+sdmSubscription.getExpires()+"'":"")+ \
",callbackReference='"+sdmSubscription.getCallbackReference()+"'"+ \
(sdmSubscription.dnnIsSet()?",dnn='"+sdmSubscription.getDnn()+"'":"")+ \
(sdmSubscription.subscriptionIdIsSet()?",subscriptionId='"+sdmSubscription.getSubscriptionId()+"'":"")+ \
(sdmSubscription.immediateReportIsSet()?(sdmSubscription.isImmediateReport()?",immediateReport=1":",immediateReport=0"):"")+ \
(sdmSubscription.supportedFeaturesIsSet()?",supportedFeatures='"+sdmSubscription.getSupportedFeatures()+"'":"");
if(sdmSubscription.amfServiceNameIsSet())
{
to_json(j,sdmSubscription.getAmfServiceName());
query += ",amfServiceName='"+j.dump()+"'";
}
if(sdmSubscription.singleNssaiIsSet())
{
to_json(j,sdmSubscription.getSingleNssai());
query += ",singleNssai='"+j.dump()+"'";
}
if(sdmSubscription.plmnIdIsSet())
{
to_json(j,sdmSubscription.getPlmnId());
query += ",plmnId='"+j.dump()+"'";
}
if(sdmSubscription.reportIsSet())
{
to_json(j,sdmSubscription.getReport());
query += ",report='"+j.dump()+"'";
}
if(sdmSubscription.contextInfoIsSet())
{
to_json(j,sdmSubscription.getContextInfo());
query += ",contextInfo='"+j.dump()+"'";
}
nlohmann::json MonitoredResourceUris_json(sdmSubscription.getMonitoredResourceUris());
query += ",monitoredResourceUris='"+MonitoredResourceUris_json.dump()+"'";
if(subsId && (subsId ==count))
{
query += ",subsId="+std::to_string(subsId);
}
//************************
// std::cout << query << std::endl;
if (mysql_real_query(mysql_WitcommUDRDB,query.c_str(), (unsigned long)query.size()))
{
std::cout << "mysql_real_query failure!" << std::endl;
return;
}
to_json(j,sdmSubscription);
response.send(Pistache::Http::Code::Created, j.dump());
} }
void SDMSubscriptionsCollectionApiImpl::querysdmsubscriptions(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response) { void SDMSubscriptionsCollectionApiImpl::querysdmsubscriptions(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "querysdmsubscriptions\n"); MYSQL_RES *res = NULL;
MYSQL_ROW row;
MYSQL_FIELD* field = nullptr;
std::vector<std::string> fields;
nlohmann::json j,tmp;
const std::string query = "SELECT * from SdmSubscriptions WHERE ueid="+ueId;
if (mysql_real_query(mysql_WitcommUDRDB,query.c_str(), (unsigned long)query.size()))
{
std::cout << "mysql_real_query failure!" << std::endl;
return;
}
res = mysql_store_result(mysql_WitcommUDRDB);
if(res == NULL)
{
std::cout << "mysql_store_result failure!" << std::endl;
return;
}
while (field = mysql_fetch_field(res))
{
fields.push_back(field->name);
}
j.clear();
while(row = mysql_fetch_row(res))
{
SdmSubscription sdmsubscriptions;
tmp.clear();
for (int i = 0; i<fields.size(); i++)
{
if(!strcmp("nfInstanceId", fields[i].c_str()))
{
sdmsubscriptions.setNfInstanceId(row[i]);
}
else if(!strcmp("implicitUnsubscribe", fields[i].c_str()) && row[i] != NULL)
{
if(strcmp(row[i], "0"))
sdmsubscriptions.setImplicitUnsubscribe(true);
else
sdmsubscriptions.setImplicitUnsubscribe(false);
}
else if(!strcmp("expires", fields[i].c_str()) && row[i] != NULL)
{
sdmsubscriptions.setExpires(row[i]);
}
else if(!strcmp("callbackReference", fields[i].c_str()))
{
sdmsubscriptions.setCallbackReference(row[i]);
}
else if(!strcmp("amfServiceName", fields[i].c_str()) && row[i] != NULL)
{
ServiceName amfservicename;
nlohmann::json::parse(row[i]).get_to(amfservicename);
sdmsubscriptions.setAmfServiceName(amfservicename);
}
else if(!strcmp("monitoredResourceUris", fields[i].c_str()))
{
std::vector<std::string> monitoredresourceuris;
nlohmann::json::parse(row[i]).get_to(monitoredresourceuris);
sdmsubscriptions.setMonitoredResourceUris(monitoredresourceuris);
}
else if(!strcmp("singleNssai", fields[i].c_str()) && row[i] != NULL)
{
Snssai singlenssai;
nlohmann::json::parse(row[i]).get_to(singlenssai);
sdmsubscriptions.setSingleNssai(singlenssai);
}
else if(!strcmp("dnn", fields[i].c_str()) && row[i] != NULL)
{
sdmsubscriptions.setDnn(row[i]);
}
else if(!strcmp("subscriptionId", fields[i].c_str()) && row[i] != NULL)
{
sdmsubscriptions.setSubscriptionId(row[i]);
}
else if(!strcmp("plmnId", fields[i].c_str()) && row[i] != NULL)
{
PlmnId plmnid;
nlohmann::json::parse(row[i]).get_to(plmnid);
sdmsubscriptions.setPlmnId(plmnid);
}
else if(!strcmp("immediateReport", fields[i].c_str()) && row[i] != NULL)
{
if(strcmp(row[i], "0"))
sdmsubscriptions.setImmediateReport(true);
else
sdmsubscriptions.setImmediateReport(false);
}
else if(!strcmp("report", fields[i].c_str()) && row[i] != NULL)
{
SubscriptionDataSets report;
nlohmann::json::parse(row[i]).get_to(report);
sdmsubscriptions.setReport(report);
}
else if(!strcmp("supportedFeatures", fields[i].c_str()) && row[i] != NULL)
{
sdmsubscriptions.setSupportedFeatures(row[i]);
}
else if(!strcmp("contextInfo", fields[i].c_str()) && row[i] != NULL)
{
ContextInfo contextinfo;
nlohmann::json::parse(row[i]).get_to(contextinfo);
sdmsubscriptions.setContextInfo(contextinfo);
}
}
to_json(tmp,sdmsubscriptions);
j+=tmp;
}
mysql_free_result(res);
response.send(Pistache::Http::Code::Ok, j.dump());
} }
} }
......
/** /**
* Nudr_DataRepository API OpenAPI file * Nudr_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* *
* The version of the OpenAPI document: 2.1.2 * The version of the OpenAPI document: 2.1.2
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech * https://openapi-generator.tech
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/* /*
* SDMSubscriptionsCollectionApiImpl.h * SDMSubscriptionsCollectionApiImpl.h
* *
* *
*/ */
#ifndef SDM_SUBSCRIPTIONS_COLLECTION_API_IMPL_H_ #ifndef SDM_SUBSCRIPTIONS_COLLECTION_API_IMPL_H_
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "SdmSubscription.h" #include "SdmSubscription.h"
#include <string> #include <string>
#include <mysql/mysql.h>
namespace org { namespace org {
namespace openapitools { namespace openapitools {
namespace server { namespace server {
...@@ -41,12 +43,13 @@ using namespace org::openapitools::server::model; ...@@ -41,12 +43,13 @@ using namespace org::openapitools::server::model;
class SDMSubscriptionsCollectionApiImpl : public org::openapitools::server::api::SDMSubscriptionsCollectionApi { class SDMSubscriptionsCollectionApiImpl : public org::openapitools::server::api::SDMSubscriptionsCollectionApi {
public: public:
SDMSubscriptionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router>); SDMSubscriptionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router>, MYSQL *mysql);
~SDMSubscriptionsCollectionApiImpl() {} ~SDMSubscriptionsCollectionApiImpl() {}
void create_sdm_subscriptions(const std::string &ueId, const SdmSubscription &sdmSubscription, Pistache::Http::ResponseWriter &response); void create_sdm_subscriptions(const std::string &ueId, SdmSubscription &sdmSubscription, Pistache::Http::ResponseWriter &response);
void querysdmsubscriptions(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response); void querysdmsubscriptions(const std::string &ueId, const Pistache::Optional<std::string> &supportedFeatures, Pistache::Http::ResponseWriter &response);
private:
MYSQL *mysql_WitcommUDRDB;
}; };
} }
......
...@@ -305,7 +305,7 @@ int main() { ...@@ -305,7 +305,7 @@ int main() {
RetrievalOfSharedDataApiserver.init(); RetrievalOfSharedDataApiserver.init();
SDMSubscriptionDocumentApiImpl SDMSubscriptionDocumentApiserver(router, &mysql); SDMSubscriptionDocumentApiImpl SDMSubscriptionDocumentApiserver(router, &mysql);
SDMSubscriptionDocumentApiserver.init(); SDMSubscriptionDocumentApiserver.init();
SDMSubscriptionsCollectionApiImpl SDMSubscriptionsCollectionApiserver(router); SDMSubscriptionsCollectionApiImpl SDMSubscriptionsCollectionApiserver(router, &mysql);
SDMSubscriptionsCollectionApiserver.init(); SDMSubscriptionsCollectionApiserver.init();
SMFRegistrationDocumentApiImpl SMFRegistrationDocumentApiserver(router,&mysql); SMFRegistrationDocumentApiImpl SMFRegistrationDocumentApiserver(router,&mysql);
SMFRegistrationDocumentApiserver.init(); SMFRegistrationDocumentApiserver.init();
......
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