Bric::Util::AlertType::Parts::Rule - Interface to AlertType Rules. $LastChangedRevision$ $LastChangedDate: 2006-03-18 01:26:34 +0100 (Sat, 18 Mar 2006) $ use Bric::Util::AlertType::Parts::Rule; # Constructors. my $rule = Bric::Util::AlertType::Parts::Rule->new($init); $rule = Bric::Util::AlertType::Parts::Rule->lookup({ id => 1 }); my @rules = Bric::Util::AlertType::Parts::Rule->list($params); my $rules_href = Bric::Util::AlertType::Parts::Rule->href($params); # Class Methods. my @rule_ids = Bric::Util::AlertType::Parts::Rule->list_ids($params); # Instance Methods. my $id = $rule->get_id; my $at_id = $rule->get_at_id; my $attr = $rule->get_attr; $rule = $rule->set_attr($attr); my $operator = $rule->get_operator; $rule = $rule->set_operator($operator); my $value = $rule->get_value; $rule = $rule->set_value($value); $rule->save; Bric::Util::AlertType::Parts::Rule objects are strictly associated with Bric::Util::AlertType objects. They constitute the rules which must evaluate to true in order for an alert of that type to be sent. See Bric::Util::AlertType for more information.

Constructors
Instantiates a Bric::Util::AlertType::Parts::Rule object. An anonymous hash of initial values may be passed. The supported initial value keys are: alert_type_id attr operator value Call $rule->save() to save the new object. Throws: Incorrect number of args to Bric::_set(). Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Looks up and instantiates a new Bric::Util::AlertType::Parts::Rule object based on the Bric::Util::AlertType::Parts::Rule object ID passed. If $id is not found in the database, lookup() returns undef. Throws: Too many Bric::Util::AlertType::Parts::Rule objects found. 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::Util::AlertType::Parts::Rule object with data from the database before returning it. Notes: NONE. Returns a list or anonymous array of Bric::Util::AlertType::Parts::Rule objects based on the search parameters passed via an anonymous hash. The supported lookup keys are: AlertType Rule ID. May use "ANY" for a list of possible values. A Bric::Util::AlertType ID. May use "ANY" for a list of possible values. Attribute against which a rule matches. May use "ANY" for a list of possible values. Operator used to compare attributes to values. May use "ANY" for a list of possible values. Value to compare against event and object attributes. 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: Populates each Bric::Util::AlertType::Parts::Rule object with data from the database before returning them all. Notes: NONE. Works the same as list(), with the same arguments, except it returns a hash or hashref of Bric::Util::AlertType::Parts::Rule objects, where the keys are the contact IDs, and the values are the contact objects. 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::Util::AlertType::Parts::Rule object with data from the database before returning them all. 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 "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: The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned. The display name of the property or attribute. A reference to the method that will retrieve the value of the property or attribute. An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute. A reference to the method that will set the value of the property or attribute. An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute. The type of value the property or attribute contains. There are only three types: If the value is a 'short' value, this hash key contains the length of the field. The property is searchable via the list() and list_ids() methods. The property or attribute is required. An anonymous hash of properties used to display the property or attribute. Possible keys include: The display field type. Possible values are The Length, in letters, to display a text or password field. The maximum length of the property or value - usually defined by the SQL DDL. The number of rows to format in a textarea field. The number of columns to format in a textarea field. 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.

Destructors
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::Util::AlertType::Parts::Rule object IDs based on the search parameters 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.

Public Instance Methods
Returns the ID of the Bric::Util::AlertType::Parts::Rule 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::Util::AlertType::Parts::Rule 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. Returns the ID of the Bric::Util::AlertType object to which this rule belongs. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'alert_type_id' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the name of the attribute or property to be retreived by the method returned by get_meth(). Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'attr' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the name of the attribute or property to be retrieved by the method returned by get_meth(). Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: WRITE access for field 'attr' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the operator that will compare the value specifed via $rule->set_value() to the value returned from the event on which the alert is based. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'operator' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the operator that will compare the value specifed via $rule->set_value() to the value returned from the event on which the alert is based. Acceptable values are only 'eq', 'ne', 'gt', 'lt', 'ge', 'le', '=~', and '!~'. Any other values will trigger a fatal error. Throws: Incorrect number of args to Bric::_set(). Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns the value for the rule. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'value' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the value for the rule. This value must match the value from the event or the object on which the event is based--as returned a call to the method returned from get_meth()--in order for the alert to be sent. Currently, any value can be put in here, but there must be an exact, case-senstive match in order for the evaluation to return true. Only short and date datatypes will be supported, though either will be stored in the database in a short datafield [VARCHAR2(256)] for this rule. If the value is a date, be sure that $is_date is true. Supply dates in ISO-8601 format; use Bric::Util::Time::local_date() to ensure proper formatting of dates. Throws: Incorrect number of args to Bric::_set(). Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Deletes the rule. Be sure to call $rul->save to delete it from the database. Throws: Incorrect number of args to Bric::_set(). Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Saves any changes to the Bric::Util::AlertType::Parts::Rule 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 Class Methods
NONE.

Private Instance Methods
NONE.

Private Functions
Function used by lookup() and list() to return a list of Bric::Util::AlertType::Parts::Rule objects or, if called with an optional third argument, returns a listof Bric::Util::AlertType::Parts::Rule object IDs (used by list_ids()). Throws: 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. NONE. David Wheeler <david@justatheory.com> Bric, Bric::Util::AlertType, Bric::Util::Event