From b836e15784038508af8a7bbda9ff3859d61e21b3 Mon Sep 17 00:00:00 2001 From: scottmk Date: Wed, 29 Apr 2009 16:06:00 +0000 Subject: [PATCH] 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 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13015 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/c-apps/oils_idl-core.c | 12 +++++------- Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm | 4 +++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/c-apps/oils_idl-core.c b/Open-ILS/src/c-apps/oils_idl-core.c index c263141d8b..b0cce8dd26 100644 --- a/Open-ILS/src/c-apps/oils_idl-core.c +++ b/Open-ILS/src/c-apps/oils_idl-core.c @@ -119,6 +119,8 @@ osrfHash* oilsIDLInit( const char* idl_filename ) { ); } + 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* oilsIDLInit( const char* idl_filename ) { 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( diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm b/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm index ac0190fe3b..308976bd4b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm @@ -71,13 +71,13 @@ sub load_fields { # Load each field ------------------------------------------- + my $array_position = 0; for my $field ( $field_list->childNodes() ) { # For each 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 @@ sub load_fields { if( defined( $selector ) ) { $$fieldmap{$fm}{selector} = $selector; } + + ++$array_position; } } } -- 2.11.0