adding last_xact_id support to cstore -- need to validate xact_id
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 27 Jul 2006 07:20:47 +0000 (07:20 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 27 Jul 2006 07:20:47 +0000 (07:20 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5118 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_cstore.c

index 6f1edb0..02ee14c 100644 (file)
@@ -654,6 +654,16 @@ jsonObject* doCreate(osrfMethodContext* ctx, int* err ) {
                return jsonNULL;
        }
 
+       char* trans_id = osrfHashGet( (osrfHash*)ctx->session->userData, "xact_id" );
+
+        // Set the last_xact_id
+       osrfHash* last_xact_id;
+       if ((last_xact_id = oilsIDLFindPath("/%s/fields/last_xact_id", target->classname))) {
+               int index = atoi( osrfHashGet(last_xact_id, "array_position") );
+               osrfLogDebug(OSRF_LOG_MARK, "Setting last_xact_id to %s on %s at position %d", trans_id, target->classname, index);
+               jsonObjectSetIndex(target, index, jsonNewObject(trans_id));
+       }       
+
        osrfLogDebug( OSRF_LOG_MARK, "There is a transaction running..." );
 
        dbhandle = writehandle;
@@ -1571,6 +1581,16 @@ jsonObject* doUpdate(osrfMethodContext* ctx, int* err ) {
 
        dbhandle = writehandle;
 
+       char* trans_id = osrfHashGet( (osrfHash*)ctx->session->userData, "xact_id" );
+
+        // Set the last_xact_id
+       osrfHash* last_xact_id;
+       if ((last_xact_id = oilsIDLFindPath("/%s/fields/last_xact_id", target->classname))) {
+               int index = atoi( osrfHashGet(last_xact_id, "array_position") );
+               osrfLogDebug(OSRF_LOG_MARK, "Setting last_xact_id to %s on %s at position %d", trans_id, target->classname, index);
+               jsonObjectSetIndex(target, index, jsonNewObject(trans_id));
+       }       
+
        char* pkey = osrfHashGet(meta, "primarykey");
        osrfHash* fields = osrfHashGet(meta, "fields");