man Bric::Biz::Org::Person () - Manages Organizations Related to Persons
NAME
Bric::Biz::Org::Person - Manages Organizations Related to Persons
VERSION
$LastChangedRevision$
DATE
$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $
SYNOPSIS
# How to create brand new Bric::Biz::Org::Person object. my $org = Bric::Biz::Org->lookup({ id => $org_id }); my $porg = $org->add_object($person);
# How to retreive existing Bric::Biz::Org::Person objects. my $person = Bric::Biz::Person->lookup({ id => $person_id }); my @porgs = $person->get_orgs;
# Other contstructors. my $porg = Bric::Biz::Org::Person->lookup({ id => $porg_id }) my @porgs = Bric::Biz::Org::Person->list($search_href);
# Class Methods. my @porg_ids = Bric::Biz::Org::Person->list_ids($search_href);
# Instance Methods. my $id = $porg->get_id; my $oid = $porg->get_org_id; my $person = $porg->get_person; my $pid = $porg->get_person_id; my $role = $porg->get_role; $porg = $porg->set_role($role); my $title = $porg->get_title; $porg = $porg->set_title($title); my $dept = $porg->get_department; $porg = $porg->set_department($dept);
$porg = $porg->activate; $porg = $porg->deactivate; $porg = $porg->is_active;
my @addr = $porg->get_addresses; my $addr = $porg->new_address; $porg = $porg->add_addresses($addr); $porg = $porg->del_addresses;
$porg = $porg->save;
DESCRIPTION
This class manages the association between a Bric::Biz::Person object and a Bric::Biz::Org object. There may be numerous adddresses associated with a given Bric::Biz::Org object, but only some of them may apply to any given person. This class limits a Bric::Biz::Org objects addresses to those associated with a given person. It also manages the details of the person's association with the organization by offering properites for the person's title and department within the organization.
When a Bric::Biz::Person object is created, it automatically has a single Bric::Biz::Org::Person object associated with it, an object which represents the Bric::Biz::Person object itself and the personal addresses of the person represented. These Bric::Biz::Org::Person objects are identified by their role properties, which will all be Personal by default, and by the is_persona() method returning CW$self when the Org is personal, and undef whe it is not.
For example, a Bric::Biz::Peron object created for Ian Kallen will have at least one Bric::Biz::Org::Person object, named for Ian Kallen, and in which Ian's personal addresses may be stored. However, Ian has other addresses by his association with the companies he works for and other organizations to which he belongs. Thus, one can add a Bric::Biz::Org object representing About.com and then associated create a Bric::Biz::Org::Person object by calling CW$org->add_object, passing in Ian Kallen's Bric::Biz::Person object. Then one can add addresses to the Bric::Biz::Org::Person object, either by referencing Bric::Biz::Org::Parts::Addr object IDs, or by creating new Bric::Biz::Org::Parts::Addr objects.
INTERFACE
Constructors
- $porg = Bric::Biz::Org::Person->new
- Instantiates a Bric::Biz::Org::Person object. An anonymous hash of initial values may be passed. The supported intial value keys are:
- *
- org_id
- *
- name
- *
- long_name
- *
- role
- *
- person - A Bric::Biz::Person object.
- *
- obj - Alias for person.
- *
- person_id
- *
- title
- *
- department
- *
- _personal - should only be passed a true value by a call from Bric::Biz::Person->save. Call CW$porg->save to save the new object. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Looks up and instantiates a new Bric::Biz::Org::Person object based on the Bric::Biz::Org::Person object ID passed. If CW$id is not found in the database, lookup() returns undef. If the ID is found more than once, lookup() returns zero (0). This should not happen. Throws:
- *
- Too many Bric::Biz::Org::Person objects found.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle. Side Effects: If CW$id is found, populates the new Bric::Biz::Org::Person object with data from the database before returning it. Notes: Bric::Biz::Org::Person objects have different IDs than the equivalent Bric::Biz::Org object. The IDs vary based on the person who is associated with the Bric::Biz::Org object. Returns a list or anonymous array of Bric::Biz::Org objects based on the search criteria passed via a hashref. The lookup searches are case-insensitive. The supported lookup keys are:
- *
- name
- *
- long_name
- *
- org_id
- *
- role
- *
- person_id
- *
- title
- *
- department
- *
- grp_id Throws:
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle. Side Effects: Populates each Bric::Biz::Org::Person object with data from the database before returning them all. Notes: NONE.
Destructors
- $porg->DESTROY
- Dummy method to prevent wasting time trying to AUTOLOAD DESTROY. Throws: NONE. Side Effects: NONE. Notes: NONE.
Public Class Methods
Functionally identical to list(), but returns Bric::Biz::Org::Person object IDs rather than objects. See list() for a description of its interface. Throws:
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns an anonymous hash of introspection data for this object. If called with a true argument, it will return an ordered list or anonymous array of introspection data. If a second true argument is passed instead of a first, then a list or anonymous array of introspection data will be returned for properties that uniquely identify an object (excluding CWid, which is assumed). Each hash key is the name of a property or attribute of the object. The value for a hash key is another anonymous hash containing the following keys:
- name
- The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned.
- disp
- The display name of the property or attribute.
- get_meth
- A reference to the method that will retrieve the value of the property or attribute.
- get_args
- An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute.
- set_meth
- A reference to the method that will set the value of the property or attribute.
- set_args
- An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute.
- type
- The type of value the property or attribute contains. There are only three types:
- short
- date
- blob
- len
- If the value is a 'short' value, this hash key contains the length of the field.
- search
- The property is searchable via the list() and list_ids() methods.
- req
- The property or attribute is required.
- props
- An anonymous hash of properties used to display the property or attribute. Possible keys include:
- type
- The display field type. Possible values are
- text
- textarea
- password
- hidden
- radio
- checkbox
- select
- length
- The Length, in letters, to display a text or password field.
- maxlength
- The maximum length of the property or value - usually defined by the SQL DDL.
- rows
- The number of rows to format in a textarea field.
- cols
- The number of columns to format in a textarea field.
- vals
- An anonymous hash of key/value pairs reprsenting the values and display names to use in a select list. Throws: NONE. Side Effects: NONE. Notes: NONE.
Public Instance Methods
In addition to the Public Instance Methods offered by the Bric::Biz::Org API, Bric::Biz::Org::Person offers the following additional or overridden methods. Returns the ID of the Bric::Biz::Org::Person object. This ID will be different from the ID of the equivalent Bric::Biz::Org object. Use the get_org_id() method to fetch that ID. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'id' required.
- *
- No AUTOLOAD method. Side Effects: If called by Bric::Util::Grp or Bric::Util::Grp::Parts::Member or a subclass of either, this method will return the same value as CWget_org_id(). This is because it is the Org ID that is used for group membership, rather than the Org::Person ID. Notes: If the Bric::Biz::Org::Person object has been instantiated via the new() constructor and has not yet been CWsaved, the object will not yet have an ID, so this method call will return undef. Returns the ID of the Bric::Biz::Org object associated with this Bric::Biz::Org::Person object. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'org_id' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the Bric::Biz::Person object associated with this Bric::Biz::Org::Person object. Throws: NONE. Side Effects: NONE. Notes: NONE. Returns the ID of the Bric::Biz::Person object referenced by this Bric::Biz::Org::Person object. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'person_id' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the role of person represented by the Bric::Biz::Person object in the organization represented by the Bric::Biz::Org object. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'role' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the role of person represented by the Bric::Biz::Person object in the organization represented by the Bric::Biz::Org object. May be anything, such as Work, Professional, etc. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: WRITE access for field 'role' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the title of the person associated with this organization. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'title' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the title of the person associated with this organization. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: WRITE access for field 'title' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the department of the person associated with this organization. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: READ access for field 'dept' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the department of the person associated with this organization. Throws:
- *
- Bad AUTOLOAD method format.
- *
- Cannot AUTOLOAD private methods.
- *
- Access denied: WRITE access for field 'dept' required.
- *
- No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Activates the Bric::Biz::Org::Person object. Call CW$porg->save to make the change persistent. Bric::Biz::Org::Person objects instantiated by new() are active by default. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: Inherited from Bric::Biz::Org, but uses the active value specific to the user, rather than the person. Notes: This method only affects the Bric::Biz::Org::Person object representing the relationship between the underlying Bric::Biz::Org object and the Bric::Biz::Person object. Deactivates (deletes) the Bric::Biz::Org::Person object. Call CW$porg->save to make the change persistent. Throws:
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: Inherited from Bric::Biz::Org, but uses the active value specific to the user, rather than the person. Notes: This method only affects the Bric::Biz::Org::Person object representing the relationship between the underlying Bric::Biz::Org object and the Bric::Biz::Person object. The underlying Bric::Biz::Org object must have its activate() and deactivate() methods called separately from those called from a Bric::Biz::Org::Person object. Returns CW$self if the Bric::Org::Person object is active, and undef if it is not. Throws:
- *
- Bric::_get() - Problems retrieving fields. Side Effects: Inherited from Bric::Biz::Org, but uses the active value specific to the user, rather than the person. Notes: See notes for activate() and deactivate() above. Returns a list or anonymous array of Bric::Biz::Org::Parts::Addr objects. The addresses returned will be a subset of those associated with the underlying Bric::Biz::Org object, being only the organizational addresses corresponding to a particular Bric::Biz::Person object. Returns an empty list when there are no addresses associated with this object, and undef upon failure. See the Bric::Biz::Org::Parts::Addr documentation for its API. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: Stores the list of Bric::Biz::Org::Parts::Addr objects internally in the Bric::Biz::Org::Person object the first time it or any other address method is called on a given Bric::Biz::Org::Person instance. Notes: Changes made to Bric::Biz::Org::Parts::Addr objects retreived from this method can be persistently saved to the database only by calling the Bric::Biz::Org::Person object's save() method. Adds and returns a new Bric::Biz::Org::Parts::Addr object associated with the Bric::Biz::Org::Person object. Once CW$porg->save has been called, the new address will be associated both with this Bric::Biz::Org::Person object and the underlying Bric::Biz::Org object. Returns undef on failure. See the Bric::Biz::Org::Parts::Addr documentation for its API. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: Stores the list of Bric::Biz::Org::Parts::Addr objects internally in the Bric::Biz::Org object the first time it or any other address method is called on a given Bric::Biz::Org instance. Notes: Changes made to CW$address objects retreived from this method can be persistently saved to the database only by calling the Bric::Biz::Org object's save() method. Associates the list of Bric::Biz::Org::Parts::Addr objects with the Bric::Biz::Person identified by the Bric::Biz::Org::Person object. The addresses must already be associated with the underlying Bric::Biz::Org object. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: Stores the list of Bric::Biz::Org::Parts::Addr objects internally in the Bric::Biz::Org object the first time it or any other address method is called on a given Bric::Biz::Org instance. Notes: NONE. If called with no arguments, deletes all Bric::Biz::Org::Parts::Addr objects associated with the Bric::Biz::Org::Person object. Pass Bric::Biz::Org::Parts::Addr object IDs to delete only those Bric::Biz::Org::Parts::Addr objects. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: Deletes the Bric::Biz::Org::Parts::Addr objects from the Bric::Biz::Org::Person object's internal structure, but retains a list of the IDs. These will be used to delete the Bric::Biz::Org::Parts::Addr objects from the database when CW$porg->save is called, then are deleted from the Bric::Biz::Org object's internal structure. The Bric::Biz::Org::Parts::Addr objects will not actually be deleted from the database until CW$porg->save is called. Notes: The addresses will not be deleted from the underlying Bric::Biz::Org object. Saves any changes to the Bric::Biz::Org::Person and underlying Bric::Biz::Org objects, including changes to associated address (Bric::Biz::Org::Parts::Addr) objects. Returns CW$self on success and undef on failure. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to execute SQL statement.
- *
- Unable to select row.
- *
- Incorrect number of args to _set.
- *
- Bric::_set() - Problems setting fields. Side Effects: Cleans out internal cache of Bric::Biz::Org::Parts::Addr objects to reflect what is in the database. Notes: NONE.
PRIVATE
Private Class Methods
NONE.
Private Instance Methods
NONE.
Private Functions
Function used by lookup() and list() to return a list of Bric::Biz::Org::Person objects or, if called with an optional third argument, returns a list of Bric::Biz::Org::Person object IDs (used by list_ids()). Throws:
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns the collection of addresses for this organization. The collection is a Bric::Util::Coll::Addr object. See that class and its parent, Bric::Util::Coll, for interface details. Throws:
- *
- Bric::_get() - Problems retrieving fields.
- *
- Unable to connect to database.
- *
- Unable to prepare SQL statement.
- *
- Unable to select column into arrayref.
- *
- Unable to execute SQL statement.
- *
- Unable to bind to columns to statement handle.
- *
- Unable to fetch row from statement handle.
- *
- Incorrect number of args to Bric::_set().
- *
- Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE.
NOTES
This is an early draft of this class, and therefore subject to change.
AUTHOR
David Wheeler <david@wheeler.net>
SEE ALSO
Bric, Bric::Biz::Org, Bric::Biz::Person