Package net.sf.basedb.core
Class Install
- java.lang.Object
-
- net.sf.basedb.core.Install
-
public final class Install extends Object
This class contains static methods used to install items into an empty database.- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2019-03-15 14:35:35 +0100 (fre, 15 mars 2019) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Install.ItemSubtypeFT
private static class
Install.PlatformFT
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
log
Log core events.static int
NEW_SCHEMA_VERSION
The schema version to give to new installations.private static SchemaVersionData
schemaVersion
private static Session
session
private static SessionControl
sessionControl
-
Constructor Summary
Constructors Constructor Description Install()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addRolePermissions(RoleData role, Map<Item,Integer> permissions)
Add permissions for a role for specific item types.private static AnnotationTypeData
createAnnotationType(String name, String description, Type type, int multiplicity, Object[] enumeration, Item[] itemTypes, Map<String,String> options, boolean requiredForMiame, boolean isProtocolParameter, UserData owner, ItemKeyData shareTo)
Create anAnnotationType
.private static BioPlateEventTypeData
createBioPlateEventType(String name, String systemId, String description)
Create aBioPlateEventType
.private static BioPlateTypeData
createBioPlateType(String name, String description, Item biomaterialType, ItemSubtypeData subtype, BioWell.LockMode lockedMode)
Create aBioPlateType
.private static ClientData
createClient(UserData owner, String externalId, String name, String description, ItemKeyData key)
Create aClient
.private static DataFileTypeData
createDataFileType(String externalId, String name, String description, Item itemType, String extension, ItemSubtypeData genericType, Install.ItemSubtypeFT... itemSubtypes)
Create aDataFileType
.private static DirectoryData
createDirectory(UserData owner, DirectoryData parent, String systemId, String name, String description, ItemKeyData itemKey, boolean autoCompress)
Create aDirectory
.private static FormulaData
createFormula(Formula.Type type, Type valueType, Formula.Parser parser, Formula.AverageMethod avgMethod, IntensityTransform source, IntensityTransform result, String name, String description, String rawDataType, int channels, String[] formulas, ColoringData coloring, UserData owner, ItemKeyData shareTo)
Create aFormula
.private static GroupData
createGroup(String systemId, String name, boolean isDefault, boolean hiddenMembers, String description)
Create aGroup
.private static HardwareData
createHardware(String name, String version, String description, ItemSubtypeData type, UserData owner, ItemKeyData shareTo)
Create aHardwareData
.private static ItemKeyData
createItemKey(String message, Map<UserData,Integer> userPermissions, Map<GroupData,Integer> groupPermissions)
Create anItemKey
.private static ItemSubtypeData
createItemSubtype(Item itemType, String systemId, String name, String description, ItemSubtypeData... related)
Create anItemSubtype
.private static MimeTypeData
createMimeType(String name, String description, String extension, ItemSubtypeData fileType, boolean autoCompress)
Create aMimeType
.private static NewsData
createNews(String name, String description)
Create aNews
.private static PlateGeometryData
createPlateGeometry(String name, String description, int rows, int columns)
Create aPlateGeometry
.private static PlateMappingData
createPlateMapping(String name, String description, PlateGeometryData source, int sourceCount, PlateGeometryData destination, int destinationCount, String image, UserData owner, ItemKeyData shareTo)
Create aPlateMapping
.private static PlatformData
createPlatform(String externalId, String name, String description, boolean fileOnly, String rawDataType, int channels, Install.PlatformFT... fileTypes)
Create aPlatform
.private static PlatformVariantData
createPlatformVariant(PlatformData platform, String externalId, String name, String description, boolean fileOnly, String rawDataType, int channels, Install.PlatformFT... fileTypes)
Create aPlatformVariant
.private static void
createPluginConfigurations(String filePath, boolean update)
CreatePluginConfiguration
s from a XML file.private static PluginDefinition
createPluginDefinition(PluginInfo info, ItemKey shareToEveryone)
Create aPluginDefinition
.private static void
createPluginDefinitions(String filePath, ItemKey shareToEveryone, boolean update)
Read plug-in definitions from the given file.private static PluginTypeData
createPluginType(String name, String description, String interfaceName, String jarFile)
Create aPluginType
.private static QuantityData
createQuantity(String systemId, String name, String description, String referenceUnit)
Create aQuantity
.private static QuotaData
createQuota(String systemId, String name, String description, long totalPrimaryQuota)
Create aQuota
.private static QuotaTypeData
createQuotaType(String systemId, String name, String description)
Create aQuotaType
.private static RoleData
createRole(String systemId, String name, boolean isDefault, String description)
Create aRole
.private static RoleKeyData
createRoleKey(Item itemType, String name, String description, Map<RoleData,Integer> permissions)
Create aRoleKey
.private static SchemaVersionData
createSchemaVersion(int sv)
Create the schema version.private static SoftwareData
createSoftware(String name, String version, String description, ItemSubtypeData type, UserData owner, ItemKeyData shareTo)
Create aSoftware
.static int
createTables(SchemaGenerator.Mode mode, ProgressReporter progress, String rootLogin, String rootPassword)
private static TagData
createTag(String name, String description, ItemSubtypeData subtype, UserData owner, ItemKeyData shareTo)
Create aTag
.private static UnitData
createUnit(QuantityData quantity, String name, String description, double factor, double offset, String symbol, String... aliasSymbols)
Create aUnit
.private static UserData
createUser(String systemId, String login, String password, String name, String description, RoleData role, QuotaData quota, boolean disabled, boolean multiUserAccount)
Create aUser
.static void
initDatabase(SchemaGenerator.Mode mode, ProgressReporter progress, String rootLogin, String rootPassword)
Initialise the BASE database by creating all items that are required for BASE to work properly.private static void
installUnits(String xmlFile, boolean update)
private static void
setPermissions(Item itemType, int itemId, ItemKeyData itemKey, ProjectKeyData projectKey)
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
Log core events.
-
session
private static Session session
-
schemaVersion
private static SchemaVersionData schemaVersion
-
sessionControl
private static SessionControl sessionControl
-
NEW_SCHEMA_VERSION
public static final int NEW_SCHEMA_VERSION
The schema version to give to new installations. Already existing installations will be updated to this version number by theUpdate.updateDatabase(ProgressReporter, String, String)
method.
-
-
Method Detail
-
createTables
public static int createTables(SchemaGenerator.Mode mode, ProgressReporter progress, String rootLogin, String rootPassword) throws BaseException
- Throws:
BaseException
-
initDatabase
public static void initDatabase(SchemaGenerator.Mode mode, ProgressReporter progress, String rootLogin, String rootPassword) throws BaseException
Initialise the BASE database by creating all items that are required for BASE to work properly. Items that already exists will not be modified.- Parameters:
mode
- The installation modeprogress
- An object implementing theProgressReporter
interfacerootLogin
- The root user's login name.rootPassword
- The root user's password.- Throws:
BaseException
- This exception is thrown if there is an error
-
createSchemaVersion
private static SchemaVersionData createSchemaVersion(int sv) throws BaseException
Create the schema version.- Throws:
BaseException
-
createDirectory
private static DirectoryData createDirectory(UserData owner, DirectoryData parent, String systemId, String name, String description, ItemKeyData itemKey, boolean autoCompress) throws BaseException
Create aDirectory
.- Throws:
BaseException
-
createMimeType
private static MimeTypeData createMimeType(String name, String description, String extension, ItemSubtypeData fileType, boolean autoCompress) throws BaseException
Create aMimeType
.- Throws:
BaseException
-
createQuotaType
private static QuotaTypeData createQuotaType(String systemId, String name, String description) throws BaseException
Create aQuotaType
.- Throws:
BaseException
-
createQuota
private static QuotaData createQuota(String systemId, String name, String description, long totalPrimaryQuota) throws BaseException
Create aQuota
.- Throws:
BaseException
-
createUser
private static UserData createUser(String systemId, String login, String password, String name, String description, RoleData role, QuotaData quota, boolean disabled, boolean multiUserAccount) throws BaseException
Create aUser
.- Throws:
BaseException
-
createGroup
private static GroupData createGroup(String systemId, String name, boolean isDefault, boolean hiddenMembers, String description) throws BaseException
Create aGroup
.- Throws:
BaseException
-
createRole
private static RoleData createRole(String systemId, String name, boolean isDefault, String description) throws BaseException
Create aRole
.- Throws:
BaseException
-
installUnits
private static void installUnits(String xmlFile, boolean update)
-
createQuantity
private static QuantityData createQuantity(String systemId, String name, String description, String referenceUnit) throws BaseException
Create aQuantity
.- Throws:
BaseException
-
createUnit
private static UnitData createUnit(QuantityData quantity, String name, String description, double factor, double offset, String symbol, String... aliasSymbols) throws BaseException
Create aUnit
.- Throws:
BaseException
-
createSoftware
private static SoftwareData createSoftware(String name, String version, String description, ItemSubtypeData type, UserData owner, ItemKeyData shareTo) throws BaseException
Create aSoftware
.- Throws:
BaseException
-
createHardware
private static HardwareData createHardware(String name, String version, String description, ItemSubtypeData type, UserData owner, ItemKeyData shareTo) throws BaseException
Create aHardwareData
.- Throws:
BaseException
-
createItemSubtype
private static ItemSubtypeData createItemSubtype(Item itemType, String systemId, String name, String description, ItemSubtypeData... related)
Create anItemSubtype
.
-
createBioPlateType
private static BioPlateTypeData createBioPlateType(String name, String description, Item biomaterialType, ItemSubtypeData subtype, BioWell.LockMode lockedMode) throws BaseException
Create aBioPlateType
.- Throws:
BaseException
-
createBioPlateEventType
private static BioPlateEventTypeData createBioPlateEventType(String name, String systemId, String description) throws BaseException
Create aBioPlateEventType
.- Throws:
BaseException
-
createPlateGeometry
private static PlateGeometryData createPlateGeometry(String name, String description, int rows, int columns) throws BaseException
Create aPlateGeometry
.- Throws:
BaseException
-
createPlateMapping
private static PlateMappingData createPlateMapping(String name, String description, PlateGeometryData source, int sourceCount, PlateGeometryData destination, int destinationCount, String image, UserData owner, ItemKeyData shareTo) throws BaseException
Create aPlateMapping
. At the moment only 1:1 and 4:1 mappings are allowed. If the 4:1 mapping is choosen it creates a 1243 mapping as defines in the "Merge 96-well -> 384-well" in base 1.2.14.- Parameters:
source
- the PlateGeometry of the source plate(s).sourceCount
- the number of source plates. 1 or 4 at the moment.destination
- the PlateGeometry of the destination plate(s).destinationCount
- the number of destination plate. Only 1 at the moment.- Throws:
BaseException
-
createTag
private static TagData createTag(String name, String description, ItemSubtypeData subtype, UserData owner, ItemKeyData shareTo) throws BaseException
Create aTag
.- Throws:
BaseException
-
createAnnotationType
private static AnnotationTypeData createAnnotationType(String name, String description, Type type, int multiplicity, Object[] enumeration, Item[] itemTypes, Map<String,String> options, boolean requiredForMiame, boolean isProtocolParameter, UserData owner, ItemKeyData shareTo)
Create anAnnotationType
.
-
createRoleKey
private static RoleKeyData createRoleKey(Item itemType, String name, String description, Map<RoleData,Integer> permissions) throws BaseException
Create aRoleKey
.- Parameters:
permissions
- A map with RoleData as keys and permission codes as values- Throws:
BaseException
-
addRolePermissions
private static void addRolePermissions(RoleData role, Map<Item,Integer> permissions)
Add permissions for a role for specific item types. The role keys for all item types must exist.- Parameters:
role
- The role to add the permissions topermissions
- The permissions to add
-
createItemKey
private static ItemKeyData createItemKey(String message, Map<UserData,Integer> userPermissions, Map<GroupData,Integer> groupPermissions) throws BaseException
Create anItemKey
.- Parameters:
message
- Message will be written to the loguserPermissions
- A map with UserData as keys and permission codes as valuesgroupPermissions
- A map with GroupData as keys and permission codes as values- Throws:
BaseException
-
createClient
private static ClientData createClient(UserData owner, String externalId, String name, String description, ItemKeyData key) throws BaseException
Create aClient
.- Throws:
BaseException
-
createNews
private static NewsData createNews(String name, String description) throws BaseException
Create aNews
.- Throws:
BaseException
-
createPluginType
private static PluginTypeData createPluginType(String name, String description, String interfaceName, String jarFile) throws BaseException
Create aPluginType
.- Throws:
BaseException
-
createPluginDefinitions
private static void createPluginDefinitions(String filePath, ItemKey shareToEveryone, boolean update)
Read plug-in definitions from the given file.
-
createPluginDefinition
private static PluginDefinition createPluginDefinition(PluginInfo info, ItemKey shareToEveryone) throws BaseException
Create aPluginDefinition
.- Throws:
BaseException
-
createPluginConfigurations
private static void createPluginConfigurations(String filePath, boolean update) throws BaseException
CreatePluginConfiguration
s from a XML file.- Throws:
BaseException
-
createFormula
private static FormulaData createFormula(Formula.Type type, Type valueType, Formula.Parser parser, Formula.AverageMethod avgMethod, IntensityTransform source, IntensityTransform result, String name, String description, String rawDataType, int channels, String[] formulas, ColoringData coloring, UserData owner, ItemKeyData shareTo) throws BaseException
Create aFormula
.- Throws:
BaseException
-
createPlatform
private static PlatformData createPlatform(String externalId, String name, String description, boolean fileOnly, String rawDataType, int channels, Install.PlatformFT... fileTypes) throws BaseException
Create aPlatform
.- Throws:
BaseException
-
createPlatformVariant
private static PlatformVariantData createPlatformVariant(PlatformData platform, String externalId, String name, String description, boolean fileOnly, String rawDataType, int channels, Install.PlatformFT... fileTypes) throws BaseException
Create aPlatformVariant
.- Throws:
BaseException
-
createDataFileType
private static DataFileTypeData createDataFileType(String externalId, String name, String description, Item itemType, String extension, ItemSubtypeData genericType, Install.ItemSubtypeFT... itemSubtypes) throws BaseException
Create aDataFileType
.- Throws:
BaseException
-
setPermissions
private static void setPermissions(Item itemType, int itemId, ItemKeyData itemKey, ProjectKeyData projectKey)
-
-