summaryrefslogtreecommitdiffstats
path: root/server/parser/pgsql.c
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-10-12 17:44:10 +0200
committerDavid Sommerseth <davids@redhat.com>2009-10-12 17:44:10 +0200
commitd4037cd833166e5bd0c0d706887e4ec537cdfda4 (patch)
tree53b070424c6876a778fc5ed5f3f06ec4b7b333cc /server/parser/pgsql.c
parent1b8d1a8d97df4643f3fa9c0eeba683febd0a35d3 (diff)
downloadrteval-d4037cd833166e5bd0c0d706887e4ec537cdfda4.tar.gz
rteval-d4037cd833166e5bd0c0d706887e4ec537cdfda4.tar.xz
rteval-d4037cd833166e5bd0c0d706887e4ec537cdfda4.zip
Added db_register_rtevalrun()
Registers report XML data into the rtevalruns and rtevalruns_details tables in the database.
Diffstat (limited to 'server/parser/pgsql.c')
-rw-r--r--server/parser/pgsql.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/server/parser/pgsql.c b/server/parser/pgsql.c
index 6a4f9e2..f046557 100644
--- a/server/parser/pgsql.c
+++ b/server/parser/pgsql.c
@@ -349,3 +349,83 @@ int db_register_system(void *indbc, xsltStylesheet *xslt, xmlDoc *summaryxml) {
}
return syskey;
}
+
+
+int db_register_rtevalrun(void *indbc, xsltStylesheet *xslt, xmlDoc *summaryxml,
+ int syskey, const char *report_fname)
+{
+ PGconn *dbc = (PGconn *) indbc;
+ int rterid = -1;
+ xmlDoc *rtevalrun_d = NULL, *rtevalrundets_d = NULL;
+ parseParams prms;
+ eurephiaVALUES *dbdata = NULL;
+
+ // Parse the rtevalruns information
+ memset(&prms, 0, sizeof(parseParams));
+ prms.table = "rtevalruns";
+ prms.syskey = syskey;
+ prms.report_filename = report_fname;
+ rtevalrun_d = parseToSQLdata(xslt, summaryxml, &prms);
+ if( !rtevalrun_d ) {
+ fprintf(stderr, "** ERROR ** Could not parse the input XML data\n");
+ rterid = -1;
+ goto exit;
+ }
+
+ // Register the rteval run information
+ dbdata = pgsql_INSERT(dbc, rtevalrun_d);
+ if( !dbdata ) {
+ rterid = -1;
+ goto exit;
+ }
+
+ // Grab the rterid value from the database
+ if( eCount(dbdata) != 1 ) {
+ fprintf(stderr, "** ERROR ** Failed to register the rteval run\n");
+ rterid = -1;
+ eFree_values(dbdata);
+ goto exit;
+ }
+ rterid = atoi_nullsafe(dbdata->val);
+ if( rterid < 1 ) {
+ fprintf(stderr, "** ERROR ** Failed to register the rteval run. Invalid rterid value.\n");
+ rterid = -1;
+ eFree_values(dbdata);
+ goto exit;
+ }
+ eFree_values(dbdata);
+
+ // Parse the rtevalruns_details information
+ memset(&prms, 0, sizeof(parseParams));
+ prms.table = "rtevalruns_details";
+ prms.rterid = rterid;
+ rtevalrundets_d = parseToSQLdata(xslt, summaryxml, &prms);
+ if( !rtevalrundets_d ) {
+ fprintf(stderr, "** ERROR ** Could not parse the input XML data (rtevalruns_details)\n");
+ rterid = -1;
+ goto exit;
+ }
+
+ // Register the rteval_details information
+ dbdata = pgsql_INSERT(dbc, rtevalrundets_d);
+ if( !dbdata ) {
+ rterid = -1;
+ goto exit;
+ }
+
+ // Check that only one record was inserted
+ if( eCount(dbdata) != 1 ) {
+ fprintf(stderr, "** ERROR ** Failed to register the rteval run\n");
+ rterid = -1;
+ }
+ eFree_values(dbdata);
+
+ exit:
+ if( rtevalrun_d ) {
+ xmlFreeDoc(rtevalrun_d);
+ }
+ if( rtevalrundets_d ) {
+ xmlFreeDoc(rtevalrundets_d);
+ }
+ return rterid;
+}