Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UDR
Commits
0031f439
Commit
0031f439
authored
Jan 20, 2021
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update SDMSubscriptions
parent
c71cd9ff
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
245 additions
and
42 deletions
+245
-42
api/SDMSubscriptionsCollectionApi.h
api/SDMSubscriptionsCollectionApi.h
+6
-6
impl/SDMSubscriptionDocumentApiImpl.cpp
impl/SDMSubscriptionDocumentApiImpl.cpp
+14
-14
impl/SDMSubscriptionsCollectionApiImpl.cpp
impl/SDMSubscriptionsCollectionApiImpl.cpp
+215
-15
impl/SDMSubscriptionsCollectionApiImpl.h
impl/SDMSubscriptionsCollectionApiImpl.h
+9
-6
main-api-server.cpp
main-api-server.cpp
+1
-1
No files found.
api/SDMSubscriptionsCollectionApi.h
View file @
0031f439
...
...
@@ -60,7 +60,7 @@ private:
/// </remarks>
/// <param name="ueId">UE ID</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>
/// Retrieves the sdm subscriptions of a UE
...
...
impl/SDMSubscriptionDocumentApiImpl.cpp
View file @
0031f439
...
...
@@ -210,42 +210,42 @@ void SDMSubscriptionDocumentApiImpl::updatesdmsubscriptions(const std::string &u
{
nlohmann
::
json
MonitoredResourceUris_json
(
sdmSubscription
.
getMonitoredResourceUris
());
query
=
"update SdmSubscriptions set 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
()
+
"',
"
:
""
);
query
=
"update SdmSubscriptions set 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
()
+
"',
"
;
query
+=
"
,amfServiceName='"
+
j
.
dump
()
+
"'
"
;
}
if
(
sdmSubscription
.
singleNssaiIsSet
())
{
to_json
(
j
,
sdmSubscription
.
getSingleNssai
());
query
+=
"
singleNssai='"
+
j
.
dump
()
+
"',
"
;
query
+=
"
,singleNssai='"
+
j
.
dump
()
+
"'
"
;
}
if
(
sdmSubscription
.
plmnIdIsSet
())
{
to_json
(
j
,
sdmSubscription
.
getPlmnId
());
query
+=
"
plmnId='"
+
j
.
dump
()
+
"',
"
;
query
+=
"
,plmnId='"
+
j
.
dump
()
+
"'
"
;
}
if
(
sdmSubscription
.
reportIsSet
())
{
to_json
(
j
,
sdmSubscription
.
getReport
());
query
+=
"
report='"
+
j
.
dump
()
+
"',
"
;
query
+=
"
,report='"
+
j
.
dump
()
+
"'
"
;
}
if
(
sdmSubscription
.
contextInfoIsSet
())
{
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
;
}
...
...
impl/SDMSubscriptionsCollectionApiImpl.cpp
View file @
0031f439
...
...
@@ -19,22 +19,222 @@ namespace api {
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
)
{
}
{
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");
/************************ test ************************/
void
SDMSubscriptionsCollectionApiImpl
::
create_sdm_subscriptions
(
const
std
::
string
&
ueId
,
SdmSubscription
&
sdmSubscription
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
nlohmann
::
json
j
;
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
());
//response.send(Pistache::Http::Code::Ok, "Do some magic hello\n");
/******************************************************/
}
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
());
}
}
...
...
impl/SDMSubscriptionsCollectionApiImpl.h
View file @
0031f439
...
...
@@ -32,6 +32,8 @@
#include "SdmSubscription.h"
#include <string>
#include <mysql/mysql.h>
namespace
org
{
namespace
openapitools
{
namespace
server
{
...
...
@@ -41,12 +43,13 @@ using namespace org::openapitools::server::model;
class
SDMSubscriptionsCollectionApiImpl
:
public
org
::
openapitools
::
server
::
api
::
SDMSubscriptionsCollectionApi
{
public:
SDMSubscriptionsCollectionApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
);
SDMSubscriptionsCollectionApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
,
MYSQL
*
mysql
);
~
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
);
private:
MYSQL
*
mysql_WitcommUDRDB
;
};
}
...
...
main-api-server.cpp
View file @
0031f439
...
...
@@ -305,7 +305,7 @@ int main() {
RetrievalOfSharedDataApiserver
.
init
();
SDMSubscriptionDocumentApiImpl
SDMSubscriptionDocumentApiserver
(
router
,
&
mysql
);
SDMSubscriptionDocumentApiserver
.
init
();
SDMSubscriptionsCollectionApiImpl
SDMSubscriptionsCollectionApiserver
(
router
);
SDMSubscriptionsCollectionApiImpl
SDMSubscriptionsCollectionApiserver
(
router
,
&
mysql
);
SDMSubscriptionsCollectionApiserver
.
init
();
SMFRegistrationDocumentApiImpl
SMFRegistrationDocumentApiserver
(
router
,
&
mysql
);
SMFRegistrationDocumentApiserver
.
init
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment