NAME

Net::OAI::ORE::Model - Module for model component of an OAI-ORE Resource Map

SYNOPSIS

In essence, the model is simply a set of triples and we thus store them in a triple store provided by RDF::Core::Model, RDF::Core::Storage etc..

METHODS

CREATION AND MODIFICATION

Net::OAI::ORE::Model->new(%args) or Net::OAI::ORE::Model->new($rdf_model)

Create new relationships object as part of a resource map.

If supplied with a single argument that is a RDF::Core::Model then that object is blessed into this class an returned. Otherwise a new RDF::Core::Model object is created and any %args are passed to the creator.

$model->add($model_or_statement)

Add either another model object or a single statement to this $model. Returns the number of statements added.

$model->add_rel_to_resource($subject,$predicate,$object)

Add relationship where the object is a resource (URI).

$model->add_rel_to_literal($subject,$predicate,$object)

Add relationship where the object is a literal.

$model->count()

Returns the number of statements or relationships.

$model->as_array()

Return an array reference to all triples each as a four element array with [subject, predicate, object, object_is_literal] for each statement.

FIXME - should perhaps implement iterator or similar...

$model->objects_matching($subject,$predicate,$only)

Return an array of objects from triples where the subject and predicate are as specified. Will return an empty array if there are no matches.

If $only is not specified then the objects matching will be returned.

If $only is RESOURCE then only resource labels will be included, if LITERAL then only literal labels will be returned.

$model->literal_matching($subject,$predicate)

Wrapper around objects_matching to get the first literal matching the specified condition, else retursn undef. Ignores any other matches.

VALIDATION

$model->check_model($uri_rem,$rem)

Take an RDF model of type RDF::Core::Model in $self and a Resource Map URI $uri_rem. Attempt to parse/interpret it as a resource map. Will croak if parsing fails so usual call would be to wrap in an eval:

eval {
  $model->check_model($uri_rem,$rem);
};
if ($@) {
  # oops
}

If $rem is supplied then this is expected to be a Net::OAI::ORE::ReM object with methods uri(), aggregation(), creator() and timestamp_as_iso8601() which are used to set these values for easy reference.

The requirements are based mainly on the table given in http://www.openarchives.org/ore/1.0/datamodel#Constraints.

$model->creators($uri)

Find all the CREATOR objects (resources or literals) for $uri.

$model->get_timestamp($uri_rem,$throw_error)

Return timestamp literal associated with $uri_rem. There must be just one otherwise nothing (error) will be returned.

$model->err($level,$msg)

Error handling. Will use similar error method of $self->{errobj} if that is set. Otherwise handles here.

INTROSPECTION

These routines support examination of the model to pull out key reference points and information such as the Resource Map URI or the Aggregation URI.

$model->find_rem

Attempt to find the Resource Map. Returns the appropriate Resource object if successful, nothing otherwise.

$model->find_rem_uri(%opts)

Wrapper around $model->find_rem that returns a URI on success, nothing otherwise.

$model->find_aggregation(%opts)

Find the Aggregation in this Resource Map. Returns the appropriate Resource object if successful, nothing otherwise.

Valid options are:

uri_rem -> Resurce Map URI,

$model->find_aggregation_uri(%opts)

Wrapper around $model->find_aggregation that returns a URI on success, nothing otherwise.

DATA DUMP

These are low-level data dump methods. It is expected that normally the methods provided via Net::OAI::ORE::ReM::serialize will be used.

$model->as_n3($unsorted)

Very simple dump of this object as N3. No prefixes are used and the triples are sorted alphabetically by line unless $unsorted is set true (in which case the output will be essentially random).

See Net::OAI::ORE::N3 for "pretty printing" methods.

$model->as_rdfxml

Simple RDF XML dump, returns string. For more sophisticated output see Net::OAI::ORE::RDFXML.

SEE ALSO

Net::OAI::ORE::ReM

AUTHOR

Simeon Warner

LICENSE AND COPYRIGHT

Copyright 2007-2010 Simeon Warner.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.