Location. Location. Location.

In the world of realestate the mantra is “Location. Location. Location.” In MyLibrary, locations are pointers to content and services.

Most of us will think of locations as URL’s. Pointers to bibliographic databases, electronic books, electronic journals, mailing list archives, JPEG images, etc. MyLibrary is not limited to storing information about electronic items. It can also be used to describe physical items. Books. Archival material. Journals. Realia. Therefore, the locations for these types of items might be call numbers, box numbers, shelves, or even buildings. Moreover, each item in your collection may have more than one “location”. For example, a bibliograhic index might have a physical form and therefore a call number. It might be Internet-accessible, and therefore it has a URL. It might have an associated and locally-developed set of help texts, and therefore a second URL. An electronic journal might be located at the publisher’s site but also kept in a local mirror. Location. Location. Location.

As a librarian you must decide what types of locations your content requires. You will probably what a location type called “URL”, but you also mightd a location type called “Call number”. When resources are saved to MyLibrary, you will then want to know what the URL’s and call numbers are. No, you don’t have to have both. You can have either/or.

Programatically, the underlying software will need to create location types, accept input regarding resource objects, accept input regarding locations, and associate the them with location types and resource objects.

Here is a simple program that:

  1. creates a location type called URL, if it doesn’t already exist
  2. prompts the user for the title of a resource
  3. prompt the user for a URL
  4. makes the necessary associations
  5. commits the resource object to the database
  6. echos the result
#!/usr/bin/perl

# require mylibrary & practice good programming
use MyLibrary::Core;
use strict;

# define what mylibrary instance to use
MyLibrary::Config->instance( 'mylibrary4blog' );

# define a two scalar constants
use constant LOCATIONNAME => 'URL';
use constant LOCATIONNOTE => 'Internet-accessible resources';

# create a location and/or return a location type id; a cool hack
my $location_type = &make_or_get_location_type( LOCATIONNAME, LOCATIONNOTE );

# get user input
print "Enter information about your resource.n";
print "  Name: "; chop ( my $name = <STDIN> );
print "  Note: "; chop ( my $note = <STDIN> );
print "   URL: "; chop ( my $url  = <STDIN> );

# create a resource object, fill it, and save
my $resource = MyLibrary::Resource->new;
$resource->name( $name );
$resource->note( $note );
$resource->add_location( location => $url, location_type => $location_type );
my $results = $resource->commit;

# check the results
if ( $results == 1 ) {

  # get the resource
  my $resource = MyLibrary::Resource->new( id => $resource->id );

  # echo
  print "n";
  print "The resource was successfully created:n";
  print "     ID = " . $resource->id . "\n";
  print "   Name = " . $resource->name . "\n";
  print "   Note = " . $resource->note . "\n";

  # get all the locations for this resource
  my @locations = $resource->resource_locations;

  # loop through them and display
  for ( my $i = 0; $i <= $#locations; $i++ ) {

    print "    URL = " . $locations[$i]->location . "\n";

  }

  print "\n";

}

# done
exit;

# create a location type and/or return a location type id
sub make_or_get_location_type {

  # get input
  my $name = shift;
  my $note = shift;

  # initialize
  my $location_type;

  # see if it exists
  foreach ( MyLibrary::Resource::Location::Type->all_types ) {

    my $type = MyLibrary::Resource::Location::Type->new( id => $_ );
    if ( $type->name eq $name ) {

      $location_type = $type->location_type_id;
      last;

    }

  }

  # if not, then create it
  if ( ! $location_type ) {

    my $type = MyLibrary::Resource::Location::Type->new;
    $type->name( $name );
    $type->description( $note );
    $type->commit;
    $location_type = $type->location_type_id;

  }

  # done
  return $location_type;

}

After you run the program a few times, you can run the following program. It finds all of your resources and displays their titles and locations.

#!/usr/bin/perl

# require mylibrary & practice good programming
use MyLibrary::Core;
use strict;

# define what mylibrary instance to use
MyLibrary::Config->instance( 'mylibrary4blog' );

# loop through each resource object
foreach my $resource ( MyLibrary::Resource->get_resources ) {

  # echo
  print "        ID: " . $resource->id . "\n";
  print "      Name: " . $resource->name . "\n";
  print "      Note: " . $resource->note . "\n";

  # get all the locations for this resource
  my @locations = $resource->resource_locations;
  for ( my $i = 0; $i <= $#locations; $i++ ) {

    print "  Location: " . $locations[$i]->location . "\n";

  }

  print "\n";

}

# done
exit;

Get creative with locations. If they are URL’s maybe they can be pointers to services. Convert this file into PDF. Email this description to a friend. Pre-populate the ILL form with certain content. Library collections need to include services. “Collections without services are useless. Services without collections are empty.”

Discussion Area - Leave a Comment

You must be logged in to post a comment.