Mechanism to associate sensor/effecter to FRU entity

The "entity_path" key is defined in PDR JSONs and will have an FRU D-Bus object
path as the value, if this is present, the entity type, instance, and container
id should be associate with the FRU entity.

Tested: test JSON with https://gist.github.com/lxwinspur/7225a9301ccfcbff1f6549203405b4fa
after executing the following command, get the entity information from FruHandler
entity_type = 120
entity_instance_num = 1
entity_container_id = 0

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I019f9a0b9d4dbec20a71dfd797f30ac8f57f67b8
diff --git a/libpldmresponder/pdr_state_sensor.hpp b/libpldmresponder/pdr_state_sensor.hpp
index f57773a..04b6965 100644
--- a/libpldmresponder/pdr_state_sensor.hpp
+++ b/libpldmresponder/pdr_state_sensor.hpp
@@ -68,9 +68,35 @@
 
         pdr->terminus_handle = 0;
         pdr->sensor_id = handler.getNextSensorId();
-        pdr->entity_type = e.value("type", 0);
-        pdr->entity_instance = e.value("instance", 0);
-        pdr->container_id = e.value("container", 0);
+
+        try
+        {
+            std::string entity_path = e.value("entity_path", "");
+            auto& associatedEntityMap = handler.getAssociateEntityMap();
+            if (entity_path != "" && associatedEntityMap.find(entity_path) !=
+                                         associatedEntityMap.end())
+            {
+                pdr->entity_type =
+                    associatedEntityMap.at(entity_path).entity_type;
+                pdr->entity_instance =
+                    associatedEntityMap.at(entity_path).entity_instance_num;
+                pdr->container_id =
+                    associatedEntityMap.at(entity_path).entity_container_id;
+            }
+            else
+            {
+                pdr->entity_type = e.value("type", 0);
+                pdr->entity_instance = e.value("instance", 0);
+                pdr->container_id = e.value("container", 0);
+            }
+        }
+        catch (const std::exception& ex)
+        {
+            pdr->entity_type = e.value("type", 0);
+            pdr->entity_instance = e.value("instance", 0);
+            pdr->container_id = e.value("container", 0);
+        }
+
         pdr->sensor_init = PLDM_NO_INIT;
         pdr->sensor_auxiliary_names_pdr = false;
         if (sensors.size() > 8)