View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Eric Lease Morgan > MyLibrary-3.0.4 > MyLibrary::Facet



Annotate this POD

View/Report Bugs




        # require the necessary module
        use MyLibrary::Facet;

        # create a new Facet object
        my $facet = MyLibrary::Facet->new();

        # set attributes of facet object
        $facet->facet_name('Facet Name');
        $facet->facet_note('This is a facet note');

        # delete a facet note

        # commit facet to database

        # delete facet from database

        # get all facets
        my @facets = MyLibrary::Facet->get_facets();
        my @facets = MyLibrary::Facet->get_facets(sort => 'name');

        # get specific facets based on criteria
        my @facets = MyLibrary::Facet->get_facets(value => 'Discipline', field => 'name');

        # return related terms
        my @related_terms = $facet->related_terms();

        # return a sorted list of related terms
        my @related_terms = $facet->related_terms(sort => 'name');


The purpose of this module is to manipulate MyLibrary Facet objects and perform database I/O against the facets table of a MyLibrary database. You may also retrieve a list of facet objects by using a special class method. A list of term ids with which a particular facet is associated can be retrieved as well and manipulated independently. All changes to either the facet descriptive data can be commited to the database.



This method creates a new facet object. Called with no input, this constructor will return a new, empty facet object:

        # create empty facet
        $facet = MyLibrary::Facet->new();

The constructor can also be called using a known facet id or facet name:

        # create a facet object using a known facet id
        $facet = MyLibrary::Facet->new(id => $id);

        # create a facet object using a known facet name
        $facet = MyLibrary::Facet->new(name => 'Disciplines');


This object method is used to retrieve the facet id of the current facet object. This method cannot be used to set the facet id.

        # get facet id
        my $facet_id = $facet->facet_id();


This is an attribute method which allows you to either get or set the name attribute of a facet. The names for facets will be created by the institutional team tasked with the responsibility of designating the broad categories under which resources will be categorized. To retrieve the name attribute:

        # get the facet name

        # set the facet name


This method allows one to either retrieve or set the facet descriptive note.

To retrieve the note attribute:

        # get the facet note

        # set the facet note
        $facet->facet_note('The subject area under which a resource may be classified.');


This object attribute method allows the removal of the facet note

        # delete the facet note


Use this method to commit the facet in memory to the database. Any updates made to facet attributes will be saved and new facets created will be saved. This method does not take any parameters.

        # commit the facet

A numeric code will be returned upon successfull completion of the operation. A return code of 1 indicates a successful commit. Otherwise, the method will cease program execution and die with an appropriate error message.


Use this method to remove a facet record from the database. The record will be deleted permanently.

        # delete the facet


This method can be used to retrieve a list of all of the facets currently in the database. Individual facet objects will be created and can be cycled through. This is a class method, not an object method. If the sort parameter is supplied, the list of facet ids will be sorted. Currently, the list can only be sorted by facet name. A specific list of facets can also be queried for by using the field and value parameters. Searchable fields are name and description. Examples are demonstrated below.

        # get all facets
        my @facets = MyLibrary::Facet->get_facets();

        # sort the returned list
        my @facets = MyLibrary::Facet->get_facets(sort => 'name');

        # find all facets based on criteria
        my @facets = MyLibrary::Facet->get_facets(value => 'Discpline', field => 'name');


This method should be used to return an array (a list) of term ids to which this facet is related. It requires no parameter input. If the facet is not related to any terms in the database, the method will return undef. The array of term ids can then be used to process the list of related terms. The returned list of term ids can also be sorted. This is an object method.

        # return related terms
        my @related_terms = $facet->related_terms();

        # return sorted list of related terms
        my @related_terms = $facet->related_terms(sort => 'name');


Eric Lease Morgan <> Robert Fox <>

syntax highlighting: