[development] The state of import export
Roman Chyla
roman.chyla at gmail.com
Fri Jan 25 16:03:29 UTC 2008
hi,
do you think something along these lines would be possible?
It is a batch script to import documents, to create objects in
Eprints. In drupal, there would be probably node, user, comment...
paralels.
#!/usr/bin/perl -w -I/usr/share/eprints3/perl_lib
# Deposit an eprint in the repository
use EPrints;
use strict;
# Start session
my $session = new EPrints::Session( 1, "et" );
exit( 0 ) unless( defined $session );
# Get archive dataset
my $dataset = $session->get_repository->get_dataset( "archive" );
# Create new eprint
my $eprint = EPrints::DataObj::EPrint::create( $session, $dataset );
$eprint->set_value( "title", "Hello World" );
$eprint->set_value( "creators_name",
[
{ family=>"Smith", given=>"John" },
{ family=>"Jones", given=>"Mary" },
] );
$eprint->set_value( "date", "2005-02-02" );
$eprint->set_value( "type", "article" );
$eprint->commit();
# Add document to eprint
my $pdf;
my $filename = "demo.pdf";
if( open( $pdf, $filename ) )
{
my $doc = EPrints::DataObj::Document::create( $session, $eprint );
$doc->set_value( "format", "application/pdf" );
$doc->upload( $pdf, "paper.pdf" );
close $pdf;
$doc->set_value( "main", "paper.pdf" );
$doc->commit;
}
else
{
print STDERR "Failed to open file: $filename: $!\n";
print STDERR "Did not create document.\n";
}
# Generate abstract page for new eprint
$eprint->generate_static;
print "Created EPrint #" . $eprint->get_id . "\n";
# End session
$session->terminate();
On Jan 25, 2008 4:07 PM, Moshe Weitzman <weitzman at tejasa.com> wrote:
> my .02 is that importexportapi tried to solve the full range of issues
> associated with data migration and crumbled under the weight of such a
> task. i would recommend putting effort into node_import or feed api.
>
> a firm which specializes in data migration into drupal is a *really* good idea.
>
> -moshe
>
More information about the development
mailing list