2.17.2: 2011-06-17

net.sf.basedb.util.biomaterial
Class ListUtil

java.lang.Object
  extended by net.sf.basedb.util.biomaterial.ListUtil

public class ListUtil
extends Object

Utility class for working with biomaterials.

Version:
2.10
Author:
Nicklas
Last modified
$Date: 2009-01-13 09:20:26 +0100 (Tue, 13 Jan 2009) $

Constructor Summary
ListUtil()
           
 
Method Summary
static
<S extends BioMaterial>
int
addToList(BioMaterialList list, Collection<? extends S> sources, CollectionTransformer<S,? extends BioMaterial> transformer)
          Adds items to a biomaterial list.
static CollectionTransformer createTransformer(DbControl dc, Item sourceItem, Item destinationItem, boolean pooled)
          Create a transformer that can transform a collection with sourceItem:s into a collection with destinationItem:s by following parent/child paths.
static ItemQuery<? extends BioMaterial> getQuery(Item biomaterialType)
          Get a query that returns all biomaterials that can possibly be members of this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListUtil

public ListUtil()
Method Detail

getQuery

public static ItemQuery<? extends BioMaterial> getQuery(Item biomaterialType)
                                                 throws BaseException
Get a query that returns all biomaterials that can possibly be members of this list. NOTE! This is just a convenience function that calls BioSource.getQuery(), etc. depending on the member type of the list.

Returns:
An ItemQuery object
Throws:
BaseException - If the query could not be created and configured.

addToList

public static <S extends BioMaterial> int addToList(BioMaterialList list,
                                                    Collection<? extends S> sources,
                                                    CollectionTransformer<S,? extends BioMaterial> transformer)
                     throws InvalidDataException,
                            PermissionDeniedException
Adds items to a biomaterial list. The source collection can optionally be transformed by a transformer. If no transformer is given, the source collection is added. The items added to the list must of course be of the correct BioMaterialList.getMemberType() for the list.

Parameters:
list - The list to add items to
sources - The source collection of biomaterials
transformer - An optional transformer
Returns:
The number of items added to the biomaterial list
Throws:
InvalidDataException - If an item is not of the correct member type
PermissionDeniedException - If the logged in user doesn't have write permission for the list

createTransformer

public static CollectionTransformer createTransformer(DbControl dc,
                                                      Item sourceItem,
                                                      Item destinationItem,
                                                      boolean pooled)
Create a transformer that can transform a collection with sourceItem:s into a collection with destinationItem:s by following parent/child paths. Both the source and destination must be one of Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT or Item.LABELEDEXTRACT.

Parameters:
dc - The DbControl the transformers should use for loading items from the database
sourceItem - The type of source items
destinationItem - The type of destination items
pooled - If pooled children/parents should be considered or not
Returns:
A collection transformer (never null)

2.17.2: 2011-06-17