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_numeric_effecter.hpp b/libpldmresponder/pdr_numeric_effecter.hpp
index 402a426..0258ab2 100644
--- a/libpldmresponder/pdr_numeric_effecter.hpp
+++ b/libpldmresponder/pdr_numeric_effecter.hpp
@@ -47,9 +47,35 @@
 
         pdr->terminus_handle = e.value("terminus_handle", 0);
         pdr->effecter_id = handler.getNextEffecterId();
-        pdr->entity_type = e.value("entity_type", 0);
-        pdr->entity_instance = e.value("entity_instance", 0);
-        pdr->container_id = e.value("container_id", 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->effecter_semantic_id = e.value("effecter_semantic_id", 0);
         pdr->effecter_init = e.value("effecter_init", PLDM_NO_INIT);
         pdr->effecter_auxiliary_names = e.value("effecter_init", false);