Class 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) $
  • Field Details

    • TYPE

      public static final Item TYPE
      The type of item represented by this class.
      See Also:
    • 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:
    • coloring

      private Coloring coloring
  • Constructor Details

  • Method Details

    • 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
    • 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
    • getData

      FormulaData getData()
      Description copied from class: BasicItem
      Get the BasicData object that holds all data for this item.
      Overrides:
      getData in class CommonItem
    • 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
    • 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 interface Registered
      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 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
      Throws:
      BaseException - If there is an error
      InvalidDataException
      See Also:
    • 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 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 - A Formula.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:
      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
      InvalidDataException
    • 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