Difference between revisions of "API:EPrints/DataObj"

From EPrints Documentation
Jump to: navigation, search
Line 15: Line 15:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=head_description -->
+
<!-- Pod2Wiki=head_synopsis -->
==DESCRIPTION==
+
==SYNOPSIS==
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.
+
$dataobj = $dataset-&gt;dataobj( $id );
  
It is ABSTRACT - its methods should not be called directly.
+
$dataobj-&gt;delete;
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
$dataobj-&gt;commit( $force );
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
  
 +
$dataset = $dataobj-&gt;dataset;
  
<!-- Pod2Wiki= -->
+
$repo = $dataobj-&gt;repository;
</div>
+
<!-- Pod2Wiki=item_get_system_field_info -->
+
===$sys_fields = EPrints::DataObj-&gt;get_system_field_info===
+
  
Return an array describing the system metadata of the this  dataset.
+
$id = $dataobj-&gt;id;
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
$dataobj-&gt;set_value( $fieldname, $value );
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
  
 +
$value = $dataobj-&gt;value( $fieldname );
  
<!-- Pod2Wiki= -->
+
\@value = $dataobj-&gt;value( $fieldname ); # multiple
</div>
+
<!-- Pod2Wiki=item_new -->
+
===$dataobj = EPrints::DataObj-&gt;new( $session, $id [, $dataset] )===
+
  
Return new data object, created by loading it from the database.
+
$boolean = $dataobj-&gt;is_set( $fieldname );
  
If $dataset is not defined uses the default dataset for this object.
+
$xhtml = $dataobj-&gt;render_value( $fieldname );
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
$xhtml = $dataobj-&gt;render_citation( $style, %opts );
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
  
 +
$uri = $dataobj-&gt;uri;
  
<!-- Pod2Wiki= -->
+
$url = $dataobj-&gt;url;
</div>
+
<!-- Pod2Wiki=item_new_from_data -->
+
===$dataobj = EPrints::DataObj-&gt;new_from_data( $session, $data [, $dataset ] )===
+
  
Construct a new EPrints::DataObj object based on the $data hash  reference of metadata.
+
$string = $dataobj-&gt;export( $plugin_id, %opts );
  
Used to create an object from the data retrieved from the database.
+
$dataobj = $dataobj-&gt;create_subobject( $fieldname, $epdata );
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 68: Line 56:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_create_subdataobj -->
+
<!-- Pod2Wiki=head_description -->
===$dataobj = $dataobj-&gt;create_subdataobj( $fieldname, $epdata )===
+
==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.
  
Creates and returns a new dataobj that is a sub-object of this object in field $fieldname with initial data $epdata.
+
It is ABSTRACT - its methods should not be called directly.
  
Clears the sub-object cache for this $fieldname which is equivalent to:
 
 
  $dataobj-&gt;set_value( $fieldname, undef );
 
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<span style='display:none'>User Comments</span>
Line 84: Line 69:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_defaults -->
+
<!-- Pod2Wiki=item_delete -->
===$defaults = EPrints::User-&gt;get_defaults( $session, $data, $dataset )===
+
===$success = $dataobj-&gt;delete===
  
Return default values for this object based on the starting data.
+
Delete this data object from the database and any sub-objects or related files.  
 
+
Should be subclassed.
+
 
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
 
+
 
+
<!-- Pod2Wiki= -->
+
</div>
+
<!-- Pod2Wiki=item_remove -->
+
===$success = $dataobj-&gt;remove===
+
 
+
Remove this data object from the database and any sub-objects or related files.  
+
  
 
Return true if successful.
 
Return true if successful.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_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.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 142: Line 99:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_value -->
+
<!-- Pod2Wiki=item_value -->
===$value = $dataobj-&gt;get_value( $fieldname )===
+
===$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).
 
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).
Line 172: Line 129:
  
 
For example "author.id/editor.id" would return a list of all author and editor ids from this record.
 
For example "author.id/editor.id" would return a list of all author and editor ids from this record.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_session -->
 
===$session = $dataobj-&gt;get_session===
 
 
Returns the EPrints::Session object to which this record belongs.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_data -->
 
===$data = $dataobj-&gt;get_data===
 
 
Returns a reference to the hash table of all the metadata for this record keyed  by fieldname.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_dataset_id -->
 
===$dataset = EPrints::DataObj-&gt;get_dataset_id===
 
 
Returns the id of the [[API:EPrints/DataSet|EPrints::DataSet]] object to which this record belongs.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_dataset -->
 
===$dataset = $dataobj-&gt;get_dataset===
 
 
Returns the [[API:EPrints/DataSet|EPrints::DataSet]] object to which this record belongs.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 258: Line 167:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_id -->
+
<!-- Pod2Wiki=item_id -->
===$id = $dataobj-&gt;get_id===
+
===$id = $dataobj-&gt;id===
  
 
Returns the value of the primary key of this record.
 
Returns the value of the primary key of this record.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_gid -->
 
===$id = $dataobj-&gt;get_gid===
 
 
DEPRECATED (see uri())
 
 
Returns the globally referential fully-qualified identifier for this object or undef if this object can not be externally referenced.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_datestamp -->
 
===$datestamp = $dataobj-&gt;get_datestamp===
 
 
Returns the datestamp of this object in "YYYY-MM-DD hh:mm:ss" format.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 324: Line 207:
  
 
Renders a citation (as above) but as a link to the URL for this item. For example - the abstract page of an eprint.  
 
Renders a citation (as above) but as a link to the URL for this item. For example - the abstract page of an eprint.  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_render_description -->
 
===$xhtml = $dataobj-&gt;render_description===
 
 
Returns a short description of this object using the default citation style for this dataset.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_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.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_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.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_render_export_links -->
 
===$xhtml_ul_list = $dataobj-&gt;render_export_links( [$staff] )===
 
 
Return a &lt;ul&gt; list containing links to all the formats this eprint is available in.
 
 
If $staff is true then show all formats available to staff, and link to the staff export URL.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 396: Line 229:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_internal_uri -->
+
<!-- Pod2Wiki=item_url -->
===$uri = $dataobj-&gt;internal_uri()===
+
===$url = $dataobj-&gt;url===
 
+
Return an internal URI for this object (independent of repository hostname).
+
 
+
To retrieve an object by internal URI use [[API:EPrints/DataSet|EPrints::DataSet]]::get_object_from_uri().
+
 
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
 
+
 
+
<!-- Pod2Wiki= -->
+
</div>
+
<!-- Pod2Wiki=item_get_url -->
+
===$url = $dataobj-&gt;get_url===
+
  
 
Returns the URL for this record, for example the URL of the abstract page of an eprint.
 
Returns the URL for this record, for example the URL of the abstract page of an eprint.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_control_url -->
 
===$url = $dataobj-&gt;get_control_url===
 
 
Returns the URL for the control page for this object.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_type -->
 
===$type = $dataobj-&gt;get_type===
 
 
Returns the type of this record - type of user, type of eprint etc.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_to_xml -->
 
===$xmlfragment = $dataobj-&gt;to_xml( %opts )===
 
 
Convert this object into an XML fragment.
 
 
%opts are:
 
 
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.
 
 
showempty=&gt;1 : fields with no value are shown.
 
 
embed=&gt;1 : include the data of a file, not just it's URL.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_xml_to_epdata -->
 
===$epdata = EPrints::DataObj-&gt;xml_to_epdata( $session, $xml, %opts )===
 
 
Populates $epdata based on $xml. This is the inverse of to_xml() but doesn't create a new object.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_to_sax -->
 
===$dataobj-&gt;to_sax( Handler =&gt; $handler, %opts )===
 
 
Stream this object to a SAX handler.
 
 
This does not output any document-level events.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_start_element -->
 
===EPrints::Dataobj-&gt;start_element( $data, $epdata, $state )===
 
 
Consumes a SAX event.
 
 
$data is the SAX node data.
 
 
$epdata is an EPrints data structure to write values to.
 
 
$state maintains state between SAX calls but must contain at least:
 
 
  dataset - the dataset the class belongs to
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_end_element -->
 
===EPrints::DataObj-&gt;end_element( $data, $epdata, $state )===
 
 
See {{API:PodLink|file=|package_name=|section=start_element|text=/start_element}}.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_characters -->
 
===EPrints::DataObj-&gt;characters( $data, $epdata, $state )===
 
 
See {{API:PodLink|file=|package_name=|section=start_element|text=/start_element}}.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 537: Line 242:
 
</div>
 
</div>
 
<!-- Pod2Wiki=item_export -->
 
<!-- Pod2Wiki=item_export -->
===$plugin_output = $detaobj-&gt;export( $plugin_id, %params )===
+
===$plugin_output = $dataobj-&gt;export( $plugin_id, %params )===
  
 
Apply an output plugin to this items. Return the results.
 
Apply an output plugin to this items. Return the results.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_queue_changes -->
 
===$dataobj-&gt;queue_changes===
 
 
Add all the changed fields into the indexers todo queue.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_queue_all -->
 
===$dataobj-&gt;queue_all===
 
 
Add all the fields into the indexers todo queue.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_queue_fulltext -->
 
===$dataobj-&gt;queue_fulltext===
 
 
Add a fulltext index into the indexers todo queue.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_queue_removed -->
 
===$dataobj-&gt;queue_removed()===
 
 
Add an index removed event to the indexer's queue.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_has_owner -->
 
===$boolean = $dataobj-&gt;has_owner( $user )===
 
 
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.
 
 
It's false on most dataobjs, except those which override this method.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_in_editorial_scope_of -->
 
===$boolean = $dataobj-&gt;in_editorial_scope_of( $user )===
 
 
As for has_owner, but if the user is identified as someone with an editorial scope which includes this record.
 
 
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.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_validate -->
 
===$problems = $dataobj-&gt;validate( [ $for_archive ], $workflow_id )===
 
 
Return a reference to an array of XHTML DOM objects describing validation problems with the entire $dataobj based on $workflow_id.
 
 
If $workflow_id is undefined defaults to "default".
 
 
A reference to an empty array indicates no problems.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_warnings -->
 
===$warnings = $dataobj-&gt;get_warnings( )===
 
 
Return a reference to an array of XHTML DOM objects describing problems with the entire $dataobj.
 
 
A reference to an empty array indicates no problems.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_add_stored_file -->
 
===$file = $dataobj-&gt;add_stored_file( $filename, $filehandle, $filesize )===
 
 
Convenience method to add (or replace) the file record for $filename to this object. Reads $filesize bytes from $filehandle.
 
 
Returns the file object or undef if the storage failed.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_stored_file -->
 
===$file = $dataobj-&gt;stored_file( $filename )===
 
 
Get the file object for $filename.
 
 
Returns the file object or undef if the file doesn't exist.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=head_related_objects -->
 
===Related Objects===
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_add_dataobj_relations -->
 
====$dataobj-&gt;add_dataobj_relations( $target, $has =&gt; $is [, $has =&gt; $is ] )====
 
 
Add a relation between this object and $target of type $has. If $is is defined will also add the reciprocal relationship $is from $target to this object. May be repeated to add multiple relationships.
 
 
You must commit $target after calling this method.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_has_dataobj_relations -->
 
====$bool = $dataobj-&gt;has_dataobj_relations( $target, @types )====
 
 
Returns true if this object is related to $target by all @types.
 
 
If @types is empty will return true if any relationships exist.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_has_related_dataobjs -->
 
====$bool = $dataobj-&gt;has_related_dataobjs( @types )====
 
 
Returns true if related_dataobjs() would return some objects, but without actually retrieving the related objects from the database.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_related_dataobjs -->
 
====@dataobjs = $dataobj-&gt;related_dataobjs( @types )====
 
 
Returns a list of objects related to this object by @types.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_remove_dataobj_relations -->
 
====$dataobj-&gt;remove_dataobj_relations( $target [, $has =&gt; $is [, $has =&gt; $is ] )====
 
 
Remove relations between this object and $target. If $has =&gt; $is pairs are defined will only remove those relationships given.
 
 
You must {{API:PodLink|file=|package_name=|section=commit|text=/commit}} this object and $target to write the changes.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>

Revision as of 17:18, 31 December 2010

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.3, 3.2) | Revision Log | Before editing this page please read Pod2Wiki


NAME

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

User Comments


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 );

User Comments


DESCRIPTION

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

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

User Comments


$success = $dataobj->delete

Delete this data object from the database and any sub-objects or related files.

Return true if successful.

User Comments


$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.

User Comments


$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).

User Comments


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

Set the value of the named metadata field in this record.

User Comments


@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.

User Comments


$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.

User Comments


$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.

User Comments


$id = $dataobj->id

Returns the value of the primary key of this record.

User Comments


$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.

User Comments


$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.

User Comments


$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.

User Comments


$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.

User Comments


$url = $dataobj->url

Returns the URL for this record, for example the URL of the abstract page of an eprint.

User Comments


$plugin_output = $dataobj->export( $plugin_id, %params )

Apply an output plugin to this items. Return the results.

User Comments