From: miker Date: Thu, 27 Jul 2006 07:20:47 +0000 (+0000) Subject: adding last_xact_id support to cstore -- need to validate xact_id X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=629aa3a12c1a69d808d8b39f38d14f454dac7b3a;p=Evergreen.git adding last_xact_id support to cstore -- need to validate xact_id git-svn-id: svn://svn.open-ils.org/ILS/trunk@5118 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index 6f1edb0f71..02ee14c482 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -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");