</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>
<!-- ********************************************************************************************************************* -->
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);
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
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" ) );
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;
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
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 );
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" );
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;