Fixes around persisting values in entity-manager

This fixes three problems that were causing "Faild to set dbus
property." error traces to show up.

1. In VirtualSensor::createThresholds() the setEntityPath() and
   setEntityInterfaceHigh/Low() calls have to be made on the threshold
   objects before the critical/warning/High/Low() functions are called
   so that the path and interface is known for the property set call.
   Reorder the code so this is the case.

2. Saving the value in entity-manager only works when the virtual sensor
   config was obtained from entity-manager D-Bus objects, and not when
   it was obtained from virtual_sensor_config.json.  In the latter case,
   the 'entityPath' variable won't have a value, so check for that
   before trying to set a property on entity-manager.

3. If either a 'high' or 'low' threshold property isn't set, then the
   'entityInterfaceHigh/Low' variable will be empty.  Also skip the
   property write in that case.

Tested:  No more error traces, and verified that changing a threshold
value on a virtual sensor is still reflected in entity-manager when its
config was from EM in the first place.

Change-Id: I67dc35fb4b8f4c1367231e22ddde91fbd1bb354d
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/thresholds.hpp b/thresholds.hpp
index 1860d7c..be238a1 100644
--- a/thresholds.hpp
+++ b/thresholds.hpp
@@ -120,18 +120,24 @@
     /** @brief Set value of WarningHigh */
     virtual double warningHigh(double value)
     {
-        // persistThreshold
-        setDbusProperty(bus, entityManagerBusName, entityPath,
-                        entityInterfaceHigh, "Value", value);
+        if (!entityPath.empty() && !entityInterfaceHigh.empty())
+        {
+            // persistThreshold
+            setDbusProperty(bus, entityManagerBusName, entityPath,
+                            entityInterfaceHigh, "Value", value);
+        }
         return WarningObject::warningHigh(value);
     }
 
     /** @brief Set value of WarningLow */
     virtual double warningLow(double value)
     {
-        // persistThreshold
-        setDbusProperty(bus, entityManagerBusName, entityPath,
-                        entityInterfaceLow, "Value", value);
+        if (!entityPath.empty() && !entityInterfaceLow.empty())
+        {
+            // persistThreshold
+            setDbusProperty(bus, entityManagerBusName, entityPath,
+                            entityInterfaceLow, "Value", value);
+        }
         return WarningObject::warningLow(value);
     }
 
@@ -234,16 +240,22 @@
     virtual double criticalHigh(double value)
     {
         // persistThreshold
-        setDbusProperty(bus, entityManagerBusName, entityPath,
-                        entityInterfaceHigh, "Value", value);
+        if (!entityPath.empty() && !entityInterfaceHigh.empty())
+        {
+            setDbusProperty(bus, entityManagerBusName, entityPath,
+                            entityInterfaceHigh, "Value", value);
+        }
         return CriticalObject::criticalHigh(value);
     }
 
     /** @brief Set value of CriticalLow */
     virtual double criticalLow(double value)
     {
-        setDbusProperty(bus, entityManagerBusName, entityPath,
-                        entityInterfaceLow, "Value", value);
+        if (!entityPath.empty() && !entityInterfaceLow.empty())
+        {
+            setDbusProperty(bus, entityManagerBusName, entityPath,
+                            entityInterfaceLow, "Value", value);
+        }
         return CriticalObject::criticalLow(value);
     }