Bric::Biz::Org::Source(3)

NAME
Bric::Biz::Org::Source - Manages content sources.

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2004-06-04 12:21:12 -0700 (Fri, 04 Jun 2004) $

SYNOPSIS
  use Bric::Biz::Org::Source;

  # Constructors.
  my $src = Bric::Biz::Org::Source->new($init);
  $src = Bric::Biz::Org::Source->lookup({ id => $id });
  my @srces = Bric::Biz::Org::Source->list($params);

  # Class methods.
  my @sids = Bric::Biz::Org::Source->list_ids($params);
  my $meths = Bric::Biz::Org::Source->my_meths;

  # Instance Methods.
  my $id = $src->get_id;
  my $org_id = $src->get_org_id;
  $src = $src->set_org($org);
  my $src_name = $src->get_source_name;
  $src = $src->set_source_name($src_name);
  my $desc = $src->get_description;
  $src = $src->set_description($desc);
  my $expire = $src->get_expire;
  $src = $src->set_expire($expire);

  $src = $src->activate;
  $src = $src->deactivate;
  print "Active: ", $src->is_active ? 'Yes' : 'No', "\n";

  $src = $src->save;

DESCRIPTION
This class manages asset sources. A source is an organization that provides content, such as a wire service or a syndicate. Thus, each source object is a kind of organization, and inherits all of an relevant data accessors, including those for addresses.

This class adds three basic data points to the organization: A description, an expire, and an active flag. The description is a simple free-text description of the source. The expire property is a simple integer representing the number of days an asset provided by a given source may be used before it must be removed as content. The active flag is just like any other active flag, except that it is separate from the Bric::Biz::Org active flag. Thus a Bric::Biz::Org::Source object may be deactivated while its parent Bric::Biz::Org object remains active.

INTERFACE

  Constructors

my $src = Bric::Biz::Org::Source->new($init)
    Instantiates a Bric::Biz::Org::Source object. An anonymous hash of initial values may be passed. The supported initial value keys are:

    *   name

    *   long_name

    *   description

    *   expire

    The new source will be active by default. Call $src->save() to save the new object.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

my $src = Bric::Biz::Org::Source->lookup({ id => $id })
my $src = Bric::Biz::Org::Source->lookup({ source_name => $source_name })
    Looks up and instantiates a new Bric::Biz::Org::Source object based on the Bric::Biz::Org::Source object ID or name passed. If $id or $name is not found in the database, "lookup()" returns "undef".

    Throws:

    *   Invalid property.

    *   Too many Bric::Dist::Biz::Org::Source objects found.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   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 $id is found, populates the new Bric::Biz::Org::Source object with data from the database before returning it.

    Notes: NONE.

my (@srcs || $srcs_aref) = Bric::Biz::Org::Source->list($params)
    Returns a list or anonymous array of Bric::Biz::Org::Source objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:

    *   name

    *   long_name

    *   source_name

    *   description

    *   expire

    *   org_id

    *   grp_id

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   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::Source object with data from the database before returning them all.

    Notes: NONE.

  Destructors

$src->DESTROY
    Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

  Public Class Methods

my (@src_ids || $src_ids_aref) = Bric::Biz::Org::Source->list_ids($params)
    Returns a list or anonymous array of Bric::Biz::Org::Source object IDs based on the search criteria passed via an anonymous hash. The supported lookup keys are the same as those for "list()".

    Throws:

    *   Invalid property.

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   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.

my $meths = Bric::Biz::Org::Source->my_meths
my (@meths || $meths_aref) = Bric::Biz::Org::Source->my_meths(TRUE)
my (@meths || $meths_aref) = Bric::Biz::Org::Source->my_meths(0, TRUE)
    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 "id", 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
Besides the methods inherited from Bric::Biz::Org, Bric::Biz::Org::Source offers accessors relevant to source-specific data.

my $id = $src->get_id
    Returns the ID of the Bric::Biz::Org::Source object.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    Side Effects: NONE.

    Notes: If the Bric::Biz::Org::Source object has been instantiated via the new() constructor and has not yet been "save"d, the object will not yet have an ID, so this method call will return undef.

my $org_id = $src->get_org_id
    Returns the ID of the Bric::Biz::Org object from which this source object inherits.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    Side Effects: NONE.

    Notes: NONE.

$self = $src->set_org($org)
    Sets the ID representing Bric::Biz::Org object from which this Bric::Biz::Org::Source object inherits.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    Side Effects: NONE.

    Notes: NONE.

my $source_name = $src->get_source_name
    Returns the source_name of this source.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'source_name' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

$self = $src->set_source_name($source_name)
    Sets the source_name of this source.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: WRITE access for field 'source_name' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $description = $src->get_description
    Returns the description of this source.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'description' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

$self = $src->set_description($description)
    Sets the description of this source.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: WRITE access for field 'description' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $expire = $src->get_expire
    Returns the number of days before assets associated with this source expire.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'expire' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

$self = $src->set_expire($expire)
    Sets the number of days before assets associated with this source expire. Set this value to 0 (zero) to prevent assets provided by this source from ever expiring.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: WRITE access for field 'expire' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

    ################################################################################

$self = $src->activate
    Activates the Bric::Biz::Org::Source object. Call $src->save to make the change persistent. Bric::Biz::Org::Source 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: A Bric::Biz::Org::Source object's active status is not inherited from Bric::Biz::Org. A Bric::Biz::Org::Source object may be deactivated while its parent Bric::Biz::Org object remains active.

$self = $src->deactivate
    Deactivates (deletes) the Bric::Biz::Org::Source object. Call $src->save to make the change persistent.

    Throws:

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    Side Effects: NONE.

    Notes: See activate() above.

$self = $src->is_active
    Returns $self if the Bric::Biz::Org::Source object is active, and undef if it is not.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    Side Effects: NONE.

    Notes: See activate() above.

my (@gids || $gids_aref) = $u->get_grp_ids
my (@gids || $gids_aref) = Bric::Biz::Person::User->get_grp_ids
    Returns a list or anonymous array of Bric::Biz::Group object ids representing the groups of which this Bric::Biz::Org::Source object is a member.

    Throws: See Bric::Util::Grp::list().

    Side Effects: NONE.

    Notes: This method returns the group IDs for the current object both as a Bric::Biz::Org object and as a Bric::Biz::Org::Source object. [Actually, I've commented this out for now, since it seems more likely at this point that we'll want only the source group IDs, not also the organization IDs. We can uncomment this later if we decide we need it, though.]

$self = $src->save
    Saves any changes to the Bric::Biz::Org::Source object. Returns $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: NONE.

    Notes: NONE.

PRIVATE

  Private Class Methods
NONE.

  Private Instance Methods
NONE.

  Private Functions

my $src_aref = &$get_em( $pkg, $params )
my $src_ids_aref = &$get_em( $pkg, $params, 1 )
    Function used by lookup() and list() to return a list of Bric::Biz::Org::Source objects or, if called with an optional third argument, returns a listof Bric::Biz::Org::Source object IDs (used by list_ids()).

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   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.

NOTES
NONE.

AUTHOR
David Wheeler <david@wheeler.net>

SEE ALSO
Bric