The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

M3::ServerView::View - Base class for views

DESCRIPTION

This class serves as a base class for 'views'. A view is a page in the web-interface which contains a set of data we want to be able to access and search.

INTERFACE

CLASS METHODS

new ( CONNECTION, URL )

Creates a new view which maps to given URL.

INSTANCE METHODS

connection

Returns the M3::ServerView-instance that was used to retrieve the view with.

reload

Reloads the data for the view from the server.

response_time

Returns the number of seconds it took to get the reply from the server.

request_time

The date and time in ISO 8601 format when the request was made.

search ( [QUERY [, OPTIONS ]] )

Performs a search of the data and returns a M3::ServerView::ResultSet-instance.

QUERY FORMAT

If QUERY is specified it must be a hash reference. Each key is a name of an attribute in the entry which must exist or the match will fail. The value should either be a scalar which will be compared with the entries value for the attribute using either == or eq depending on whether it's numerical or not. More complex comparisions can be declared by passing an array reference as value where the first element is an comparison operator and the second element the value to compare with. The following comparisions can be defined

== != < > <= >= - Numerical equals, not equals, less than, greater than, less or equal than, greater or equal than

eq ne lt gt le ge - Same as above but string equivalents

like - Regular expression comparision

Examples

  # Find all entries who's status is down
  $rs = $view->search({ status => 'down' });
  
  # Find all entries with more than 20 threads and order by threads descending
  $rs = $view->search({ 
    threads => [ '>' => 20] 
  }, { 
    order_by => 'threads', 
    sort_order => 'desc',
  });
  
  # Find all entries whose type begins with "Sub:A"
  $rs = $view->search({ type => [ 'like' => '^Sub:A' ]});

OPTIONS

Specifiying options the the search is possible by passing a hash reference. The following options valid:

case_sensitive = 1 | 0

Sets if comparision should be case_insensitive or not. Defaults to true.

order_by = attribute

Sets the name of the attribute to sort by.

sort_order = "asc" | "desc"

Sets the order of the search. Defaults to "asc".

sort_as = "text" | "numerical"

Sets the if the sort should be considered numerical or not. In numerical mode (1, 55, 7) sortes as (1, 7, 55) while in text mode it sorts as (1, 55, 7).