Difference between revisions of "API:EPrints/DataObj"

From EPrints Documentation
Jump to: navigation, search
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost.
+
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{Pod2Wiki}}{{API:Source|file=EPrints/DataObj.pm|package_name=EPrints::DataObj}}[[Category:API|DataObj]]<!-- End of Pod2Wiki -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=perl_lib/EPrints/DataObj.pm|package_name=EPrints::DataObj}}[[Category:API|DATAOBJ]][[Category:API:EPrints/DataObj|DATAOBJ]]<div><!-- Edit below this comment -->
<!-- Pod2Wiki=head_name -->=NAME=
 
'''EPrints::DataObj''' - Base class for records in EPrints.
 
  
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_description -->=DESCRIPTION=
 
This module is a base class which is inherited by [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]], [[API:EPrints/User|EPrints::User]], [[API:EPrints/DataObj/Subject|EPrints::DataObj::Subject]] and [[API:EPrints/DataObj/Document|EPrints::DataObj::Document]] and several other classes.
 
  
It is ABSTRACT - its methods should not be called directly.
+
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 +
==NAME==
 +
'''EPrints::DataObj''' - Base class for records in EPrints.
  
<!-- End of Pod2Wiki -->
+
<!-- Edit below this comment -->
<!-- Pod2Wiki=item_get_system_field_info -->==get_system_field_info==
 
  
  $sys_fields = EPrints::DataObj-&gt;get_system_field_info
 
  
ABSTRACT.
+
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_synopsis -->
 +
==SYNOPSIS==
 +
$dataobj = $dataset-&gt;dataobj( $id );
  
Return an array describing the system metadata of the this  dataset.
+
$dataobj-&gt;delete;
  
<!-- End of Pod2Wiki -->
+
$dataobj-&gt;commit( $force );
<!-- Pod2Wiki=item_new -->==new==
 
  
  $dataobj = EPrints::DataObj-&gt;new( $session, $id, [$dataset] )
+
$dataset = $dataobj-&gt;dataset;
  
ABSTRACT.
+
$repo = $dataobj-&gt;repository;
  
Return new data object, created by loading it from the database.
+
$id = $dataobj-&gt;id;
  
$dataset is used by EPrint-&gt;new to save searching through all four tables that it could be in.
+
$dataobj-&gt;set_value( $fieldname, $value );
  
<!-- End of Pod2Wiki -->
+
$value = $dataobj-&gt;value( $fieldname );
<!-- Pod2Wiki=item_new_from_data -->==new_from_data==
 
  
  $dataobj = EPrints::DataObj-&gt;new_from_data( $session, $data, $dataset )
+
\@value = $dataobj-&gt;value( $fieldname ); # multiple
  
ABSTRACT.
+
$boolean = $dataobj-&gt;is_set( $fieldname );
  
Construct a new EPrints::DataObj object based on the $data hash  reference of metadata.
+
$xhtml = $dataobj-&gt;render_value( $fieldname );
  
Used to create an object from the data retrieved from the database.
+
$xhtml = $dataobj-&gt;render_citation( $style, %opts );
  
<!-- End of Pod2Wiki -->
+
$uri = $dataobj-&gt;uri;
<!-- Pod2Wiki=item_get_defaults -->==get_defaults==
 
  
  $defaults = EPrints::User-&gt;get_defaults( $session, $data )
+
$url = $dataobj-&gt;url;
  
Return default values for this object based on the starting data.
+
$string = $dataobj-&gt;export( $plugin_id, %opts );
  
Should be subclassed.
+
$dataobj = $dataobj-&gt;create_subobject( $fieldname, $epdata );
  
<!-- End of Pod2Wiki -->
+
<!-- Edit below this comment -->
<!-- Pod2Wiki=item_remove -->==remove==
 
  
  $success = $dataobj-&gt;remove
 
  
ABSTRACT
+
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_description -->
 +
==DESCRIPTION==
 +
This module is a base class which is inherited by [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]], [[API:EPrints/DataObj/User|EPrints::DataObj::User]], [[API:EPrints/DataObj/Subject|EPrints::DataObj::Subject]] and [[API:EPrints/DataObj/Document|EPrints::DataObj::Document]] and several other classes.
  
Remove this data object from the database.
+
It is ABSTRACT - its methods should not be called directly.
 
 
Also removes any sub-objects or related files.
 
 
 
Return true if successful.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_clear_changed -->==clear_changed==
 
 
 
  $dataobj-&gt;clear_changed( )
 
 
 
Clear any changed fields, which will result in them not being committed unless force is used.
 
 
 
This method is used by the Database to avoid unnecessary commits.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_commit -->==commit==
 
 
 
  $success = $dataobj-&gt;commit( [$force] )
 
 
 
ABSTRACT.
 
 
 
Write this object to the database.
 
 
 
If $force isn't true then it only actually modifies the database if one or more fields have been changed.
 
 
 
Commit may also log the changes, depending on the type of data  object.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_value -->==get_value==
 
 
 
  $value = $dataobj-&gt;get_value( $fieldname )
 
 
 
Get a the value of a metadata field. If the field is not set then it returns undef unless the field has the property multiple set, in which case it returns  [] (a reference to an empty array).
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_set_value -->==set_value==
 
 
 
  $dataobj-&gt;set_value( $fieldname, $value )
 
 
 
Set the value of the named metadata field in this record.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_values -->==get_values==
 
 
 
  @values = $dataobj-&gt;get_values( $fieldnames )
 
 
 
Returns a list of all the values in this record of all the fields specified by $fieldnames. $fieldnames should be in the format used by browse views - slash seperated fieldnames with an optional .id suffix to indicate the id part rather than the main part.
 
 
 
For example "author.id/editor.id" would return a list of all author and editor ids from this record.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_session -->==get_session==
 
 
 
  $session = $dataobj-&gt;get_session
 
 
 
Returns the EPrints::Session object to which this record belongs.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_data -->==get_data==
 
 
 
  $data = $dataobj-&gt;get_data
 
 
 
Returns a reference to the hash table of all the metadata for this record keyed  by fieldname.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_dataset -->==get_dataset==
 
 
 
  $dataset = $dataobj-&gt;get_dataset
 
 
 
Returns the EPrints::DataSet object to which this record belongs.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_set -->==is_set==
 
 
 
  $bool = $dataobj-&gt;is_set( $fieldname )
 
 
 
Returns true if the named field is set in this record, otherwise false.
 
 
 
Warns if the field does not exist.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_exists_and_set -->==exists_and_set==
 
 
 
  $bool = $dataobj-&gt;exists_and_set( $fieldname )
 
 
 
Returns true if the named field is set in this record, otherwise false.
 
 
 
If the field does not exist, just return false.
 
 
 
This method is useful for plugins which may operate on multiple  repositories, and the fact a field does not exist is not an issue.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_id -->==get_id==
 
 
 
  $id = $dataobj-&gt;get_id
 
 
 
Returns the value of the primary key of this record.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_gid -->==get_gid==
 
 
 
  $id = $dataobj-&gt;get_gid
 
 
 
Returns the globally referential fully-qualified identifier for this object or undef if this object can not be externally referenced.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_value -->==render_value==
 
 
 
  $xhtml = $dataobj-&gt;render_value( $fieldname, [$showall] )
 
 
 
Returns the rendered version of the value of the given field, as appropriate for the current session. If $showall is true then all values are rendered -  this is usually used for staff viewing data.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_citation -->==render_citation==
 
 
 
  $xhtml = $dataobj-&gt;render_citation( [$style], [%params] )
 
 
 
Renders the record as a citation. If $style is set then it uses that citation style from the citations config file. Otherwise $style defaults to the type of this record. If $params{url} is set then the citiation will link to the specified URL.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_citation_link -->==render_citation_link==
 
 
 
  $xhtml = $dataobj-&gt;render_citation_link( [$style], %params )
 
 
 
Renders a citation (as above) but as a link to the URL for this item. For example - the abstract page of an eprint.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_description -->==render_description==
 
 
 
  $xhtml = $dataobj-&gt;render_description
 
 
 
Returns a short description of this object using the default citation style for this dataset.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render -->==render==
 
 
 
  ($xhtml, $title ) = $dataobj-&gt;render
 
 
 
Return a chunk of XHTML DOM describing this object in the normal way. This is the public view of the record, not the staff view.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_full -->==render_full==
 
 
 
  ($xhtml, $title ) = $dataobj-&gt;render_full
 
 
 
Return an XHTML table in DOM describing this record. All values of all fields are listed. This is the staff view.
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_uri -->==uri==
 
  
  $url = $dataobj-&gt;uri
+
<!-- Edit below this comment -->
  
Returns a unique URI for this object. Not certain to resolve as a  URL.
 
  
If $c-&gt;{dataobj_uri}-&gt;{eprint} is a function, call that to work it out.
+
<!-- Pod2Wiki= -->
 +
* $success = $dataobj-&gt;delete
 +
: Delete this data object from the database and any sub-objects or related files.  
  
<!-- End of Pod2Wiki -->
+
: Return true if successful.
<!-- Pod2Wiki=item_get_url -->==get_url==
 
  
  $url = $dataobj-&gt;get_url
+
* $dataobj-&gt;empty()
 +
: Remove all of this object's values that may be imported.
  
Returns the URL for this record, for example the URL of the abstract page of an eprint.
+
* $dataobj-&gt;update( $epdata [, %opts ] )
 +
: Update this object's values from $epdata. Ignores any values that do not exist in the dataset or do not have the 'import' property set.
  
<!-- End of Pod2Wiki -->
+
<pre>  include_subdataobjs - replace sub-dataobjs if given
<!-- Pod2Wiki=item_get_control_url -->==get_control_url==
+
 
 +
  # replaces all documents in $dataobj
 +
  $dataobj->update( {
 +
    title => "Wombats on Fire",
 +
    documents => [{
 +
      main => "wombat.pdf",
 +
      ...
 +
    }],
 +
  }, include_subdataobjs => 1 );</pre>
  
  $url = $dataobj-&gt;get_control_url
+
* $success = $dataobj-&gt;commit( [$force] )
 +
: Write this object to the database and reset the changed fields.
  
Returns the URL for the control page for this object.  
+
: If $force isn't true then it only actually modifies the database if one or more fields have been changed.
  
<!-- End of Pod2Wiki -->
+
: Commit may also queue indexer jobs or log changes, depending on the object.
<!-- Pod2Wiki=item_get_type -->==get_type==
 
  
  $type = $dataobj-&gt;get_type
+
* $value = $dataobj-&gt;value( $fieldname )
 +
: Get a the value of a metadata field. If the field is not set then it returns undef unless the field has the property multiple set, in which case it returns  [] (a reference to an empty array).
  
Returns the type of this record - type of user, type of eprint etc.
+
* $dataobj-&gt;set_value( $fieldname, $value )
 +
: Set the value of the named metadata field in this record.
  
<!-- End of Pod2Wiki -->
+
* @values = $dataobj-&gt;get_values( $fieldnames )
<!-- Pod2Wiki=item_to_xml -->==to_xml==
+
: Returns a list of all the values in this record of all the fields specified by $fieldnames. $fieldnames should be in the format used by browse views - slash seperated fieldnames with an optional .id suffix to indicate the id part rather than the main part.
  
  $xmlfragment = $dataobj-&gt;to_xml( %opts )
+
: For example "author.id/editor.id" would return a list of all author and editor ids from this record.
  
Convert this object into an XML fragment.  
+
* $bool = $dataobj-&gt;is_set( $fieldname )
 +
: Returns true if the named field is set in this record, otherwise false.
  
%opts are:
+
: Warns if the field does not exist.
  
no_xmlns=&gt;1 : do not include a xmlns attribute in the  outer element. (This assumes this chunk appears in a larger tree  where the xmlns is already set correctly.
+
* $bool = $dataobj-&gt;exists_and_set( $fieldname )
 +
: Returns true if the named field is set in this record, otherwise false.
  
showempty=&gt;1 : fields with no value are shown.
+
: If the field does not exist, just return false.
  
version=&gt;"code" : pick what version of the EPrints XML format to use "1" or "2"
+
: This method is useful for plugins which may operate on multiple  repositories, and the fact a field does not exist is not an issue.
  
embed=&gt;1 : include the data of a file, not just it's URL.
+
* $id = $dataobj-&gt;id
 +
: Returns the value of the primary key of this record.
  
<!-- End of Pod2Wiki -->
+
* $uuid = $dataobj-&gt;uuid( [ $fragment ] )
<!-- Pod2Wiki=item_export -->==export==
+
: Generates a version 5 UUID for this object e.g.
  
  $plugin_output = $detaobj-&gt;export( $plugin_id, %params )
+
<pre>  f70ef731-be66-50f4-8e72-8b8de36778b5</pre>
  
Apply an output plugin to this items. Return the results.
+
: The UUID is generated from the SHA1 hash of the concantenation of <code>uuid_namespace</code>, the {{API:PodLink|file=|package_name=|section=internal_uri|text=object's uri}} and, if defined, '''$fragment'''.
  
<!-- End of Pod2Wiki -->
+
: <code>uuid_namespace</code> is a configuration variable. If <code>uuid_namespace</code> is undefined uses <code>base_url</code>:
<!-- Pod2Wiki=item_queue_changes -->==queue_changes==
 
  
   $dataobj-&gt;queue_changes
+
<pre>  # Note: deliberate typo to prevent copy-and-paste
 +
   $c-&gt;{uuid_namespace} = "http://your-repository's url"";</pre>
  
Add all the changed fields into the indexers todo queue.
+
: Returns the formatted UUID.
  
<!-- End of Pod2Wiki -->
+
* $xhtml = $dataobj-&gt;render_value( $fieldname, [$showall] )
<!-- Pod2Wiki=item_queue_all -->==queue_all==
+
: Returns the rendered version of the value of the given field, as appropriate for the current session. If $showall is true then all values are rendered - this is usually used for staff viewing data.
  
  $dataobj-&gt;queue_all
+
* $xhtml = $dataobj-&gt;render_citation( [$style], [%params] )
 +
: Renders the record as a citation. If $style is set then it uses that citation style from the citations config file. Otherwise $style defaults to the type of this record. If $params{url} is set then the citiation will link to the specified URL.
  
Add all the fields into the indexers todo queue.
+
* $xhtml = $dataobj-&gt;render_citation_link( [$style], %params )
 +
: Renders a citation (as above) but as a link to the URL for this item. For example - the abstract page of an eprint.  
  
<!-- End of Pod2Wiki -->
+
* $xhtml = $dataobj-&gt;render_export_bar( [ $staff ] )
<!-- Pod2Wiki=item_has_owner -->==has_owner==
+
: Render a drop-down list of exports.
  
  $boolean = $dataobj-&gt;has_owner( $user )
+
* $url = $dataobj-&gt;uri
 +
: Returns a unique URI for this object. Not certain to resolve as a  URL.
  
Return true if $user owns this record. Normally this means they  created it, but a group of users could count as owners of the same record if you wanted.
+
: If $c-&gt;{dataobj_uri}-&gt;{eprint} is a function, call that to work it out.
  
It's false on most dataobjs, except those which override this method.
+
* $path = $dataobj-&gt;path
 +
: Returns the relative path to this object from the repository's base URL, if the object has a URL.
  
<!-- End of Pod2Wiki -->
+
: Does not include any leading slash.
<!-- Pod2Wiki=item_in_editorial_scope_of -->==in_editorial_scope_of==
 
  
  $boolean = $dataobj-&gt;in_editorial_scope_of( $user )
+
* $url = $dataobj-&gt;url
 +
: Returns the URL for this record, for example the URL of the abstract page of an eprint.
  
As for has_owner, but if the user is identified as someone with an editorial scope which includes this record.
+
* $plugin_output = $dataobj-&gt;export( $plugin_id, %params )
 +
: Apply an output plugin to this items. Return the results.
  
Defaults to true. Which doesn't mean that they have the right to edit it, just that their scope matches. You also need editor rights to use this. It's currently used just to filter eprint editors so that only ones with a scope AND a priv can edit.
+
* $rc = $dataobj-&gt;permit( $priv [, $user ] )
 +
<pre> # current user can edit via editorial role
 +
  if( $dataobj-&gt;permit( "xxx/edit", $user ) &amp; 8 )
 +
  {
 +
    ...
 +
  }
 +
  # anyone can view this object
 +
  if( $dataobj-&gt;permit( "xxx/view" ) )
 +
  {
 +
  }</pre>
  
<!-- End of Pod2Wiki -->
+
: Returns true if the current user (or 'anybody') can perform this action.
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
 
{{API:Undocumented Methods}}<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_create -->==create==
 
  
<!-- End of Pod2Wiki -->
+
: Returns a bit mask where:
<!-- Pod2Wiki=item_create_from_data -->==create_from_data==
 
  
<!-- End of Pod2Wiki -->
+
<pre>  0 - not permitted
<!-- Pod2Wiki=item_get_value_raw -->==get_value_raw==
+
  1 - anybody
 +
  2 - logged in user
 +
  4 - user as owner
 +
  8 - user as editor</pre>
  
<!-- End of Pod2Wiki -->
+
: See also [[API:EPrints/Repository#allow_anybody|EPrints::Repository/allow_anybody]] and [[API:EPrints/DataObj/User#allow|EPrints::DataObj::User/allow]].
<!-- Pod2Wiki=item_render_citation_link_staff -->==render_citation_link_staff==
 
  
<!-- End of Pod2Wiki -->
+
* $list = $dataobj-&gt;duplicates()
<!-- Pod2Wiki=item_set_under_construction -->==set_under_construction==
+
: Return a conservative list of other objects that look like this one.
  
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=head_copyright -->
<!-- Pod2Wiki=item_set_value_raw -->==set_value_raw==
+
==COPYRIGHT==
 +
Copyright 2000-2011 University of Southampton.
  
<!-- End of Pod2Wiki -->
+
This file is part of EPrints http://www.eprints.org/.
<!-- Pod2Wiki=item_tidy -->==tidy==
 
  
<!-- End of Pod2Wiki -->
+
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.
<!-- Pod2Wiki=item_under_construction -->==under_construction==
 
  
<!-- End of Pod2Wiki -->
+
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.
  
  $boolean = $dataobj->set_under_construction()
+
You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.
  
Returns true if this dataobj is under construction i.e. don't perform expensive maintenance processes on this object yet.
+
<!-- Edit below this comment -->
  
<!-- Pod2Wiki=item_validate_field -->==validate_field==
 
  
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=_postamble_ -->
 +
<!-- Edit below this comment -->

Revision as of 09:56, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

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


NAME

EPrints::DataObj - Base class for records in EPrints.


SYNOPSIS

$dataobj = $dataset->dataobj( $id );

$dataobj->delete;

$dataobj->commit( $force );

$dataset = $dataobj->dataset;

$repo = $dataobj->repository;

$id = $dataobj->id;

$dataobj->set_value( $fieldname, $value );

$value = $dataobj->value( $fieldname );

\@value = $dataobj->value( $fieldname ); # multiple

$boolean = $dataobj->is_set( $fieldname );

$xhtml = $dataobj->render_value( $fieldname );

$xhtml = $dataobj->render_citation( $style, %opts );

$uri = $dataobj->uri;

$url = $dataobj->url;

$string = $dataobj->export( $plugin_id, %opts );

$dataobj = $dataobj->create_subobject( $fieldname, $epdata );


DESCRIPTION

This module is a base class which is inherited by EPrints::DataObj::EPrint, EPrints::DataObj::User, EPrints::DataObj::Subject and EPrints::DataObj::Document and several other classes.

It is ABSTRACT - its methods should not be called directly.


  • $success = $dataobj->delete
Delete this data object from the database and any sub-objects or related files.
Return true if successful.
  • $dataobj->empty()
Remove all of this object's values that may be imported.
  • $dataobj->update( $epdata [, %opts ] )
Update this object's values from $epdata. Ignores any values that do not exist in the dataset or do not have the 'import' property set.
  include_subdataobjs - replace sub-dataobjs if given
  
  # replaces all documents in $dataobj
  $dataobj->update( {
    title => "Wombats on Fire",
    documents => [{
      main => "wombat.pdf",
      ...
    }],
  }, include_subdataobjs => 1 );
  • $success = $dataobj->commit( [$force] )
Write this object to the database and reset the changed fields.
If $force isn't true then it only actually modifies the database if one or more fields have been changed.
Commit may also queue indexer jobs or log changes, depending on the object.
  • $value = $dataobj->value( $fieldname )
Get a the value of a metadata field. If the field is not set then it returns undef unless the field has the property multiple set, in which case it returns [] (a reference to an empty array).
  • $dataobj->set_value( $fieldname, $value )
Set the value of the named metadata field in this record.
  • @values = $dataobj->get_values( $fieldnames )
Returns a list of all the values in this record of all the fields specified by $fieldnames. $fieldnames should be in the format used by browse views - slash seperated fieldnames with an optional .id suffix to indicate the id part rather than the main part.
For example "author.id/editor.id" would return a list of all author and editor ids from this record.
  • $bool = $dataobj->is_set( $fieldname )
Returns true if the named field is set in this record, otherwise false.
Warns if the field does not exist.
  • $bool = $dataobj->exists_and_set( $fieldname )
Returns true if the named field is set in this record, otherwise false.
If the field does not exist, just return false.
This method is useful for plugins which may operate on multiple repositories, and the fact a field does not exist is not an issue.
  • $id = $dataobj->id
Returns the value of the primary key of this record.
  • $uuid = $dataobj->uuid( [ $fragment ] )
Generates a version 5 UUID for this object e.g.
  f70ef731-be66-50f4-8e72-8b8de36778b5
The UUID is generated from the SHA1 hash of the concantenation of uuid_namespace, the object's uri and, if defined, $fragment.
uuid_namespace is a configuration variable. If uuid_namespace is undefined uses base_url:
  # Note: deliberate typo to prevent copy-and-paste
  $c->{uuid_namespace} = "http://your-repository's url"";
Returns the formatted UUID.
  • $xhtml = $dataobj->render_value( $fieldname, [$showall] )
Returns the rendered version of the value of the given field, as appropriate for the current session. If $showall is true then all values are rendered - this is usually used for staff viewing data.
  • $xhtml = $dataobj->render_citation( [$style], [%params] )
Renders the record as a citation. If $style is set then it uses that citation style from the citations config file. Otherwise $style defaults to the type of this record. If $params{url} is set then the citiation will link to the specified URL.
  • $xhtml = $dataobj->render_citation_link( [$style], %params )
Renders a citation (as above) but as a link to the URL for this item. For example - the abstract page of an eprint.
  • $xhtml = $dataobj->render_export_bar( [ $staff ] )
Render a drop-down list of exports.
  • $url = $dataobj->uri
Returns a unique URI for this object. Not certain to resolve as a URL.
If $c->{dataobj_uri}->{eprint} is a function, call that to work it out.
  • $path = $dataobj->path
Returns the relative path to this object from the repository's base URL, if the object has a URL.
Does not include any leading slash.
  • $url = $dataobj->url
Returns the URL for this record, for example the URL of the abstract page of an eprint.
  • $plugin_output = $dataobj->export( $plugin_id, %params )
Apply an output plugin to this items. Return the results.
  • $rc = $dataobj->permit( $priv [, $user ] )
  # current user can edit via editorial role
  if( $dataobj->permit( "xxx/edit", $user ) & 8 )
  {
    ...
  }
  # anyone can view this object
  if( $dataobj->permit( "xxx/view" ) )
  {
  }
Returns true if the current user (or 'anybody') can perform this action.
Returns a bit mask where:
  0 - not permitted
  1 - anybody
  2 - logged in user
  4 - user as owner
  8 - user as editor
See also EPrints::Repository/allow_anybody and EPrints::DataObj::User/allow.
  • $list = $dataobj->duplicates()
Return a conservative list of other objects that look like this one.

COPYRIGHT

Copyright 2000-2011 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/.