entity-manager: populateInterfacePropertyFromJson

Extract populateInterfacePropertyFromJson from populateInterfaceFromJson
because of the lengthy handling of the different property types.

Tested: on Tyan s8030 board

Inventory is properly exposed and object paths appear as expected.

```
root@s8030-bmc-30303035c0c1:~# busctl tree xyz.openbmc_project.EntityManager
`- /xyz
  `- /xyz/openbmc_project
    |- /xyz/openbmc_project/EntityManager
    `- /xyz/openbmc_project/inventory
      `- /xyz/openbmc_project/inventory/system
        |- /xyz/openbmc_project/inventory/system/board
        | `- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/CPU0_Power_Consumption
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/CPU0_Temp
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/GARBO_SENSOR
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_18_RUN
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_CORE_RUN
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_MEM_ABCD
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_MEM_EFGH
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_SOC_RUN
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VBAT_33
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_12_RUN
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_33_DUAL
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_33_RUN
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_5_DUAL
        |   |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_5_RUN
        |   `- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/X550
```

DBus interfaces appear as expected

```
root@s8030-bmc-30303035c0c1:~# busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VBAT_33
NAME                                              TYPE      SIGNATURE RESULT/VALUE     FLAGS
org.freedesktop.DBus.Introspectable               interface -         -                -
.Introspect                                       method    -         s                -
org.freedesktop.DBus.Peer                         interface -         -                -
.GetMachineId                                     method    -         s                -
.Ping                                             method    -         -                -
org.freedesktop.DBus.Properties                   interface -         -                -
.Get                                              method    ss        v                -
.GetAll                                           method    s         a{sv}            -
.Set                                              method    ssv       -                -
.PropertiesChanged                                signal    sa{sv}as  -                -
xyz.openbmc_project.Configuration.ADC             interface -         -                -
.Index                                            property  t         10               emits-change
.Name                                             property  s         "VBAT_33"        emits-change
.PowerState                                       property  s         "Always"         emits-change
.ScaleFactor                                      property  d         0.3333           emits-change
.Type                                             property  s         "ADC"            emits-change
xyz.openbmc_project.Configuration.ADC.Thresholds0 interface -         -                -
.Delete                                           method    -         -                -
.Direction                                        property  s         "greater than"   emits-change
.Name                                             property  s         "upper critical" emits-change
.Severity                                         property  d         1                emits-change
.Value                                            property  d         3.507            emits-change
xyz.openbmc_project.Configuration.ADC.Thresholds1 interface -         -                -
.Delete                                           method    -         -                -
.Direction                                        property  s         "less than"      emits-change
.Name                                             property  s         "lower critical" emits-change
.Severity                                         property  d         1                emits-change
.Value                                            property  d         2.688            emits-change
```

Change-Id: If0a86a21fabb6a28df7e5469399b3026c28cf402
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/dbus_interface.cpp b/src/entity_manager/dbus_interface.cpp
index 45e4f6d..c4bd311 100644
--- a/src/entity_manager/dbus_interface.cpp
+++ b/src/entity_manager/dbus_interface.cpp
@@ -122,6 +122,85 @@
     });
 }
 
+static void populateInterfacePropertyFromJson(
+    nlohmann::json& systemConfiguration, const std::string& path,
+    const nlohmann::json& key, const nlohmann::json& value,
+    nlohmann::json::value_t type,
+    std::shared_ptr<sdbusplus::asio::dbus_interface>& iface,
+    sdbusplus::asio::PropertyPermission permission)
+{
+    const bool array = value.type() == nlohmann::json::value_t::array;
+
+    if (permission == sdbusplus::asio::PropertyPermission::readWrite)
+    {
+        // all setable numbers are doubles as it is difficult to always
+        // create a configuration file with all whole numbers as decimals
+        // i.e. 1.0
+        if (array)
+        {
+            if (value[0].is_number())
+            {
+                type = nlohmann::json::value_t::number_float;
+            }
+        }
+        else if (value.is_number())
+        {
+            type = nlohmann::json::value_t::number_float;
+        }
+    }
+
+    switch (type)
+    {
+        case (nlohmann::json::value_t::boolean):
+        {
+            if (array)
+            {
+                // todo: array of bool isn't detected correctly by
+                // sdbusplus, change it to numbers
+                addArrayToDbus<uint64_t>(key, value, iface.get(), permission,
+                                         systemConfiguration, path);
+            }
+
+            else
+            {
+                addProperty(key, value.get<bool>(), iface.get(),
+                            systemConfiguration, path, permission);
+            }
+            break;
+        }
+        case (nlohmann::json::value_t::number_integer):
+        {
+            addValueToDBus<int64_t>(key, value, *iface, permission,
+                                    systemConfiguration, path);
+            break;
+        }
+        case (nlohmann::json::value_t::number_unsigned):
+        {
+            addValueToDBus<uint64_t>(key, value, *iface, permission,
+                                     systemConfiguration, path);
+            break;
+        }
+        case (nlohmann::json::value_t::number_float):
+        {
+            addValueToDBus<double>(key, value, *iface, permission,
+                                   systemConfiguration, path);
+            break;
+        }
+        case (nlohmann::json::value_t::string):
+        {
+            addValueToDBus<std::string>(key, value, *iface, permission,
+                                        systemConfiguration, path);
+            break;
+        }
+        default:
+        {
+            std::cerr << "Unexpected json type in system configuration " << key
+                      << ": " << value.type_name() << "\n";
+            break;
+        }
+    }
+}
+
 // adds simple json types to interface's properties
 void populateInterfaceFromJson(
     nlohmann::json& systemConfiguration, const std::string& jsonPointerPath,
@@ -132,10 +211,8 @@
     for (const auto& [key, value] : dict.items())
     {
         auto type = value.type();
-        bool array = false;
         if (value.type() == nlohmann::json::value_t::array)
         {
-            array = true;
             if (value.empty())
             {
                 continue;
@@ -154,75 +231,9 @@
 
         std::string path = jsonPointerPath;
         path.append("/").append(key);
-        if (permission == sdbusplus::asio::PropertyPermission::readWrite)
-        {
-            // all setable numbers are doubles as it is difficult to always
-            // create a configuration file with all whole numbers as decimals
-            // i.e. 1.0
-            if (array)
-            {
-                if (value[0].is_number())
-                {
-                    type = nlohmann::json::value_t::number_float;
-                }
-            }
-            else if (value.is_number())
-            {
-                type = nlohmann::json::value_t::number_float;
-            }
-        }
 
-        switch (type)
-        {
-            case (nlohmann::json::value_t::boolean):
-            {
-                if (array)
-                {
-                    // todo: array of bool isn't detected correctly by
-                    // sdbusplus, change it to numbers
-                    addArrayToDbus<uint64_t>(key, value, iface.get(),
-                                             permission, systemConfiguration,
-                                             path);
-                }
-
-                else
-                {
-                    addProperty(key, value.get<bool>(), iface.get(),
-                                systemConfiguration, path, permission);
-                }
-                break;
-            }
-            case (nlohmann::json::value_t::number_integer):
-            {
-                addValueToDBus<int64_t>(key, value, *iface, permission,
-                                        systemConfiguration, path);
-                break;
-            }
-            case (nlohmann::json::value_t::number_unsigned):
-            {
-                addValueToDBus<uint64_t>(key, value, *iface, permission,
-                                         systemConfiguration, path);
-                break;
-            }
-            case (nlohmann::json::value_t::number_float):
-            {
-                addValueToDBus<double>(key, value, *iface, permission,
-                                       systemConfiguration, path);
-                break;
-            }
-            case (nlohmann::json::value_t::string):
-            {
-                addValueToDBus<std::string>(key, value, *iface, permission,
-                                            systemConfiguration, path);
-                break;
-            }
-            default:
-            {
-                std::cerr << "Unexpected json type in system configuration "
-                          << key << ": " << value.type_name() << "\n";
-                break;
-            }
-        }
+        populateInterfacePropertyFromJson(systemConfiguration, path, key, value,
+                                          type, iface, permission);
     }
     if (permission == sdbusplus::asio::PropertyPermission::readWrite)
     {