Added some debug info
[gnucomo.git] / src / gcm_input / message.cpp
index ce006fc..185fa0e 100644 (file)
@@ -8,7 +8,7 @@
 ***********************
 **      FILE NAME      : message.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.18 $
+**      VERSION NUMBER : $Revision: 1.19 $
 **
 **  DESCRIPTION      :  Implementation of the message handling classes
 **
 
 /*****************************
    $Log: message.cpp,v $
-   Revision 1.18  2007-11-03 10:23:53  arjen
+   Revision 1.19  2011-03-24 10:20:37  arjen
+   Added some debug info
+
+   Revision 1.18  2007/11/03 10:23:53  arjen
    Handling of parameters is greatly improved.
    When creating a new parameter from an XML report which is fed into
    gcm_input, the class definition is used as a template to fill in
 
 *****************************/
 
-static const char *RCSID = "$Id: message.cpp,v 1.18 2007-11-03 10:23:53 arjen Exp $";
+static const char *RCSID = "$Id: message.cpp,v 1.19 2011-03-24 10:20:37 arjen Exp $";
 
 #include <algorithm>
 #include <libxml/xpath.h>
@@ -990,22 +993,35 @@ void client_message::enterXML()
          {
             //  Check if any parameters in this class have disappeared.
 
+#ifdef DEBUG
+            *Log << "Checking for disappeared parameters.\n";
+#endif
             qry = "select name, paramid from parameter where objectid='";
             qry += objectid + "' and class='" + param_class + "'";
 
             int          nr_parameters = database.Query(qry);
-            pqxx::Result parameter_set = database.Result();
+            pqxx::result parameter_set = database.Result();
 
+#ifdef DEBUG
+            *Log << nr_parameters << " parameters of class " << param_class << " found in the database.\n";
+#endif
             for (int i = 0; i < nr_parameters; i++)
             {
                String XPath;
                String param_name, paramid;
 
                param_name = database.Field(parameter_set, i, "name");
+#ifdef DEBUG
+               *Log << "Looking for " << param_name << " in XML tree.\n";
+#endif
                XPath = "gcmt:parameter[@name='" + param_name + "']";
 
                res = xmlXPathEval((const xmlChar *)(const char *)XPath, pathcontext);
-               if (res->nodesetval->nodeTab == NULL)
+#ifdef DEBUG
+               *Log << "XPATH result: " << res->type << ".\n";
+               *Log << "Nr of nodes found: " << res->nodesetval->nodeNr << ".\n";
+#endif
+               if (res->nodesetval->nodeNr == 0)
                {
                   // The parameter is in the database but not in the report
 
@@ -1057,6 +1073,12 @@ void client_message::enterXML()
                      }
                   }
                }
+               else
+               {
+#ifdef DEBUG
+                  *Log << XPath << " was found in XML tree.\n";
+#endif
+               }
             }
          }
       }