);
if (result) {
- osrfLogDebug( OSRF_LOG_MARK, "Recieved a result for permission [%s] for user %d at org %d", perm, userid, atoi(context_org) );
+ osrfLogDebug( OSRF_LOG_MARK, "Received a result for permission [%s] for user %d at org %d", perm, userid, atoi(context_org) );
if (dbi_result_first_row(result)) {
jsonObject* return_val = oilsMakeJSONFromResult( result );
char* has_perm = jsonObjectToSimpleString( jsonObjectGetKeyConst(return_val, "has_perm") );
jsonIterator* search_itr = jsonNewIterator( working_hash );
while ( (snode = jsonIteratorNext( search_itr )) ) {
- osrfHash* idlClass = osrfHashGet( oilsIDL(), search_itr->key );
+ const char* class = search_itr->key;
+ osrfHash* idlClass = osrfHashGet( oilsIDL(), class );
if( !idlClass ) {
osrfLogError(
OSRF_LOG_MARK,
return NULL;
}
- const char* class = osrfHashGet(idlClass, "classname");
-
char* fkey = jsonObjectToSimpleString( jsonObjectGetKeyConst( snode, "fkey" ) );
char* field = jsonObjectToSimpleString( jsonObjectGetKeyConst( snode, "field" ) );
field = strdup( field );
} else if (!field && !fkey) {
- osrfHash* _links = oilsIDLFindPath("/%s/links", leftclass);
+ osrfHash* _links = oilsIDL_links( leftclass );
// For each link defined for the left class:
// see if the link references the joined class
if (!field || !fkey) {
// Do another such search, with the classes reversed
- _links = oilsIDLFindPath("/%s/links", class);
+ _links = oilsIDL_links( class );
// For each link defined for the joined class:
// see if the link references the left class
jsonIterator* class_itr = jsonNewIterator( selhash );
while ( (snode = jsonIteratorNext( class_itr )) ) {
- osrfHash* idlClass = osrfHashGet( oilsIDL(), class_itr->key );
+ char* cname = class_itr->key;
+ osrfHash* idlClass = osrfHashGet( oilsIDL(), cname );
if (!idlClass) continue;
- char* cname = osrfHashGet(idlClass, "classname");
if (strcmp(core_class,class_itr->key)) {
if (!join_hash) continue;
return osrfHashGet( idlHash, classname );
}
+osrfHash* oilsIDL_links( const char* classname ) {
+ osrfHash* classdef = findClassDef( classname );
+ if( classdef )
+ return osrfHashGet( classdef, "links" );
+ else
+ return NULL;
+}
+
+osrfHash* oilsIDL_fields( const char* classname ) {
+ osrfHash* classdef = findClassDef( classname );
+ if( classdef )
+ return osrfHashGet( classdef, "fields" );
+ else
+ return NULL;
+}
+
int oilsIDL_classIsFieldmapper ( const char* classname ) {
if( findClassDef( classname ) )
return 1;
return 0;
}
+// For a given class: return the array_position associated with a
+// specified field. (or -1 if it doesn't exist)
int oilsIDL_ntop (const char* classname, const char* fieldname) {
- osrfHash* class_def_hash = findClassDef( classname );
- if( !class_def_hash )
- return -1; // No such class
-
- osrfHash* fields_hash = osrfHashGet( class_def_hash, "fields" );
+ osrfHash* fields_hash = oilsIDL_fields( classname );
if( !fields_hash )
- return -1; // No list of fields fo the class
+ return -1; // No such class, or no fields for it
osrfHash* field_def_hash = osrfHashGet( fields_hash, fieldname );
if( !field_def_hash )
return atoi( pos_attr ); // Return position as int
}
+// For a given class: return a copy of the name of the field
+// at a specified array_position (or NULL if there is none)
char * oilsIDL_pton (const char* classname, int pos) {
- osrfHash* class_def_hash = findClassDef( classname );
- if( !class_def_hash )
- return NULL; // No such class
-
- osrfHash* fields_hash = osrfHashGet( class_def_hash, "fields" );
+ osrfHash* fields_hash = oilsIDL_fields( classname );
if( !fields_hash )
- return NULL; // No list of fields fo the class
+ return NULL; // No such class, or no fields for it
char* ret = NULL;
osrfHash* field_def_hash = NULL;