EPrints Technical Mailing List Archive

Message: #03966

< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Populating Eprints Repository with data from an OAI Data Provider


	I would strongly recommend against using SQL to write directly to the database.  Using the EPrints API is the best way to do this, and you can read more about that on the wiki (e.g. http://wiki.eprints.org/w/Core_API#DataObj ).  Your code would look something like this:

sub create_eprint_record
	my ($repository, $oai_data) = @_;
	#$oai_data is a hashref of fields that have been harvested via OAI for a single record

	my $oai_data = get_oai_reco
	my $data = {};

	$data->{title} = $oai_data->{Title};

	#map the type from the harvester to the type in EPrints
	my $type_map = {
		'oai_type_1' => 'eprints_type_1',
		'oai_type_1' => 'eprints_type_2',
		'etc' => 'etc',
	$data->{type} = 'article'; #default type
	if ($type_map->{$oai_data->{'Material Type'}})
		$data->{type} = $type_map->{$oai_data->{'Material Type'}};

	#more mapping

	#now that $data is complete, convert it into an eprint
	my $eprint = $repository->dataset('eprint')->create_dataobj($data);

	return $eprint;

Note that this was just typed directly into my email, so is almost certainly not correct, but should get you started on writing your own function.

Best Wishes

Adam Field
Business Relationship Manager and Community Lead
EPrints Services

On 19 Feb 2015, at 12:39, Admire Mutsikiwa wrote:

> Hi
> I am in the process of implementing an OAI Service Provider ( Harvester) using the  Net::OAI::Harvester. I have managed to harvest from the data provider the following metadata:
> Title,
> Author,
> Material Type,
> Item URL ,
> Date of Last Modification,
> Language,
> Keywords,
> Descriptions,
> item oai_identifier
> I would appreciate the mapping that should be done to EPrints tables to create a complete item record in EPrints.  An SQL statement would be most appropriate.
> Kind Regards,
> Admire Mutsikiwa (Mr)
> ICT Manager
> Libraries
> University of Zimbabwe
> Tel:+263-4-303276
> Mob:+263782476883
> “It is easy to dodge our responsibilities, but we cannot dodge the consequences of dodging our responsibilities.”  Josiah Charles Stamp
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/