Difference between revisions of "API:EPrints/DataSet"

From EPrints Documentation
Jump to: navigation, search
Line 17: Line 17:
 
<!-- Pod2Wiki=head_synopsis --></div>
 
<!-- Pod2Wiki=head_synopsis --></div>
 
==SYNOPSIS==
 
==SYNOPSIS==
   my $ds = $handle-&gt;get_dataset( "inbox" );
+
   my $dataset = $repository-&gt;get_dataset( "inbox" );
  my $ds = $repository-&gt;get_dataset( "inbox" );
 
 
    
 
    
   $confid = $ds-&gt;confid; # eprint
+
   print sprintf("There are %d records in the inbox\n",
  $id = $ds-&gt;id;        # inbox
+
    $dataset-&gt;count);
 
 
  $metafield = $ds-&gt;get_field( $fieldname );
 
  $metafield = $ds-&gt;get_key_field;
 
  $bool = $ds-&gt;has_field( $fieldname );
 
  @metafields = $ds-&gt;get_fields;
 
 
 
  $n = $ds-&gt;count( $handle );
 
  $ds-&gt;map( $handle, $fn, $info );
 
  @ids = $dataset-&gt;get_item_ids( $handle );
 
 
 
  $obj = $ds-&gt;create_object( $handle, $data );
 
 
    
 
    
 
<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 81: Line 69:
  
  
<!-- Pod2Wiki=item_get_field --></div>
+
<!-- Pod2Wiki=head_class_methods --></div>
===$metafield = $ds-&gt;get_field( $fieldname )===
+
===Class Methods===
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_new --></div>
 +
====$ds = EPrints::DataSet-&gt;new( %properties )====
  
Return a MetaField object describing the asked for field in this dataset, or undef if there is no such field.
+
Creates and returns a new dataset based on %properties.
 +
 
 +
Requires at least '''repository''' and '''name''' properties.
 +
 
 +
Available properties:
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_repository --></div>
 +
====repository OBJ====
 +
 
 +
Reference to the repository object.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_name --></div>
 +
====name STRING====
 +
 
 +
Name of the dataset.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_confid --></div>
 +
====confid STRING====
 +
 
 +
Name of the dataset this dataset is a subset of (e.g. 'archive' is a subset of 'eprint'). If defined requires dataset_id_field.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_dataset_id_field --></div>
 +
====dataset_id_field====
 +
 
 +
Name of the text field that contains the subset dataset id.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_sql_name --></div>
 +
====sql_name STRING====
 +
 
 +
Name of the primary database table.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_virtual --></div>
 +
====virtual BOOL====
 +
 
 +
Set to 1 if this dataset doesn't require it's own database tables.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_type --></div>
 +
====type STRING====
 +
 
 +
Type of data object the dataset contains e.g. for [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]] specify "EPrint".
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_class --></div>
 +
====class STRING====
 +
 
 +
Explicit class to use for data objects. To use the default object specify [[API:EPrints/DataObj|EPrints::DataObj]].
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_filters --></div>
 +
====filters ARRAYREF====
 +
 
 +
Filters to apply to this dataset before searching (see [[API:EPrints/Search|EPrints::Search]]).
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_datestamp --></div>
 +
====datestamp STRING====
 +
 
 +
The field name that contains a datestamp to order this dataset by.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_index --></div>
 +
====index BOOL====
 +
 
 +
Whether this dataset should be indexed.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_import --></div>
 +
====import BOOL====
 +
 
 +
Whether you can import into 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%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_system_dataset_info --></div>
 +
====$info = EPrints::DataSet::get_system_dataset_info()====
 +
 
 +
Returns a hash reference of core system datasets.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=head_object_methods --></div>
 +
===Object Methods===
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_base_id --></div>
 +
====$id = $ds-&gt;base_id====
 +
 
 +
  $ds = $repo-&gt;dataset( "inbox" );
 +
  $id = $ds-&gt;base_id; # returns "eprint"
 +
 
 +
Returns the identifier of the base dataset for this dataset (same as {{API:PodLink|file=|package_name=|section=id|text=/id}} unless this dataset is virtual).
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_process_field --></div>
 +
====$field = $ds-&gt;process_field( $data [, $system ] )====
 +
 
 +
Creates a new field in this dataset based on $data. If $system is true defines the new field as a "core" field.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_register_field --></div>
 +
====$ds-&gt;register_field( $field [, $system ] )====
 +
 
 +
Register a new field with 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%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_unregister_field --></div>
 +
====$ds-&gt;unregister_field( $field )====
 +
 
 +
Unregister a field from 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%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_field --></div>
 +
====$metafield = $ds-&gt;field( $fieldname )====
 +
 
 +
Returns the [[API:EPrints/MetaField|EPrints::MetaField]] from this dataset with the given name, or 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%; '>
Line 92: Line 281:
  
 
<!-- Pod2Wiki=item_has_field --></div>
 
<!-- Pod2Wiki=item_has_field --></div>
===$bool = $ds-&gt;has_field( $fieldname )===
+
====$bool = $ds-&gt;has_field( $fieldname )====
  
 
True if the dataset has a field of that name.
 
True if the dataset has a field of that name.
Line 101: Line 290:
  
  
<!-- Pod2Wiki=item_confid --></div>
+
<!-- Pod2Wiki=item_default_order --></div>
===$confid = $ds-&gt;confid===
+
====$ordertype = $ds-&gt;default_order====
  
Return the string to use when getting configuration for this dataset.
+
Return the id string of the default order for this dataset.  
  
archive, buffer, inbox and deletion all return "eprint" as they must have the same configuration.
+
For example "bytitle" for eprints.
  
 
<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 114: Line 303:
  
 
<!-- Pod2Wiki=item_id --></div>
 
<!-- Pod2Wiki=item_id --></div>
===$id = $ds-&gt;id===
+
====$id = $ds-&gt;id====
  
Return the id of this dataset. Unlike confid the buffer dataset will  return "buffer".  
+
Return the id of 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%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 124: Line 313:
  
 
<!-- Pod2Wiki=item_count --></div>
 
<!-- Pod2Wiki=item_count --></div>
===$n = $ds-&gt;count( $handle )===
+
====$n = $ds-&gt;count( $session )====
  
 
Return the number of records in this dataset.
 
Return the number of records in this dataset.
Line 133: Line 322:
  
  
<!-- Pod2Wiki=item_get_fields --></div>
+
<!-- Pod2Wiki=item_get_sql_table_name --></div>
===@fields = $ds-&gt;get_fields===
+
====$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.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_sql_index_table_name --></div>
 +
====$tablename = $ds-&gt;get_sql_index_table_name====
  
Returns a list of the EPrints::Metafields belonging to this dataset.
+
Return the name of the SQL table which contains the free text indexing information.
  
 
<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 143: Line 342:
  
  
<!-- Pod2Wiki=item_get_key_field --></div>
+
<!-- Pod2Wiki=item_get_sql_grep_table_name --></div>
===$field = $ds-&gt;get_key_field===
+
====$tablename = $ds-&gt;get_sql_grep_table_name====
  
Return the EPrints::MetaField representing the primary key field. Always the first field.
+
Reutrn the name of the SQL table which contains the strings to be used with LIKE in a final pass of a search.
  
 
<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 153: Line 352:
  
  
<!-- Pod2Wiki=item_create_object --></div>
+
<!-- Pod2Wiki=item_get_sql_rindex_table_name --></div>
===$obj = $ds-&gt;create_object( $handle, $data )===
+
====$tablename = $ds-&gt;get_sql_rindex_table_name====
  
Create a new object in the given dataset. Return the new object.
+
Reutrn the name of the SQL table which contains the reverse text indexing information. (Used for deleting freetext indexes when removing a record).
  
Return undef if the object could not be created.
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
  
If $data describes sub-objects too then those will also be created.
+
 
 +
<!-- Pod2Wiki=item_get_ordervalues_table_name --></div>
 +
====$tablename = $ds-&gt;get_ordervalues_table_name( $langid )====
 +
 
 +
Return the name of the SQL table containing values used for ordering 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%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_sql_sub_table_name --></div>
 +
====$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.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_fields --></div>
 +
====@fields = $ds-&gt;fields====
 +
 
 +
Returns a list of the [[API:EPrints/Metafield|EPrints::Metafield]]s belonging to 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%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_key_field --></div>
 +
====$field = $ds-&gt;key_field====
 +
 
 +
Return the [[API:EPrints/MetaField|EPrints::MetaField]] representing the primary key field.
 +
 
 +
Always the first field.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_make_object --></div>
 +
====$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.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_create_dataobj --></div>
 +
====$obj = $ds-&gt;create_dataobj( $data )====
 +
 
 +
Returns a new object in this dataset based on $data or undef on failure.
 +
 
 +
If $data describes sub-objects then those will also be created.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_object_class --></div>
 +
====$class = $ds-&gt;get_object_class;====
 +
 
 +
Return the perl class to which objects in this dataset belong.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_object --></div>
 +
====$obj = $ds-&gt;get_object( $session, $id );====
 +
 
 +
Return the object from this dataset with the given id, or undefined.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_dataobj --></div>
 +
====$dataobj = $ds-&gt;dataobj( $id )====
 +
 
 +
Returns the object from this dataset with the given id, or undefined.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_object_from_uri --></div>
 +
====$dataobj = EPrints::DataSet-&gt;get_object_from_uri( $session, $uri )====
 +
 
 +
Returns a the dataobj identified by internal URI $uri.
 +
 
 +
Returns undef if $uri isn't an internal URI or the object is no longer available.
  
 
<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 168: Line 473:
  
 
<!-- Pod2Wiki=item_render_name --></div>
 
<!-- Pod2Wiki=item_render_name --></div>
===$xhtml = $ds-&gt;render_name( $handle )===
+
====$xhtml = $ds-&gt;render_name( $session )====
  
Return a piece of XHTML describing this dataset, in the language of the given handle.
+
Return a piece of XHTML describing this dataset, in the language of the current session.
  
 
<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 178: Line 483:
  
 
<!-- Pod2Wiki=item_map --></div>
 
<!-- Pod2Wiki=item_map --></div>
===$ds-&gt;map( $handle, $fn, $info )===
+
====$ds-&gt;map( $session, $fn, $info )====
 +
 
 +
Maps the function $fn onto every record in this dataset. See  Search for a full explanation.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_repository --></div>
 +
====$repository = $ds-&gt;repository====
 +
 
 +
Returns the [[API:EPrints/Repository|EPrints::Repository]] to which this dataset belongs.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_reindex --></div>
 +
====$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.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_dataset_ids --></div>
 +
====@ids = EPrints::DataSet::get_dataset_ids()====
  
Maps the function $fn onto every record in this dataset. See  EPrints::List for a full explanation.
+
Deprecated, use $repository-&gt;get_dataset_ids().
  
 
<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 187: Line 524:
  
  
<!-- Pod2Wiki=item_get_repository --></div>
+
<!-- Pod2Wiki=item_get_sql_dataset_ids --></div>
===$repository = $ds-&gt;get_repository===
+
====@ids = EPrints::DataSet::get_sql_dataset_ids()====
 +
 
 +
Deprecated, use $repository-&gt;get_sql_dataset_ids().
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_count_indexes --></div>
 +
====$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)
  
Returns the EPrints::Repository to which this dataset belongs.
+
Assumes things either have 1 or 0 indexes which might not always be true.
  
 
<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 198: Line 547:
  
 
<!-- Pod2Wiki=item_get_item_ids --></div>
 
<!-- Pod2Wiki=item_get_item_ids --></div>
===@ids = $dataset-&gt;get_item_ids( $handle )===
+
====@ids = $dataset-&gt;get_item_ids( $session )====
  
 
Return a list of the id's of all items in this set.
 
Return a list of the id's of all items in this set.
Line 207: Line 556:
  
  
<!-- Pod2Wiki=head_see_also --></div>
+
<!-- Pod2Wiki=item_is_virtual --></div>
==SEE ALSO==
+
====$bool = $dataset-&gt;is_virtual()====
EPrints::MetaField, EPrints::DataObj
+
 
 +
Returns whether this dataset is virtual (i.e. has no database tables).
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_get_datestamp_field --></div>
 +
====$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.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_prepare_search --></div>
 +
====$searchexp = $ds-&gt;prepare_search( %options )====
 +
 
 +
Returns a [[API:EPrints/Search|EPrints::Search]] for this dataset with %options.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_search --></div>
 +
====$list = $ds-&gt;search( %options )====
 +
 
 +
Short-cut to {{API:PodLink|file=|package_name=|section=prepare_search|text=/prepare_search}}( %options )-&gt;execute.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_list --></div>
 +
====$list = $ds-&gt;list( $ids )====
 +
 
 +
Returns a [[API:EPrints/List|EPrints::List]] for this dataset for the given $ids list.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<h4><span style='display:none'>User Comments</span></h4>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=item_columns --></div>
 +
====$fields = $dataset-&gt;columns()====
 +
 
 +
Returns the default list of fields to show the user when browsing this dataset in a table. Returns an array ref of [[API:EPrints/MetaField|EPrints::MetaField]] objects.
  
 
<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 16:33, 12 February 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.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::DataSet - a dataset is a set of records in the eprints system with the same metadata.

User Comments


SYNOPSIS

 my $dataset = $repository->get_dataset( "inbox" );
 
 print sprintf("There are %d records in the inbox\n",
   $dataset->count);
 

User Comments


DESCRIPTION

This module describes an EPrint dataset.

A repository has several datasets that make up the repository's database. The list of dataset ids can be obtained from the repository object (see EPrints::Repository).

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.

The fields contained in a dataset are defined by the data object and by any additional fields defined in cfg.d. Some datasets don't have any fields while others may just be "virtual" datasets made from others.

User Comments


cachemap, counter

Don't have a package or metadata fields associated.

User Comments


archive, buffer, inbox, deletion

All have the same package and metadata fields as eprints, but are filtered by eprint_status.

User Comments


METHODS

User Comments


Class Methods

User Comments


$ds = EPrints::DataSet->new( %properties )

Creates and returns a new dataset based on %properties.

Requires at least repository and name properties.

Available properties:

User Comments


repository OBJ

Reference to the repository object.

User Comments


name STRING

Name of the dataset.

User Comments


confid STRING

Name of the dataset this dataset is a subset of (e.g. 'archive' is a subset of 'eprint'). If defined requires dataset_id_field.

User Comments


dataset_id_field

Name of the text field that contains the subset dataset id.

User Comments


sql_name STRING

Name of the primary database table.

User Comments


virtual BOOL

Set to 1 if this dataset doesn't require it's own database tables.

User Comments


type STRING

Type of data object the dataset contains e.g. for EPrints::DataObj::EPrint specify "EPrint".

User Comments


class STRING

Explicit class to use for data objects. To use the default object specify EPrints::DataObj.

User Comments


filters ARRAYREF

Filters to apply to this dataset before searching (see EPrints::Search).

User Comments


datestamp STRING

The field name that contains a datestamp to order this dataset by.

User Comments


index BOOL

Whether this dataset should be indexed.

User Comments


import BOOL

Whether you can import into this dataset.

User Comments


$info = EPrints::DataSet::get_system_dataset_info()

Returns a hash reference of core system datasets.

User Comments


Object Methods

User Comments


$id = $ds->base_id

 $ds = $repo->dataset( "inbox" );
 $id = $ds->base_id; # returns "eprint"
 

Returns the identifier of the base dataset for this dataset (same as /id unless this dataset is virtual).

User Comments


$field = $ds->process_field( $data [, $system ] )

Creates a new field in this dataset based on $data. If $system is true defines the new field as a "core" field.

User Comments


$ds->register_field( $field [, $system ] )

Register a new field with this dataset.

User Comments


$ds->unregister_field( $field )

Unregister a field from this dataset.

User Comments


$metafield = $ds->field( $fieldname )

Returns the EPrints::MetaField from this dataset with the given name, or undef.

User Comments


$bool = $ds->has_field( $fieldname )

True if the dataset has a field of that name.

User Comments


$ordertype = $ds->default_order

Return the id string of the default order for this dataset.

For example "bytitle" for eprints.

User Comments


$id = $ds->id

Return the id of this dataset.

User Comments


$n = $ds->count( $session )

Return the number of records in this dataset.

User Comments


$tablename = $ds->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.

User Comments


$tablename = $ds->get_sql_index_table_name

Return the name of the SQL table which contains the free text indexing information.

User Comments


$tablename = $ds->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.

User Comments


$tablename = $ds->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).

User Comments


$tablename = $ds->get_ordervalues_table_name( $langid )

Return the name of the SQL table containing values used for ordering this dataset.

User Comments


$tablename = $ds->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.

User Comments


@fields = $ds->fields

Returns a list of the EPrints::Metafields belonging to this dataset.

User Comments


$field = $ds->key_field

Return the EPrints::MetaField representing the primary key field.

Always the first field.

User Comments


$obj = $ds->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.

User Comments


$obj = $ds->create_dataobj( $data )

Returns a new object in this dataset based on $data or undef on failure.

If $data describes sub-objects then those will also be created.

User Comments


$class = $ds->get_object_class;

Return the perl class to which objects in this dataset belong.

User Comments


$obj = $ds->get_object( $session, $id );

Return the object from this dataset with the given id, or undefined.

User Comments


$dataobj = $ds->dataobj( $id )

Returns the object from this dataset with the given id, or undefined.

User Comments


$dataobj = EPrints::DataSet->get_object_from_uri( $session, $uri )

Returns a the dataobj identified by internal URI $uri.

Returns undef if $uri isn't an internal URI or the object is no longer available.

User Comments


$xhtml = $ds->render_name( $session )

Return a piece of XHTML describing this dataset, in the language of the current session.

User Comments


$ds->map( $session, $fn, $info )

Maps the function $fn onto every record in this dataset. See Search for a full explanation.

User Comments


$repository = $ds->repository

Returns the EPrints::Repository to which this dataset belongs.

User Comments


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

User Comments


@ids = EPrints::DataSet::get_dataset_ids()

Deprecated, use $repository->get_dataset_ids().

User Comments


@ids = EPrints::DataSet::get_sql_dataset_ids()

Deprecated, use $repository->get_sql_dataset_ids().

User Comments


$n = $ds->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.

User Comments


@ids = $dataset->get_item_ids( $session )

Return a list of the id's of all items in this set.

User Comments


$bool = $dataset->is_virtual()

Returns whether this dataset is virtual (i.e. has no database tables).

User Comments


$field = $dataset->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.

User Comments


$searchexp = $ds->prepare_search( %options )

Returns a EPrints::Search for this dataset with %options.

User Comments


$list = $ds->search( %options )

Short-cut to /prepare_search( %options )->execute.

User Comments


$list = $ds->list( $ids )

Returns a EPrints::List for this dataset for the given $ids list.

User Comments


$fields = $dataset->columns()

Returns the default list of fields to show the user when browsing this dataset in a table. Returns an array ref of EPrints::MetaField objects.

User Comments