Ignore:
Timestamp:
2004-08-02T15:41:33+12:00 (20 years ago)
Author:
jrm21
Message:

record mdoffset for each document when adding to a sub list. List.pm checks
for this offset in the document, and uses it if found.

File:
1 edited

Legend:

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

    r6968 r7835  
    153153    my $metaname;
    154154    if (defined $self->{'meta_list'}) {
    155     # find the first available metadata
    156     foreach $m (@{$self->{'meta_list'}}) {
    157         $metavalue = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $m);
    158         $metaname = $m;
    159         last if defined $metavalue;
     155    my $topsection=$doc_obj->get_top_section();
     156
     157    # find the correct bit of metadata, if multi-valued metadata field
     158    if (exists $doc_obj->{'mdoffset'}) { # set by AZCompactList
     159        my $mdoffset=$doc_obj->{'mdoffset'} - 1;
     160        # if this List is used by AZCompactList, then $metavalue is
     161        # only really needed for sorting.
     162        # assume (!!) there is only one fieldname in the meta_list
     163        $metaname=(@{$self->{'meta_list'}})[0];
     164        # get all metadata values for this field
     165        my $values_listref=
     166        $doc_obj->get_metadata($topsection, $metaname);
     167        # get the correct one (from the offset)
     168        $metavalue=@$values_listref[$mdoffset];
     169        # use a special format for docOID...
     170        $doc_OID .= ".offset$mdoffset";
     171
     172    } else {
     173        # use the first available metadata
     174        foreach my $m (@{$self->{'meta_list'}}) {
     175        $metavalue = $doc_obj->
     176            get_metadata_element($topsection, $m);
     177        $metaname = $m;
     178        last if defined $metavalue;
     179        }
    160180    }
    161     #if we haven't found a metavalue here, then the doc shouldn't be included
     181    # if we haven't found a metavalue, then the doc shouldn't be included
    162182    return unless defined $metavalue;
    163183    }
     
    213233
    214234    foreach $OID (@list) {
    215     push (@{$classifyinfo{'contains'}}, {'OID'=>$OID});
     235    my $hashref={};
     236    # special oid format, if using offsets (from AZCompactList)
     237    if ($OID =~ s/\.offset(\d+)$//) {
     238        $hashref->{'offset'}=$1;
     239    }
     240    $hashref->{'OID'}=$OID;
     241
     242    push (@{$classifyinfo{'contains'}}, $hashref);
    216243    }
    217244
Note: See TracChangeset for help on using the changeset viewer.