Difference between revisions of "API:EPrints/DataObj"

From EPrints Documentation
Jump to: navigation, search
Line 323: Line 323:
<!-- End of Pod2Wiki -->
<!-- End of Pod2Wiki -->
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
```Warning!``` These methods have no documentation which may mean they are intended for internal use only.
{{Template:Undocumented Methods}}<!-- End of Pod2Wiki -->
<!-- End of Pod2Wiki -->
<!-- Pod2Wiki=item_under_construction -->==under_construction==
<!-- Pod2Wiki=item_under_construction -->==under_construction==

Revision as of 10:26, 11 August 2009

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


This module is a base class which is inherited by EPrints::DataObj::EPrint,EPrints::User, EPrints::DataObj::Subject andEPrints::DataObj::Document and several other classes. It is ABSTRACT - its methods should not be called directly.


 $sys_fields = EPrints::DataObj->get_system_field_info

Return an array describing the system metadata of the this dataset.


 $dataobj = EPrints::DataObj->new( $session, $id [, $dataset] )

Return new data object, created by loading it from the database. If $dataset is not defined uses the default dataset for this object.


 $dataobj = EPrints::DataObj->new_from_data( $session, $data [, $dataset ] )

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.


 $defaults = EPrints::User->get_defaults( $session, $data, $dataset )

Return default values for this object based on the starting data. Should be subclassed.


 $success = $dataobj->remove

Remove this data object from the database and any sub-objects or related files. Return true if successful.


 $dataobj->clear_changed( )

Clear any changed fields, which will result in them not being committed unlessforce is used. This method is used by the Database to avoid unnecessary commits.


 $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 databaseif one or more fields have been changed. Commit may also queue indexer jobs or log changes, depending on the object.


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

Get a the value of a metadata field. If the field is not set then it returnsundef 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 specifiedby $fieldnames. $fieldnames should be in the format used by browse views - slashseperated fieldnames with an optional .id suffix to indicate the id part ratherthan the main part. For example "author.id/editor.id" would return a list of all author and editorids from this record.


 $session = $dataobj->get_session

Returns the EPrints::Session object to which this record belongs.


 $data = $dataobj->get_data

Returns a reference to the hash table of all the metadata for this record keyed by fieldname.


 $dataset = EPrints::DataObj->get_dataset_id

Returns the id of the EPrints::DataSet object to which this record belongs.


 $dataset = $dataobj->get_dataset

Returns the EPrints::DataSet object to which this record belongs.


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

Returns the value of the primary key of this record.


 $id = $dataobj->get_gid

DEPRECATED (see uri()) Returns the globally referential fully-qualified identifier for this object orundef if this object can not be externally referenced.


 $datestamp = $dataobj->get_datestamp

Returns the datestamp of this object in "YYYY-MM-DD hh:mm:ss" format.


 $xhtml = $dataobj->render_value( $fieldname, [$showall] )

Returns the rendered version of the value of the given field, as appropriatefor 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 citationstyle from the citations config file. Otherwise $style defaults to the typeof this record. If $params{url} is set then the citiation will link to the specifiedURL.


 $xhtml = $dataobj->render_citation_link( [$style], %params )

Renders a citation (as above) but as a link to the URL for this item. Forexample - the abstract page of an eprint.


 $xhtml = $dataobj->render_description

Returns a short description of this object using the default citation stylefor this dataset.


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


 ($xhtml, $title ) = $dataobj->render_full

Return an XHTML table in DOM describing this record. All values ofall fields are listed. This is the staff view.


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


 $uri = $dataobj->internal_uri()

Return an internal URI for this object (independent of repository hostname). To retrieve an object by internal URI use EPrints::DataSet::get_object_from_uri().


 $url = $dataobj->get_url

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


 $url = $dataobj->get_control_url

Returns the URL for the control page for this object.


 $type = $dataobj->get_type

Returns the type of this record - type of user, type of eprint etc.


 $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 formatto use "1" or "2" embed=>1 : include the data of a file, not just it's URL.


 $epdata = EPrints::DataObj->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.


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

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



Add all the changed fields into the indexers todo queue.



Add all the fields into the indexers todo queue.



Add a fulltext index into the indexers todo queue.


 $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 samerecord if you wanted. It's false on most dataobjs, except those which override this method.


 $boolean = $dataobj->in_editorial_scope_of( $user )

As for has_owner, but if the user is identified as someone with aneditorial 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 rightsto use this. It's currently used just to filter eprint editors sothat only ones with a scope AND a priv can edit.


 $problems = $dataobj->validate( [ $for_archive ], $workflow_id )

Return a reference to an array of XHTML DOM objects describingvalidation 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.


 $warnings = $dataobj->get_warnings( )

Return a reference to an array of XHTML DOM objects describingproblems with the entire $dataobj. A reference to an empty array indicates no problems.


 $file = $dataobj->add_stored_file( $filename, $filehandle [, $filesize ] )

Convenience method to add the file record for $filename to this object. Reads data from $filehandle. If $filesize is defined it may used to determine where the file should be stored. Returns the file object or undef if the storage failed.


 $file = $dataobj->get_stored_file( $filename )

Get the file object for $filename. Returns the file object or undef if the file doesn't exist.

Related Objects


 $dataobj->add_object_relations( $target, $has => $is [, $has => $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.


 $bool = $dataobj->has_object_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.


 $bool = $dataobj->has_related_objects( @types )

Returns true if get_related_objects() would return some objects, but without actually retrieving the related objects from the database.


 $dataobjs = $dataobj->get_related_objects( @types )

Returns a list of objects related to this object by @types.


 $dataobj->remove_object_relations( $target [, $has => $is [, $has => $is ] )

Remove relations between this object and $target. If $has => $is pairs are defined will only remove those relationships given. You must commit $target after calling this method.


Template:Undocumented Methods