3.2.4: 2013-12-06

net.sf.basedb.core
Class Install

java.lang.Object
  extended by 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: 2013-03-06 13:51:33 +0100 (Wed, 06 Mar 2013) $

Nested Class Summary
private static class Install.ItemSubtypeFT
           
private static class Install.PlatformFT
           
 
Field Summary
private static org.apache.log4j.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
Install()
           
 
Method Summary
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 an AnnotationType.
private static BioPlateEventTypeData createBioPlateEventType(String name, String systemId, String description)
          Create a BioPlateEventType.
private static BioPlateTypeData createBioPlateType(String name, String description, Item biomaterialType, ItemSubtypeData subtype, BioWell.LockMode lockedMode)
          Create a BioPlateType.
private static ClientData createClient(UserData owner, String externalId, String name, String description, ItemKeyData key)
          Create a Client.
private static DataFileTypeData createDataFileType(String externalId, String name, String description, Item itemType, String extension, ItemSubtypeData genericType, Install.ItemSubtypeFT... itemSubtypes)
          Create a DataFileType.
private static DirectoryData createDirectory(UserData owner, DirectoryData parent, String systemId, String name, String description, ItemKeyData itemKey, boolean autoCompress)
          Create a Directory.
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 a Formula.
private static GroupData createGroup(String systemId, String name, boolean isDefault, boolean hiddenMembers, String description)
          Create a Group.
private static HardwareData createHardware(String name, String version, String description, ItemSubtypeData type, UserData owner, ItemKeyData shareTo)
          Create a HardwareData.
private static ItemKeyData createItemKey(String message, Map<UserData,Integer> userPermissions, Map<GroupData,Integer> groupPermissions)
          Create an ItemKey.
private static ItemSubtypeData createItemSubtype(Item itemType, String systemId, String name, String description, ItemSubtypeData... related)
          Create an ItemSubtype.
private static MimeTypeData createMimeType(String name, String description, String extension, ItemSubtypeData fileType, boolean autoCompress)
          Create a MimeType.
private static NewsData createNews(String name, String description)
          Create a News.
private static PlateGeometryData createPlateGeometry(String name, String description, int rows, int columns)
          Create a PlateGeometry.
private static PlateMappingData createPlateMapping(String name, String description, PlateGeometryData source, int sourceCount, PlateGeometryData destination, int destinationCount, String image, UserData owner, ItemKeyData shareTo)
          Create a PlateMapping.
private static PlatformData createPlatform(String externalId, String name, String description, boolean fileOnly, String rawDataType, int channels, Install.PlatformFT... fileTypes)
          Create a Platform.
private static PlatformVariantData createPlatformVariant(PlatformData platform, String externalId, String name, String description, boolean fileOnly, String rawDataType, int channels, Install.PlatformFT... fileTypes)
          Create a PlatformVariant.
private static void createPluginConfigurations(String filePath, boolean update)
          Create PluginConfigurations from a XML file.
private static PluginDefinition createPluginDefinition(PluginInfo info, ItemKey shareToEveryone)
          Create a PluginDefinition.
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 a PluginType.
private static QuantityData createQuantity(String systemId, String name, String description, String referenceUnit)
          Create a Quantity.
private static QuotaData createQuota(String systemId, String name, String description, long totalPrimaryQuota)
          Create a Quota.
private static QuotaTypeData createQuotaType(String systemId, String name, String description, boolean secondaryLocation)
          Create a QuotaType.
private static RoleData createRole(String systemId, String name, boolean isDefault, String description)
          Create a Role.
private static RoleKeyData createRoleKey(Item itemType, String name, String description, Map<RoleData,Integer> permissions)
          Create a RoleKey.
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 a Software.
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 a Tag.
private static UnitData createUnit(QuantityData quantity, String name, String description, double factor, double offset, String symbol, String... aliasSymbols)
          Create a Unit.
private static UserData createUser(String systemId, String login, String password, String name, String description, RoleData role, QuotaData quota, boolean disabled, boolean multiUserAccount)
          Create a User.
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.log4j.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 the Update.updateDatabase(ProgressReporter, String, String) method.

Constructor Detail

Install

public Install()
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 mode
progress - An object implementing the ProgressReporter interface
rootLogin - 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 a Directory.

Throws:
BaseException

createMimeType

private static MimeTypeData createMimeType(String name,
                                           String description,
                                           String extension,
                                           ItemSubtypeData fileType,
                                           boolean autoCompress)
                                    throws BaseException
Create a MimeType.

Throws:
BaseException

createQuotaType

private static QuotaTypeData createQuotaType(String systemId,
                                             String name,
                                             String description,
                                             boolean secondaryLocation)
                                      throws BaseException
Create a QuotaType.

Throws:
BaseException

createQuota

private static QuotaData createQuota(String systemId,
                                     String name,
                                     String description,
                                     long totalPrimaryQuota)
                              throws BaseException
Create a Quota.

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 a User.

Throws:
BaseException

createGroup

private static GroupData createGroup(String systemId,
                                     String name,
                                     boolean isDefault,
                                     boolean hiddenMembers,
                                     String description)
                              throws BaseException
Create a Group.

Throws:
BaseException

createRole

private static RoleData createRole(String systemId,
                                   String name,
                                   boolean isDefault,
                                   String description)
                            throws BaseException
Create a Role.

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 a Quantity.

Throws:
BaseException

createUnit

private static UnitData createUnit(QuantityData quantity,
                                   String name,
                                   String description,
                                   double factor,
                                   double offset,
                                   String symbol,
                                   String... aliasSymbols)
                            throws BaseException
Create a Unit.

Throws:
BaseException

createSoftware

private static SoftwareData createSoftware(String name,
                                           String version,
                                           String description,
                                           ItemSubtypeData type,
                                           UserData owner,
                                           ItemKeyData shareTo)
                                    throws BaseException
Create a Software.

Throws:
BaseException

createHardware

private static HardwareData createHardware(String name,
                                           String version,
                                           String description,
                                           ItemSubtypeData type,
                                           UserData owner,
                                           ItemKeyData shareTo)
                                    throws BaseException
Create a HardwareData.

Throws:
BaseException

createItemSubtype

private static ItemSubtypeData createItemSubtype(Item itemType,
                                                 String systemId,
                                                 String name,
                                                 String description,
                                                 ItemSubtypeData... related)
Create an ItemSubtype.


createBioPlateType

private static BioPlateTypeData createBioPlateType(String name,
                                                   String description,
                                                   Item biomaterialType,
                                                   ItemSubtypeData subtype,
                                                   BioWell.LockMode lockedMode)
                                            throws BaseException
Create a BioPlateType.

Throws:
BaseException

createBioPlateEventType

private static BioPlateEventTypeData createBioPlateEventType(String name,
                                                             String systemId,
                                                             String description)
                                                      throws BaseException
Create a BioPlateEventType.

Throws:
BaseException

createPlateGeometry

private static PlateGeometryData createPlateGeometry(String name,
                                                     String description,
                                                     int rows,
                                                     int columns)
                                              throws BaseException
Create a PlateGeometry.

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 a PlateMapping. 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 a Tag.

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 an AnnotationType.


createRoleKey

private static RoleKeyData createRoleKey(Item itemType,
                                         String name,
                                         String description,
                                         Map<RoleData,Integer> permissions)
                                  throws BaseException
Create a RoleKey.

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 to
permissions - The permissions to add

createItemKey

private static ItemKeyData createItemKey(String message,
                                         Map<UserData,Integer> userPermissions,
                                         Map<GroupData,Integer> groupPermissions)
                                  throws BaseException
Create an ItemKey.

Parameters:
message - Message will be written to the log
userPermissions - A map with UserData as keys and permission codes as values
groupPermissions - 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 a Client.

Throws:
BaseException

createNews

private static NewsData createNews(String name,
                                   String description)
                            throws BaseException
Create a News.

Throws:
BaseException

createPluginType

private static PluginTypeData createPluginType(String name,
                                               String description,
                                               String interfaceName,
                                               String jarFile)
                                        throws BaseException
Create a PluginType.

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 a PluginDefinition.

Throws:
BaseException

createPluginConfigurations

private static void createPluginConfigurations(String filePath,
                                               boolean update)
                                        throws BaseException
Create PluginConfigurations 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 a Formula.

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 a Platform.

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 a PlatformVariant.

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 a DataFileType.

Throws:
BaseException

setPermissions

private static void setPermissions(Item itemType,
                                   int itemId,
                                   ItemKeyData itemKey,
                                   ProjectKeyData projectKey)

3.2.4: 2013-12-06