[open-ils-commits] r13015 - in trunk/Open-ILS/src: c-apps perlmods/OpenILS/Utils (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 29 12:06:02 EDT 2009


Author: scottmk
Date: 2009-04-29 12:06:00 -0400 (Wed, 29 Apr 2009)
New Revision: 13015

Modified:
   trunk/Open-ILS/src/c-apps/oils_idl-core.c
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm
Log:
When loading the IDL code in C or Perl: generate the array_positions
based on the sequence in which the fields appear in the IDL file
(rather than from attributes in the <field> elements).

In most cases this change will make no difference, because the
fields appear in sequence.  However for classes "brn" and "mvr" the 
sequences of fields in the IDL are scrambled.  For those classes, 
this change will effectively renumber the fields.

This commit does not affect the corresponding Python or Java code.
So don't go editing the IDL yet to remove the array_position
attributes.


Modified: trunk/Open-ILS/src/c-apps/oils_idl-core.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_idl-core.c	2009-04-29 14:34:10 UTC (rev 13014)
+++ trunk/Open-ILS/src/c-apps/oils_idl-core.c	2009-04-29 16:06:00 UTC (rev 13015)
@@ -119,6 +119,8 @@
 						);
 					}
 
+					unsigned int array_pos = 0;
+					char array_pos_buf[ 7 ];  // For up to 1,000,000 fields per class
 					xmlNodePtr _f = _cur->children;
 
 					while(_f) {
@@ -129,13 +131,9 @@
 
 						osrfHash* field_def_hash = osrfNewHash();
 
-						if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "array_position", BAD_CAST OBJECT_NS)) ) {
-							osrfHashSet(
-								field_def_hash,
-								prop_str,
-								"array_position"
-							);
-						}
+						// Insert array_position
+						snprintf( array_pos_buf, sizeof( array_pos_buf ), "%u", array_pos++ );
+						osrfHashSet( field_def_hash, strdup( array_pos_buf ), "array_position" );
 
 						if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "i18n", BAD_CAST PERSIST_NS)) ) {
 							osrfHashSet(

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm	2009-04-29 14:34:10 UTC (rev 13014)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm	2009-04-29 16:06:00 UTC (rev 13015)
@@ -71,13 +71,13 @@
 
 	# Load each field -------------------------------------------
 
+	my $array_position = 0;
 	for my $field ( $field_list->childNodes() ) {    # For each <field>
 		if( $field->nodeName eq 'field' ) {
 	
 			my $attribute_list = $field->attributes();
 			
 			my $name     = get_attribute( $attribute_list, 'name' );
-			my $array_position = get_attribute( $attribute_list, 'oils_obj:array_position' );
 			my $virtual  = get_attribute( $attribute_list, 'oils_persist:virtual' );
 			if( ! defined( $virtual ) ) {
 				$virtual = "false";
@@ -96,6 +96,8 @@
 			if( defined( $selector ) ) {
 				$$fieldmap{$fm}{selector} = $selector;
 			}
+
+			++$array_position;
 		}
 	}
 }



More information about the open-ils-commits mailing list