Package net.sf.basedb.core
Class Quantity
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.Quantity
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Removable
,SystemItem
This class is used to represent a quantity for specifying units
to annotations.
- Version:
- 2.9
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The id for theQuantity
object representing absorbed dose.static final String
The id for theQuantity
object representing acceleration.static final String
The id for theQuantity
object representing angle.static final String
The id for theQuantity
object representing area.static final String
The id for theQuantity
object representing capacitance.static final String
The id for theQuantity
object representing electrical charge.static final String
The id for theQuantity
object representing electric current.static final String
The id for theQuantity
object representing density.static final String
The id for theQuantity
object representing energy.static final String
The id for theQuantity
object representing equivalent dose.static final String
The id for theQuantity
object representing flow rate.static final String
The id for theQuantity
object representing force.static final String
The id for theQuantity
object representing fractions.static final String
The id for theQuantity
object representing frequency.static final String
The id for theQuantity
object representing length.static final String
The id for theQuantity
object representing magnetic field.static final String
The id for theQuantity
object representing magnetic flux.static final String
The id for theQuantity
object representing mass.static final int
The maximum length of the reference unit that can be stored in the database.static final String
The id for theQuantity
object representing substance concentration.static final String
The id for theQuantity
object representing momentum.static final String
The id for theQuantity
object representing electrical potential.static final String
The id for theQuantity
object representing power.static final String
The id for theQuantity
object representing pressure.static final String
The id for theQuantity
object representing radioactivity.static final String
The id for theQuantity
object representing electrical resistance.static final String
The id for theQuantity
object representing storage sizes.static final String
The id for theQuantity
object representing "amount of substance".static final String
The id for theQuantity
object representing temperature.static final String
The id for theQuantity
object representing thermal conductivity.static final String
The id for theQuantity
object representing time.static final String
The id for theQuantity
object representing torque.static final Item
The type of item represented by this class.static final String
The id for theQuantity
object representing velocity.static final String
The id for theQuantity
object representing volume.Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
Fields inherited from interface net.sf.basedb.core.SystemItem
MAX_SYSTEM_ID_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Quantity
Get aQuantity
object when you know the ID.(package private) QuantityData
getData()
Get theBasicData
object that holds all data for this item.Get the description for the item.getName()
Get the name of the item.static Quantity
Create a newQuantity
item.getQuery()
Get a query configured to retrieve quantities.The reference unit describes the unit that all other units must relate to.Get the user that flagged this item for removal.Get the system id for the item.getType()
Get the type of item represented by the object.Get a a unit by symbol, also checking among the aliases.(package private) UnitData
Get the unit with a given symbol, or null if no unit is found.getUnits()
Get a query that returns all units of this quantity.Get all:Unit
:s for this quantityAnnotationType
:s using this quantity(package private) void
initPermissions
(int granted, int denied) If this is a system quantity, delete and create permissions are revoked.boolean
Check if the removed flag is set for this item.boolean
Check if the item is a system item or not.boolean
isUsed()
Check if: Units for this quantity exists.void
setDescription
(String description) Set the description for the item.void
Set the name of the item.void
setReferenceUnit
(String referenceUnit) Sets the reference unit.void
setRemoved
(boolean removed) Set the removed flag for this item.Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
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
-
Field Details
-
TYPE
The type of item represented by this class.- See Also:
-
LENGTH
The id for theQuantity
object representing length.- See Also:
-
- "http://physics.nist.gov/cuu/Units/meter.html"
- Constant Field Values
-
MASS
The id for theQuantity
object representing mass.- See Also:
-
- "http://physics.nist.gov/cuu/Units/kilogram.html"
- Constant Field Values
-
TIME
The id for theQuantity
object representing time.- See Also:
-
- "http://physics.nist.gov/cuu/Units/second.html"
- Constant Field Values
-
TEMPERATURE
The id for theQuantity
object representing temperature.- See Also:
-
- "http://physics.nist.gov/cuu/Units/kelvin.html"
- Constant Field Values
-
CURRENT
The id for theQuantity
object representing electric current.- See Also:
-
- "http://physics.nist.gov/cuu/Units/ampere.html"
- Constant Field Values
-
SUBSTANCE
The id for theQuantity
object representing "amount of substance".- See Also:
-
- "http://physics.nist.gov/cuu/Units/mole.html"
- Constant Field Values
-
AREA
The id for theQuantity
object representing area.- See Also:
-
- "http://en.wikipedia.org/wiki/Area"
- Constant Field Values
-
VOLUME
The id for theQuantity
object representing volume.- See Also:
-
- "http://en.wikipedia.org/wiki/Volume"
- Constant Field Values
-
VELOCITY
The id for theQuantity
object representing velocity.- See Also:
-
- "http://en.wikipedia.org/wiki/Speed"
- Constant Field Values
-
ANGLE
The id for theQuantity
object representing angle.- See Also:
-
- "http://en.wikipedia.org/wiki/Radian"
- Constant Field Values
-
FORCE
The id for theQuantity
object representing force.- See Also:
-
- "http://en.wikipedia.org/wiki/Newton"
- Constant Field Values
-
FREQUENCY
The id for theQuantity
object representing frequency.- See Also:
-
- "http://en.wikipedia.org/wiki/Newton"
- Constant Field Values
-
DENSITY
The id for theQuantity
object representing density.- See Also:
-
- "http://en.wikipedia.org/wiki/Density"
- Constant Field Values
-
ENERGY
The id for theQuantity
object representing energy.- See Also:
-
- "http://en.wikipedia.org/wiki/Joule"
- Constant Field Values
-
POWER
The id for theQuantity
object representing power.- See Also:
-
- "http://en.wikipedia.org/wiki/Watt"
- Constant Field Values
-
PRESSURE
The id for theQuantity
object representing pressure.- See Also:
-
- "http://en.wikipedia.org/wiki/Pascal_(unit)"
- Constant Field Values
-
POTENTIAL
The id for theQuantity
object representing electrical potential.- See Also:
-
- "http://en.wikipedia.org/wiki/Volt"
- Constant Field Values
-
RESISTANCE
The id for theQuantity
object representing electrical resistance.- See Also:
-
- "http://en.wikipedia.org/wiki/Ohm"
- Constant Field Values
-
CHARGE
The id for theQuantity
object representing electrical charge.- See Also:
-
- "http://en.wikipedia.org/wiki/Coulomb"
- Constant Field Values
-
CAPACITANCE
The id for theQuantity
object representing capacitance.- See Also:
-
- "http://en.wikipedia.org/wiki/Farad"
- Constant Field Values
-
MAGNETIC_FIELD
The id for theQuantity
object representing magnetic field.- See Also:
-
- "http://en.wikipedia.org/wiki/Tesla_(unit)"
- Constant Field Values
-
MAGNETIC_FLUX
The id for theQuantity
object representing magnetic flux.- See Also:
-
- "http://en.wikipedia.org/wiki/Weber_(unit)"
- Constant Field Values
-
ABSORBED_DOSE
The id for theQuantity
object representing absorbed dose.- See Also:
-
- "http://en.wikipedia.org/wiki/Gray_(unit)"
- Constant Field Values
-
EQUIVALENT_DOSE
The id for theQuantity
object representing equivalent dose.- See Also:
-
- "http://en.wikipedia.org/wiki/Sievert"
- Constant Field Values
-
RADIOACTIVITY
The id for theQuantity
object representing radioactivity.- See Also:
-
- "http://en.wikipedia.org/wiki/Becquerel"
- Constant Field Values
-
FRACTION
The id for theQuantity
object representing fractions.- See Also:
-
- "http://en.wikipedia.org/wiki/Parts-per_notation"
- Constant Field Values
-
ACCELERATION
The id for theQuantity
object representing acceleration.- See Also:
-
- "http://en.wikipedia.org/wiki/Acceleration"
- Constant Field Values
-
TORGUE
The id for theQuantity
object representing torque.- See Also:
-
- "http://en.wikipedia.org/wiki/Torque"
- Constant Field Values
-
MOMENTUM
The id for theQuantity
object representing momentum.- See Also:
-
- "http://en.wikipedia.org/wiki/Momentum"
- Constant Field Values
-
FLOW_RATE
The id for theQuantity
object representing flow rate.- See Also:
-
- "http://en.wikipedia.org/wiki/Volumetric_flow_rate"
- Constant Field Values
-
THERMAL_CONDUCTIVITY
The id for theQuantity
object representing thermal conductivity.- See Also:
-
- "http://en.wikipedia.org/wiki/Thermal_conductivity"
- Constant Field Values
-
STORAGE_SIZE
The id for theQuantity
object representing storage sizes.- See Also:
-
- "http://en.wikipedia.org/wiki/Byte"
- Constant Field Values
-
MOLAR_CONCENTRATION
The id for theQuantity
object representing substance concentration.- Since:
- 3.11
- See Also:
-
- "https://en.wikipedia.org/wiki/Molar_concentration"
- Constant Field Values
-
MAX_REFERENCE_UNIT_LENGTH
public static final int MAX_REFERENCE_UNIT_LENGTHThe maximum length of the reference unit that can be stored in the database.
-
-
Constructor Details
-
Quantity
Quantity(QuantityData data) Creates a quantity item.- Parameters:
data
- the data
-
-
Method Details
-
getNew
Create a newQuantity
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessreferenceUnit
- The reference unit which all units must relate to- Returns:
- The new
Quantity
item - Throws:
BaseException
- If there is an error
-
getById
public static Quantity getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aQuantity
object when you know the ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The system ID of the item to load.- Returns:
- The
Quantity
item - Throws:
ItemNotFoundException
- This exception is thrown if an item with the specified ID is not foundPermissionDeniedException
- This exception is thrown if the logged in user doesn't have read permission to the itemBaseException
- This exception is thrown if there is another error
-
getQuery
Get a query configured to retrieve quantities.- Returns:
- An
ItemQuery
object
-
getData
QuantityData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item. -
isUsed
Check if:- Units for this quantity exists.
- Annotation types are using this quantity
- Overrides:
isUsed
in classBasicItem
- Returns:
- TRUE if this item is used, FALSE otherwise
- Throws:
BaseException
- If not able to tell if item is used or not.- See Also:
-
getUsingItems
Get all:Unit
:s for this quantityAnnotationType
:s using this quantity
- Overrides:
getUsingItems
in classBasicItem
- Returns:
- A set containing proxies for the items, or an empty set if no items are using this item
- See Also:
-
initPermissions
If this is a system quantity, delete and create permissions are revoked.- Overrides:
initPermissions
in classBasicItem
- Parameters:
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass- Throws:
BaseException
- If the permissions couldn't be initialised
-
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
-
isRemoved
public boolean isRemoved()Description copied from interface:Removable
Check if the removed flag is set for this item. -
setRemoved
Description copied from interface:Removable
Set the removed flag for this item.- Specified by:
setRemoved
in interfaceRemovable
- Parameters:
removed
- TRUE if the item should be flagged as removed, FALSE otherwise- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.DELETE
permission for setting the flag to TRUE orPermission.WRITE
permission for setting the flag to FALSE
-
getRemovedBy
Description copied from interface:Removable
Get the user that flagged this item for removal.- Specified by:
getRemovedBy
in interfaceRemovable
- Returns:
- A User object, or null if this item has not been flagged
- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission for the userItemNotFoundException
- If the user that removed this item can't be found
-
getSystemId
Description copied from interface:SystemItem
Get the system id for the item.- Specified by:
getSystemId
in interfaceSystemItem
- Returns:
- The id of the item or null if it is not a system item
-
isSystemItem
public boolean isSystemItem()Description copied from interface:SystemItem
Check if the item is a system item or not. A system item have a non-null value for the system id.- Specified by:
isSystemItem
in interfaceSystemItem
- Returns:
- TRUE if this item is a system item, FALSE otherwise
-
getName
Description copied from interface:Nameable
Get the name of the item. -
setName
Description copied from interface:Nameable
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by theNameable.MAX_NAME_LENGTH
constant.- Specified by:
setName
in interfaceNameable
- Parameters:
name
- The new name for the item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the name is null or longer than specified by theNameable.MAX_NAME_LENGTH
constant
-
getDescription
Description copied from interface:Nameable
Get the description for the item.- Specified by:
getDescription
in interfaceNameable
- Returns:
- A
String
with a description of the item
-
setDescription
public void setDescription(String description) throws PermissionDeniedException, InvalidDataException Description copied from interface:Nameable
Set the description for the item. The description can be null but mustn't be longer than the value specified by theNameable.MAX_DESCRIPTION_LENGTH
constant.- Specified by:
setDescription
in interfaceNameable
- Parameters:
description
- The new description for the item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the description longer than specified by theNameable.MAX_DESCRIPTION_LENGTH
constant
-
getReferenceUnit
The reference unit describes the unit that all other units must relate to. When settingUnit.getReferenceFactor()
andUnit.getReferenceOffset()
for a unit the following formula should be used:1 reference unit * factor + offset = 1 of the unit
For example:1 meter * 0.001 + 0 = 1 millimeter 1 kelvin * 1 + 273.15 = 1 °Celsius
-
setReferenceUnit
public void setReferenceUnit(String referenceUnit) throws PermissionDeniedException, InvalidDataException Sets the reference unit.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the value is null, or longer thanMAX_REFERENCE_UNIT_LENGTH
-
getUnits
Get a query that returns all units of this quantity.- Returns:
- An
ItemQuery
object
-
getUnit
Get a a unit by symbol, also checking among the aliases. Note! This method always results in a database query. If you need to lookup lots of symbols, use aUnitCache
instead which has better performance.- Parameters:
symbol
- The symbol
-
getUnit
Get the unit with a given symbol, or null if no unit is found.
-