]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Save and load Jobs with specific parameters
authorribes <ribes>
Wed, 13 Apr 2011 17:24:34 +0000 (17:24 +0000)
committerribes <ribes>
Wed, 13 Apr 2011 17:24:34 +0000 (17:24 +0000)
src/Launcher/Launcher_Job.cxx
src/Launcher/SALOME_Launcher.cxx

index 19daa34c1c6468708a324fb3c58dc35a6978eeed..d2023ae128176c95ce077160a20fb1de335c1d8e 100644 (file)
@@ -574,6 +574,16 @@ Launcher::Job::addToXmlDocument(xmlNodePtr root_node)
   xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str()));
   xmlNewChild(node, NULL, xmlCharStrdup("queue"),            xmlCharStrdup(getQueue().c_str()));
 
+  // Specific parameters part
+  xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL);
+  std::map<std::string, std::string> specific_parameters = getSpecificParameters();
+  for(std::map<std::string, std::string>::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++)
+  {
+    xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL);
+    xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str()));
+    xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str()));
+  }
+
   // Run part
   xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL);
   xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(getState().c_str()));
index ec1993e656f7f2dd2621bd6cc7270dfc79ab1479..be953f9017fa783001e990061cbd0735499a4282 100644 (file)
@@ -677,6 +677,61 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
         xmlFree(maximum_duration);
         xmlFree(queue);
 
+        xmlNodePtr specific_node = xmlNextElementSibling(queue_node);
+        if (specific_node == NULL)
+        {
+          INFOS("A bad job is found, specific_parameters part is not found");
+          delete new_job;
+          break;
+        }
+        xmlNodePtr parameter_node = xmlFirstElementChild(specific_node);
+        while (parameter_node != NULL)
+        {
+          if (!xmlStrcmp(parameter_node->name, xmlCharStrdup("specific_parameter")))
+          {
+            xmlNodePtr name_node = xmlFirstElementChild(parameter_node);
+            xmlNodePtr value_node = xmlNextElementSibling(name_node);
+            if (name_node == NULL ||
+                value_node == NULL)
+            {
+              INFOS("A bad job is found, specific_parameter parts are not found");
+              delete new_job;
+              break;
+            }
+            if (xmlStrcmp(name_node->name, xmlCharStrdup("name")) ||
+                xmlStrcmp(value_node->name, xmlCharStrdup("value")))
+            {
+              INFOS("A bad job is found, specific_parameter bad parts are found");
+              delete new_job;
+              break;
+            }
+
+            xmlChar* name  = xmlNodeGetContent(name_node);
+            xmlChar* value = xmlNodeGetContent(value_node);
+            try
+            {
+              new_job->addSpecificParameter(std::string((const char*)name), std::string((const char*)value));
+              xmlFree(name);
+              xmlFree(value);
+            }
+            catch(const LauncherException &ex)
+            {
+              INFOS("Exception receice for a specific parameter, cannot add the job" << ex.msg.c_str());
+              delete new_job;
+              xmlFree(name);
+              xmlFree(value);
+              break;
+            }
+          }
+          else
+          {
+            INFOS("A bad job is found, specific_parameters part is bad, a node that is not a specific parameter is found");
+            delete new_job;
+            break;
+          }
+          parameter_node = xmlNextElementSibling(parameter_node);
+        }
+
         xmlNodePtr res_name_node             = xmlFirstElementChild(res_node);
         xmlNodePtr res_hostname_node         = xmlNextElementSibling(res_name_node);
         xmlNodePtr res_os_node               = xmlNextElementSibling(res_hostname_node);