1 # ---------------------------------------------------------------------
2 # Dublin Core helper class
5 # ------------------+--------------------------------------------------
7 # ------------------+----------------------+---------------------------
8 # Department of Computer Science |
9 # -----------------------------------------+-------------+-------------
10 # Ecole Nationale Superieure des Mines de St-Etienne | www.emse.fr
11 # -------------------------------------------------------+-------------
13 =head1 OAI::DC Dublin Core formating helper
15 OAI::DC is an helper class for Dublin Core metadata. As Dublin Core have a well known
16 set of fields, OAI::DC is a subclass of the OAI::DP class and it implements a default
17 behavior to build correct answers. The data references returned by Archive_GetRecord
18 and Archive_ListRecords must be instance providing the following method (they are used
19 to translate your own data to Dublin Core) : Title(), Identifier(), Subject(), Creator(),
20 Date(), Description(), Publisher(), Language() and Type(). The semantic of these methods is
21 the same as the corresponding Dublin Core field.
23 To return correct metadata, you must provide or overide theses methods:
29 =item B<new>: initialization step,
31 =item B<dispose>: clean up step,
33 =item B<Archive_ListSets>: return list of defined sets,
35 =item B<Archive_GetRecord>: return a record,
37 =item B<Archive_ListRecords>: return a list of records,
39 =item B<Archive_ListIdentifiers>: return a list of record identifiers,
49 Object of this method is to build a new instance of your OAI data provider. At this step
50 you can overide somme default information about the repository, you can also initiate
51 connexion to a database... Parameters to the new method are user defined.
59 It's time to disconnect from database (if required). Must explicitly call SUPER::dispose().
63 =head2 Archive_ListSets
67 Return a reference to an array of list set. Each list set is a reference to a two element array.
68 The first element is the set name of the set and the second is its short description.
70 sub Archive_ListSets {
72 [ 'SET1', 'Description of the SET1'],
73 [ 'SET2', 'Description of the SET2'],
79 =head2 Archive_GetRecord
83 This method take a record identifier and metadata format as parameter. It must return a reference to
84 the data associated to identifier. Data are reference to a hash and must provide methodes describe
85 at the begining of DC section.
89 =head2 Archive_ListRecords
93 Object of this method is to return a list of records occording to the user query. Parameters of the method
94 are the set, the from date, the until date, the metadata type required and a resumption token if supported.
96 The method must return a reference to a list of records, the metadata type of the answer and reference to
97 token information. Token information must be undefined or a reference to a hash with the I<completeListSize>
98 and the I<cursor> keys set.
109 @ISA = ("C4::OAI::DP");
114 my ($self, $hashref) = @_;
116 return undef if( $hashref->Status() eq 'deleted' );
119 title => $hashref->Title(),
120 identifier => $hashref->Identifier(),
121 subject => $hashref->Subject(),
122 creator => $hashref->Creator(),
123 date => $hashref->Date(),
124 description => $hashref->Description(),
125 publisher => $hashref->Publisher(),
126 language => $hashref->Language(),
127 type => $hashref->Type(),
128 mdorder => [ qw (title creator subject description contributor publisher date type format identifier source language relation coverage rights) ]
132 # format header for ListIdentifiers
133 sub Archive_FormatHeader
135 my ($self, $hashref, $metadataFormat) = @_;
137 $self->FormatHeader ($hashref->Identifier()->[0] ,
138 $hashref->DateStamp(),
144 # retrieve records from the source archive as required
145 sub Archive_FormatRecord
147 my ($self, $hashref, $metadataFormat) = @_;
149 if ($self->MetadataFormatisValid ($metadataFormat) == 0)
151 $self->AddError ('cannotDisseminateFormat', 'The value of metadataPrefix ('.$metadataFormat.') is not supported by the repository');
155 my $dc = $self->FormatDC ($hashref);
156 my $header = "<oaidc:dc xmlns=\"http://purl.org/dc/elements/1.1/\" ".
157 "xmlns:oaidc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" ".
158 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ".
159 "xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/ ".
160 "http://www.openarchives.org/OAI/2.0/oai_dc.xsd\">\n";
161 my $footer = "</oaidc:dc>\n";
164 $metadata = $header . encode("utf8", decode( "iso-8859-1",$self->{'utility'}->FormatXML($dc))) . $footer if( $dc );
166 $self->FormatRecord ($hashref->Identifier()->[0] ,
167 $hashref->DateStamp(),
176 # get full list of mdps or list for specific identifier
177 sub Archive_ListMetadataFormats
179 my ($self, $identifier) = @_;
181 if ((! defined $identifier) || ($identifier eq '')) {
185 $self->AddError ('idDoesNotExist', 'The value of the identifier argument is unknown or illegal in this repository');
191 # get full list of sets from the archive
198 # get a single record from the archive
199 sub Archive_GetRecord
201 my ($self, $identifier, $metadataFormat) = @_;
203 $self->AddError ('idDoesNotExist', 'The value of the identifier argument is unknown or illegal in this repository');
207 # list metadata records from the archive
208 sub Archive_ListRecords
210 my ($self, $set, $from, $until, $metadataPrefix, $resumptionToken) = @_;
211 my $tokenInfo = undef;
213 $self->AddError ('noRecordsMatch', 'The combination of the values of arguments results in an empty set');
214 ( [], $resumptionToken, $metadataPrefix, $tokenInfo );
218 # list identifiers (headers) from the archive
219 sub Archive_ListIdentifiers
221 my ($self, $set, $from, $until, $metadataPrefix, $resumptionToken) = @_;
223 if (($metadataPrefix ne '') && ($self->MetadataFormatisValid ($metadataPrefix) == 0))
225 $self->AddError ('cannotDisseminateFormat', 'The value of metadataPrefix ('.$metadataPrefix.')is not supported by the repository');
229 $self->Archive_ListRecords ($set, $from, $until, $metadataPrefix, $resumptionToken);