[SSM] Fix IOT-322, 323 issues
authorjk13 <jihyeok13.kim@samsung.com>
Fri, 27 Feb 2015 01:21:38 +0000 (10:21 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 27 Feb 2015 06:11:21 +0000 (06:11 +0000)
1. Fix IOT 322, duplicated callback if query contains
   multiple 'and' operation to one resource
2. Fix IOT 323, init-term exceptional case

Change-Id: If78af1060c905c52c36aa6cdbf01af1f8a11db73
Signed-off-by: jk13 <jihyeok13.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/416
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/soft-sensor-manager/SDK/cpp/src/InprocSSMCore.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ContextQuery.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp

index 6b691de..82d2c6f 100644 (file)
@@ -72,7 +72,8 @@ SSMRESULT OIC::InitializeSSM(std::string xmlDescription)
     SSM_CLEANUP_ASSERT(g_pQueryEngineInstance->registerQueryEvent(g_pEventReceiver));
 
 CLEANUP:
     SSM_CLEANUP_ASSERT(g_pQueryEngineInstance->registerQueryEvent(g_pEventReceiver));
 
 CLEANUP:
-    if (res != SSM_S_OK)
+    if (res != SSM_S_OK &&
+        res != SSM_E_INITIALIZED)
     {
         SAFE_DELETE(g_pEventReceiver);
     }
     {
         SAFE_DELETE(g_pEventReceiver);
     }
index 0fa9a79..1112318 100644 (file)
@@ -288,15 +288,13 @@ void CContextQuery::make_QueryCondition(OUT QueryCondition *result)
     {
         int k = m_root.child_token.at(1).child_token.size();
         std::string model_name = "";
     {
         int k = m_root.child_token.at(1).child_token.size();
         std::string model_name = "";
-        ModelConditionVec modelcondition;
-        ModelCondition model_data;
 
 
-        for (int i = 0 ; i < k ; i++)
+        std::map<std::string, ModelConditionVec> modelConditionList;
+
+        for (int i = 0; i < k; i++)
         {
         {
-            modelcondition.clear();
             Token *temp = &(m_root.child_token.at(1).child_token.at(i));
 
             Token *temp = &(m_root.child_token.at(1).child_token.at(i));
 
-
             if (temp->type == Context)
             {
                 while (1)
             if (temp->type == Context)
             {
                 while (1)
@@ -313,16 +311,20 @@ void CContextQuery::make_QueryCondition(OUT QueryCondition *result)
                     }
                 }
 
                     }
                 }
 
-
-
+                ModelCondition model_data;
                 model_data.predicate = m_root.child_token.at(1).child_token.at(i + 1).condition;
                 model_data.modelProperty.propertyName = temp->model_property.propertyName;
                 model_data.modelProperty.propertyType = temp->model_property.propertyType;
                 model_data.modelProperty.propertyValue = temp->model_property.propertyValue;
                 model_data.predicate = m_root.child_token.at(1).child_token.at(i + 1).condition;
                 model_data.modelProperty.propertyName = temp->model_property.propertyName;
                 model_data.modelProperty.propertyType = temp->model_property.propertyType;
                 model_data.modelProperty.propertyValue = temp->model_property.propertyValue;
-                modelcondition.push_back(model_data);
-                result->push_back(std::pair<std::string, ModelConditionVec>(model_name, modelcondition));
-                ///result->push_back(model_name[i],modelcondition);
+                modelConditionList[model_name].push_back(model_data);
             }
         }
             }
         }
+
+        for (std::map<std::string, ModelConditionVec>::iterator itor = modelConditionList.begin();
+             itor != modelConditionList.end(); ++itor)
+        {
+            result->push_back(std::pair<std::string, ModelConditionVec>(itor->first,
+                              itor->second));
+        }
     }
 }
     }
 }
index 2c735ef..4008239 100644 (file)
@@ -53,12 +53,16 @@ SSMRESULT InitializeSSMCore(IN std::string xmlDescription)
 {
     SSMRESULT res = SSM_E_FAIL;
 
 {
     SSMRESULT res = SSM_E_FAIL;
 
+    if (g_pSoftSensorManager != NULL)
+        SSM_CLEANUP_ASSERT(SSM_E_INITIALIZED);
+
     SSM_CLEANUP_ASSERT(CreateGlobalInstanceRepo());
     SSM_CLEANUP_ASSERT(CreateInstance(OID_ISoftSensorManager, (IBase **)&g_pSoftSensorManager));
     SSM_CLEANUP_ASSERT(g_pSoftSensorManager->initializeCore(xmlDescription));
 
 CLEANUP:
     SSM_CLEANUP_ASSERT(CreateGlobalInstanceRepo());
     SSM_CLEANUP_ASSERT(CreateInstance(OID_ISoftSensorManager, (IBase **)&g_pSoftSensorManager));
     SSM_CLEANUP_ASSERT(g_pSoftSensorManager->initializeCore(xmlDescription));
 
 CLEANUP:
-    if (res != SSM_S_OK)
+    if (res != SSM_S_OK &&
+        res != SSM_E_INITIALIZED)
     {
         SAFE_RELEASE(g_pSoftSensorManager);
     }
     {
         SAFE_RELEASE(g_pSoftSensorManager);
     }
index 4b9c023..c9a8ce7 100644 (file)
@@ -58,9 +58,11 @@ SSMRESULT CSoftSensorManager::initializeCore(IN std::string xmlDescription)
     std::string                 pathSoftSensors;
     std::string                 pathDescription;
 
     std::string                 pathSoftSensors;
     std::string                 pathDescription;
 
+    std::string                 copyDescription = xmlDescription.c_str();
+
     try
     {
     try
     {
-        xmlDoc.parse<0>((char *)xmlDescription.c_str());
+        xmlDoc.parse<0>((char *)copyDescription.c_str());
 
         root = xmlDoc.first_node();
 
 
         root = xmlDoc.first_node();