Package net.sf.basedb.core
Class Formula
- java.lang.Object
-
- net.sf.basedb.core.BasicItem
-
- net.sf.basedb.core.OwnedItem
-
- net.sf.basedb.core.SharedItem
-
- net.sf.basedb.core.CommonItem
-
- net.sf.basedb.core.Formula
-
- All Implemented Interfaces:
AccessControlled
,Controlled
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
,Validatable
public class Formula extends CommonItem 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: 2017-03-13 09:15:46 +0100 (må, 13 mar 2017) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
Fields Modifier and Type Field Description 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
Constructors Constructor Description Formula(FormulaData formulaData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Formula.AverageMethod
getAverageMethod()
Get the average method for this formula.static Formula
getById(DbControl dc, int id)
Get aFormula
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.(package private) FormulaData
getData()
Get theBasicData
object that holds all data for this item.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 newFormula
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
setEntryDate(Date entryDate)
Set the date the entry was registered in the database.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 eachValidatable
item before is saved to the database.-
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
-
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
-
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership
-
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
-
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
-
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 thesetFormulas(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 newFormula
item.- Parameters:
dc
- TheDbControl
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 aFormula
item when you know the ID.- Parameters:
dc
- TheDbControl
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 foundPermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is another error
-
getQuery
public static ItemQuery<Formula> getQuery()
Get a new query object for this class.- Returns:
- An
ItemQuery
object
-
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 typerawDataType
- The raw data type the formula should be useful for, or null to not filter on the raw data typesource
- 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
-
getData
FormulaData getData()
Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classCommonItem
-
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 theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- 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 interfaceRegistered
- Returns:
- A date or null if this is not known
-
setEntryDate
public void setEntryDate(Date entryDate)
Description copied from interface:Registered
Set the date the entry was registered in the database. Implementations should only allow this property to be set before the item is first stored in the database. The intention of this method is to facilitate export/import of data between server.- Specified by:
setEntryDate
in interfaceRegistered
- Parameters:
entryDate
- A date or null to use today's date
-
validate
void validate() throws InvalidDataException, BaseException
Description copied from class:BasicItem
This method is called on eachValidatable
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 classBasicItem
- Throws:
BaseException
- If there is an errorInvalidDataException
- 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
- AFormula.AverageMethod
object, null is not allowed- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- 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
Formula.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
- AFormula.Type
object, null is not allowed- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- 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 onlyFormula.Type.COLUMN_EXPRESSION
formulas that can have a free value type. Calls to this method are ignored for other formula types.- Parameters:
valueType
- AType
object, or null if not known- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- 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
- TheFormula.Parser
object, null is not allowed- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- 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 permissionInvalidDataException
- 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:
InvalidUseOfNullException
- If the list is null or empty or if an individual element in the list is nullPermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
-
getFormulas
public List<String> getFormulas()
Get all expressions as an unmodifiable list.- Returns:
- A list with the expressions
-
-