2.17.2: 2011-06-17

net.sf.basedb.core
Class Formula

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.OwnedItem<D>
          extended by net.sf.basedb.core.SharedItem<D>
              extended by net.sf.basedb.core.CommonItem<FormulaData>
                  extended by net.sf.basedb.core.Formula
All Implemented Interfaces:
AccessControlled, Controlled, Identifiable, Nameable, Ownable, Registered, Removable, Shareable, Validatable

public class Formula
extends CommonItem<FormulaData>
implements Validatable, Registered

This class represents a formula. Formulas can be used for various things such as calculating the spot intensities from raw data or filtering bioassay sets.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2010-08-13 12:48:17 +0200 (Fri, 13 Aug 2010) $

Nested Class Summary
static class Formula.AverageMethod
          The average method used for the values of this formula.
static class Formula.Parser
          The parser used to parse the formula.
static class Formula.Type
          The type of formula indicats in which situations it can be used.
 
Field Summary
private  Coloring coloring
           
static int MAX_FORMULA_LENGTH
          The maximum length of the formula that can be stored in the database.
static Item TYPE
          The type of item represented by this class.
 
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Constructor Summary
Formula(FormulaData formulaData)
           
 
Method Summary
 Formula.AverageMethod getAverageMethod()
          Get the average method for this formula.
static Formula getById(DbControl dc, int id)
          Get a Formula item when you know the ID.
 int getChannels()
          Get the number of channels required to be able to use this formula.
 Coloring getColoring()
          Get coloring information for this formula.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 String getFormula(int index)
          Get an expression.
 List<String> getFormulas()
          Get all expressions as an unmodifiable list.
 Formula.Type getFormulaType()
          Get the type of formula.
static Formula getNew(DbControl dc)
          Create a new Formula item.
 int getNumFormulas()
          Get the number of expression defined by this formula.
 Formula.Parser getParser()
          Get the parser that converts the formula to an expresion or restriction.
static ItemQuery<Formula> getQuery()
          Get a new query object for this class.
static ItemQuery<Formula> getQuery(Formula.Type type, RawDataType rawDataType, IntensityTransform source)
          Get a query that return formulas that can be used with the specified raw data type.
 RawDataType getRawDataType()
          Get the raw data type this formula can be used on.
 IntensityTransform getResultIntensityTransform()
          Get the spot intensity transformation that this formula generates.
 IntensityTransform getSourceIntensityTransform()
          Get the intensity transformation that is required on spot data if this formula should generate the correct result.
 Item getType()
          Get the type of item represented by the object.
 Type getValueType()
          Get the type of values that this formula produces.
 void setAverageMethod(Formula.AverageMethod averageMethod)
          Set the average method of the formula.
 void setChannels(int channels)
          Set the number of channels that are required to use this formula.
 void setFormulas(List<String> formulas)
          Set the expressions used by this formula.
 void setFormulaType(Formula.Type type)
          Set the type of the formula.
 void setParser(Formula.Parser parser)
          Set the parser used to convert the formula to an expression or restriction.
 void setRawDataType(RawDataType rawDataType)
          Set the raw data type this formula can be used on.
 void setResultIntensityTransform(IntensityTransform transform)
          Sets the transform that this formula generates.
 void setSourceIntensityTransform(IntensityTransform transform)
          Sets the transform that is required on spot data if this formula should generate the correct result.
 void setValueType(Type valueType)
          Set the type of the values that this formula produces.
(package private)  void validate()
          This method is called on each Validatable item before is saved to the database.
static ItemQuery<Formula> xgetQuery(Formula.Type type, RawDataType rawDataType)
          Deprecated. In 2.12. Use getQuery(Type, RawDataType, IntensityTransform) instead
 
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable
 
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable
 
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership, toTransferable
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.CLIENT, getType()

MAX_FORMULA_LENGTH

public static final int MAX_FORMULA_LENGTH
The maximum length of the formula that can be stored in the database. Check the length against this value before calling the setFormulas(List) method to avoid exceptions.

See Also:
Constant Field Values

coloring

private Coloring coloring
Constructor Detail

Formula

Formula(FormulaData formulaData)
Method Detail

getNew

public static Formula getNew(DbControl dc)
                      throws BaseException
Create a new Formula item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
Returns:
The new Formula item
Throws:
BaseException - If there is an error

getById

public static Formula getById(DbControl dc,
                              int id)
                       throws ItemNotFoundException,
                              PermissionDeniedException,
                              BaseException
Get a Formula item when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load
Returns:
The Formula item
Throws:
ItemNotFoundException - If an item with the specified ID is not found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

getQuery

public static ItemQuery<Formula> getQuery()
Get a new query object for this class.

Returns:
An ItemQuery object

xgetQuery

public static ItemQuery<Formula> xgetQuery(Formula.Type type,
                                           RawDataType rawDataType)
Deprecated. In 2.12. Use getQuery(Type, RawDataType, IntensityTransform) instead


getQuery

public static ItemQuery<Formula> getQuery(Formula.Type type,
                                          RawDataType rawDataType,
                                          IntensityTransform source)
Get a query that return formulas that can be used with the specified raw data type. The formulas returned are those that match the specified raw data type or are generic for the number of channels.

Parameters:
type - The type of formula to return, or null to return any type
rawDataType - The raw data type the formula should be useful for, or null to not filter on the raw data type
source - Source data intensity transformation that the formula should be useful for. This includes all formulas that has specified the same transformation and those that hasn't specified any transformation at all. If this parameter is null, no filtering on intensity transformation is done.
Returns:
An ItemQuery object
Since:
2.12

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Specified by:
getType in interface Identifiable
Returns:
A value indicating the type of item

getEntryDate

public Date getEntryDate()
Description copied from interface: Registered
Get the date that the item was registered in the database.

Specified by:
getEntryDate in interface Registered
Returns:
A date or null if this is not known

validate

void validate()
        throws InvalidDataException,
               BaseException
Description copied from class: BasicItem
This method is called on each Validatable item before is saved to the database. If the subclass overrides this method it should also propagate the call to the superclass, ie. super.validate().

Overrides:
validate in class BasicItem<FormulaData>
Throws:
BaseException - If there is an error
InvalidDataException
See Also:
Formula.Type.validate(Formula)

getAverageMethod

public Formula.AverageMethod getAverageMethod()
Get the average method for this formula.

Returns:
A Formula.AverageMethod object
Since:
2.4

setAverageMethod

public void setAverageMethod(Formula.AverageMethod averageMethod)
                      throws PermissionDeniedException,
                             InvalidDataException
Set the average method of the formula.

Parameters:
averageMethod - A Formula.AverageMethod object, null is not allowed
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the averageMethod is null
Since:
2.4

getFormulaType

public Formula.Type getFormulaType()
Get the type of formula. The type indicates in which situation the formula can be used.

Returns:
A Type object

setFormulaType

public void setFormulaType(Formula.Type type)
                    throws PermissionDeniedException,
                           InvalidDataException
Set the type of the formula. If the type is locked to a specific value type this is also changed.

Parameters:
type - A Type object, null is not allowed
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the type is null

getValueType

public Type getValueType()
Get the type of values that this formula produces.

Returns:
A Type object, or null if not known
Since:
2.15

setValueType

public void setValueType(Type valueType)
                  throws PermissionDeniedException,
                         InvalidDataException
Set the type of the values that this formula produces. Note! It is only Formula.Type.COLUMN_EXPRESSION formulas that can have a free value type. Calls to this method are ignored for other formula types.

Parameters:
valueType - A Type object, or null if not known
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException
Since:
2.15

getParser

public Formula.Parser getParser()
Get the parser that converts the formula to an expresion or restriction.

Returns:
A Formula.Parser object

setParser

public void setParser(Formula.Parser parser)
               throws PermissionDeniedException
Set the parser used to convert the formula to an expression or restriction.

Parameters:
parser - The Formula.Parser object, null is not allowed
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the parser is null

getSourceIntensityTransform

public IntensityTransform getSourceIntensityTransform()
Get the intensity transformation that is required on spot data if this formula should generate the correct result.

Returns:
An intensity transform or null if the formula can be used on all types of spot data
Since:
2.12

setSourceIntensityTransform

public void setSourceIntensityTransform(IntensityTransform transform)
Sets the transform that is required on spot data if this formula should generate the correct result.

Parameters:
transform - The required transform or null if the formula works with all kind of data
Since:
2.12

getResultIntensityTransform

public IntensityTransform getResultIntensityTransform()
Get the spot intensity transformation that this formula generates.

Returns:
An intensity transform or null if the formula generates the same kind of data used as source or doesn't generate intensity data at all
Since:
2.12

setResultIntensityTransform

public void setResultIntensityTransform(IntensityTransform transform)
Sets the transform that this formula generates.

Parameters:
transform - An intensity transform or null if the formula generates the same kind of data used as source or doesn't generate intensity data at all
Since:
2.12

getRawDataType

public RawDataType getRawDataType()
Get the raw data type this formula can be used on. A null value indicates that the formula can be used on any raw data type.

Returns:
A RawDataType object

setRawDataType

public void setRawDataType(RawDataType rawDataType)
                    throws PermissionDeniedException
Set the raw data type this formula can be used on. A null value indicates that the formula can be used on any raw data type.

Parameters:
rawDataType - The raw data type, or null
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission

getChannels

public int getChannels()
Get the number of channels required to be able to use this formula. A value of 0 indicates that the formula may be used on any number of channels.

Returns:
The number of channels or 0

setChannels

public void setChannels(int channels)
                 throws PermissionDeniedException,
                        InvalidDataException
Set the number of channels that are required to use this formula.

Parameters:
channels - The number of channels or 0
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the value is negative

getNumFormulas

public int getNumFormulas()
Get the number of expression defined by this formula.


getFormula

public String getFormula(int index)
Get an expression.

Parameters:
index - The index of the expression, starting at 0
Returns:
The expression

setFormulas

public void setFormulas(List<String> formulas)
                 throws InvalidDataException
Set the expressions used by this formula. All expressions must be set at once, they can't be changed individually.

Parameters:
formulas - The list of expressions
Throws:
InvalidDataException
InvalidUseOfNullException - If the list is null or empty or if an individual element in the list is null
PermissionDeniedException - If the logged in user doesn't have write permission

getFormulas

public List<String> getFormulas()
Get all expressions as an unmodifiable list.

Returns:
A list with the expressions

getColoring

public Coloring getColoring()
Get coloring information for this formula.

Returns:
A Coloring object

2.17.2: 2011-06-17