Changeset 10979 for trunk/gsdl


Ignore:
Timestamp:
2005-12-09T10:52:21+13:00 (18 years ago)
Author:
kjdon
Message:

DateList can now take a comma separated list of metadata names.

Location:
trunk/gsdl/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/DateList.pm

    r10630 r10979  
    102102    $self->{'metadata'} = "Date";
    103103    }
    104    
     104    # now can have comma separated list of Dates - we just use the first one (for now)
     105    my @meta_list = split(/,/, $self->{"metadata"});
     106    $self->{'meta_list'} = \@meta_list;
     107 
    105108    return bless $self, $class;
    106109}
     
    117120
    118121    my $doc_OID = $doc_obj->get_OID();
    119     my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'metadata'});
     122
     123    # find the first available metadata
     124    my $date;
     125    foreach my $m (@{$self->{'meta_list'}}) {
     126    $date = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $m);
     127    last if defined $date;
     128    }
     129   
     130    #my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'metadata'});
     131    if (!defined $date || $date eq "") {
     132    # if this document doesn't contain Date element we won't
     133    # include it in this classification
     134    return;
     135    }
    120136   
    121137    my $sort_other = "";
     
    124140    $sort_other = &sorttools::format_metadata_for_sorting($self->{'sort'}, $sort_other, $doc_obj) unless $self->{'no_metadata_formatting'};
    125141    }
    126     # if this document doesn't contain Date element we won't
    127     # include it in this classification
    128     if (defined $date && $date =~ /\d/) {
    129     if (defined $self->{'list'}->{$doc_OID}) {
    130         my $outhandle = $self->{'outhandle'};
    131         print $outhandle "WARNING: DateList::classify called multiple times for $doc_OID\n";
    132     }
    133 
    134     $self->{'list'}->{$doc_OID} = "$date$sort_other";
    135     }
     142   
     143    if (defined $self->{'list'}->{$doc_OID}) {
     144    my $outhandle = $self->{'outhandle'};
     145    print $outhandle "WARNING: DateList::classify called multiple times for $doc_OID\n";
     146    }
     147
     148    $self->{'list'}->{$doc_OID} = "$date$sort_other";
     149   
    136150}
    137151
  • trunk/gsdl/perllib/strings.rb

    r10978 r10979  
    428428DateList.desc:Classifier plugin for sorting by date. By default, sorts by 'Date' metadata. Date is assumed to be in the form yyyymmdd.
    429429
    430 DateList.metadata:The metadata that contains the dates to classify by. The format is expected to be yyyymmdd.
     430DateList.metadata:The metadata that contains the dates to classify by. The format is expected to be yyyymmdd. Can be a comma separated list, in which case the first date found will be used.
    431431
    432432DateList.reverse_sort:Sort the documents in reverse chronological order (newest first).
Note: See TracChangeset for help on using the changeset viewer.