[open-ils-commits] r7834 - in trunk/Open-ILS: examples src/c-apps
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 26 13:07:35 EDT 2007
Author: miker
Date: 2007-09-26 12:57:46 -0400 (Wed, 26 Sep 2007)
New Revision: 7834
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/c-apps/oils_cstore.c
trunk/Open-ILS/src/c-apps/oils_idl-core.c
Log:
initial test of in-xml views for reporting
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2007-09-26 15:30:21 UTC (rev 7833)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2007-09-26 16:57:46 UTC (rev 7834)
@@ -2584,8 +2584,41 @@
</links>
</class>
+ <class id="iatc" controller="open-ils.reporter-store" oils_obj:fieldmapper="action::intersystem_transit_copy" oils_persist:readonly="true" reporter:core="true" reporter:label="Inter-system Copy Transit">
+ <oils_persist:source_definition>
+ SELECT t.*
+ FROM action.transit_copy t
+ JOIN actor.org_unit so ON (t.source = so.id)
+ JOIN actor.org_unit do ON (t.dest = do.id)
+ WHERE so.parent_ou <> do.parent_ou
+ </oils_persist:source_definition>
+ <fields oils_persist:primary="id" oils_persist:sequence="action.transit_copy_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="Pretransit Copy Status" name="copy_status" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="bool"/>
+ <field reporter:label="Destination" name="dest" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link"/>
+ <field reporter:label="Receive Date/Time" name="dest_recv_time" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="timestamp"/>
+ <field reporter:label="Transit ID" name="id" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="id"/>
+ <field reporter:label="Is Persistent? (unused)" name="persistant_transfer" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="bool"/>
+ <field reporter:label="Previous Hop (unused)" name="prev_hop" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="link"/>
+ <field reporter:label="Source" name="source" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="link"/>
+ <field reporter:label="Send Date/Time" name="source_send_time" oils_obj:array_position="10" oils_persist:virtual="false" reporter:datatype="timestamp"/>
+ <field reporter:label="Transited Copy" name="target_copy" oils_obj:array_position="11" oils_persist:virtual="false" reporter:datatype="link"/>
+ <field reporter:label="Hold Transit" name="hold_transit_copy" oils_obj:array_position="12" oils_persist:virtual="true" reporter:datatype="link"/>
+ </fields>
+ <links>
+ <link field="hold_transit_copy" reltype="might_have" key="id" map="" class="ahtc"/>
+ <link field="source" reltype="has_a" key="id" map="" class="aou"/>
+ <link field="copy_status" reltype="has_a" key="id" map="" class="ccs"/>
+ <link field="dest" reltype="has_a" key="id" map="" class="aou"/>
+ <link field="target_copy" reltype="has_a" key="id" map="" class="acp"/>
+ </links>
+ </class>
+
+
<!-- ********************************************************************************************************************* -->
</IDL>
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2007-09-26 15:30:21 UTC (rev 7833)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2007-09-26 16:57:46 UTC (rev 7834)
@@ -283,10 +283,24 @@
continue;
}
-
+ growing_buffer* tablebuf = buffer_init(128);
+ char* tabledef = osrfHashGet(class, "tablename");
+ if (!tabledef) {
+ tabledef = osrfHashGet(class, "source_definition");
+ buffer_fadd( tablebuf, "(%s)x", tabledef );
+ } else {
+ buffer_add( tablebuf, tabledef );
+ }
+
+ free(tabledef);
+ tabledef = buffer_data(tablebuf);
+ buffer_free(tablebuf);
+
growing_buffer* sql_buf = buffer_init(32);
- buffer_fadd( sql_buf, "SELECT * FROM %s WHERE 1=0;", osrfHashGet(class, "tablename") );
+ buffer_fadd( sql_buf, "SELECT * FROM %s WHERE 1=0;", tabledef );
+ free(tabledef);
+
char* sql = buffer_data(sql_buf);
buffer_free(sql_buf);
osrfLogDebug(OSRF_LOG_MARK, "%s Investigatory SQL = %s", MODULENAME, sql);
@@ -705,6 +719,19 @@
return jsonNULL;
}
+ if (osrfHashGet( meta, "readonly" ) && strncasecmp("true", osrfHashGet( meta, "readonly" ), 4)) {
+ osrfAppSessionStatus(
+ ctx->session,
+ OSRF_STATUS_BADREQUEST,
+ "osrfMethodException",
+ ctx->request,
+ "Cannot INSERT readonly class"
+ );
+ *err = -1;
+ return jsonNULL;
+ }
+
+
char* trans_id = osrfHashGet( (osrfHash*)ctx->session->userData, "xact_id" );
// Set the last_xact_id
@@ -1325,7 +1352,16 @@
osrfHash* idlClass = osrfHashGet( oilsIDL(), snode->key );
char* class = osrfHashGet(idlClass, "classname");
+
+ growing_buffer* tablebuf = buffer_init(128);
char* table = osrfHashGet(idlClass, "tablename");
+ if (!table) {
+ table = osrfHashGet(idlClass, "source_definition");
+ buffer_fadd( tablebuf, "(%s)", table );
+ free(table);
+ table = buffer_data(tablebuf);
+ buffer_free(tablebuf);
+ }
char* type = jsonObjectToSimpleString( jsonObjectGetKey( snode->item, "type" ) );
char* filter_op = jsonObjectToSimpleString( jsonObjectGetKey( snode->item, "filter_op" ) );
@@ -1511,13 +1547,17 @@
osrfHash* fields = osrfHashGet(meta, "fields");
osrfHash* field = osrfHashGet( fields, node->key );
+ char* table = osrfHashGet(meta, "tablename");
+ if (!table) table = "[CUSTOM RESULT SOURCE]";
+
if (!field) {
osrfLogError(
OSRF_LOG_MARK,
- "%s: Attempt to reference non-existant column %s on table %s",
+ "%s: Attempt to reference non-existant column %s on %s (%s)",
MODULENAME,
node->key,
- osrfHashGet(meta, "tablename")
+ table,
+ class
);
buffer_free(sql_buf);
return NULL;
@@ -1765,8 +1805,18 @@
char* col_list = buffer_data(select_buf);
buffer_free(select_buf);
+ growing_buffer* tablebuf = buffer_init(128);
+ char* table = osrfHashGet(core_meta, "tablename");
+ if (!table) {
+ table = osrfHashGet(core_meta, "source_definition");
+ buffer_fadd( tablebuf, "(%s)", table );
+ free(table);
+ table = buffer_data(tablebuf);
+ buffer_free(tablebuf);
+ }
+
// Put it all together
- buffer_fadd(sql_buf, "SELECT %s FROM %s AS \"%s\" ", col_list, osrfHashGet(core_meta, "tablename"), core_class );
+ buffer_fadd(sql_buf, "SELECT %s FROM %s AS \"%s\" ", col_list, table, core_class );
free(col_list);
// Now, walk the join tree and add that clause
@@ -2048,8 +2098,18 @@
char* col_list = buffer_data(select_buf);
buffer_free(select_buf);
- buffer_fadd(sql_buf, "SELECT %s FROM %s AS \"%s\"", col_list, osrfHashGet(meta, "tablename"), core_class );
+ growing_buffer* tablebuf = buffer_init(128);
+ char* table = osrfHashGet(meta, "tablename");
+ if (!table) {
+ table = osrfHashGet(meta, "source_definition");
+ buffer_fadd( tablebuf, "(%s)", table );
+ free(table);
+ table = buffer_data(tablebuf);
+ buffer_free(tablebuf);
+ }
+ buffer_fadd(sql_buf, "SELECT %s FROM %s AS \"%s\"", col_list, table, core_class );
+
if ( join_hash ) {
char* join_clause = searchJOIN( join_hash, meta );
buffer_fadd(sql_buf, " %s", join_clause);
@@ -2586,6 +2646,18 @@
return jsonNULL;
}
+ if (osrfHashGet( meta, "readonly" ) && strncasecmp("true", osrfHashGet( meta, "readonly" ), 4)) {
+ osrfAppSessionStatus(
+ ctx->session,
+ OSRF_STATUS_BADREQUEST,
+ "osrfMethodException",
+ ctx->request,
+ "Cannot UPDATE readonly class"
+ );
+ *err = -1;
+ return jsonNULL;
+ }
+
dbhandle = writehandle;
char* trans_id = osrfHashGet( (osrfHash*)ctx->session->userData, "xact_id" );
@@ -2752,6 +2824,18 @@
return jsonNULL;
}
+ if (osrfHashGet( meta, "readonly" ) && strncasecmp("true", osrfHashGet( meta, "readonly" ), 4)) {
+ osrfAppSessionStatus(
+ ctx->session,
+ OSRF_STATUS_BADREQUEST,
+ "osrfMethodException",
+ ctx->request,
+ "Cannot DELETE readonly class"
+ );
+ *err = -1;
+ return jsonNULL;
+ }
+
dbhandle = writehandle;
jsonObject* obj;
Modified: trunk/Open-ILS/src/c-apps/oils_idl-core.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_idl-core.c 2007-09-26 15:30:21 UTC (rev 7833)
+++ trunk/Open-ILS/src/c-apps/oils_idl-core.c 2007-09-26 16:57:46 UTC (rev 7834)
@@ -46,6 +46,7 @@
usrData = osrfNewHash();
osrfHashSet( usrData, xmlGetProp(kid, BAD_CAST "id"), "classname");
osrfHashSet( usrData, xmlGetNsProp(kid, BAD_CAST "fieldmapper", BAD_CAST OBJECT_NS), "fieldmapper");
+ osrfHashSet( usrData, xmlGetNsProp(kid, BAD_CAST "readonly", BAD_CAST PERSIST_NS), "readonly");
osrfHashSet( idlHash, usrData, (char*)osrfHashGet(usrData, "classname") );
@@ -255,6 +256,18 @@
}
}
+ if (!strcmp( (char*)_cur->name, "source_definition" )) {
+ string_tmp = NULL;
+ if( (string_tmp = (char*)xmlNodeGetContent(_cur)) ) {
+ osrfHashSet(
+ usrData,
+ strdup( string_tmp ),
+ "source_definition"
+ );
+ }
+
+ }
+
_cur = _cur->next;
}
}
More information about the open-ils-commits
mailing list