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
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
Modifier and TypeClassDescriptionstatic enum
The average method used for the values of this formula.static enum
The parser used to parse the formula.static enum
The type of formula indicats in which situations it can be used. -
Field Summary
Modifier and TypeFieldDescriptionprivate Coloring
static final int
The maximum length of the formula that can be stored in the database.static final Item
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
-
Method Summary
Modifier and TypeMethodDescriptionGet the average method for this formula.static Formula
Get aFormula
item when you know the ID.int
Get the number of channels required to be able to use this formula.Get coloring information for this formula.(package private) FormulaData
getData()
Get theBasicData
object that holds all data for this item.Get the date that the item was registered in the database.getFormula
(int index) Get an expression.Get all expressions as an unmodifiable list.Get the type of formula.static Formula
Create a newFormula
item.int
Get the number of expression defined by this formula.Get the parser that converts the formula to an expresion or restriction.getQuery()
Get a new query object for this class.getQuery
(Formula.Type type, RawDataType rawDataType, IntensityTransform source) Get a query that return formulas that can be used with the specified raw data type.Get the raw data type this formula can be used on.Get the spot intensity transformation that this formula generates.Get the intensity transformation that is required on spot data if this formula should generate the correct result.getType()
Get the type of item represented by the object.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 Details
-
TYPE
The type of item represented by this class.- See Also:
-
MAX_FORMULA_LENGTH
public static final int MAX_FORMULA_LENGTHThe 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:
-
coloring
-
-
Constructor Details
-
Formula
Formula(FormulaData formulaData)
-
-
Method Details
-
getNew
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
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
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
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
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
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:
-
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
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
Get the type of values that this formula produces.- Returns:
- A
Type
object, or null if not known - Since:
- 2.15
-
setValueType
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
Get the parser that converts the formula to an expresion or restriction.- Returns:
- A
Formula.Parser
object
-
setParser
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
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
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
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
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
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
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
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
Get an expression.- Parameters:
index
- The index of the expression, starting at 0- Returns:
- The expression
-
setFormulas
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
Get all expressions as an unmodifiable list.- Returns:
- A list with the expressions
-
getColoring
Get coloring information for this formula.- Returns:
- A
Coloring
object
-