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

NAME

PICA::Store - CRUD interface to a PICA::Record storage

VERSION

version 0.585

SYNOPSIS

  use PICA::Store;

  # connect to store via SOAP API (SOAPClient)
  $store = PICA::Store->new( webcat => $baseurl, %params );

  # connect to SQLiteStore
  $store = PICA::Store->new( SQLite => $dbfile, %params );

  # Get connection details from a config file
  $store = PICA::Store->new( config => "myconf.conf" );

  # CRUD operations
  %result = $store->get( $id );
  %result = $store->create( $record );
  %result = $store->update( $id, $record, $version );
  %result = $store->delete( $id );

  # set additional access parameters
  $store->access( userkey => $userkey, password => $passwd );

DESCRIPTION

This class is an abstract class to provide a simple CRUD (create/insert, retrieve/get, update, delete) access to a record store of PICA::Record objects.

See PICA::SQLiteStore and PICA::SOAPClient for specific implementations. Other implementations that may be implemented later include WebDAV, and REST (for instance Jangle).

METHODS

new ( %parameters )

Return a new PICA::Store. You must either specify a parameter named 'webcat' to get a PICA::SOAPClient or a parameter named 'SQLite' to get a PICA::SQLiteStore. Alternatively you can specify a parameter named 'config' that points to a configuration file. If you set this parameter to undef, the file will be searched as environment variable PICASTORE or pica.conf in the current directory.

get ( $id )

Retrieve the latest revision of record by ID. Returns a hash with either 'errorcode' and 'errormessage' or a hash with 'id', 'record' (a PICA::Record object), 'version', and 'timestamp'.

create ( $record )

Insert a new record. The parameter must be a PICA::Record object. Returns a hash with either 'errorcode' and 'errormessage' or a hash with 'id', 'record', 'version', and 'timestamp'.

update ( $id, $record [, $version ] )

Update a record by ID, updated record (of type PICA::Record), and version (of a previous get, create, or update command).

Returns a hash with either 'errorcode' and 'errormessage' or a hash with 'id', 'record', 'version', and 'timestamp'.

delete ( $id )

Delete a record by ID. Returns a hash with either 'errorcode' and 'errormessage' or a hash with 'id'.

access ( key => value ... )

Set general access parameters (userkey, password, dbsid and/or language). Returns the store itself so you can chain anothe method call. By default the parameters are just ignored so any subclass should override this method to make sense of it.

about

Return a string with printable information about this store, for instance a name and/or a base URL.

INTERNAL FUNCTIONS

readconfigfile ( $hashref, $defaultfile )

Expand a hash with config parameters by reading from a config file. The config file may be set in $hashref->{config} or the file $defaultfile or in the file pica.conf in the current directory.

SEE ALSO

This distribution contains the command line client picawebcat based on PICA::Store. See also PICA::SQLiteStore, PICA::SOAPClient, and PICA::SOAPServer.

AUTHOR

Jakob Voß <voss@gbv.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Verbundzentrale Goettingen (VZG) and Jakob Voss.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.