Difference between revisions of "API:EPrints/List"

From EPrints Documentation
Jump to: navigation, search
(New page: <!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost. -...)
 
(Removing all content from page)
Line 1: Line 1:
<!-- Pod2Wiki=_preamble_
 
This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost.
 
-->{{Pod2Wiki}}{{API:Source|file=EPrints/List.pm|package_name=EPrints::List}}[[Category:API|List]]<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_name -->=NAME=
 
'''EPrints::List''' - List of data objects, usually a search result.
 
  
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_description -->=DESCRIPTION=
 
This class represents an ordered list of objects, all from the same dataset. Usually this is the results of a search.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_new -->==new==
 
 
  $list = EPrints::List-&gt;new( session =&gt; $session, dataset =&gt; $dataset, [desc =&gt; $desc], [desc_order =&gt; $desc_order], ids =&gt; $ids, [encoded =&gt; $encoded], [keep_cache =&gt; $keep_cache], [order =&gt; $order] );
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_new -->==new==
 
 
  $list = EPrints::List-&gt;new( session =&gt; $session, dataset =&gt; $dataset, [desc =&gt; $desc], [desc_order =&gt; $desc_order], cache_id =&gt; $cache_id );
 
 
Creates a new list object in memory only. Lists will be cached if anything method requiring order is called, or an explicit  cache() method is called.
 
 
encoded is the serialised version of the searchExpression which created this list, if there was one.
 
 
If keep_cache is set then the cache will not be disposed of at the end of the current $session. If cache_id is set then keep_cache is automatically true.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_reorder -->==reorder==
 
 
  $new_list = $list-&gt;reorder( $new_order );
 
 
Create a new list from this one, but sorted in a new way.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_union -->==union==
 
 
  $new_list = $list-&gt;union( $list2, [$order] );
 
 
Create a new list from this one plus another one. If order is not set then this list will not be in any certain order.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_remainder -->==remainder==
 
 
  $new_list = $list-&gt;remainder( $list2, [$order] );
 
 
Create a new list from this one minus another one. If order is not set then this list will not be in any certain order.
 
 
Remove all items in $list2 from $list and return the result as a new EPrints::List.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_intersect -->==intersect==
 
 
  $new_list = $list-&gt;intersect( $list2, [$order] );
 
 
Create a new list containing only the items which are in both lists. If order is not set then this list will not be in any certain order.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_cache -->==cache==
 
 
  $list-&gt;cache
 
 
Cause this list to be cached in the database.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_cache_id -->==get_cache_id==
 
 
  $cache_id = $list-&gt;get_cache_id
 
 
Return the ID of the cache table for this list, or undef.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_dispose -->==dispose==
 
 
  $list-&gt;dispose
 
 
Clean up the cache table if appropriate.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_count -->==count==
 
 
  $n = $list-&gt;count
 
 
Return the number of values in this list.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_records -->==get_records==
 
 
  @dataobjs = $list-&gt;get_records( [$offset], [$count] )
 
 
Return the objects described by this list. $count is the maximum to return. $offset is what index through the list to start from.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_ids -->==get_ids==
 
 
  $ids = $list-&gt;get_ids( [$offset], [$count] )
 
 
Return a reference to an array containing the ids of the specified range from the list. This is more efficient if you just need the ids.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_map -->==map==
 
 
  $list-&gt;map( $function, $info )
 
 
Map the given function pointer to all the items in the list, in order. This loads the items in batches of 100 to reduce memory  requirements.
 
 
$info is a datastructure which will be passed to the function each  time and is useful for holding or collecting state.
 
 
Example:
 
 
my $info = { matches =&gt; 0 };
 
$list-&gt;map( \&amp;deal, $info );
 
print "Matches: ".$info-&gt;{matches}."\n";
 
 
 
 
sub deal
 
{
 
  my( $session, $dataset, $eprint, $info ) = @_;
 
 
  if( $eprint-&gt;get_value( "a" ) eq $eprint-&gt;get_value( "b" ) ) {
 
    $info-&gt;{matches} += 1;
 
  }
 
 
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_export -->==export==
 
 
  $plugin_output = $list-&gt;export( $plugin_id, %params )
 
 
Apply an output plugin to this list of items. If the param "fh" is set it will send the results to a filehandle rather than return them as a string.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_dataset -->==get_dataset==
 
 
  $dataset = $list-&gt;get_dataset
 
 
Return the EPrints::DataSet which this list relates to.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_description -->==render_description==
 
 
  $xhtml = $list-&gt;render_description
 
 
Return a DOM XHTML description of this list, if available, or an empty fragment.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
 

Revision as of 15:40, 12 August 2009