From 1cba12b934f9a28a0d59d0532f8dda0a29b4b717 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Thu, 3 Nov 2022 23:09:27 -0700 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-11477 Signed-off-by: stephb9959 --- src/RESTAPI/RESTAPI_inventory_handler.cpp | 2 ++ src/RESTObjects/RESTAPI_ProvObjects.cpp | 2 ++ src/RESTObjects/RESTAPI_ProvObjects.h | 1 + src/storage/storage_inventory.cpp | 8 ++++++-- src/storage/storage_inventory.h | 3 ++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/RESTAPI/RESTAPI_inventory_handler.cpp b/src/RESTAPI/RESTAPI_inventory_handler.cpp index 2610077..a7a1ca3 100644 --- a/src/RESTAPI/RESTAPI_inventory_handler.cpp +++ b/src/RESTAPI/RESTAPI_inventory_handler.cpp @@ -386,6 +386,8 @@ namespace OpenWifi{ } } + AssignIfPresent(RawObject, "doNotAllowOverrides", Existing.doNotAllowOverrides); + if( RawObject->has("devClass") && NewObject.devClass!= Existing.devClass) { Existing.devClass = NewObject.devClass; } diff --git a/src/RESTObjects/RESTAPI_ProvObjects.cpp b/src/RESTObjects/RESTAPI_ProvObjects.cpp index f5fa14f..c5387a8 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.cpp +++ b/src/RESTObjects/RESTAPI_ProvObjects.cpp @@ -602,6 +602,7 @@ namespace OpenWifi::ProvObjects { field_to_json( Obj, "devClass",devClass); field_to_json( Obj, "locale",locale); field_to_json( Obj, "realMacAddress",realMacAddress); + field_to_json( Obj, "doNotAllowOverrides",doNotAllowOverrides); } bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -623,6 +624,7 @@ namespace OpenWifi::ProvObjects { field_from_json( Obj,"devClass",devClass); field_from_json( Obj,"locale",locale); field_from_json( Obj,"realMacAddress",realMacAddress); + field_from_json( Obj, "doNotAllowOverrides",doNotAllowOverrides); return true; } catch(...) { diff --git a/src/RESTObjects/RESTAPI_ProvObjects.h b/src/RESTObjects/RESTAPI_ProvObjects.h index 0f3834e..3c0ed3e 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.h +++ b/src/RESTObjects/RESTAPI_ProvObjects.h @@ -428,6 +428,7 @@ namespace OpenWifi::ProvObjects { std::string devClass; std::string locale; std::string realMacAddress; + bool doNotAllowOverrides=false; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); diff --git a/src/storage/storage_inventory.cpp b/src/storage/storage_inventory.cpp index 3fcbae6..1761ac9 100644 --- a/src/storage/storage_inventory.cpp +++ b/src/storage/storage_inventory.cpp @@ -44,7 +44,8 @@ namespace OpenWifi { ORM::Field{"state",ORM::FieldType::FT_TEXT}, ORM::Field{"devClass",ORM::FieldType::FT_TEXT}, ORM::Field{"locale",ORM::FieldType::FT_TEXT}, - ORM::Field{"realMacAddress",ORM::FieldType::FT_TEXT} + ORM::Field{"realMacAddress",ORM::FieldType::FT_TEXT}, + ORM::Field{"doNotAllowOverrides",ORM::FieldType::FT_BOOLEAN} }; static ORM::IndexVec InventoryDB_Indexes{ @@ -65,7 +66,8 @@ namespace OpenWifi { "alter table " + TableName_ + " add column locale varchar(16)" , "alter table " + TableName_ + " add column realMacAddress text" , "alter table " + TableName_ + " add column devClass text", - "alter table " + TableName_ + " add column deviceRules text" + "alter table " + TableName_ + " add column deviceRules text", + "alter table " + TableName_ + " add column doNotAllowOverrides boolean" }; for(const auto &i:Script) { @@ -257,6 +259,7 @@ template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjec Out.devClass = In.get<20>(); Out.locale = In.get<21>(); Out.realMacAddress = In.get<22>(); + Out.doNotAllowOverrides = In.get<23>(); } template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjects::InventoryTag>::Convert(const OpenWifi::ProvObjects::InventoryTag &In, OpenWifi::InventoryDBRecordType &Out) { @@ -283,4 +286,5 @@ template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjec Out.set<20>(In.devClass); Out.set<21>(In.locale); Out.set<22>(In.realMacAddress); + Out.set<23>(In.doNotAllowOverrides); } diff --git a/src/storage/storage_inventory.h b/src/storage/storage_inventory.h index c4141ac..658ee12 100644 --- a/src/storage/storage_inventory.h +++ b/src/storage/storage_inventory.h @@ -35,7 +35,8 @@ namespace OpenWifi { std::string, std::string, std::string, - std::string + std::string, + bool > InventoryDBRecordType; class InventoryDB : public ORM::DB {