Package net.sf.basedb.core
Class VirtualDb
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.ChildItem
net.sf.basedb.core.VirtualDb
- All Implemented Interfaces:
AccessControlled
,Identifiable
A virtual database represents the set of tables in the dynamic database used
by a single experiment to store it's analysed data.
This class is not intended to be exposed to client applications. It is only used internally to handle the creation and deletion of the tables in the dynamic database.
The names of the dynamic tables depends on the ID of this object. The name
is generated by the VirtualTable
enumeration.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
Field Summary
-
Constructor Summary
ConstructorDescriptionVirtualDb
(VirtualDbData data) Creates a new experiment item from the given data. -
Method Summary
Modifier and TypeMethodDescription(package private) void
createTables
(VirtualTable... tables) Create the real database tables for this virtual database.(package private) int
deleteAllCubeData
(short cubeNo) Delete all analysed data for the specified data cube.(package private) int
deleteAllCubeExtraValueData
(short cubeNo, short extraNo, VirtualTable extraTable) Delete all extra value data for the specified extra value type in the specified data cube.(package private) int
deleteAllCubeFilterData
(short cubeNo, short filterNo) Delete all analysed data for the specified filter in the specified data cube.(package private) int
deleteAllCubeLayerData
(short cubeNo, short layerNo) Delete all analysed data for the specified layer in the specified data cube.private void
Drop all real database tables in this virtual database.(package private) static VirtualDb
Get aVirtualDb
item when you know the id.short
getCubes()
Get the number ofDataCube
:s in this virtual database.(package private) VirtualDbData
getData()
Get theBasicData
object that holds all data for this item.Get the experiment this set of tables stores data for.short
Get the number of DataCubeMapping:s in this virtual database.(package private) static VirtualDb
Create a newDynamicTables
item.(package private) short
Generate the next available cube number.(package private) Permission
USE permission is enough to be able to manage virtual db.Return a filter that can be used to check that a query is only using cloned reporter properties for sorting, filtering, etc.Get the raw data type the experiment uses for the raw data.Get the reporter clone template that is active in the current virtual database.(package private) SharedData
Get the experiment.getType()
Get the type of item represented by the object.boolean
hasClonedReporterProperty
(String propertyName) Checks if this virtual db has cloned the given reporter property or not.boolean
Check if this virtual db is storing cloned reporter information or not.boolean
hasTable
(VirtualTable table) Check if a real database table for this virtual database exists.(package private) DataCube
Create a new data cube in this virtual database.(package private) void
onAfterCommit
(Transactional.Action action) Remove all dynamic tables if action == Action.DELETEMethods inherited from class net.sf.basedb.core.ChildItem
getPermissionForUse, getPluginPermissions, initPermissions
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
-
Field Details
-
logSql
Log all SQL statements. -
debugSqlEnabled
private static final boolean debugSqlEnabledSo we don't always have to call logSql.debug() -
TYPE
The type of item represented by this class.- See Also:
-
-
Constructor Details
-
VirtualDb
VirtualDb(VirtualDbData data) Creates a new experiment item from the given data.- Parameters:
data
- the data
-
-
Method Details
-
getNew
Create a newDynamicTables
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.- Returns:
- The new
DynamicTables
item - Throws:
BaseException
- If there is an error
-
getById
static VirtualDb getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aVirtualDb
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
VirtualDb
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
-
getData
VirtualDbData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this 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.- Returns:
- A value indicating the type of item
-
onAfterCommit
Remove all dynamic tables if action == Action.DELETE -
getPermissionForWriteDeleteAndCreate
Permission getPermissionForWriteDeleteAndCreate()USE permission is enough to be able to manage virtual db.- Overrides:
getPermissionForWriteDeleteAndCreate
in classChildItem
-
getRawDataType
Get the raw data type the experiment uses for the raw data.- Returns:
- A
RawDataType
object
-
getExperiment
Get the experiment this set of tables stores data for.- Returns:
- An
Experiment
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the experimentBaseException
- If there is another error
-
getReporterCloneTemplate
Get the reporter clone template that is active in the current virtual database. If no cloned reporter information exists, this method return null.- Returns:
- A
ReporterCloneTemplate
(locked) or null - Since:
- 3.1
-
hasClonedReporters
public boolean hasClonedReporters()Check if this virtual db is storing cloned reporter information or not.- Since:
- 3.1
-
hasClonedReporterProperty
Checks if this virtual db has cloned the given reporter property or not.- Parameters:
propertyName
- The name of a reporter property- Since:
- 3.1
-
getQueryPropertyInspector
Return a filter that can be used to check that a query is only using cloned reporter properties for sorting, filtering, etc. The filter will reject reporter properties (starting with '@') that have not been cloned.- Returns:
- A filter or null if this virtual db doesn't have cloned reporters
- Since:
- 3.1
- See Also:
-
getCubes
public short getCubes()Get the number ofDataCube
:s in this virtual database. Each new data cube increases this value with one. -
getNextCubeNo
Generate the next available cube number. This method will open a second transaction and update thegetCubes()
property by one.- Returns:
- The next cube number
- Throws:
BaseException
-
getMappings
public short getMappings()Get the number of DataCubeMapping:s in this virtual database. Each new mapping increases this value with one. -
newDataCube
Create a new data cube in this virtual database. The number of the new data cube will be one more than the current value ofgetCubes()
. -
createTables
Create the real database tables for this virtual database. The table is created by first building a Hibernate mapping structure and then using Hibernate to generate the SQL that is needed.- Parameters:
tables
- The tables to create- Throws:
BaseException
- See Also:
-
hasTable
Check if a real database table for this virtual database exists.- Parameters:
table
- The table to check- Returns:
- TRUE if database table exists, FALSE otherwise
- Throws:
BaseException
- If there is some kind of error.- See Also:
-
dropAllTables
Drop all real database tables in this virtual database. The tables are deleted by first building a Hibernate mapping structure and then using Hibernate to generate the SQL that is needed.- Throws:
BaseException
- See Also:
-
deleteAllCubeData
Delete all analysed data for the specified data cube.- Parameters:
cubeNo
- The number of the cube- Returns:
- The number of deleted rows
- Throws:
BaseException
- See Also:
-
deleteAllCubeLayerData
Delete all analysed data for the specified layer in the specified data cube.- Parameters:
cubeNo
- The number of the cubelayerNo
- The number of the layer- Returns:
- The number of deleted rows
- Throws:
BaseException
- See Also:
-
deleteAllCubeFilterData
Delete all analysed data for the specified filter in the specified data cube.- Parameters:
cubeNo
- The number of the cubefilterNo
- The number of the filter- Returns:
- The number of deleted rows
- Throws:
BaseException
- See Also:
-
deleteAllCubeExtraValueData
int deleteAllCubeExtraValueData(short cubeNo, short extraNo, VirtualTable extraTable) throws BaseException Delete all extra value data for the specified extra value type in the specified data cube.- Parameters:
cubeNo
- The number of the cubeextraNo
- The number of the extra value type- Returns:
- The number of deleted rows
- Throws:
BaseException
- See Also:
-