Difference between revisions of "API:EPrints/DataObj"

From EPrints Documentation
Jump to: navigation, search
Line 245: Line 245:
  
 
If $c->{dataobj_uri}->{eprint} is a function, call that to work it out.
 
If $c->{dataobj_uri}->{eprint} is a function, call that to work it out.
 +
 +
<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_path -->
 +
===$path = $dataobj-&gt;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.
  
 
<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 12:27, 1 December 2011

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.

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::DataObj::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


$dataobj->empty()

Remove all of this object's values that may be imported.

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


$xhtml = $dataobj->render_export_bar( [ $staff ] )

Render a drop-down list of exports.

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


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

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


COPYRIGHT

User Comments