Changeset 10498


Ignore:
Timestamp:
2005-08-12T11:12:26+12:00 (19 years ago)
Author:
mdewsnip
Message:

Renamed the GenericList arguments to be more descriptive.

Location:
trunk/gsdl/perllib
Files:
2 edited

Legend:

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

    r10398 r10498  
    5555
    5656      # The interesting options
    57       { 'name' => "alwaysgrouplastelement",
    58     'desc' => "{GenericList.alwaysgrouplastelement}",
    59     'type' => "string" },
    60       { 'name' => "hlistgrouptype",
    61     'desc' => "{GenericList.hlistgrouptype}",
     57      { 'name' => "always_bookshelf_last_level",
     58    'desc' => "{GenericList.always_bookshelf_last_level}",
     59    'type' => "flag" },
     60      { 'name' => "classify_sections",
     61    'desc' => "{GenericList.classify_sections}",
     62    'type' => "flag" },
     63      { 'name' => "partition_type_within_level",
     64    'desc' => "{GenericList.partition_type_within_level}",
    6265    'type' => "string",
    6366    'deft' => "none" },
    64       { 'name' => "hlistgroupsize",
    65     'desc' => "{GenericList.hlistgroupsize}",
     67      { 'name' => "partition_size_within_level",
     68    'desc' => "{GenericList.partition_size_within_level}",
    6669    'type' => "string" },
    67       { 'name' => "leafnodesort",
    68     'desc' => "{GenericList.leafnodesort}",
     70      { 'name' => "sort_leaf_nodes_using",
     71    'desc' => "{GenericList.sort_leaf_nodes_using}",
    6972    'type' => "metadata",
    70     'deft' => "Title" },
    71       { 'name' => "classify_sections",
    72     'desc' => "{GenericList.classify_sections}",
    73     'type' => "flag" } ];
     73    'deft' => "Title" } ];
    7474
    7575my $options = { 'name'     => "GenericList",
     
    9898    my $metadata = $self->{'metadata'};
    9999    my $buttonname = $self->{'buttonname'};
    100     my $hlistgrouptype = $self->{'hlistgrouptype'};
    101     my $hlistgroupsize = $self->{'hlistgroupsize'};
    102     my $leafnodesort = $self->{'leafnodesort'};
     100    my $partition_type_within_level = $self->{'partition_type_within_level'};
     101    my $partition_size_within_level = $self->{'partition_size_within_level'};
     102    my $sort_leaf_nodes_using = $self->{'sort_leaf_nodes_using'};
    103103
    104104    # The metadata elements to use (required)
     
    120120    # Whether to group single items into a bookshelf (must be true for all metadata fields except the last)
    121121    foreach my $metagroup (@metalist) {
    122     $self->{$metagroup . ".alwaysgroup"} = "t";
    123     }
    124     if (!$self->{'alwaysgrouplastelement'}) {
     122    $self->{$metagroup . ".always_bookshelf"} = "t";
     123    }
     124    if (!$self->{'always_bookshelf_last_level'}) {
    125125    # Default: leave leafnodes ungrouped (equivalent to AZCompactList -mingroup 2)
    126126    my $lastmetagroup = $metalist[$#metalist];
    127     $self->{$lastmetagroup . ".alwaysgroup"} = "f";
     127    $self->{$lastmetagroup . ".always_bookshelf"} = "f";
    128128    }
    129129
    130130    # How the items are grouped into hlists
    131     if (!$hlistgrouptype) {
     131    if (!$partition_type_within_level) {
    132132    # Default: none
    133     $hlistgrouptype = "none";
    134     }
    135     $self->{"hlistgrouptype"} = $hlistgrouptype;
     133    $partition_type_within_level = "none";
     134    }
     135    $self->{"partition_type_within_level"} = $partition_type_within_level;
    136136
    137137    # The number of items in each group
    138     if (!$hlistgroupsize) {
     138    if (!$partition_size_within_level) {
    139139    # Default: 20
    140140    foreach my $metagroup (@metalist) {
    141         $self->{$metagroup . ".hlistgroupsize"} = 20;
     141        $self->{$metagroup . ".partition_size_within_level"} = 20;
    142142    }
    143143    }
    144144    else {
    145     my @hlistgroupsizelist = split(/\//, $hlistgroupsize);
    146 
    147     # Assign values based on the hlistgroupsize parameter
     145    my @partition_size_within_levellist = split(/\//, $partition_size_within_level);
     146
     147    # Assign values based on the partition_size_within_level parameter
    148148    foreach my $metagroup (@metalist) {
    149         my $hlistgroupsizeelem = shift(@hlistgroupsizelist);
    150         if (defined($hlistgroupsizeelem)) {
    151         $self->{$metagroup . ".hlistgroupsize"} = $hlistgroupsizeelem;
     149        my $partition_size_within_levelelem = shift(@partition_size_within_levellist);
     150        if (defined($partition_size_within_levelelem)) {
     151        $self->{$metagroup . ".partition_size_within_level"} = $partition_size_within_levelelem;
    152152        }
    153153        else {
    154         $self->{$metagroup . ".hlistgroupsize"} = $self->{$metalist[0] . ".hlistgroupsize"};
     154        $self->{$metagroup . ".partition_size_within_level"} = $self->{$metalist[0] . ".partition_size_within_level"};
    155155        }
    156156    }
     
    158158
    159159    # The metadata elements to use to sort the leaf nodes
    160     my @leafnodesortmetalist = ( "Title" );
    161     if ($leafnodesort) {
    162     @leafnodesortmetalist = split(/\;/, $leafnodesort);
    163     }
    164     $self->{'leafnodesortmetalist'} = \@leafnodesortmetalist;
     160    my @sort_leaf_nodes_usingmetalist = ( "Title" );
     161    if ($sort_leaf_nodes_using) {
     162    @sort_leaf_nodes_usingmetalist = split(/\;/, $sort_leaf_nodes_using);
     163    }
     164    $self->{'sort_leaf_nodes_usingmetalist'} = \@sort_leaf_nodes_usingmetalist;
    165165
    166166    return bless $self, $class;
     
    211211        # Create a hash for the metadata values of each metadata element we're interested in
    212212        my %metagroupsdone = ();
    213         foreach my $metagroup (@metalist, @{$self->{'leafnodesortmetalist'}}) {
     213        foreach my $metagroup (@metalist, @{$self->{'sort_leaf_nodes_usingmetalist'}}) {
    214214        # Take care not to do a metadata group more than once
    215215        unless ($metagroupsdone{$metagroup}) {
     
    283283
    284284    # Partition the values (if necessary)
    285     my $hlistgrouptype = $self->{"hlistgrouptype"};
    286     if ($hlistgrouptype =~ /^perletter$/i) {
     285    my $partition_type_within_level = $self->{"partition_type_within_level"};
     286    if ($partition_type_within_level =~ /^per_letter$/i) {
    287287    # Generate one hlist for each letter
    288288    my @sortedmetavalues = sort(keys %metavaluetoOIDhash);
     
    312312    else {
    313313    # Generate hlists of a certain size
    314     my $hlistgroupsize = $self->{$metagroup . ".hlistgroupsize"};
    315     if ($hlistgrouptype =~ /^constantsize$/i && scalar(keys %metavaluetoOIDhash) > $hlistgroupsize) {
     314    my $partition_size_within_level = $self->{$metagroup . ".partition_size_within_level"};
     315    if ($partition_type_within_level =~ /^constant_size$/i && scalar(keys %metavaluetoOIDhash) > $partition_size_within_level) {
    316316        my @sortedmetavalues = sort(keys %metavaluetoOIDhash);
    317317        my $itemsdone = 0;
     
    330330
    331331        # Is this the end of the partition?
    332         if ($itemsinpartition == $hlistgroupsize || $itemsdone == @sortedmetavalues) {
     332        if ($itemsinpartition == $partition_size_within_level || $itemsdone == @sortedmetavalues) {
    333333            my $partitionend = &generate_partition_end($metavalue, $partitionstart);
    334334            my $partitionname = $partitionstart;
     
    436436    my @OIDlist = @{$metavaluetoOIDhash{$metavalue}};
    437437
    438     # If there is only one item and 'alwaysgroup' is false, add the item to the list
    439     if (@OIDlist == 1 && $self->{$metagroup . ".alwaysgroup"} eq "f") {
     438    # If there is only one item and 'always_bookshelf' is false, add the item to the list
     439    if (@OIDlist == 1 && $self->{$metagroup . ".always_bookshelf"} eq "f") {
    440440        push(@{$classifyinfo->{'contains'}}, { 'OID' => $OIDlist[0] });
    441441    }
     
    453453        # Otherwise just add the documents as children of this list
    454454        else {
    455         # Sort the leaf nodes by the metadata elements specified with -leafnodesort
    456         my @leafnodesortmetalist = @{$self->{'leafnodesortmetalist'}};
    457         foreach my $leafnodesortmetaelem (reverse @leafnodesortmetalist) {
    458             my %OIDtometavaluehash = %{$self->{$leafnodesortmetaelem . ".list"}};
     455        # Sort the leaf nodes by the metadata elements specified with -sort_leaf_nodes_using
     456        my @sort_leaf_nodes_usingmetalist = @{$self->{'sort_leaf_nodes_usingmetalist'}};
     457        foreach my $sort_leaf_nodes_usingmetaelem (reverse @sort_leaf_nodes_usingmetalist) {
     458            my %OIDtometavaluehash = %{$self->{$sort_leaf_nodes_usingmetaelem . ".list"}};
    459459            # Force a stable sort (Perl 5.6's sort isn't stable)
    460460            # !! The [0] bits aren't ideal (multiple metadata values) !!
  • trunk/gsdl/perllib/strings.rb

    r10497 r10498  
    434434DateList.sort:An extra metadata field to sort by in the case where two documents have the same date.
    435435
    436 GenericList.alwaysgrouplastelement:Create a bookshelf icon even if there is only one item in each group at the leaf nodes.
     436GenericList.always_bookshelf_last_level:Create a bookshelf icon even if there is only one item in each group at the leaf nodes.
    437437GenericList.classify_sections:Classify sections instead of documents.
    438438GenericList.desc:A general and flexible list classifier with most of the abilities of AZCompactList, but with better Unicode, metadata and sorting capabilities.
    439 GenericList.hlistgroupsize:The number of items in each hlist group (constantsize hlistgrouptype only).
    440 GenericList.hlistgrouptype:The type of hlist grouping done: either perletter, constantsize, or none.
    441 GenericList.leafnodesort:Metadata fields used for sorting the leaf nodes. Use ';' to separate the metadata groups to stable sort and ',' to separate metadata fields within each group.
     439GenericList.partition_size_within_level:The number of items in each partition (only applies when partition_type_within_level is set to 'constant_size').
     440GenericList.partition_type_within_level:The type of partitioning done: either 'per_letter', 'constant_size', or 'none'.
     441GenericList.sort_leaf_nodes_using:Metadata fields used for sorting the leaf nodes. Use ';' to separate the metadata groups to stable sort and ',' to separate metadata fields within each group.
    442442GenericList.metadata:Metadata fields used for classification. Use '/' to separate the levels in the hierarchy and ',' to separate metadata fields within each level.
    443443
Note: See TracChangeset for help on using the changeset viewer.