Difference between revisions of "API:EPrints/DataSet"

From EPrints Documentation
Jump to: navigation, search
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/DataSet.pm|package_name=EPrints::DataSet}}[[Category:API|DATASET]][[Category:API:EPrints/DataSet|DATASET]]<div><!-- Edit below this comment -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=perl_lib/EPrints/DataSet.pm|package_name=EPrints::DataSet}}[[Category:API|DATASET]][[Category:API:EPrints/DataSet|DATASET]]<div><!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 
==NAME==
 
==NAME==
'''EPrints::DataSet''' - a dataset is a set of records in the eprints system with the same metadata.
+
'''EPrints::DataSet''' - a set of records with the same metadata scheme
  
<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 -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_synopsis -->
 
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
  my $dataset = $repository-&gt;get_dataset( "inbox" );
+
<source lang="perl">my $dataset = $repository->dataset( "inbox" );
 
 
  print sprintf("There are %d records in the inbox\n",
 
    $dataset-&gt;count);
 
 
 
<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 -->
 
  
 +
print sprintf("There are %d records in the inbox\n",
 +
$dataset->count);
  
<!-- Pod2Wiki= -->
+
$string = $dataset->base_id; # eprint
</div>
+
$string = $dataset->id; # inbox
<!-- Pod2Wiki=head_description -->
 
==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 [[API:EPrints/Repository|EPrints::Repository]]).
+
$dataobj = $dataset->create_dataobj( $data );
 +
$user = $dataset->dataobj( 23 );
  
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.
+
$search = $dataset->prepare_search( %options );
 +
$list = $dataset->search( %options ); # prepare_search( %options )->execute
 +
$list = $dataset->search; # match ALL
  
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.
+
$metafield = $dataset->field( $fieldname );
 
+
$metafield = $dataset->key_field;
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '>
+
@metafields = $dataset->fields;
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_cachemap_counter -->
 
===cachemap, counter===
 
  
Don't have a package or metadata fields associated.
+
$dataset->search->map( sub {}, $ctx );
 +
$n = $dataset->search->count;
 +
$ids = $dataset->search->ids;
 +
$list = $dataset->list( \@ids );</source>
  
<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 -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_description -->
<!-- Pod2Wiki=item_archive_buffer_inbox_deletion -->
+
==DESCRIPTION==
===archive, buffer, inbox, deletion===
+
This module describes a dataset.
  
All have the same package and metadata fields as '''eprints''', but are filtered by '''eprint_status'''.
+
A repository has several datasets that make up the repository's metadata schema. The list of dataset ids can be obtained from the repository object (see [[API:EPrints/Repository|EPrints::Repository]]).
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
A normal dataset (eg. "user") has a package associated with it  (eg. [[API:EPrints/DataObj/User|EPrints::DataObj::User]]) which must be a subclass of [[API:EPrints/DataObj|EPrints::DataObj]]  and a number of SQL tables which are prefixed with the dataset name. Most datasets also have a set of associated [[API:EPrints/MetaField|EPrints::MetaField]]'s which may be optional or required depending on the type eg. books have editors but posters don't but they are both EPrints.
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
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.
  
<!-- Pod2Wiki= -->
+
Some datasets are "virtual" datasets made from others. Examples include  "inbox", "archive", "buffer" and "deletion" which are all virtual datasets  of of the "eprint" dataset. That is to say "inbox" is a subset of "eprint"  and by inference contains [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]]. You can define your own virtual datasets which opperate on existing datasets.
</div>
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
<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=head_class_methods -->
 
===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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_creating_custom_datasets -->
<!-- Pod2Wiki=item_new -->
+
==CREATING CUSTOM DATASETS==
====new====
+
New datasets can be defined in a configuration file, e.g.
  
  $ds = EPrints::DataSet-&gt;new( %properties )
+
<pre> $c-&gt;{datasets}-&gt;{bread} = {
Creates and returns a new dataset based on %properties.
+
    class =&gt; "EPrints::DataObj::Bread",
 +
    sqlname =&gt; "bread",
 +
  };</pre>
  
Requires at least '''repository''' and '''name''' properties.
+
This defines a dataset with the id <code>bread</code> (must be unique). The dataobj package (class) to instantiate objects with is <code>EPrints::DataObj::Bread</code>, which must be a sub-class of [[API:EPrints/DataObj|EPrints::DataObj]]. Lastly, the database tables used by the dataset will be called 'bread' or prefixed 'bread_'.
  
Available properties:
+
Other optional properties:
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<pre>  columns - an array ref of field ids to default the user view to
<span style='display:none'>User Comments</span>
+
  datestamp - field id to use to sort this dataset
<!-- Edit below this comment -->
+
  import - is the dataset importable?
 +
  index - is the dataset text-indexed?
 +
  order - is the dataset orderable?
 +
  virtual - completely virtual dataset (no database tables)</pre>
  
 +
To make one dataset a virtual dataset of another (as 'inbox' is to 'eprint') use the following properties:
  
<!-- Pod2Wiki= -->
+
<pre>  confid - the super-dataset this is a virtual sub-dataset of
</div>
+
  dataset_id_field - the field containing the sub-dataset id
<!-- Pod2Wiki=item_repository -->
+
  filters - an array ref of filters to apply when retrieving records</pre>
====repository====
 
  
repository OBJ
+
As with system datasets, the [[API:EPrints/MetaField|EPrints::MetaField]]s can be defined via [[API:EPrints/DataObj#get_system_field_info|EPrints::DataObj/get_system_field_info]] or via configuration:
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%; '>
+
<pre>  $c-&gt;add_dataset_field(
<span style='display:none'>User Comments</span>
+
    "bread",
<!-- Edit below this comment -->
+
    { name =&gt; "breadid", type =&gt; "counter", sql_counter =&gt; "bread" }
 +
  );
 +
  $c-&gt;add_dataset_field(
 +
    "bread",
 +
    { name =&gt; "toasted", type =&gt; "bool", }
 +
  );
 +
  $c-&gt;add_dataset_field(
 +
    "bread",
 +
    { name =&gt; "description", type =&gt; "text", }
 +
  );</pre>
  
 +
See [[API:EPrints/RepositoryConfig#add_dataset_field|EPrints::RepositoryConfig/add_dataset_field]] for details on <code>add_dataset_field</code>.
  
<!-- Pod2Wiki= -->
+
Creating a fully-operational dataset will require more configuration files. You will probably want at least a [[API:EPrints/Workflow|workflow]], [[API:EPrints/Citation|citations]] for the summary page, search results etc, and permissions and searching settings:
</div>
 
<!-- Pod2Wiki=item_name -->
 
====name====
 
  
  name STRING
+
<pre> push @{$c-&gt;{user_roles}-&gt;{admin}}, qw(
Name of the dataset.
+
    +bread/create
 +
    +bread/edit
 +
    +bread/view
 +
    +bread/destroy
 +
    +bread/details
 +
  );
 +
  push @{$c-&gt;{plugins}-&gt;{"Export::SummaryPage"}-&gt;{params}-&gt;{accept}}, qw(
 +
    dataobj/bread
 +
  );
 +
  $c-&gt;{datasets}-&gt;{bread}-&gt;{search}-&gt;{simple} = {
 +
    search_fields =&gt; {
 +
      id =&gt; "q",
 +
      meta_fields =&gt; [qw(
 +
        breadid
 +
        description
 +
      )],
 +
    },
 +
  };</pre>
  
<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 -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_methods -->
<!-- Pod2Wiki=item_confid -->
+
==METHODS==
====confid====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_class_methods -->
<!-- Pod2Wiki=item_dataset_id_field -->
+
===Class Methods===
====dataset_id_field====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_sql_name -->
 
====sql_name====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_virtual -->
 
====virtual====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_type -->
 
====type====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_class -->
 
====class====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_filters -->
 
====filters====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_datestamp -->
 
====datestamp====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_index -->
 
====index====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_import -->
 
====import====
 
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
<!-- Pod2Wiki=item_get_system_dataset_info -->
 
====get_system_dataset_info====
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
 
<!-- Pod2Wiki=head_object_methods -->
 
<!-- Pod2Wiki=head_object_methods -->
 
===Object Methods===
 
===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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_base_id -->
 
====base_id====
 
 
 
  $id = $ds-&gt;base_id
 
  $id = $ds-&gt;base_id
  $ds = $repo-&gt;dataset( "inbox" );
+
<pre>  $ds = $repo-&gt;dataset( "inbox" );
   $id = $ds-&gt;base_id; # returns "eprint"
+
   $id = $ds-&gt;base_id; # returns "eprint"</pre>
 
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_process_field -->
 
====process_field====
 
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_register_field -->
 
====register_field====
 
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
  
<!-- Pod2Wiki= -->
+
Returns the identifier of the base dataset for this dataset (same as [[API:EPrints/DataSet#id|id]] unless this dataset is virtual).
</div>
 
<!-- Pod2Wiki=item_unregister_field -->
 
====unregister_field====
 
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_field -->
 
====field====
 
  
 
  $metafield = $ds-&gt;field( $fieldname )
 
  $metafield = $ds-&gt;field( $fieldname )
 
Returns the [[API:EPrints/MetaField|EPrints::MetaField]] from this dataset with the given name, or undef.
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_has_field -->
 
====has_field====
 
 
$bool = $ds-&gt;has_field( $fieldname )
 
True if the dataset has a field of that name.
 
 
<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_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.
 
 
<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_id -->
 
====id====
 
  
 
  $id = $ds-&gt;id
 
  $id = $ds-&gt;id
 
Return the id of this dataset.
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_count -->
 
====count====
 
  
 
  $n = $ds-&gt;count( $session )
 
  $n = $ds-&gt;count( $session )
 
Return the number of records in this dataset.
 
Return the number of records in 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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- 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.
 
 
<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_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.
 
 
<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_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.
 
 
<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_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).
 
 
<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_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.
 
 
<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_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.
 
 
<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_fields -->
 
====fields====
 
  
 
  @fields = $ds-&gt;fields
 
  @fields = $ds-&gt;fields
 
Returns a list of the [[API:EPrints/MetaField|EPrints::MetaField]]s belonging to this dataset.
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_key_field -->
 
====key_field====
 
  
 
  $field = $ds-&gt;key_field
 
  $field = $ds-&gt;key_field
Line 504: Line 164:
 
Always the first 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%; '>
+
$dataobj = $ds-&gt;make_dataobj( $epdata )
<span style='display:none'>User Comments</span>
+
Return an object of the class associated with this dataset, always a subclass of [[API:EPrints/DataObj|EPrints::DataObj]].
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_make_object -->
 
====make_object====
 
  
$obj = $ds-&gt;make_object( $session, $data )
+
$epdata is a hash of values for fields in this dataset.
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.
+
Returns $epdata if no class is associated with 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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_create_dataobj -->
 
====create_dataobj====
 
  
 
  $obj = $ds-&gt;create_dataobj( $data )
 
  $obj = $ds-&gt;create_dataobj( $data )
Line 535: Line 175:
  
 
If $data describes sub-objects then those will also be created.
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- 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.
 
 
<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_get_object -->
 
====get_object====
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_dataobj -->
 
====dataobj====
 
  
 
  $dataobj = $ds-&gt;dataobj( $id )
 
  $dataobj = $ds-&gt;dataobj( $id )
 
Returns the object from this dataset with the given id, or undefined.
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_get_object_from_uri -->
 
====get_object_from_uri====
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- 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.
 
 
<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_map -->
 
====map====
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_repository -->
 
====repository====
 
  
 
  $repository = $ds-&gt;repository
 
  $repository = $ds-&gt;repository
 
Returns the [[API:EPrints/Repository|EPrints::Repository]] to which this dataset belongs.
 
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%; '>
+
$searchexp = $ds-&gt;prepare_search( %options )
<span style='display:none'>User Comments</span>
+
Returns a [[API:EPrints/Search|EPrints::Search]] for this dataset with %options.
<!-- Edit below this comment -->
 
  
 +
$list = $ds-&gt;search( %options )
 +
Short-cut to [[API:EPrints/DataSet#prepare_search|prepare_search]]( %options )-&gt;execute.
  
<!-- Pod2Wiki= -->
+
* satisfy_all
</div>
+
<pre>  satisfy_all"=&gt;1</pre>
<!-- Pod2Wiki=item_reindex -->
 
====reindex====
 
  
$ds-&gt;reindex( $session )
+
: Satify all conditions specified. 0 means satisfy any of the conditions specified. Default is 1
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.
+
* staff
 +
<pre>  "staff"=&gt;1</pre>
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
: Do search as an adminstrator means you get everything back
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
* custom_order
 +
<pre>  "custom_order" =&gt; "field1/-field2/field3"</pre>
  
<!-- Pod2Wiki= -->
+
: Order the search results by field order. prefixing the field name with a "-" results in reverse ordering
</div>
 
<!-- Pod2Wiki=item_get_dataset_ids -->
 
====get_dataset_ids====
 
  
  @ids = EPrints::DataSet::get_dataset_ids()
+
* filters
Deprecated, use $repository-&gt;get_dataset_ids().
+
<pre> "filters" =&gt; \@(
 +
                        { meta_fields=&gt;[ "field1", "field2" "document.field3" ],
 +
                          merge=&gt;"ANY", match=&gt;"EX",
 +
                          value=&gt;"bees"
 +
                        },
 +
                        { meta_fields=&gt;[ "field4" ],
 +
                          value=&gt; qw( honey ),
 +
                          match=&gt;"IN"
 +
                        }
 +
                      );</pre>
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
: This searchs for 'bees' in <code>field1</code> or <code>field2</code> or <code>document.field3</code>, and 'honey' in <code>field4</code>
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
: For details on the <code>merge</code> and <code>match</code> parameters, refer to [[API:EPrints/Search/Field|EPrints::Search::Field]]
  
<!-- Pod2Wiki= -->
+
<pre>  "limit" =&gt; 10</pre>
</div>
 
<!-- Pod2Wiki=item_get_sql_dataset_ids -->
 
====get_sql_dataset_ids====
 
  
@ids = EPrints::DataSet::get_sql_dataset_ids()
+
Only return 10 results
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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_list -->
<!-- Pod2Wiki=item_count_indexes -->
+
===list===
====count_indexes====
 
  
$n = $ds-&gt;count_indexes
+
<source lang="perl">$list = $ds->list( $ids )
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.
+
</source>
 +
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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_search_config -->
<!-- Pod2Wiki=item_get_item_ids -->
+
===search_config===
====get_item_ids====
 
 
 
@ids = $dataset-&gt;get_item_ids( $session )
 
Return a list of the id's of all items in this set.
 
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<source lang="perl">$sconf = $dataset->search_config( $searchid )
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
</source>
 +
Retrieve the search configuration $searchid for this dataset. This typically contains a set of fields to search over, order values and rendering parameters.
  
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_is_virtual -->
 
====is_virtual====
 
 
$bool = $dataset-&gt;is_virtual()
 
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%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- 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.
 
 
<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_prepare_search -->
 
====prepare_search====
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_copyright -->
<!-- Pod2Wiki=item_search -->
+
==COPYRIGHT==
====search====
+
Copyright 2000-2011 University of Southampton.
  
$list = $ds-&gt;search( %options )
+
This file is part of EPrints http://www.eprints.org/.
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%; '>
+
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  
<!-- Pod2Wiki= -->
+
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
</div>
 
<!-- Pod2Wiki=item_list -->
 
====list====
 
  
$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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=item_columns -->
 
====columns====
 
 
 
$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%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_run_trigger -->
 
====run_trigger====
 
 
$dataset-&gt;run_trigger( TRIGGER_ID, %params )
 
Runs all of the registered triggers for TRIGGER_ID on this dataset.
 
 
%params is passed to the trigger functions.
 
 
<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=_postamble_ --><!-- Edit below this comment -->
 

Latest revision as of 09:56, 22 January 2013

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 set of records with the same metadata scheme


SYNOPSIS

my $dataset = $repository->dataset( "inbox" );

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

$string = $dataset->base_id; # eprint
$string = $dataset->id; # inbox

$dataobj = $dataset->create_dataobj( $data );
$user = $dataset->dataobj( 23 );

$search = $dataset->prepare_search( %options );
$list = $dataset->search( %options ); # prepare_search( %options )->execute
$list = $dataset->search; # match ALL

$metafield = $dataset->field( $fieldname );
$metafield = $dataset->key_field;
@metafields = $dataset->fields;

$dataset->search->map( sub {}, $ctx );
$n = $dataset->search->count; 
$ids = $dataset->search->ids;
$list = $dataset->list( \@ids );


DESCRIPTION

This module describes a dataset.

A repository has several datasets that make up the repository's metadata schema. 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 required 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.

Some datasets are "virtual" datasets made from others. Examples include "inbox", "archive", "buffer" and "deletion" which are all virtual datasets of of the "eprint" dataset. That is to say "inbox" is a subset of "eprint" and by inference contains EPrints::DataObj::EPrint. You can define your own virtual datasets which opperate on existing datasets.


CREATING CUSTOM DATASETS

New datasets can be defined in a configuration file, e.g.

  $c->{datasets}->{bread} = {
    class => "EPrints::DataObj::Bread",
    sqlname => "bread",
  };

This defines a dataset with the id bread (must be unique). The dataobj package (class) to instantiate objects with is EPrints::DataObj::Bread, which must be a sub-class of EPrints::DataObj. Lastly, the database tables used by the dataset will be called 'bread' or prefixed 'bread_'.

Other optional properties:

  columns - an array ref of field ids to default the user view to
  datestamp - field id to use to sort this dataset
  import - is the dataset importable?
  index - is the dataset text-indexed?
  order - is the dataset orderable?
  virtual - completely virtual dataset (no database tables)

To make one dataset a virtual dataset of another (as 'inbox' is to 'eprint') use the following properties:

  confid - the super-dataset this is a virtual sub-dataset of
  dataset_id_field - the field containing the sub-dataset id
  filters - an array ref of filters to apply when retrieving records

As with system datasets, the EPrints::MetaFields can be defined via EPrints::DataObj/get_system_field_info or via configuration:

  $c->add_dataset_field(
    "bread",
    { name => "breadid", type => "counter", sql_counter => "bread" }
  );
  $c->add_dataset_field(
    "bread",
    { name => "toasted", type => "bool", }
  );
  $c->add_dataset_field(
    "bread",
    { name => "description", type => "text", }
  );

See EPrints::RepositoryConfig/add_dataset_field for details on add_dataset_field.

Creating a fully-operational dataset will require more configuration files. You will probably want at least a workflow, citations for the summary page, search results etc, and permissions and searching settings:

  push @{$c->{user_roles}->{admin}}, qw(
    +bread/create
    +bread/edit
    +bread/view
    +bread/destroy
    +bread/details
  );
  push @{$c->{plugins}->{"Export::SummaryPage"}->{params}->{accept}}, qw(
    dataobj/bread
  );
  $c->{datasets}->{bread}->{search}->{simple} = {
    search_fields => {
      id => "q",
      meta_fields => [qw(
        breadid
        description
      )],
    },
  };


METHODS

Class Methods

Object Methods

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

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

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

$id = $ds->id

Return the id of this dataset.

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

Return the number of records in this dataset.

@fields = $ds->fields

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

$field = $ds->key_field

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

Always the first field.

$dataobj = $ds->make_dataobj( $epdata )

Return an object of the class associated with this dataset, always a subclass of EPrints::DataObj.

$epdata is a hash of values for fields in this dataset.

Returns $epdata if no class is associated with this dataset.

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

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

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

$repository = $ds->repository

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

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

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

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

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

  • satisfy_all
   satisfy_all"=>1
Satify all conditions specified. 0 means satisfy any of the conditions specified. Default is 1
  • staff
  "staff"=>1
Do search as an adminstrator means you get everything back
  • custom_order
  "custom_order" => "field1/-field2/field3"
Order the search results by field order. prefixing the field name with a "-" results in reverse ordering
  • filters
  "filters" => \@(
                         { meta_fields=>[ "field1", "field2" "document.field3" ],
                           merge=>"ANY", match=>"EX",
                           value=>"bees"
                         },
                         { meta_fields=>[ "field4" ],
                           value=> qw( honey ),
                           match=>"IN"
                         }
                       );
This searchs for 'bees' in field1 or field2 or document.field3, and 'honey' in field4
For details on the merge and match parameters, refer to EPrints::Search::Field
  "limit" => 10

Only return 10 results


list

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

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


search_config

$sconf = $dataset->search_config( $searchid )

Retrieve the search configuration $searchid for this dataset. This typically contains a set of fields to search over, order values and rendering parameters.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.