blob: 2ac5e5de0177b183bc2d94bb2e2fbf789928ef86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#include "XPnfRegistrationFieldsImp.h"
const std::string XEnumPnfRegistrationFieldsPnfRegistrationFieldsVersionMapping[] = {
"2.0"
};
XPnfRegistrationFieldsImp::XPnfRegistrationFieldsImp(std::shared_ptr<XCommonEventHeader> header):
header_(header),
pnfRegistrationFieldsVersion_(XEnumPnfRegistrationFieldsPnfRegistrationFieldsVersion2_0)
{
}
std::string XPnfRegistrationFieldsImp::toString()
{
try
{
auto js = toJson();
return js.dump();
}
catch (json::exception& e)
{
SPDLOG_ERROR("Fail to dump XPnfRegistrationFields to json string:{}.", e.what());
return "";
}
}
void XPnfRegistrationFieldsImp::setMacAddress(const XString& macAddress)
{
comVals_["macAddress"] = macAddress;
}
void XPnfRegistrationFieldsImp::setUnitFamily(const XString& unitFamily)
{
comVals_["unitFamily"] = unitFamily;
}
void XPnfRegistrationFieldsImp::setSerialNumber(const XString& serialNumber)
{
comVals_["serialNumber"] = serialNumber;
}
void XPnfRegistrationFieldsImp::setUnitType(const XString& unitType)
{
comVals_["unitType"] = unitType;
}
void XPnfRegistrationFieldsImp::setManufactureDate(const XString& manufactureDate)
{
comVals_["manufactureDate"] = manufactureDate;
}
void XPnfRegistrationFieldsImp::setSoftwareVersion(const XString& softwareVersion)
{
comVals_["softwareVersion"] = softwareVersion;
}
void XPnfRegistrationFieldsImp::setModelNumber(const XString& modelNumber)
{
comVals_["modelNumber"] = modelNumber;
}
void XPnfRegistrationFieldsImp::setLastServiceDate(const XString& lastServiceDate)
{
comVals_["lastServiceDate"] = lastServiceDate;
}
void XPnfRegistrationFieldsImp::setOamV6IpAddress(const XString& oamV6IpAddress)
{
comVals_["oamV6IpAddress"] = oamV6IpAddress;
}
void XPnfRegistrationFieldsImp::setAdditionalFields(const XHashMap& additionalFields)
{
additionalFields_ = additionalFields;
}
void XPnfRegistrationFieldsImp::setVendorName(const XString& vendorName)
{
comVals_["vendorName"] = vendorName;
}
void XPnfRegistrationFieldsImp::setOamV4IpAddress(const XString& oamV4IpAddress)
{
comVals_["oamV4IpAddress"] = oamV4IpAddress;
}
std::shared_ptr<XCommonEventHeader> XPnfRegistrationFieldsImp::getCommonHeader()
{
return header_;
}
json XPnfRegistrationFieldsImp::toJson()
{
try
{
json field = {
{"pnfRegistrationFieldsVersion", XEnumPnfRegistrationFieldsPnfRegistrationFieldsVersionMapping[pnfRegistrationFieldsVersion_]}
};
//optional val
if (!additionalFields_.empty())
{
field["additionalFields"] = additionalFields_;
}
field = mergeCommonValues(field, comVals_);
json jsEvent;
header_->setDomain(XEnumCommonEventHeaderDomainPnfRegistration);
jsEvent["event"]["commonEventHeader"] = dynamic_pointer_cast<XJsonable>(header_)->toJson();
jsEvent["event"]["pnfRegistrationFields"] = field;
return jsEvent;
}
catch (json::exception& e)
{
SPDLOG_ERROR("Fail to build XPnfRegistrationFields to json object:{}.", e.what());
return json();
}
}
|