Changeset 10498
- Timestamp:
- 2005-08-12T11:12:26+12:00 (19 years ago)
- Location:
- trunk/gsdl/perllib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/GenericList.pm
r10398 r10498 55 55 56 56 # 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}", 62 65 'type' => "string", 63 66 'deft' => "none" }, 64 { 'name' => " hlistgroupsize",65 'desc' => "{GenericList. hlistgroupsize}",67 { 'name' => "partition_size_within_level", 68 'desc' => "{GenericList.partition_size_within_level}", 66 69 'type' => "string" }, 67 { 'name' => " leafnodesort",68 'desc' => "{GenericList. leafnodesort}",70 { 'name' => "sort_leaf_nodes_using", 71 'desc' => "{GenericList.sort_leaf_nodes_using}", 69 72 'type' => "metadata", 70 'deft' => "Title" }, 71 { 'name' => "classify_sections", 72 'desc' => "{GenericList.classify_sections}", 73 'type' => "flag" } ]; 73 'deft' => "Title" } ]; 74 74 75 75 my $options = { 'name' => "GenericList", … … 98 98 my $metadata = $self->{'metadata'}; 99 99 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'}; 103 103 104 104 # The metadata elements to use (required) … … 120 120 # Whether to group single items into a bookshelf (must be true for all metadata fields except the last) 121 121 foreach my $metagroup (@metalist) { 122 $self->{$metagroup . ".always group"} = "t";123 } 124 if (!$self->{'always grouplastelement'}) {122 $self->{$metagroup . ".always_bookshelf"} = "t"; 123 } 124 if (!$self->{'always_bookshelf_last_level'}) { 125 125 # Default: leave leafnodes ungrouped (equivalent to AZCompactList -mingroup 2) 126 126 my $lastmetagroup = $metalist[$#metalist]; 127 $self->{$lastmetagroup . ".always group"} = "f";127 $self->{$lastmetagroup . ".always_bookshelf"} = "f"; 128 128 } 129 129 130 130 # How the items are grouped into hlists 131 if (!$ hlistgrouptype) {131 if (!$partition_type_within_level) { 132 132 # 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; 136 136 137 137 # The number of items in each group 138 if (!$ hlistgroupsize) {138 if (!$partition_size_within_level) { 139 139 # Default: 20 140 140 foreach my $metagroup (@metalist) { 141 $self->{$metagroup . ". hlistgroupsize"} = 20;141 $self->{$metagroup . ".partition_size_within_level"} = 20; 142 142 } 143 143 } 144 144 else { 145 my @ hlistgroupsizelist = split(/\//, $hlistgroupsize);146 147 # Assign values based on the hlistgroupsizeparameter145 my @partition_size_within_levellist = split(/\//, $partition_size_within_level); 146 147 # Assign values based on the partition_size_within_level parameter 148 148 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; 152 152 } 153 153 else { 154 $self->{$metagroup . ". hlistgroupsize"} = $self->{$metalist[0] . ".hlistgroupsize"};154 $self->{$metagroup . ".partition_size_within_level"} = $self->{$metalist[0] . ".partition_size_within_level"}; 155 155 } 156 156 } … … 158 158 159 159 # 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; 165 165 166 166 return bless $self, $class; … … 211 211 # Create a hash for the metadata values of each metadata element we're interested in 212 212 my %metagroupsdone = (); 213 foreach my $metagroup (@metalist, @{$self->{' leafnodesortmetalist'}}) {213 foreach my $metagroup (@metalist, @{$self->{'sort_leaf_nodes_usingmetalist'}}) { 214 214 # Take care not to do a metadata group more than once 215 215 unless ($metagroupsdone{$metagroup}) { … … 283 283 284 284 # 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) { 287 287 # Generate one hlist for each letter 288 288 my @sortedmetavalues = sort(keys %metavaluetoOIDhash); … … 312 312 else { 313 313 # 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) { 316 316 my @sortedmetavalues = sort(keys %metavaluetoOIDhash); 317 317 my $itemsdone = 0; … … 330 330 331 331 # Is this the end of the partition? 332 if ($itemsinpartition == $ hlistgroupsize|| $itemsdone == @sortedmetavalues) {332 if ($itemsinpartition == $partition_size_within_level || $itemsdone == @sortedmetavalues) { 333 333 my $partitionend = &generate_partition_end($metavalue, $partitionstart); 334 334 my $partitionname = $partitionstart; … … 436 436 my @OIDlist = @{$metavaluetoOIDhash{$metavalue}}; 437 437 438 # If there is only one item and 'always group' is false, add the item to the list439 if (@OIDlist == 1 && $self->{$metagroup . ".always group"} 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") { 440 440 push(@{$classifyinfo->{'contains'}}, { 'OID' => $OIDlist[0] }); 441 441 } … … 453 453 # Otherwise just add the documents as children of this list 454 454 else { 455 # Sort the leaf nodes by the metadata elements specified with - leafnodesort456 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"}}; 459 459 # Force a stable sort (Perl 5.6's sort isn't stable) 460 460 # !! The [0] bits aren't ideal (multiple metadata values) !! -
trunk/gsdl/perllib/strings.rb
r10497 r10498 434 434 DateList.sort:An extra metadata field to sort by in the case where two documents have the same date. 435 435 436 GenericList.always grouplastelement:Create a bookshelf icon even if there is only one item in each group at the leaf nodes.436 GenericList.always_bookshelf_last_level:Create a bookshelf icon even if there is only one item in each group at the leaf nodes. 437 437 GenericList.classify_sections:Classify sections instead of documents. 438 438 GenericList.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.439 GenericList.partition_size_within_level:The number of items in each partition (only applies when partition_type_within_level is set to 'constant_size'). 440 GenericList.partition_type_within_level:The type of partitioning done: either 'per_letter', 'constant_size', or 'none'. 441 GenericList.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. 442 442 GenericList.metadata:Metadata fields used for classification. Use '/' to separate the levels in the hierarchy and ',' to separate metadata fields within each level. 443 443
Note:
See TracChangeset
for help on using the changeset viewer.