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

Diff of /FigKernelPackages/UserData.pm

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

revision 1.4, Wed Dec 7 19:38:22 2005 UTC revision 1.6, Thu Dec 6 13:59:34 2007 UTC
# Line 84  Line 84 
84  database tables and supports both reads and updates. The SFXlate object  database tables and supports both reads and updates. The SFXlate object
85  uses a pure database scheme and is mostly read-only.  uses a pure database scheme and is mostly read-only.
86    
87  =head3 GetDefault  #: Constructor UserData->new();
   
 C<< my ($group, $level) = $fig->GetDefault($objectID, $objectType); >>  
   
 Return the group name and default access level for the specified object.  
   
 =over 4  
   
 =item objectID  
   
 ID of the object whose capabilities data is desired.  
   
 =item objectType  
   
 Type of the object whose capabilities data is desired. This should be expressed  
 as a Sprout entity name. Currently, the only types supported are C<Genome>  
 and C<Subsystem>.  
   
 =item RETURN  
   
 Returns a two-element list. The first element is the name of the group  
 to witch the object belongs; the second is the default access level  
 (C<RW>, C<RO>, or C<NO>). If the object is not found, an empty list  
 should be returned.  
   
 =back  
   
 =head3 GetPreferences  
   
 C<< my $preferences = $fig->GetPreferences($userID, $category); >>  
   
 Return a map of preference keys to values for the specified user in the  
 specified category.  
   
 =over 4  
   
 =item userID  
   
 ID of the user whose preferences are desired.  
   
 =item category (optional)  
   
 Name of the category whose preferences are desired. If omitted, all  
 preferences should be returned.  
   
 =item RETURN  
   
 Returns a reference to a hash mapping each preference key to a value. The  
 keys are fully-qualified; in other words, the category name is included.  
 It is acceptable for the hash to contain key-value pairs outside the  
 category. In other words, if it's easier for you to read the entire  
 preference set into memory, you can return that one set every time  
 this method is called without worrying about the extra keys.  
   
 =back  
   
 =head3 GetCapabilities  
   
 C<< my $level = $fig->GetCapabilities($userID); >>  
   
 Return a map of group names to access levels (C<RW>, C<RO>, or C<NO>) for the  
 specified user.  
   
 =over 4  
   
 =item userID  
   
 ID of the user whose access level is desired.  
   
 =item RETURN  
   
 Returns a reference to a hash mapping group names to the user's access level  
 for that group.  
   
 =back  
   
 =head3 AllowsUpdates  
   
 C<< my $flag = $fig->AllowsUpdates(); >>  
   
 Return TRUE if this access object supports updates, else FALSE. If the access object  
 does not support updates, none of the B<SetXXXX> methods will be called.  
   
 =head3 SetDefault  
   
 C<< $fig->SetDefault($objectID, $objectType, $group, $level); >>  
   
 Set the group and default access level for the specified object.  
   
 =over 4  
   
 =item objectID  
   
 ID of the object whose access level and group are to be set.  
   
 =item objectType  
   
 Type of the relevant object. This should be expressed as a Sprout entity name.  
 Currently, only C<Genome> and C<Subsystem> are supported.  
   
 =item group  
   
 Name of the group to which the object will belong. A user's access level for  
 this group will override the default access level.  
   
 =item level  
   
 Default access level. This is the access level used for user's who do not have  
 an explicit capability specified for the object's group.  
   
 =back  
   
 =head3 SetCapabilities  
   
 C<< $fig->SetCapabilities($userID, \%groupLevelMap); >>  
   
 Set the access levels by the specified user for the specified groups.  
   
 =over 4  
   
 =item userID  
   
 ID of the user whose capabilities are to be updated.  
   
 =item groupLevelMap  
   
 Reference to a hash that maps group names to access levels. The legal  
 access levels are C<RW> (read-write), C<RO> (read-only), and C<NO> (no  
 access). An undefined value for the access level indicates the default  
 level should be used for that group. The map will not replace all of  
 the user's capability date; instead, it overrides existing data, with  
 the undefined values indicating the specified group should be deleted  
 from the list.  
   
 =back  
   
 =head3 SetPreferences  
   
 C<< $fig->SetPreferences($userID, \%preferenceMap); >>  
   
 Set the preferences for the specified user.  
   
 =over 4  
   
 =item userID  
   
 ID of the user whose preferences are to be udpated.  
   
 =item preferenceMap  
   
 Reference to a hash that maps each preference key to its value. The  
 keys should be fully-qualified (that is, they should include the  
 category name). A preference key mapped to an undefined value will  
 use the default preference value for that key. The map will not  
 replace all of the user's preference data; instead, it overrides  
 existing data, with the undefined values indicating the specified  
 preference should be deleted from the list.  
   
 =back  
   
 =head3 CleanupUserData  
   
 C<< $fig->CleanupUserData(); >>  
   
 Release any data being held in memory for use by the UserData object.  
   
 =head2 Fields  
   
 The user data object contains the following fields.  
   
 =over 4  
   
 =item capable  
   
 Reference to a hash containing all the user's capability data.  
   
 =item preferences  
   
 Reference to a hash of hashes. The key of the large hash is the preference  
 category, and the value is a small hash mapping preferences from that  
 category to values.  
   
 =item userID  
   
 Current user's ID.  
   
 =item fig  
   
 Fig-like object for accessing the data.  
   
 =item newCapable  
   
 Hash containing updated capabilities.  
   
 =item newPreferences  
   
 Hash containing updated preferences.  
   
 =back  
   
 =cut  
   
 #: Constructor Capabilities->new();  
88    
89  =head2 Public Methods  =head2 Public Methods
90    
91  =head3 new  =head3 new
92    
93  C<< my $userData = Capabilities->new($user, $fig); >>      my $userData = UserData->new($user, $fig);
94    
95  Construct the capabilities object for a specified user.  Construct the capabilities object for a specified user.
96    
# Line 331  Line 129 
129    
130  =head3 GetCapability  =head3 GetCapability
131    
132  C<< my $level = $userData->GetCapability($objectID, $objectType); >>      my $level = $userData->GetCapability($objectID, $objectType);
133    
134  Get this user's access level for the specified object-- either C<RW> (full access),  Get this user's access level for the specified object-- either C<RW> (full access),
135  C<RO> (read-only), or C<NO> (no access).  C<RO> (read-only), or C<NO> (no access).
# Line 376  Line 174 
174    
175  =head3 GetPreference  =head3 GetPreference
176    
177  C<< my $value = $userData->GetPreference($key); >>      my $value = $userData->GetPreference($key);
178    
179  Return the user's preference value for the specified key.  Return the user's preference value for the specified key.
180    
# Line 409  Line 207 
207    
208  =head3 SetCapabilities  =head3 SetCapabilities
209    
210  C<< $userData->SetCapabilities(\%groupMap); >>      $userData->SetCapabilities(\%groupMap);
211    
212  Set capabilities for this user. This does not replace all existing capabilities.  Set capabilities for this user. This does not replace all existing capabilities.
213  Instead, the capabilities specified in the group map are updated or deleted,  Instead, the capabilities specified in the group map are updated or deleted,
# Line 446  Line 244 
244    
245  =head3 SetPreferences  =head3 SetPreferences
246    
247  C<< $userData->SetPreferences(\%preferences); >>      $userData->SetPreferences(\%preferences);
248    
249  Set preferences for this user. This does not replace all existing preferences.  Set preferences for this user. This does not replace all existing preferences.
250  Instead, the preferences specified in the map are updated or deleted, and any  Instead, the preferences specified in the map are updated or deleted, and any
# Line 486  Line 284 
284    
285  =head3 SetDefault  =head3 SetDefault
286    
287  C<< $userData->SetDefault($objectID, $objectType, $group, $level); >>      $userData->SetDefault($objectID, $objectType, $group, $level);
288    
289  Set the group and default access level for the specified object. This update  Set the group and default access level for the specified object. This update
290  takes place immediately.  takes place immediately.
# Line 525  Line 323 
323    
324  =head3 SaveChanges  =head3 SaveChanges
325    
326  C<< $userData->SaveChanges(); >>      $userData->SaveChanges();
327    
328  Store accumulated preference and capability changes.  Store accumulated preference and capability changes.
329    
# Line 548  Line 346 
346    
347  =head3 ParseCategory  =head3 ParseCategory
348    
349  C<< my $category = UserData::ParseCategory($key); >>      my $category = UserData::ParseCategory($key);
350    
351  Return the category name from the specified preference key. If no category is  Return the category name from the specified preference key. If no category is
352  specified, an error will occur.  specified, an error will occur.
# Line 586  Line 384 
384    
385  =head3 GetCategoryHash  =head3 GetCategoryHash
386    
387  C<< my $categoryHash = $self->GetCategoryHash($category); >>      my $categoryHash = $self->GetCategoryHash($category);
388    
389  Return the hash for the specified category. If it is not in memory, it  Return the hash for the specified category. If it is not in memory, it
390  will be read in.  will be read in.
# Line 636  Line 434 
434      return $retVal;      return $retVal;
435  }  }
436    
437    =head2 Access Object Methods
438    
439    The following methods must be implemented by the access object (e.g. I<$fig>) passed
440    to the constructor.
441    
442    =head3 GetDefault
443    
444        my ($group, $level) = $fig->GetDefault($objectID, $objectType);
445    
446    Return the group name and default access level for the specified object.
447    
448    =over 4
449    
450    =item objectID
451    
452    ID of the object whose capabilities data is desired.
453    
454    =item objectType
455    
456    Type of the object whose capabilities data is desired. This should be expressed
457    as a Sprout entity name. Currently, the only types supported are C<Genome>
458    and C<Subsystem>.
459    
460    =item RETURN
461    
462    Returns a two-element list. The first element is the name of the group
463    to witch the object belongs; the second is the default access level
464    (C<RW>, C<RO>, or C<NO>). If the object is not found, an empty list
465    should be returned.
466    
467    =back
468    
469    =head3 GetPreferences
470    
471        my $preferences = $fig->GetPreferences($userID, $category);
472    
473    Return a map of preference keys to values for the specified user in the
474    specified category.
475    
476    =over 4
477    
478    =item userID
479    
480    ID of the user whose preferences are desired.
481    
482    =item category (optional)
483    
484    Name of the category whose preferences are desired. If omitted, all
485    preferences should be returned.
486    
487    =item RETURN
488    
489    Returns a reference to a hash mapping each preference key to a value. The
490    keys are fully-qualified; in other words, the category name is included.
491    It is acceptable for the hash to contain key-value pairs outside the
492    category. In other words, if it's easier for you to read the entire
493    preference set into memory, you can return that one set every time
494    this method is called without worrying about the extra keys.
495    
496    =back
497    
498    =head3 GetCapabilities
499    
500        my $level = $fig->GetCapabilities($userID);
501    
502    Return a map of group names to access levels (C<RW>, C<RO>, or C<NO>) for the
503    specified user.
504    
505    =over 4
506    
507    =item userID
508    
509    ID of the user whose access level is desired.
510    
511    =item RETURN
512    
513    Returns a reference to a hash mapping group names to the user's access level
514    for that group.
515    
516    =back
517    
518    =head3 AllowsUpdates
519    
520        my $flag = $fig->AllowsUpdates();
521    
522    Return TRUE if this access object supports updates, else FALSE. If the access object
523    does not support updates, none of the B<SetXXXX> methods will be called.
524    
525    =head3 SetDefault
526    
527        $fig->SetDefault($objectID, $objectType, $group, $level);
528    
529    Set the group and default access level for the specified object.
530    
531    =over 4
532    
533    =item objectID
534    
535    ID of the object whose access level and group are to be set.
536    
537    =item objectType
538    
539    Type of the relevant object. This should be expressed as a Sprout entity name.
540    Currently, only C<Genome> and C<Subsystem> are supported.
541    
542    =item group
543    
544    Name of the group to which the object will belong. A user's access level for
545    this group will override the default access level.
546    
547    =item level
548    
549    Default access level. This is the access level used for user's who do not have
550    an explicit capability specified for the object's group.
551    
552    =back
553    
554    =head3 SetCapabilities
555    
556        $fig->SetCapabilities($userID, \%groupLevelMap);
557    
558    Set the access levels by the specified user for the specified groups.
559    
560    =over 4
561    
562    =item userID
563    
564    ID of the user whose capabilities are to be updated.
565    
566    =item groupLevelMap
567    
568    Reference to a hash that maps group names to access levels. The legal
569    access levels are C<RW> (read-write), C<RO> (read-only), and C<NO> (no
570    access). An undefined value for the access level indicates the default
571    level should be used for that group. The map will not replace all of
572    the user's capability date; instead, it overrides existing data, with
573    the undefined values indicating the specified group should be deleted
574    from the list.
575    
576    =back
577    
578    =head3 SetPreferences
579    
580        $fig->SetPreferences($userID, \%preferenceMap);
581    
582    Set the preferences for the specified user.
583    
584    =over 4
585    
586    =item userID
587    
588    ID of the user whose preferences are to be udpated.
589    
590    =item preferenceMap
591    
592    Reference to a hash that maps each preference key to its value. The
593    keys should be fully-qualified (that is, they should include the
594    category name). A preference key mapped to an undefined value will
595    use the default preference value for that key. The map will not
596    replace all of the user's preference data; instead, it overrides
597    existing data, with the undefined values indicating the specified
598    preference should be deleted from the list.
599    
600    =back
601    
602    =head3 CleanupUserData
603    
604        $fig->CleanupUserData();
605    
606    Release any data being held in memory for use by the UserData object.
607    
608    =head2 Fields
609    
610    The user data object contains the following fields.
611    
612    =over 4
613    
614    =item capable
615    
616    Reference to a hash containing all the user's capability data.
617    
618    =item preferences
619    
620    Reference to a hash of hashes. The key of the large hash is the preference
621    category, and the value is a small hash mapping preferences from that
622    category to values.
623    
624    =item userID
625    
626    Current user's ID.
627    
628    =item fig
629    
630    Fig-like object for accessing the data.
631    
632    =item newCapable
633    
634    Hash containing updated capabilities.
635    
636    =item newPreferences
637    
638    Hash containing updated preferences.
639    
640    =back
641    
642    =cut
643    
644  1;  1;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3