NAME

SIAM::Driver::Simple - a reference implementation of SIAM Driver

SYNOPSIS

The driver does not connect to any external databases. Instead, it reads all the SIAM objects from its YAML data file.

The top level element in the data file is expected to be an array of objects that are contained in the SIAM root. The following object classes are expected to be contained by the root object:

  • SIAM::Contract

  • SIAM::AccessScope

  • SIAM::User

Each object definition may have an entry with the key _contains_ which points to an array of contained objects. For example, an SIAM::Contract object is expected to contain one or more SIAM::Service objects.

All other keys in the object entry define the object attributes. The values are expected to be strings and numbers. The data file should define all the attributes, including siam.object.id and siam.object.class.

See the file t/driver-simple.data.yaml in SIAM package distribution for reference.

MANDATORY METHODS

The following methods are required by SIAM::Documentation::DriverSpec.

new

Instantiates a new driver object. The method expects a driver object and a hash reference containing the attributes, as follows:

  • datafile

    Full path of the YAML data file which defines all the objects for this driver.

  • logger

    Logger configuration as specified in Log::Handler description.

connect

Reads the YAML data file

disconnect

Disconnects the driver from its underlying databases.

fetch_attributes

$status = $driver->fetch_attributes($attrs);

Retrieve the object by ID and populate the hash with object attributes.

fetch_computable

$value = $driver->fetch_computable($id, $key);

Retrieve a computable. Return empty string if unsupported.

fetch_contained_object_ids

$ids = $driver->fetch_contained_object_ids($id, 'SIAM::Contract', {
    'match_attribute' => [ 'siam.object.access_scope_id',
                           ['SCOPEID01', 'SCOPEID02'] ]
   }
  );

Retrieve the contained object IDs.

fetch_contained_classes

$classes = $driver->fetch_contained_classes($id);

Returns arrayref with class names.

fetch_container

$attr = $driver->fetch_container($id);

Retrieve the container ID and class.

fetch_object_ids_by_attribute

$list = $driver->fetch_object_ids_by_attribute($classname, $attr, $value);

Returns a list of object IDs which match the attribute value.

set_condition

The method does nothing in this driver, but only issues a debug message.

errmsg

Returns the last error message.

ADDITIONAL METHODS

The following methods are not in the Specification.

debug

Prints a debug message to the logger

error

Prints an error message to the logger. Also saves the message for errmsg();

clone_data

SIAM::Driver::Simple->clone_data($siam, $fh,
                                 {'SIAM::Contract' => 'CTRT000[12]'});

The method takes a SIAM object, a write file handle, and optional hashref with filters. The method walks through the SIAM data and produces a YAML data file suitable for use by SIAM::Driver::Simple. The method is usable for producing a test data out of productive system.

The third argument, if present, defines regular expressions to filter the object IDs. Keys are object classes, and values are regular expressions which would be matched against object IDs.

SEE ALSO

SIAM::Documentation::DriverSpec, YAML, Log::Handler