Bric::Biz::ATType(3p)

NAME
Bric::Biz::ATType - A class to represent ElementType types.

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2006-03-18 01:26:34 +0100 (Sat, 18 Mar 2006) $

SYNOPSIS
 use Bric::Biz::ATType;

DESCRIPTION
This class sets up properties that are common to all elements (Bric::Biz::ElementType) objects of a type.

INTERFACE

  Constructors

$obj = Bric::Biz::ATType->new($init);
    Constructs and returns a new Bric::Biz::ATType object initialized with the parameters in the $init hash reference. The supported keys for $init are:

    name
        The name of this ATType.

    description
        A short description of this ATType.

    top_level
        A boolean value flagging whether elements (ElementTypes) of this this ATType represent top level elements (story type elements or media type elements) or subelements. Defaults to false.

    paginated
        A boolean value flagging whether elements (ElementTypes) of this this ATType represent pages. Defaults to false.

    fixed_url
        A boolean value flagging whether elements (ElementTypes) of this this ATType are fixed URL elements. Defaults to false.

    related_story
        A boolean value flagging whether elements (ElementTypes) of this this ATType are rleated story elements. Defaults to false.

    related_media
        A boolean value flagging whether elements (ElementTypes) of this this ATType are rleated media elements. Defaults to false.

    media
        A boolean value flagging whether elements (ElementTypes) of this this ATType are media elements. Defaults to false.

    biz_class_id
        The ID corresponding to the Bric::Util::Class entry for one of the following classes:

        Bric::Biz::Asset::Business::Story
        Bric::Biz::Asset::Business::Media
        Bric::Biz::Asset::Business::Media::Image
        Bric::Biz::Asset::Business::Media::Audio
        Bric::Biz::Asset::Business::Media::Video

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

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

    Throws:

    *   Too many Bric::Biz::ATType 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: NONE.

    Notes: NONE.

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

    id  ATType ID. May use "ANY" for a list of possible values.

    name
        Lookup ATType by name. May use "ANY" for a list of possible values.

    description
        Lookup ATType by description. May use "ANY" for a list of possible values.

    top_level
        Boolean; return all top level ATTypes

    paginated
        Boolean; return all paginated ATTypes.

    fixed_url
        Boolean; return all fixed URL ATTypes.

    active
        Boolean; return all active ATTypes. If passed as "all", returns all ATTypes.

    related_story
        Boolean; return all related story ATTypes.

    related_media
        Boolean; return all related media ATTypes.

    media
        Boolean; return all media ATTypes.

    biz_class_id
        Return all ATTypes associated with this business class ID. See "new()" for a list of business asset classes. May use "ANY" for a list of possible values.

    grp_id
        Return all ATTypes in the Bric::Util::Grp::ATType group corresponding to this ID. May use "ANY" for a list of possible values.

    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

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

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

  Public Class Methods

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

    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.

my $meths = Bric::Biz::ATType->my_meths
my (@meths || $meths_aref) = Bric::Biz::ATType->my_meths(TRUE)
my (@meths || $meths_aref) = Bric::Biz::ATType->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

$name = $att->get_name;
$name = $att->set_name($name);
    Get/Set the name of this AT type.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$desc = $att->get_description;
$desc = $att->set_description($desc);
    Get/Set the description for this AT type.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$topl = $att->get_top_level;
$topl = $att->set_top_level(1 || 0);
    Get/Set the top level flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$page = $att->get_paginated;
$page = $att->set_paginated(1 || 0);
    Get/Set the paginated flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$page = $att->get_fixed_url;
$page = $att->set_fixed_url(1 || 0);
    Get/Set the fixed url flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$page = $att->get_related_story;
$page = $att->set_related_story(1 || 0);
    Get/Set the related story flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$page = $att->get_related_media;
$page = $att->set_related_media(1 || 0);
    Get/Set the related media flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$page = $att->get_media;
$page = $att->set_media(1 || 0);
    Get/Set the media flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$page = $att->get_biz_class_id;
$page = $att->set_biz_class_id(1 || 0);
    Get/Set the business class ID. See "new()" for a list of the business asset classes.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$att = $att->is_active;
$att = $att->activate;
$att = $att->deactivate;
    Get/Set the active flag.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

$success = $attype->remove;
    Deletes the AT type from the database.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    Side Effects: NONE.

    Notes: NONE.

$att = $att->save;
    Save the AT type and/or all changes to the database.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    Side Effects: NONE.

    Notes: NONE.

  Private Class Methods
NONE

  Private Instance Methods

_update_attype
    Updates the ATType in the database.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    Side Effects: NONE.

    Notes: NONE.

_insert_attype
    Inserts the ATType into the database.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    Side Effects: NONE.

    Notes: NONE.

  Private Functions

my $attypes_aref = &$get_em( $pkg, $params )
my $attypes_ids_aref = &$get_em( $pkg, $params, 1 )
    Function used by "lookup()" and "list()" to return a list of Bric::Biz::ATType objects or, if called with an optional third argument, returns a list of Bric::Biz::ATType 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.

NOTES
NONE

AUTHOR
Garth Webb <garth@perijove.com>

Refactored by David Wheeler <david@justatheory.com>

SEE ALSO
perl, Bric, Bric::Biz::ElementType