Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
API:EPrints/DataSet
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
<!-- 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. -->{{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 --> ==NAME== '''EPrints::DataSet''' - a set of records with the same metadata scheme <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_synopsis --> ==SYNOPSIS== <source lang="perl">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 );</source> <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_description --> ==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 [[API:EPrints/Repository|EPrints::Repository]]). 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. 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 [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]]. You can define your own virtual datasets which opperate on existing datasets. <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_creating_custom_datasets --> ==CREATING CUSTOM DATASETS== New datasets can be defined in a configuration file, e.g. <pre> $c->{datasets}->{bread} = { class => "EPrints::DataObj::Bread", sqlname => "bread", };</pre> 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_'. Other optional properties: <pre> 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)</pre> To make one dataset a virtual dataset of another (as 'inbox' is to 'eprint') use the following properties: <pre> 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</pre> 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: <pre> $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", } );</pre> See [[API:EPrints/RepositoryConfig#add_dataset_field|EPrints::RepositoryConfig/add_dataset_field]] for details on <code>add_dataset_field</code>. 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: <pre> 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 )], }, };</pre> <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_methods --> ==METHODS== <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_class_methods --> ===Class Methods=== <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_object_methods --> ===Object Methods=== $id = $ds->base_id <pre> $ds = $repo->dataset( "inbox" ); $id = $ds->base_id; # returns "eprint"</pre> Returns the identifier of the base dataset for this dataset (same as [[API:EPrints/DataSet#id|id]] unless this dataset is virtual). $metafield = $ds->field( $fieldname ) Returns the [[API:EPrints/MetaField|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 [[API:EPrints/MetaField|EPrints::MetaField]]s belonging to this dataset. $field = $ds->key_field Return the [[API:EPrints/MetaField|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 [[API:EPrints/DataObj|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 [[API:EPrints/Repository|EPrints::Repository]] to which this dataset belongs. $searchexp = $ds->prepare_search( %options ) Returns a [[API:EPrints/Search|EPrints::Search]] for this dataset with %options. $list = $ds->search( %options ) Short-cut to [[API:EPrints/DataSet#prepare_search|prepare_search]]( %options )->execute. * satisfy_all <pre> satisfy_all"=>1</pre> : Satify all conditions specified. 0 means satisfy any of the conditions specified. Default is 1 * staff <pre> "staff"=>1</pre> : Do search as an adminstrator means you get everything back * custom_order <pre> "custom_order" => "field1/-field2/field3"</pre> : Order the search results by field order. prefixing the field name with a "-" results in reverse ordering * filters <pre> "filters" => \@( { meta_fields=>[ "field1", "field2" "document.field3" ], merge=>"ANY", match=>"EX", value=>"bees" }, { meta_fields=>[ "field4" ], value=> qw( honey ), match=>"IN" } );</pre> : This searchs for 'bees' in <code>field1</code> or <code>field2</code> or <code>document.field3</code>, and 'honey' in <code>field4</code> : For details on the <code>merge</code> and <code>match</code> parameters, refer to [[API:EPrints/Search/Field|EPrints::Search::Field]] <pre> "limit" => 10</pre> Only return 10 results <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_list --> ===list=== <source lang="perl">$list = $ds->list( $ids ) </source> Returns a [[API:EPrints/List|EPrints::List]] for this dataset for the given $ids list. <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_search_config --> ===search_config=== <source lang="perl">$sconf = $dataset->search_config( $searchid ) </source> Retrieve the search configuration $searchid for this dataset. This typically contains a set of fields to search over, order values and rendering parameters. <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=head_copyright --> ==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/. <!-- Edit below this comment --> <!-- Pod2Wiki= --> <!-- Pod2Wiki=_postamble_ --> <!-- Edit below this comment -->
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:API
(
edit
)
Template:API:Source
(
edit
)
Template:Pod2Wiki
(
edit
)
Template:RefLinks
(
edit
)