2.17.2: 2011-06-17

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: 2011-03-15 14:45:48 +0100 (Tue, 15 Mar 2011) $

Nested Class Summary
private static class Install.PlatformFT
           
 
Field Summary
private static Logger log
          Log core events.
static int NEW_SCHEMA_VERSION
          The schema version to give to new installations.
private static SchemaVersionData schemaVersion
           
private static org.hibernate.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, 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, FileTypeData genericType, String validatorClass, String metadataReaderClass)
          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 FileTypeData createFileType(String systemId, String name, String description)
          Create a FileType.
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, HardwareTypeData type, UserData owner, ItemKeyData shareTo)
          Create a HardwareData.
private static HardwareTypeData createHardwareType(String systemId, String name, String description)
          Create a HardwareType.
private static ItemKeyData createItemKey(String message, Map<UserData,Integer> userPermissions, Map<GroupData,Integer> groupPermissions)
          Create an ItemKey.
private static LabelData createLabel(String name, String description, UserData owner, ItemKeyData shareTo)
          Create a Label.
private static MimeTypeData createMimeType(String name, String description, String extension, FileTypeData 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 void createPluginConfigurations(String filePath, boolean update)
          Create PluginConfigurations from a XML file.
private static PluginDefinition createPluginDefinition(String className, String jarPath, ItemKeyData shareTo, boolean trusted, Long maxMemory, boolean allowImmediateExecution)
          Create a PluginDefinition.
private static PluginTypeData createPluginType(String name, String description, String interfaceName, String jarPath)
          Create a PluginType.
private static ProtocolTypeData createProtocolType(String systemId, String name, String description)
          Create a ProtocolType.
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, SoftwareTypeData type, UserData owner, ItemKeyData shareTo)
          Create a Software.
private static SoftwareTypeData createSoftwareType(String systemId, String name, String description)
          Create a SoftwareType.
static void createTables(boolean update, ProgressReporter progress)
           
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(boolean update, 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 Logger log
Log core events.


session

private static org.hibernate.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 void createTables(boolean update,
                                ProgressReporter progress)
                         throws BaseException
Throws:
BaseException

initDatabase

public static void initDatabase(boolean update,
                                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:
update - TRUE if the run is an update, FALSE otherwise.
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,
                                           FileTypeData fileType,
                                           boolean autoCompress)
                                    throws BaseException
Create a MimeType.

Throws:
BaseException

createFileType

private static FileTypeData createFileType(String systemId,
                                           String name,
                                           String description)
                                    throws BaseException
Create a FileType.

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

createProtocolType

private static ProtocolTypeData createProtocolType(String systemId,
                                                   String name,
                                                   String description)
                                            throws BaseException
Create a ProtocolType.

Throws:
BaseException

createSoftwareType

private static SoftwareTypeData createSoftwareType(String systemId,
                                                   String name,
                                                   String description)
                                            throws BaseException
Create a SoftwareType.

Throws:
BaseException

createSoftware

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

Throws:
BaseException

createHardwareType

private static HardwareTypeData createHardwareType(String systemId,
                                                   String name,
                                                   String description)
                                            throws BaseException
Create a HardwareType.

Throws:
BaseException

createHardware

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

Throws:
BaseException

createBioPlateType

private static BioPlateTypeData createBioPlateType(String name,
                                                   String description,
                                                   Item biomaterialType,
                                                   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

createLabel

private static LabelData createLabel(String name,
                                     String description,
                                     UserData owner,
                                     ItemKeyData shareTo)
                              throws BaseException
Create a Label.

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 jarPath)
                                        throws BaseException
Create a PluginType.

Throws:
BaseException

createPluginDefinition

private static PluginDefinition createPluginDefinition(String className,
                                                       String jarPath,
                                                       ItemKeyData shareTo,
                                                       boolean trusted,
                                                       Long maxMemory,
                                                       boolean allowImmediateExecution)
                                                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

createDataFileType

private static DataFileTypeData createDataFileType(String externalId,
                                                   String name,
                                                   String description,
                                                   Item itemType,
                                                   String extension,
                                                   FileTypeData genericType,
                                                   String validatorClass,
                                                   String metadataReaderClass)
                                            throws BaseException
Create a DataFileType.

Throws:
BaseException

setPermissions

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

2.17.2: 2011-06-17