Changeset 11974


Ignore:
Timestamp:
2006-06-29T11:27:01+12:00 (18 years ago)
Author:
mdewsnip
Message:

Now checks place function values are valid.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cic-hcap/perllib/plugins/CICPlug.pm

    r11973 r11974  
    228228
    229229
     230my $place_functions_mapping = {
     231    "academic department building" => "",
     232    "administration" => "",
     233    "admissions office" => "",
     234    "alumni center" => "",
     235    "arboretum" => "",
     236    "archaeological site" => "",
     237    "auditorium" => "",
     238    "bell tower" => "",
     239    "chapel" => "",
     240    "classrooms" => "",
     241    "debating society" => "",
     242    "dining hall" => "",
     243    "facility management building" => "",
     244    "faculty offices" => "",
     245    "gardens" => "",
     246    "greek letter society" => "",
     247    "gymnasium" => "",
     248    "infirmary" => "",
     249    "library" => "",
     250    "master plan (campus)" => "",
     251    "master plan (landscape)" => "",
     252    "memorial site" => "",
     253    "museum" => "",
     254    "observatory" => "",
     255    "old main" => "",
     256    "outdoor space" => "",
     257    "president's house" => "",
     258    "residence hall" => "",
     259    "stadium" => "",
     260    "student union" => "",
     261    "theater" => "",
     262    "other" => "",
     263};
     264
     265
    230266sub read
    231267{
     
    622658        $place_functions_table_html .= "<tr><td valign=\"top\"><nobr>$place_year_prefix $place_year</nobr>&nbsp;</td><td valign=\"top\">$place_function</td></tr>";
    623659
    624         # Create place functions mapping
    625         $place_function = lc($place_function);
    626         $place_function =~ s/\.$//;
    627         $place_function =~ s/\(.*\)//g;
    628         $place_function =~ s/^\s*//;
    629         $place_function =~ s/\s*$//;
    630         $place_function =~ s/classroom$/classrooms/;
    631         $place_function =~ s/department buildings$/department building/;
    632         $place_function =~ s/faculty office$/faculty offices/;
    633         $place_function =~ s/garden$/gardens/;
    634         $place_function =~ s/residence halls$/residence hall/;
    635         next if ($place_function eq "");
    636         push(@{$place_function_to_ids_mapping{$place_function}}, $place_doc_obj->get_OID());
     660        # Prepare function metadata for browsing and searching
     661        my $place_function_to_index = lc($place_function);  # Casefold
     662        $place_function_to_index =~ s/^\s*//;  # Remove whitespace from the start
     663        if ($place_function_to_index =~ /^master plan/) {
     664        $place_function_to_index =~ s/ \(campus,.*/ \(campus\)/;
     665        $place_function_to_index =~ s/ \(campus:.*/ \(campus\)/;
     666        }
     667        else {
     668        $place_function_to_index =~ s/\(.*\)//g;  # Remove anything in parentheses
     669        }
     670        $place_function_to_index =~ s/\s*$//;  # Remove whitespace from the end
     671
     672        # Deal with common plural cases
     673        $place_function_to_index =~ s/classroom$/classrooms/;
     674        $place_function_to_index =~ s/department buildings$/department building/;
     675        $place_function_to_index =~ s/faculty office$/faculty offices/;
     676        $place_function_to_index =~ s/garden$/gardens/;
     677        $place_function_to_index =~ s/residence halls$/residence hall/;
     678
     679        # Check it is one of the valid function values
     680        if (!defined($place_functions_mapping->{$place_function_to_index})) {
     681        print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Unknown function: $place_function_to_index'>\n" if ($self->{'gli'});
     682        print STDERR "Error: Place $place_id -- Unknown function: $place_function_to_index.\n";
     683        print $fail_log_handle "Error: Place $place_id -- Unknown function: $place_function_to_index.\n";
     684        next;
     685        }
     686        push(@{$place_function_to_ids_mapping{$place_function_to_index}}, $place_doc_obj->get_OID());
    637687    }
    638688    &new_metadata_entry($place_doc_obj, "Functions", $place_functions);
Note: See TracChangeset for help on using the changeset viewer.