Changeset 12212


Ignore:
Timestamp:
2006-07-13T14:48:42+12:00 (18 years ago)
Author:
mdewsnip
Message:

Removed the old Construction_date metadata and added PlaceConstructionDatesTableHTML metadata instead (with old construction entries). Also added Time_period metadata for each of the construction entries.

File:
1 edited

Legend:

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

    r12210 r12212  
    481481    my $place_institution_sql_handle = $dbh->prepare($place_institution_sql_statement);
    482482
    483     # Prepare SQL statement for getting the Place "date of construction"
    484     my $place_construction_date_sql_statement = "SELECT Date FROM tblConstruction_and_Dates WHERE Entry_ID=?";
    485     my $place_construction_date_sql_handle = $dbh->prepare($place_construction_date_sql_statement);
     483    # Prepare SQL statement for getting the Place construction dates
     484    my $place_construction_dates_sql_statement = "SELECT Prefix,Date,Note FROM tblConstruction_and_Dates WHERE Entry_ID=?";
     485    my $place_construction_dates_sql_handle = $dbh->prepare($place_construction_dates_sql_statement);
    486486
    487487    # Prepare SQL statement for getting the Place images
     
    575575    }
    576576
    577     # Get place date of construction, except for landscape sites which have no date
    578     $place_construction_date_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
    579     my $place_construction_date_value = $place_construction_date_sql_handle->fetchrow();
    580     if (!defined($place_construction_date_value) && $place_type eq "Landscape site") {
    581         # Landscape sites may not have a construction date
    582         $place_construction_date_value = "";
    583     }
    584     if (!defined($place_construction_date_value)) {
    585         print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing construction date'>\n" if ($self->{'gli'});
    586         print STDERR "Error: Place $place_id -- Missing construction date.\n";
    587         print $fail_log_handle "Error: Place $place_id -- Missing construction date.\n";
    588         $self->{'num_not_processed'}++;
    589         next;
    590     }
    591     &new_metadata_entry($place_doc_obj, "Construction_date", $place_construction_date_value);
    592 
    593577    # Create place styles mapping
    594578    $place_styles_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
     
    610594    &new_metadata_entry($place_doc_obj, "State", $place_state_abbr . " " . $state_abbr_to_name_mapping->{$place_state_abbr} . " " . $state_abbr_to_area_mapping->{$place_state_abbr});
    611595
    612     # Create place dates mapping
    613     my $place_time_period = $place_construction_date_value;
    614     if ($place_construction_date_value =~ /^(\d\d\d\d).*$/) {
    615         $place_construction_date_value =~ s/^(\d\d\d\d).*$/$1/;
    616         if ($place_construction_date_value < 1800) { $place_time_period = "pre-1800"; }
    617         elsif ($place_construction_date_value < 1850) { $place_time_period = "1800-1850"; }
    618         elsif ($place_construction_date_value < 1900) { $place_time_period = "1850-1900"; }
    619         elsif ($place_construction_date_value < 1945) { $place_time_period = "1900-1945"; }
    620         elsif ($place_construction_date_value < 1995) { $place_time_period = "1945-1995"; }
    621         else { $place_time_period = "post-1995"; }
    622         push(@{$place_date_to_ids_mapping{$place_time_period}}, $place_doc_obj->get_OID());
    623     }
    624     &new_metadata_entry($place_doc_obj, "Time_period", $place_time_period);
     596    # Get place construction dates
     597    my $place_construction_dates_table_html = "";
     598    $place_construction_dates_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
     599    while (my $place_construction_dates_match_hashref = $place_construction_dates_sql_handle->fetchrow_hashref()) {
     600        my $place_construction_date = $place_construction_dates_match_hashref->{"Date"};
     601        if (!defined($place_construction_date)) {
     602        print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing construction date'>\n" if ($self->{'gli'});
     603        print STDERR "Error: Place $place_id -- Missing construction date.\n";
     604        print $fail_log_handle "Error: Place $place_id -- Missing construction date.\n";
     605        next;
     606        }
     607        # Check for multiline values (these are errors)
     608        if ($place_construction_date =~ /\n/) {
     609        print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Multiline construction date'>\n" if ($self->{'gli'});
     610        print STDERR "Error: Place $place_id -- Multiline construction date.\n";
     611        print $fail_log_handle "Error: Place $place_id -- Multiline construction date.\n";
     612        next;
     613        }
     614        my $place_construction_note = $place_construction_dates_match_hashref->{"Note"};
     615        if (!defined($place_construction_note)) {
     616        print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing construction note'>\n" if ($self->{'gli'});
     617        print STDERR "Error: Place $place_id -- Missing construction note.\n";
     618        print $fail_log_handle "Error: Place $place_id -- Missing construction note.\n";
     619        next;
     620        }
     621        my $place_construction_date_prefix = $place_construction_dates_match_hashref->{"Prefix"} || "";
     622        $place_construction_dates_table_html .= "<tr><td valign=\"top\"><nobr>$place_construction_date_prefix $place_construction_date</nobr>&nbsp;</td><td valign=\"top\">$place_construction_note</td></tr>";
     623
     624        # Convert the construction date to a time period (for searching and browsing)
     625        if ($place_construction_date =~ /^(\d\d\d\d).*$/) {
     626        $place_construction_date =~ s/^(\d\d\d\d).*$/$1/;
     627
     628        my $place_time_period;
     629        if ($place_construction_date < 1800) { $place_time_period = "pre-1800"; }
     630        elsif ($place_construction_date < 1850) { $place_time_period = "1800-1850"; }
     631        elsif ($place_construction_date < 1900) { $place_time_period = "1850-1900"; }
     632        elsif ($place_construction_date < 1945) { $place_time_period = "1900-1945"; }
     633        elsif ($place_construction_date < 1995) { $place_time_period = "1945-1995"; }
     634        else { $place_time_period = "post-1995"; }
     635        push(@{$place_date_to_ids_mapping{$place_time_period}}, $place_doc_obj->get_OID());
     636        &new_metadata_entry($place_doc_obj, "Time_period", $place_time_period);
     637        }
     638    }
     639    &new_metadata_entry($place_doc_obj, "PlaceConstructionDatesTableHTML", "<table cellpadding=\"0\" cellspacing=\"0\">" . $place_construction_dates_table_html . "</table>");
    625640
    626641    # Get place materials (individual buildings only)
Note: See TracChangeset for help on using the changeset viewer.