Difference between revisions of "API:EPrints/DataObj"
Line 15: | Line 15: | ||
$sys_fields = EPrints::DataObj->get_system_field_info | $sys_fields = EPrints::DataObj->get_system_field_info | ||
+ | |||
+ | ABSTRACT. | ||
Return an array describing the system metadata of the this dataset. | Return an array describing the system metadata of the this dataset. | ||
Line 21: | Line 23: | ||
<!-- Pod2Wiki=item_new -->==new== | <!-- Pod2Wiki=item_new -->==new== | ||
− | $dataobj = EPrints::DataObj->new( $session, $id [ | + | $dataobj = EPrints::DataObj->new( $session, $id, [$dataset] ) |
+ | |||
+ | ABSTRACT. | ||
Return new data object, created by loading it from the database. | Return new data object, created by loading it from the database. | ||
− | + | $dataset is used by EPrint->new to save searching through all four tables that it could be in. | |
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
<!-- Pod2Wiki=item_new_from_data -->==new_from_data== | <!-- Pod2Wiki=item_new_from_data -->==new_from_data== | ||
− | $dataobj = EPrints::DataObj->new_from_data( $session, $data | + | $dataobj = EPrints::DataObj->new_from_data( $session, $data, $dataset ) |
+ | |||
+ | ABSTRACT. | ||
Construct a new EPrints::DataObj object based on the $data hash reference of metadata. | Construct a new EPrints::DataObj object based on the $data hash reference of metadata. | ||
Line 39: | Line 45: | ||
<!-- Pod2Wiki=item_get_defaults -->==get_defaults== | <!-- Pod2Wiki=item_get_defaults -->==get_defaults== | ||
− | $defaults = EPrints::User->get_defaults( $session, $data | + | $defaults = EPrints::User->get_defaults( $session, $data ) |
Return default values for this object based on the starting data. | Return default values for this object based on the starting data. | ||
Line 50: | Line 56: | ||
$success = $dataobj->remove | $success = $dataobj->remove | ||
− | Remove this data object from the database | + | ABSTRACT |
+ | |||
+ | Remove this data object from the database. | ||
+ | |||
+ | Also removes any sub-objects or related files. | ||
Return true if successful. | Return true if successful. | ||
Line 68: | Line 78: | ||
$success = $dataobj->commit( [$force] ) | $success = $dataobj->commit( [$force] ) | ||
− | Write this object to the database | + | 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. | If $force isn't true then it only actually modifies the database if one or more fields have been changed. | ||
− | Commit may also | + | Commit may also log the changes, depending on the type of data object. |
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 110: | Line 122: | ||
Returns a reference to the hash table of all the metadata for this record keyed by fieldname. | Returns a reference to the hash table of all the metadata for this record keyed by fieldname. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 123: | Line 128: | ||
$dataset = $dataobj->get_dataset | $dataset = $dataobj->get_dataset | ||
− | Returns the | + | Returns the EPrints::DataSet object to which this record belongs. |
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 156: | Line 161: | ||
$id = $dataobj->get_gid | $id = $dataobj->get_gid | ||
− | |||
− | |||
Returns the globally referential fully-qualified identifier for this object or undef if this object can not be externally referenced. | Returns the globally referential fully-qualified identifier for this object or undef if this object can not be externally referenced. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 218: | Line 214: | ||
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. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 265: | Line 252: | ||
embed=>1 : include the data of a file, not just it's URL. | embed=>1 : include the data of a file, not just it's URL. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 293: | Line 273: | ||
Add all the fields into the indexers todo queue. | Add all the fields into the indexers todo queue. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
Line 318: | Line 291: | ||
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. | 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. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- End of Pod2Wiki --> | <!-- End of Pod2Wiki --> | ||
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS= | <!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS= | ||
{{API:Undocumented Methods}}<!-- End of Pod2Wiki --> | {{API:Undocumented Methods}}<!-- End of Pod2Wiki --> | ||
− | |||
− | |||
− | |||
<!-- Pod2Wiki=item_create -->==create== | <!-- Pod2Wiki=item_create -->==create== | ||
Revision as of 18:29, 11 August 2009
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 DESCRIPTION
- 2.1 get_system_field_info
- 2.2 new
- 2.3 new_from_data
- 2.4 get_defaults
- 2.5 remove
- 2.6 clear_changed
- 2.7 commit
- 2.8 get_value
- 2.9 set_value
- 2.10 get_values
- 2.11 get_session
- 2.12 get_data
- 2.13 get_dataset
- 2.14 is_set
- 2.15 exists_and_set
- 2.16 get_id
- 2.17 get_gid
- 2.18 render_value
- 2.19 render_citation
- 2.20 render_citation_link
- 2.21 render_description
- 2.22 render
- 2.23 render_full
- 2.24 uri
- 2.25 get_url
- 2.26 get_control_url
- 2.27 get_type
- 2.28 to_xml
- 2.29 export
- 2.30 queue_changes
- 2.31 queue_all
- 2.32 has_owner
- 2.33 in_editorial_scope_of
- 3 UNDOCUMENTED METHODS
NAME
EPrints::DataObj - Base class for records in EPrints.
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.
get_system_field_info
$sys_fields = EPrints::DataObj->get_system_field_info
ABSTRACT.
Return an array describing the system metadata of the this dataset.
new
$dataobj = EPrints::DataObj->new( $session, $id, [$dataset] )
ABSTRACT.
Return new data object, created by loading it from the database.
$dataset is used by EPrint->new to save searching through all four tables that it could be in.
new_from_data
$dataobj = EPrints::DataObj->new_from_data( $session, $data, $dataset )
ABSTRACT.
Construct a new EPrints::DataObj object based on the $data hash reference of metadata.
Used to create an object from the data retrieved from the database.
get_defaults
$defaults = EPrints::User->get_defaults( $session, $data )
Return default values for this object based on the starting data.
Should be subclassed.
remove
$success = $dataobj->remove
ABSTRACT
Remove this data object from the database.
Also removes any sub-objects or related files.
Return true if successful.
clear_changed
$dataobj->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.
commit
$success = $dataobj->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.
get_value
$value = $dataobj->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).
set_value
$dataobj->set_value( $fieldname, $value )
Set the value of the named metadata field in this record.
get_values
@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.
get_session
$session = $dataobj->get_session
Returns the EPrints::Session object to which this record belongs.
get_data
$data = $dataobj->get_data
Returns a reference to the hash table of all the metadata for this record keyed by fieldname.
get_dataset
$dataset = $dataobj->get_dataset
Returns the EPrints::DataSet object to which this record belongs.
is_set
$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.
exists_and_set
$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.
get_id
$id = $dataobj->get_id
Returns the value of the primary key of this record.
get_gid
$id = $dataobj->get_gid
Returns the globally referential fully-qualified identifier for this object or undef if this object can not be externally referenced.
render_value
$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.
render_citation
$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.
render_citation_link
$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.
render_description
$xhtml = $dataobj->render_description
Returns a short description of this object using the default citation style for this dataset.
render
($xhtml, $title ) = $dataobj->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.
render_full
($xhtml, $title ) = $dataobj->render_full
Return an XHTML table in DOM describing this record. All values of all fields are listed. This is the staff view.
uri
$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.
get_url
$url = $dataobj->get_url
Returns the URL for this record, for example the URL of the abstract page of an eprint.
get_control_url
$url = $dataobj->get_control_url
Returns the URL for the control page for this object.
get_type
$type = $dataobj->get_type
Returns the type of this record - type of user, type of eprint etc.
to_xml
$xmlfragment = $dataobj->to_xml( %opts )
Convert this object into an XML fragment.
%opts are:
no_xmlns=>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=>1 : fields with no value are shown.
version=>"code" : pick what version of the EPrints XML format to use "1" or "2"
embed=>1 : include the data of a file, not just it's URL.
export
$plugin_output = $detaobj->export( $plugin_id, %params )
Apply an output plugin to this items. Return the results.
queue_changes
$dataobj->queue_changes
Add all the changed fields into the indexers todo queue.
queue_all
$dataobj->queue_all
Add all the fields into the indexers todo queue.
has_owner
$boolean = $dataobj->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.
in_editorial_scope_of
$boolean = $dataobj->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.
UNDOCUMENTED METHODS
create
create_from_data
get_value_raw
render_citation_link_staff
set_under_construction
set_value_raw
tidy
under_construction
$boolean = $dataobj->set_under_construction()
Returns true if this dataobj is under construction i.e. don't perform expensive maintenance processes on this object yet.