[Bio] / FigKernelPackages / ServerThing.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/ServerThing.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20, Fri Dec 4 19:23:43 2009 UTC revision 1.21, Sun Dec 6 18:21:07 2009 UTC
# Line 103  Line 103 
103  The methods in this section are utilities of general use to the various  The methods in this section are utilities of general use to the various
104  server modules.  server modules.
105    
106    =head3 AddSubsystemFilter
107    
108        ServerThing::AddSubsystemFilter(\$filter, $args);
109    
110    Add subsystem filtering information to the specified query filter clause
111    based on data in the argument hash. The argument hash will be checked for
112    the C<-unusable> parameter, which includes unusuable subsystems, and the
113    C<-exclude> parameter, which lists types of subsystems that should be
114    excluded.
115    
116    =over 4
117    
118    =item filter
119    
120    Reference to the current filter string. If additional filtering is required,
121    this string will be updated.
122    
123    =item args
124    
125    Reference to the parameter hash for the current server call. This hash will
126    be examined for the C<-unusable> and C<-exclude> parameters.
127    
128    =back
129    
130    =cut
131    
132    use constant SS_TYPE_EXCLUDE_ITEMS => { 'cluster-based' => 1,
133                                             experimental   => 1,
134                                             private        => 1 };
135    
136    sub AddSubsystemFilter {
137        # Get the parameters.
138        my ($filter, $args) = @_;
139        # We'll put the new filter stuff in here.
140        my @newFilters;
141        # Unless unusable subsystems are desired, we must add a clause to the filter.
142        if (! $args->{-unusable}) {
143            push @newFilters, "Subsystem(usable) = 1";
144        }
145        # Check for exclusion filters.
146        my $exclusions = ServerThing::GetIdList(-exclude => $args, 1);
147        for my $exclusion (@$exclusions) {
148            if (! SS_TYPE_EXCLUDE_ITEMS->{$exclusion}) {
149                Confess("Invalid exclusion type \"$exclusion\".");
150            } else {
151                # Here we have to exclude subsystems of the specified type.
152                push @newFilters, "Subsystem($exclusion) = 0";
153            }
154        }
155        # Do we need to update the incoming filter?
156        if (@newFilters) {
157            # Yes. If the incoming filter is nonempty, push it onto the list
158            # so it gets included in the result.
159            if ($$filter) {
160                push @newFilters, $$filter;
161            }
162            # Put all the filters together to form the new filter.
163            $$filter = join(" AND ", @newFilters);
164            Trace("Subsystem filter is $$filter.") if T(3);
165        }
166    }
167    
168    
169    
170  =head3 GetIdList  =head3 GetIdList
171    
172      my $ids = ServerThing::GetIdList($name => $args, $optional);      my $ids = ServerThing::GetIdList($name => $args, $optional);

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3