man Bric::Biz::Org::Parts::Addr () - Organizational Addresses

NAME

Bric::Biz::Org::Parts::Addr - Organizational Addresses

VERSION

$LastChangedRevision$

DATE

$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $

SYNOPSIS

  # Constructors are private - construct from Bric::Biz::Org objects.
  my $org = Bric::Biz::Org->lookup({ id => $org_id });
  my @addr = $org->get_addresses;
  my $addr = $org->new_address;

  # Instance Methods.
  my $id $addr->get_id;
  my $type = $addr->get_type;
  $addr = $addr->set_type($type);
  my $city = $addr->get_city;
  $addr = $addr->set_city($city);
  my $state = $addr->get_state;
  $addr = $addr->set_state($state);
  my $code = $addr->get_code;
  $addr = $addr->set_code($code);
  my $country = $addr->get_country;
  $addr = $addr->set_country($country);
  my @lines = $addr->get_lines;
  $addr = $addr->set_lines(@lines);

  $addr = $addr->activate;
  $addr = $addr->deactivate;
  $addr = $addr->is_active;

  # Print Address Labels.
  my $p = Bric::Biz::Person->lookup({ id => $person_id });
  foreach my $porg ($p->get_orgs) {
      foreach my $addr ($porg->get_addresses($id)) {
          print $p->format_name("%f% M% l"), "\n";
          print $porg->title, "\n" if $porg->title;
          print $porg->dept, "\n" if $porg->dept;
          map { print "$_\n" } $addr->get_lines;
          print $addr->get_city, ", ", $addr->get_state, "\n";
          print $addr->get_code, "  ", $addr->get_country, "\n\n";
      }
  }

DESCRIPTION

This class represents organizational addresses as objects. Organizations are represented as Bric::Biz::Org or subclassed Bric::Biz::Org objects, and a given Bric::Biz::Org object may have an unlimited number of addresses associated with it, each represented by a Bric::Biz::Org::Parts::Addr object.

Bric::Biz::Org::Parts::Addr objects can only be instantiated via the Bric::Biz::Org get_addresses() or add_address() method calls. The Bric::Biz::Org::Parts::Addr constructors are therefore private.

INTERFACE

Constructors

$addr = Bric::Biz::Org::Parts::Addr->new($init)
Instantiates a Bric::Biz::Org::Parts::Addr object. A hashref of initial values may be passed. The supported initial value keys are:
*
org_id
*
type
*
city
*
state
*
code
*
country
*
lines If lines is passed, a single line may be passed, and multiple lines may be passed as an anonymous array. Call CW$add->_save to save the new object. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: To be called from Bric::Biz::Org only. Looks up and instantiates a new Bric::Biz::Org::Parts::Addr object based on the Bric::Biz::Org::Parts::Addr 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::Parts::Addr 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 object with data from the database before returning it. Notes: There may actually be no use for this method, since Bric::Biz::Org::Parts::Addr objects will be stored internally in a Bric::Biz::Org object, and therefore may not need to be implemented. Returns a list of Bric::Biz::Org::Parts::Addr objects based on the search criteria passed via a hashref. The lookup searches are case-insensitive. The supported lookup parameter keys are:
*
type
*
city
*
state
*
code
*
country
*
org_id
*
person_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::Parts::Addr object with data from the database before returning them all. To be called from Bric::Biz::Org only. Notes: NONE.
Bric::Biz::Org::Parts::Addr->href($params)
Exactly the same as list(), except that it returns all the Bric::Biz::Org::Parts::Addr objects in an anonymous hash, where the hash keys are the object IDs and the values are the objects. See list() for syntax. 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.

Destructors

$addr->DESTROY
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY. Throws: NONE. Side Effects: NONE. Notes: NONE.

Public Class Methods

Returns a list or anonymous array of Bric::Biz::Org::Parts::Addr object IDs based on the search criteria passed. The search parameters are the same as those for list() above. 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 a list of active address parts. Throws:
*
Unable to connect to database.
*
Unable to prepare SQL statement.
*
Unable to select column into arrayref. Side Effects: NONE. Notes: NONE.
$success = Bric::Biz::Org::Parts::Addr->add_parts(@parts)
Adds new address parts to the Bric::Biz::Org::Parts::Addr object. These parts will be available exclusively through the get_parts() instance method. Throws:
*
Unable to connect to database.
*
Unable to prepare SQL statement.
*
Unable to execute SQL statement. Side Effects: NONE. Notes: NONE.
$success = Bric::Biz::Org::Parts::Addr->del_parts(@parts)
Deletes address parts. Throws:
*
Unable to connect to database.
*
Unable to prepare SQL statement.
*
Unable to execute SQL statement. 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

Returns the ID of the Bric::Biz::Org::Parts::Addr object. Throws:

*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'id' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: If the Bric::Biz::Org::Parts::Addr object has been instantiated via the new() private constructor and has not yet been saved, via the Bric::Biz::Org save() method, the object will not yet have an ID, so this method call will return undef. Returns the type of address it is. Intended to distinguish between different addresses for a given organization. Examples might be New York Shipping or San Francisco Billing. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'type' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the type attributte. Returns CW$self on success and undef on failure. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns the address city. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the address city. Returns CW$self on success and undef on failure. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Returns the address state. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the address state. Returns CW$self on success and undef on failure. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Returns the address postal code, such as US Zip Code. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the address postal code, such as US Zip Code. Returns CW$self on success and undef on failure. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Returns the addresse country. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets the address country. Returns CW$self on success and undef on failure. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: Countries are stored in the database by their ISO 3166 code names. See http://wmbr.mit.edu/stations/ISOcodes.html. We'll need to finagle some sort of database lookup, perhaps through a trigger. Returns an ordered list of individual address lines for the addres. An infinite number of address lines are supported, though it is assumed that most addresses will have 1-3 address lines. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Sets the address lines for the address. An infinite number of address lines are supported, though it is assumed that most addresses will have 1-3 address lines. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: Stores new address lines internally to the object. The lines will not persist until the address object is saved via the Bric::Biz::Org object's save() method. Notes: NONE. Returns a hash (list) or anonymous hash of the parts of this address. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'parts' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets a part to a value. The part must exist in the database. To add a part, use the add_parts() class method. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: I could grab a list of all the parts from the database here (using list_parts() and then make sure each part exists before assigning it, but I didn't want to waste the query. Instead, there'll be a failure when save() is called and there's a non-valid part name. Activates the Bric::Biz::Org::Parts::Addr object. The change will not persist until the Bric::Biz::Org object's save() method is called. Bric::Biz::Org::Parts::Addr objects instantiated by new() are active by default. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Deactivates (deletes) the Bric::Biz::Org::Parts::Addr object. The change will not persist until the Bric::Biz::Org object's save() method is called. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns CW$self if the Bric::Biz::Org::Parts::Addr object is active, and undef if it is not. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Saves any changes to the Bric::Biz::Org::Parts::Addr object, 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 address lines and parts 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 objects or, if called with an optional third argument, returns a list of Bric::Biz::Org 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. Instantiates a new object. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Sets an address part. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Gets an address part. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE.
$success = &$save_main($self)
Saves the primary properties of the object. 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: NONE. Notes: NONE. Saves the address parts. 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: NONE. Notes: NONE.
$success = &$save_lines($self)
Saves the address lines. 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: NONE. Notes: NONE. Prepares and returns SQL statements for inserting, updating, and deleting address parts. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Unable to connect to database.
*
Unable to prepare SQL statement. Side Effects: NONE. Notes: NONE.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

Bric, Bric::Biz::Org, Bric::Biz::Person