NAME

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

VERSION

$Revision: 1.34.2.6 $

DATE

$Date: 2003/08/14 20:33:44 $

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);
$oc_id = $element->get_primary_oc_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 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
description
primary_oc_id
reference

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

$element = Bric::Biz::AssetType->lookup({ id => $id })
$element = Bric::Biz::AssetType->lookup({ name => $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 $name is not found in the database, lookup() returns undef.

Throws:

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.

description

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

output_channel

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)

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_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 )

This will set the primary output channel id field for the asset type

Throws: NONE

Side Effects: NONE

Notes: NONE

$primary_oc_id = $element->get_primary_oc_id()

This will return the primary output channel id field for the asset type

Throws: NONE

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: NONE.

Side Effects: NONE.

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:

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:

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.