Changeset 12894


Ignore:
Timestamp:
2006-09-28T12:07:50+12:00 (18 years ago)
Author:
mdewsnip
Message:

Tidied up the new() function some more.

File:
1 edited

Legend:

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

    r12893 r12894  
    8989
    9090    my $self = new BasClas($classifierslist, $inputargs, $hashArgOptLists);
    91     $self->{'OIDs'} = [];
    9291
    9392    if ($self->{'info_only'}) {
     
    9695    }
    9796
    98     my $metadata = $self->{'metadata'};
    99     my $buttonname = $self->{'buttonname'};
    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 
    10497    # The metadata elements to use (required)
    105     # print STDERR "Creating new GenericList for $metadata...\n";
    106     if (!$metadata) {
     98    if (!$self->{'metadata'}) {
    10799    die "Error: No metadata fields specified for GenericList.\n";
    108100    }
    109     my @metadata_groups = split(/\//, $metadata);
     101    my @metadata_groups = split(/\//, $self->{'metadata'});
    110102    $self->{'metadata_groups'} = \@metadata_groups;
    111103
    112     # The classifier button name
    113     if (!$buttonname) {
    114     # Default: the first metadata element specified
    115     my $firstmetagroupfirstelem = (split(/\;/, $metadata_groups[0]))[0];
    116     $buttonname = $self->generate_title_from_metadata($firstmetagroupfirstelem);
    117     }
    118     $self->{'title'} = $buttonname;
     104    # The classifier button name (default: the first metadata element specified)
     105    if (!$self->{'buttonname'}) {
     106    my $first_metadata_group = $metadata_groups[0];
     107    my $first_metadata_element = (split(/\;/, $first_metadata_group))[0];
     108    $self->{'buttonname'} = $self->generate_title_from_metadata($first_metadata_element);
     109    }
    119110
    120111    # Whether to group single items into a bookshelf (must be true for all metadata fields except the last)
     
    123114    }
    124115    if (!$self->{'always_bookshelf_last_level'}) {
    125     # Default: leave leafnodes ungrouped (equivalent to AZCompactList -mingroup 2)
     116    # Default: leave leaf nodes ungrouped (equivalent to AZCompactList -mingroup 2)
    126117    my $last_metadata_group = $metadata_groups[$#metadata_groups];
    127118    $self->{$last_metadata_group . ".always_bookshelf"} = "f";
     
    136127    }
    137128
    138     # How the items are grouped into partitions
    139     if (!$partition_type_within_level) {
    140     # Default: none
    141     $partition_type_within_level = "none";
    142     }
    143     $self->{"partition_type_within_level"} = $partition_type_within_level;
     129    # How the items are grouped into partitions (default: no partition)
     130    if (!$self->{"partition_type_within_level"}) {
     131    $self->{"partition_type_within_level"} = "none";
     132    }
    144133
    145134    # The number of items in each partition
    146     if (!$partition_size_within_level) {
     135    if (!$self->{'partition_size_within_level'}) {
    147136    # Default: 20
    148137    foreach my $metadata_group (@metadata_groups) {
     
    151140    }
    152141    else {
    153     my @partition_size_within_levellist = split(/\//, $partition_size_within_level);
     142    my @partition_size_within_levellist = split(/\//, $self->{'partition_size_within_level'});
    154143
    155144    # Assign values based on the partition_size_within_level parameter
     
    165154    }
    166155
    167     # The metadata elements to use to sort the leaf nodes
    168     my @sort_leaf_nodes_usingmetadata_groups = ( "Title" );
    169     if ($sort_leaf_nodes_using) {
    170     @sort_leaf_nodes_usingmetadata_groups = split(/\|/, $sort_leaf_nodes_using);
    171     }
    172     $self->{'sort_leaf_nodes_usingmetadata_groups'} = \@sort_leaf_nodes_usingmetadata_groups;
     156    # The metadata elements to use to sort the leaf nodes (default: Title)
     157    my @sort_leaf_nodes_using_metadata_groups = ( "Title" );
     158    if ($self->{'sort_leaf_nodes_using'}) {
     159    @sort_leaf_nodes_using_metadata_groups = split(/\|/, $self->{'sort_leaf_nodes_using'});
     160    }
     161    $self->{'sort_leaf_nodes_using_metadata_groups'} = \@sort_leaf_nodes_using_metadata_groups;
     162
     163    # An empty array for the document OIDs
     164    $self->{'OIDs'} = [];
    173165
    174166    return bless $self, $class;
     
    219211        # Create a hash for the metadata values of each metadata element we're interested in
    220212        my %metagroupsdone = ();
    221         foreach my $metadata_group (@metadata_groups, @{$self->{'sort_leaf_nodes_usingmetadata_groups'}}) {
     213        foreach my $metadata_group (@metadata_groups, @{$self->{'sort_leaf_nodes_using_metadata_groups'}}) {
    222214        # Take care not to do a metadata group more than once
    223215        unless ($metagroupsdone{$metadata_group}) {
     
    258250    my %classifier_node = ( 'thistype' => "Invisible",
    259251                'childtype' => $childtype,
    260                 'Title' => $self->{'title'},
     252                'Title' => $self->{'buttonname'},
    261253                'contains' => [] );
    262254
     
    467459        else {
    468460        # Sort the leaf nodes by the metadata elements specified with -sort_leaf_nodes_using
    469         my @sort_leaf_nodes_usingmetadata_groups = @{$self->{'sort_leaf_nodes_usingmetadata_groups'}};
     461        my @sort_leaf_nodes_usingmetadata_groups = @{$self->{'sort_leaf_nodes_using_metadata_groups'}};
    470462        foreach my $sort_leaf_nodes_usingmetaelem (reverse @sort_leaf_nodes_usingmetadata_groups) {
    471463            my %OIDtometavaluehash = %{$self->{$sort_leaf_nodes_usingmetaelem . ".list"}};
Note: See TracChangeset for help on using the changeset viewer.