⧼vector-jumptocontent⧽

API:EPrints/Plugin/Import: Difference between revisions

From EPrints Documentation
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 17: Line 17:
===new===
===new===


<source lang="perl">$plugin = EPrints::Plugin::Import->new( %opts )
<source lang="perl">$plugin = EPrints::Plugin::Import->new( %params )


</source>
</source>
Create a new Import plugin. Available options:
Creates a new Import plugin. In addition to those parameters defined by [[API:EPrints/Plugin|EPrints::Plugin]]:


* accept
* accept
*: Array reference of acceptable MIME types.
: Array reference of acceptable MIME types. By default includes '''application/x-eprints-import-XXX''', where <em>XXX</em> is the case-insensitive id of the plugin.


* actions
* actions
*: Array reference of named actions.
: Array reference of named actions.


* advertise
* advertise
*: Boolean for whether to advertise this plugin to users.
: Boolean for whether to advertise this plugin to users.


* arguments
* arguments
*: Hash reference of supported arguments/default values.
: Hash reference of supported arguments/default values.


* Handler
* Handler
*: Reference to a handler class, typically [[API:EPrints/CLIProcessor|EPrints::CLIProcessor]] or [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].
: Reference to a handler class, typically [[API:EPrints/CLIProcessor|EPrints::CLIProcessor]] or [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].


* produce
* produce
*: Array reference of eprint types this plugin can produce.
: Array reference of object types this plugin can produce.


* screen
* screen
*: The screen id this plugin uses to provide its import UI.
: The screen id this plugin uses to provide its import UI.


* visible
* visible
*: "staff" (staff only) or "all" (anyone).
: "staff" (staff only) or "all" (anyone).
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_handler -->
===handler===
 
<source lang="perl">$handler = $plugin->handler()
 
</source>
Returns the Handler object, which is used for messages and object creation.
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_set_handler -->
===set_handler===
 
<source lang="perl">$plugin->set_handler( $handler )
 
</source>
Set the handler object.
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_can_input -->
===can_input===
 
<source lang="perl">$ok = $plugin->can_input( TYPE )
 
</source>
Supports user input via:
 
* textarea
: Paste into a text area.
 
* file
: Upload a file.
 
* form
: Calls $plugin-&gt;render_input_form() to render an input form.


<!-- Edit below this comment -->
<!-- Edit below this comment -->
Line 56: Line 101:


</source>
</source>
Import one or more objects from filehandle FILEHANDLE. FILEHANDLE should be set to binary semantics.
Import one or more objects from '''FILEHANDLE'''. '''FILEHANDLE''' should be set to binary semantics using {{API:PodLink|file=perlfunc|package_name=perlfunc|section=binmode|text=perlfunc/binmode}}.


This method should by subclassed.
This method should by subclassed.
Line 70: Line 115:


</source>
</source>
Opens FILENAME for reading, sets binary semantics and calls input_fh to actually read the file.
Opens '''FILENAME''' for reading, sets binary semantics and calls [[API:EPrints/Plugin/Import#input_fh|input_fh]] to actually read the file.


This method may be subclassed (e.g. see [[API:EPrints/Plugin/Import/TextFile|EPrints::Plugin::Import::TextFile]]).
This method may be subclassed (e.g. see [[API:EPrints/Plugin/Import/TextFile|EPrints::Plugin::Import::TextFile]]).
Line 84: Line 129:


</source>
</source>
Turn $epdata into a [[API:EPrints/DataObj|EPrints::DataObj]] with the dataset passed in %opts.
Turn '''$epdata''' into a [[API:EPrints/DataObj|EPrints::DataObj]] using the [[API:EPrints/DataSet|dataset]] argument passed in %opts.
 
Uses the [[API:EPrints/Plugin/Import#handler|handler]] object to perform the actual object creation.
 
When sub-classing you '''must''' call [[API:EPrints/Plugin/Import#epdata_to_dataobj|epdata_to_dataobj]] in order to correctly handle the parse-only and test phases during import.
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_warning -->
===warning===
 
<source lang="perl">$plugin->warning( $text )
 
</source>
Generate a warning message using '''$text'''.
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_error -->
===error===
 
<source lang="perl">$plugin->error( $text )
 
</source>
Generate an error message using '''$text'''.


Calls handler to perform the actual creation.
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_is_tool -->
===is_tool===
 
<source lang="perl">$bool = $plugin->is_tool()
 
</source>
Returns true if this plugin is a tool that should be rendered as a link.


<!-- Edit below this comment -->
<!-- Edit below this comment -->
Line 94: Line 177:
<!-- Pod2Wiki=head_copyright -->
<!-- Pod2Wiki=head_copyright -->
==COPYRIGHT==
==COPYRIGHT==
: Copyright 2000-2011 University of Southampton.
Copyright 2000-2012 University of Southampton.


: This file is part of EPrints http://www.eprints.org/.
This file is part of EPrints http://www.eprints.org/.


: EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.


: EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.


: You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.


<!-- Edit below this comment -->
<!-- Edit below this comment -->

Latest revision as of 09:56, 22 January 2013

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Plugin::Import


METHODS

new

$plugin = EPrints::Plugin::Import->new( %params )

Creates a new Import plugin. In addition to those parameters defined by EPrints::Plugin:

  • accept
Array reference of acceptable MIME types. By default includes application/x-eprints-import-XXX, where XXX is the case-insensitive id of the plugin.
  • actions
Array reference of named actions.
  • advertise
Boolean for whether to advertise this plugin to users.
  • arguments
Hash reference of supported arguments/default values.
  • Handler
Reference to a handler class, typically EPrints::CLIProcessor or EPrints::ScreenProcessor.
  • produce
Array reference of object types this plugin can produce.
  • screen
The screen id this plugin uses to provide its import UI.
  • visible
"staff" (staff only) or "all" (anyone).


handler

$handler = $plugin->handler()

Returns the Handler object, which is used for messages and object creation.


set_handler

$plugin->set_handler( $handler )

Set the handler object.


can_input

$ok = $plugin->can_input( TYPE )

Supports user input via:

  • textarea
Paste into a text area.
  • file
Upload a file.
  • form
Calls $plugin->render_input_form() to render an input form.


input_fh

$plugin->input_fh( fh => FILEHANDLE [, %opts] )

Import one or more objects from FILEHANDLE. FILEHANDLE should be set to binary semantics using perlfunc/binmode.

This method should by subclassed.


input_file

$plugin->input_file( filename => FILENAME [, %opts] )

Opens FILENAME for reading, sets binary semantics and calls input_fh to actually read the file.

This method may be subclassed (e.g. see EPrints::Plugin::Import::TextFile).


epdata_to_dataobj

$dataobj = $plugin->epdata_to_dataobj( $epdata, %opts )

Turn $epdata into a EPrints::DataObj using the dataset argument passed in %opts.

Uses the handler object to perform the actual object creation.

When sub-classing you must call epdata_to_dataobj in order to correctly handle the parse-only and test phases during import.


warning

$plugin->warning( $text )

Generate a warning message using $text.


error

$plugin->error( $text )

Generate an error message using $text.


is_tool

$bool = $plugin->is_tool()

Returns true if this plugin is a tool that should be rendered as a link.


COPYRIGHT

Copyright 2000-2012 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.