Bric::Biz::AssetType(3)

NAME
Bric::Biz::AssetType - Registers new types of assets with their fields and the rules governing them.

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2005-01-27 17:37:50 -0800 (Thu, 27 Jan 2005) $

SYNOPSIS
  # Create new types of assets.
  $element = Bric::Biz::AssetType->new($init)
  $element = Bric::Biz::AssetType->lookup({id => $id})
  ($at_list || @ats) = Bric::Biz::AssetType->list($param)
  ($id_list || @ids) = Bric::Biz::AssetType->list_ids($param)

  # Return the ID of this object.
  $id = $element->get_id()

  # Get/set this asset type's name.
  $element = $element->set_name( $name )
  $name       = $element->get_name()

  # Get/set the description for this asset type
  $element  = $element->set_description($description)
  $description = $element->get_description()

  # Get/set the primary output channel ID for this asset type.
  $element = $element->set_primary_oc_id($oc_id, $site_id);
  $oc_id = $element->get_primary_oc_id($site_id);

  # Attribute methods.
  $val  = $element->set_attr($name, $value);
  $val  = $element->get_attr($name);
  \%val = $element->all_attr;

  # Attribute metadata methods.
  $val = $element->set_meta($name, $meta, $value);
  $val = $element->get_meta($name, $meta);

  # Manage output channels.
  $element        = $element->add_output_channels([$output_channel])
  ($oc_list || @ocs) = $element->get_output_channels()
  $element        = $element->delete_output_channels([$output_channel])

  # Manage sites
  $element               = $element->add_sites([$site])
  ($site_list || @sites) = $element->get_sites()
  $element               = $element->remove_sites([$site])

  # Manage the parts of an asset type.
  $element            = $element->add_data($field);
  $element_data       = $element->new_data($param);
  $element            = $element->copy_data($at, $field);
  ($part_list || @parts) = $element->get_data($field);
  $element            = $element->del_data($field);

  # Add, retrieve and delete containers from this asset type.
  $element            = $element->add_containers($at || [$at]);
  (@at_list || $at_list) = $element->get_containers();
  $element            = $element->del_containers($at || [$at]);

  # Set the repeatability of a field.
  ($element || 0) = $element->is_repeatable($at_container);
  $element        = $element->make_repeatable($at_container);
  $element        = $element->make_nonrepeatable($at_container);

  # Get/set the active flag.
  $element  = $element->activate()
  $element  = $element->deactivate()
  (undef || 1) = $element->is_active()

  # Save this asset type.
  $element = $element->save()

DESCRIPTION
The asset type class registers new type of assets that will go through work flow. The individual parts will describe how the fields of the story will be laid out.

The AssetType object is composed of AssetType Parts Data objects and AssetType Parts Container objects. These hold the fields that will become Assets when they enter workflow. Rules can be set upon these.

The AssetType object also holds what output channels this asset will be allowed to go through.

INTERFACE

  Constructors

$element = Bric::Biz::AssetType->new($init)
    Will return a new asset type object with the optional initial state

    Supported Keys:

    name
    key_name
    description
    reference

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

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

    Throws:

    *   Too many Bric::Biz::AssetType objects found.

    Side Effects: NONE

    Notes: NONE

($at_list || @at_list) = Bric::Biz::AssetType->list($param);
    This will return a list of objects that match the criteria defined.

    Supported Keys:

    name
        The name of the asset type. Matched with case-insentive LIKE.

    key_name
        The unique key name of the asset type. Matched with case insensitive LIKE

    description
        The description of the asset type. Matched with case-insentive LIKE.

    output_channel_id
        The ID of an output channel. Returned will be all AssetType objects that contain this output channel.

    data_name
        The name of an AssetType::Data object. Returned will be all AssetType objects that reference this particular AssetType::Data object.

    map_type__id
        The map_type__id of an AssetType::Data object.

    active
        Set to 0 to return active and inactive asset types. 1, the default, returns only active asset types.

    type__id
        match elements of a particular attype

    top_level
        set to 1 to return only top-level elements

    media
        match against a particular media asset type (att.media)

    site_id
        match against the given site_id

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

($at_list || @ats) = Bric::Biz::AssetType->list_ids($param)
    This will return a list of objects that match the criteria defined. See the "list()" method for the allowed keys of the $param hash reference.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

  Destructors

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

  Public Class Methods

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

$id = $element->get_id()
    This will return the id for the database

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$element = $element->set_name( $name )
    This will set the name field for the asset type

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$name = $element->get_name()
    This will return the name field for the asset type

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$element = $element->set_key_name($key_name)
    This will set the unique key name field for the asset type

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$name = $element->get_key_name()
    This will return the unique key name field for the asset type

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$element = $element->set_description($description)
    this sets the description field

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$description = $element->get_description()
    This returns the description field

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$element = $element->set_primary_oc_id( $primary_oc_id, $site )
    This will set the primary output channel id field for the asset type

    Throws:

    *   No site parameter passed to Bric::Biz::AssetType->set_primary_oc_id

    *   No output channels associated with non top-level elements.

    Side Effects: NONE.

    Notes: NONE.

$primary_oc_id = $element->get_primary_oc_id($site)
    This will return the primary output channel id field for the asset type

    Throws:

    *   No site parameter passed to Bric::Biz::AssetType->get_primary_oc_id.

    *   No output channels associated with non top-level elements.

    Side Effects: NONE.

    Notes: NONE.

$name = $at->get_type_name
    Get the type name of the asset type.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$burner = $at->get_burner
    Get the burner associated with the asset type. Possible values are the constants BURNER_MASON and BURNER_TEMPLATE defined in this package.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$at->set_burner(Bric::Biz::AssetType::BURNER_MASON);
    Get the burner associated with the asset type. Possible values are the constants BURNER_MASON and BURNER_TEMPLATE defined in this package.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$desc = $at->get_type_description
    Get the type description of the asset type.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($at || undef) = $at->get_top_level
    Return whether this is a top level story or not.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($at || undef) = $at->get_paginated
    Return whether this asset type should produce a paginated asset or not.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($at || undef) = $at->is_related_media
    Return whether this asset type can have related media objects.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($at || undef) = $at->is_related_story
    Return whether this asset type can have related story objects.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($at || undef) = $at->is_media()
$at = $at->set_media()
$at = $at->clear_media()
    Mark this Asset Type as representing a media object or a story object. Media objects do not support all the options that story objects to like nested containers or references, but they include options that story doesnt like autopopulated fields.

    The 'is_media' method returns true if this is a media object and false otherwise. The 'set_media' method marks this as a media object. It does not take any arguments, and always sets the media flag to true, so you cant do this:

    $at->set_media(0)

    and expect to set the media flag to false. To unset the media flag (set it to false) use the 'clear_media' method.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$at->get_biz_class()
$at->get_biz_class_id()
$at->set_biz_class('class' => '' || 'id' => '');
    The methods 'get_biz_class' and 'get_biz_class_id' get the business class name or the business class ID respectively from the class table.

    The 'set_biz_class' method sets the business class for this asset type given either a class name or an ID from the class table.

    This value represents the kind of bussiness object this asset type will represent. There are just two main kinds, story and media objects. However media objects have many subclasses, one for each type of supported media (image, audio, video, etc) increasing the number of package names this value could be set to.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

($at || undef) = $at->get_reference
$at = $at->set_reference(1 || 0)
    Return whether this asset type references other data.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

($at || undef) = $at->get_fixed_url
    Return whether this asset type should produce a fixed url asset or not.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$at_type = $at->get_at_type
    Return the at_type object associated with this element.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$val = $element->set_attr($name, $value);
$val = $element->get_attr($name);
$val = $element->del_attr($name);
    Get/Set/Delete attributes on this asset type.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$val = $element->set_meta($name, $field, $value);
$val = $element->get_meta($name, $field);
$val = $element->get_meta($name);
    Get/Set attribute metadata on this asset type. Calling the 'get_meta' method without '$field' returns all metadata names and values as a hash.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

($oc_list || @oc_list) = $element->get_output_channels;
($oc_list || @oc_list) = $element->get_output_channels(@oc_ids);
    This returns a list of output channels that have been associated with this asset type. If @oc_ids is passed, then only the output channels with those IDs are returned, if they're associated with this asset type.

    Throws: NONE.

    Side Effects: NONE.

    Notes: The objects returned will be Bric::Biz::OutputChannel::Element objects, and these objects contain extra information relevant to the assocation between each output channel and this element object.

my $oce = $element->add_output_channel($oc)
my $oce = $element->add_output_channel($oc_id)
    Adds an output channel to this element object and returns the resulting Bric::Biz::OutputChannel::Element object. Can pass in either an output channel object or an output channel ID.

    Throws: NONE.

    Side Effects: If a Bric::Biz::OutputChannel object is passed in as the first argument, it will be converted into a Bric::Biz::OutputChannel::Element object.

    Notes: NONE.

$element = $element->add_output_channels([$output_channels])
    This accepts an array reference of output channel objects to be associated with this asset type.

    Throws: NONE.

    Side Effects: Any Bric::Biz::OutputChannel objects passed in will be converted into Bric::Biz::OutputChannel::Element objects.

    Notes: NONE.

$element = $element->delete_output_channels([$output_channels])
    This takes an array reference of output channels and removes their association from the object.

    Throws:

    *   Cannot delete a primary output channel.

    Side Effects: NONE.

    Notes: NONE.

($site_list || @site_list) = $element->get_sites;
($site_list || @site_list) = $element->get_sites(@site_ids);
    This returns a list of sites that have been associated with this asset type. If @site_ids is passed, then only the sites with those IDs are returned, if they're associated with this asset type.

    Throws: NONE.

    Side Effects: NONE.

    Notes: The objects returned will be Bric::Biz::Site objects, and these objects contain extra information relevant to the assocation between each output channel and this element object.

my $site = $element->add_site($site)
my $site = $element->add_site($site_id)
    Adds a site to this element object and returns the resulting Bric::Biz::Site object. Can pass in either an site object or a site ID.

    Throws:

    *   You can only add sites to top level objects

    *   Cannot add sites to non top-level elements.

    *   No such site.

    Side Effects: NONE.

    Notes: NONE.

my $site = $element->add_sites([$site])
my $site = $element->add_sites([$site_id])
    Adds a site to this element object and returns the Bric::Biz::AssetType object. Can pass in multiple site objects or site IDs.

    Throws:

    *   You can only add sites to top level objects

    *   Couldn't find site

    Side Effects: NONE.

    Notes: NONE.

$element = $element->remove_sites([$sites])
    This takes an array reference of sites and removes their association from the object.

    Throws:

    *   Cannot remove last site from an element.

    Side Effects: Also disassociates any output channels for the site that are associated with this element.

    Notes: NONE.

($part_list || @part_list) = $element->get_data()
    This will return a list of the fields and containers that make up this asset type

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    The parts returned here may not have their parent IDs or order set if this object has not been saved yet.

$element = $element->add_data([$field])
    This takes a list of fields and associates them with the element object

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->new_data($param)
    Adds a new data point, creating a new Bric::Biz::AssetType::Parts::Data object. The keys to $param are the same as the keys for the hash ref passed to Bric::Biz::AssetType::Parts::Data::new.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->copy_data($param)
    Copy the definition for a data field from another asset type. Keys for $param are:

    *   at

        An existing asset type object

    *   field_name

        A field name defined within the object passed with 'at'

    *   field_obj

        A field object. Can be given in lieu of 'at' and 'field_name'.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->del_data( [ $field || $container ])
    This will take a list of parts and will disassociate them from the story type.

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

$element = $element->add_containers([$at]);
    Add AssetTypes to be contained by this AssetType.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

(@at_list || $at_list) = $element->get_containers();
    Return all contained AssetTypes.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->del_containers([$at]);
    Release an AssetType from its servitude to this AssetType. The AssetType itself will not be deleted. It will simply not be associated with this AssetType any more.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

($element || 0) = $element->is_repeatable($at_container);
$element        = $element->make_repeatable($at_container);
$element        = $element->make_nonrepeatable($at_container);
    Get/Set the repeatable flag for a contained AssetType. Note that this repeatability only applies to this AssetTypes relation to the contained AssetType.

    Throws: NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->is_active()
    Return the active flag.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->activate()
    This will set the active flag to one for the object

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->deactivate()
    This will set the active flag to undef for the asset type

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

(undef || 1) $element->get_active()
    This will return undef if the element has been deactivated and one otherwise

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$element = $element->save()
    This will save all of the changes to the database

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

PRIVATE

  Private Class Methods

_do_list
    called from list and list ids this will query the db and return either ids or objects

    Throws: NONE

    Side Effects: NONE

    Notes: NONE

  Private Instance Methods
These need documenting.

_is_referenced
(undef || $self) = $field->$remove
    Removes this object completely from the DB. Returns 1 if active or undef otherwise

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

_get_attr_obj
_get_at_type_obj
_save_attr
_get_asset_type_grp
_sync_parts
$self = $self->_update_asset_type();
    Update values in the element table.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$self = $self->_insert_asset_type
    Insert new values into the element table.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

$self = $self->_get_parts
    Call the list function of Bric::Biz::AssetType::Parts::Container to return a list of conainer parts of this AssetType object, or return the existing parts if weve already loaded them.

    Throws:

    NONE

    Side Effects:

    NONE

    Notes:

    NONE

  Private Functions

my $oc_coll = $get_oc_coll->($self)
    Returns the collection of output channels for this element. The collection is a Bric::Util::Coll::OCElement object. See that class and its parent, Bric::Util::Coll, for interface details.

    Throws:

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

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

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

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

    Side Effects: NONE.

    Notes: NONE.

my $site_coll = $get_site_coll->($self)
    Returns the collection of sites for this element. The collection is a Bric::Util::Coll::Site object. See that class and its parent, Bric::Util::Coll, for interface details.

    Throws:

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

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

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

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

    Side Effects: NONE.

    Notes: NONE.

my $key_name = $make_key_name->($name)
    Takes an element name and turns it into the key name. This is the name that will be used in templates and in the super bulk edit interface.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

NOTES
NONE.

AUTHOR
michael soderstrom <miraso@pacbell.net>

SEE ALSO
Bric, Bric::Biz::Asset, Bric::Util::Coll::OCElement.