Difference between revisions of "API:EPrints/DataSet"

From EPrints Documentation
Jump to: navigation, search
(New page: <!-- 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. -...)
 
(Removing all content from page)
Line 1: Line 1:
<!-- 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.
 
-->{{Pod2Wiki}}{{API:Source|file=EPrints/DataSet.pm|package_name=EPrints::DataSet}}[[Category:API|DataSet]]<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_name -->=NAME=
 
'''EPrints::DataSet''' - a dataset is a set of records in the eprints system with the same metadata.
 
  
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_description -->=DESCRIPTION=
 
This module describes an EPrint dataset.
 
 
An repository has one of each type of dataset:
 
 
cachemap, counter, user, archive, buffer, inbox, document, subject, saved_search, deletion, eprint, access.
 
 
A normal dataset (eg. "user") has a package associated with it  (eg. EPrints::DataObj::User) which must be a subclass of EPrints::DataObj  and a number of SQL tables which are prefixed with the dataset name. Most datasets also have a set of associated EPrints::MetaField's which may be optional or compulsary depending on the type eg. books have editors but posters don't but they are both EPrints.
 
 
Datasets have some default fields plus additional ones configured in Fields.pm.
 
 
But there are some exceptions:
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_cachemap_counter -->==cachemap_counter==
 
 
  cachemap, counter
 
 
Don't have a package or metadata fields associated.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_archive_buffer_inbox_deletion -->==archive_buffer_inbox_deletion==
 
 
  archive, buffer, inbox, deletion
 
 
All have the same package and metadata fields as eprints, but are filtered by eprint_status.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_new_stub -->==new_stub==
 
 
  $ds = EPrints::DataSet-&gt;new_stub( $id )
 
 
Creates a dataset object without any fields. Useful to avoid problems with something a dataset does depending on loading the dataset. It can still be queried about other things, such as SQL table names.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_new -->==new==
 
 
  $ds = EPrints::DataSet-&gt;new( $repository, $id )
 
 
Return the dataset specified by $id.
 
 
Note that dataset know $repository and vice versa - which means they will not get garbage collected.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_field -->==get_field==
 
 
  $metafield = $ds-&gt;get_field( $fieldname )
 
 
Return a MetaField object describing the asked for field in this dataset, or undef if there is no such field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_has_field -->==has_field==
 
 
  $bool = $ds-&gt;has_field( $fieldname )
 
 
True if the dataset has a field of that name.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_default_order -->==default_order==
 
 
  $ordertype = $ds-&gt;default_order
 
 
Return the id string of the default order for this dataset.
 
 
For example "bytitle" for eprints.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_confid -->==confid==
 
 
  $confid = $ds-&gt;confid
 
 
Return the string to use when getting configuration for this dataset.
 
 
archive, buffer, inbox and deletion all return "eprint" as they must have the same configuration.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_id -->==id==
 
 
  $id = $ds-&gt;id
 
 
Return the id of this dataset.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_count -->==count==
 
 
  $n = $ds-&gt;count( $session )
 
 
Return the number of records in this dataset.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_sql_table_name -->==get_sql_table_name==
 
 
  $tablename = $ds-&gt;get_sql_table_name
 
 
Return the name of the main SQL Table containing this dataset. the other SQL tables names are based on this name.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_sql_index_table_name -->==get_sql_index_table_name==
 
 
  $tablename = $ds-&gt;get_sql_index_table_name
 
 
Return the name of the SQL table which contains the free text indexing information.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_sql_grep_table_name -->==get_sql_grep_table_name==
 
 
  $tablename = $ds-&gt;get_sql_grep_table_name
 
 
Reutrn the name of the SQL table which contains the strings to be used with LIKE in a final pass of a search.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_sql_rindex_table_name -->==get_sql_rindex_table_name==
 
 
  $tablename = $ds-&gt;get_sql_rindex_table_name
 
 
Reutrn the name of the SQL table which contains the reverse text indexing information. (Used for deleting freetext indexes when removing a record).
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_ordervalues_table_name -->==get_ordervalues_table_name==
 
 
  $tablename = $ds-&gt;get_ordervalues_table_name( $langid )
 
 
Return the name of the SQL table containing values used for ordering this dataset.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_sql_sub_table_name -->==get_sql_sub_table_name==
 
 
  $tablename = $ds-&gt;get_sql_sub_table_name( $field )
 
 
Returns the name of the SQL table which contains the information on the "multiple" field. $field is an EPrints::MetaField belonging to this dataset.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_fields -->==get_fields==
 
 
  $fields = $ds-&gt;get_fields
 
 
Returns a list of the EPrints::Metafields belonging to this dataset.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_key_field -->==get_key_field==
 
 
  $field = $ds-&gt;get_key_field
 
 
Return the EPrints::MetaField representing the primary key field. Always the first field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_make_object -->==make_object==
 
 
  $obj = $ds-&gt;make_object( $session, $data )
 
 
Return an object of the class associated with this dataset, always a subclass of EPrints::DataObj.
 
 
$data is a hash of values for fields of a record in this dataset.
 
 
Return $data if no class associated with this dataset.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_create_object -->==create_object==
 
 
  $obj = $ds-&gt;create_object( $session, $data )
 
 
Create a new object in the given dataset. Return the new object.
 
 
Return undef if the object could not be created.
 
 
If $data describes sub-objects too then those will also be created.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_object_class -->==get_object_class==
 
 
  $class = $ds-&gt;get_object_class;
 
 
Return the perl class to which objects in this dataset belong.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_object -->==get_object==
 
 
  $obj = $ds-&gt;get_object( $session, $id );
 
 
Return the object from this dataset with the given id, or undefined.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_name -->==render_name==
 
 
  $xhtml = $ds-&gt;render_name( $session )
 
 
Return a piece of XHTML describing this dataset, in the language of the current session.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_map -->==map==
 
 
  $ds-&gt;map( $session, $fn, $info )
 
 
Maps the function $fn onto every record in this dataset. See  Search for a full explanation.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_repository -->==get_repository==
 
 
  $repository = $ds-&gt;get_repository
 
 
Returns the EPrints::Repository to which this dataset belongs.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_reindex -->==reindex==
 
 
  $ds-&gt;reindex( $session )
 
 
Recommits all the items in this dataset. This could take a real long  time on a large set of records.
 
 
Really should not be called reindex anymore as it doesn't.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_dataset_ids -->==get_dataset_ids==
 
 
  @ids = EPrints::DataSet::get_dataset_ids( get_dataset_ids )
 
 
Return a list of all dataset ids.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_@ids -->==@ids==
 
 
  @ids = EPrints::DataSet::get_sql_dataset_ids
 
 
Return a list of all dataset ids of datasets which are directly mapped into SQL (not counters or cache which work a bit differently).
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_count_indexes -->==count_indexes==
 
 
  $n = $ds-&gt;count_indexes
 
 
Return the number of indexes required for the main SQL table of this dataset. Used to check it's not over 32 (the current maximum allowed by MySQL)
 
 
Assumes things either have 1 or 0 indexes which might not always be true.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_item_ids -->==get_item_ids==
 
 
  @ids = $dataset-&gt;get_item_ids( $session )
 
 
Return a list of the id's of all items in this set.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_datestamp_field -->==get_datestamp_field==
 
 
  $field = $dataset-&gt;get_datestamp_field()
 
 
Returns the datestamp field for this dataset which may be used for incremental harvesting. Returns undef if no such field is available.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
 
{{API:Undocumented Methods}}<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_archive -->==get_archive==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_dataset_id_field -->==get_dataset_id_field==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_filters -->==get_filters==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_page_fields -->==get_page_fields==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_required_type_fields -->==get_required_type_fields==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_type_fields -->==get_type_fields==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_type_name -->==get_type_name==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_type_names -->==get_type_names==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_type_pages -->==get_type_pages==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_types -->==get_types==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_indexable -->==indexable==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_valid_type -->==is_valid_type==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_load_workflows -->==load_workflows==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_process_field -->==process_field==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_type_name -->==render_type_name==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
 

Revision as of 15:40, 12 August 2009