Changeset 5621


Ignore:
Timestamp:
May 3, 2011, 1:21:06 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1591: Upgrade script for BASE 2.17 --> 3.0

Removed unused queries from predefined query xml files. Fixes update for:

  • jarPath --> jarFile properties of PluginDefinition, PluginTypes and JobAgentSettings.
  • affy_chip column.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/mysql-queries.xml

    r5422 r5621  
    2828-->
    2929<predefined-queries>
    30   <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
    31     <sql>
    32       SELECT count(*)
    33       FROM MessageData msg
    34       WHERE msg.to = :user AND msg.read = 0 AND msg.removed = 0
    35     </sql>
    36     <description>
    37       A Hibernate query that counts the number of
    38       unread messages for a given user. The default query use 'false'
    39       instead of '0' which doesn't work for MySQL.
    40     </description>
    41   </query>
    42  
    43   <query id="LOAD_CONTEXT_NAMES" type="HQL">
    44     <sql>
    45       SELECT ctx.id, ctx.name
    46       FROM ContextData ctx
    47       WHERE ctx.client = :client AND
    48       (ctx.user = :user OR ctx.public = 1)
    49       AND ctx.itemType = :itemType
    50       AND ctx.subContext = :subContext
    51       ORDER BY ctx.name
    52     </sql>
    53     <description>
    54       A Hibernate query that selects the id and name of all contexts for
    55       a user and item type. The names should be sorted in ascending order.
    56       The default query use 'true' instead of '1' which doesn't work for MySQL.
    57     </description>
    58   </query>
    59  
    60   <query id="GET_REMOVED_ITEMS" type="HQL">
    61     <sql>
    62       SELECT trash
    63       FROM net.sf.basedb.core.data.RemovableData trash
    64       WHERE trash.removed = 1
    65     </sql>
    66     <description>
    67       A Hibernate query that loads all items flagged for deletion.
    68       The default query use 'true' instead of '1' which doesn't work for MySQL.
    69     </description>
    70   </query> 
    71 
    72   <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
    73     <sql>
    74       DELETE FROM AnyToAnyData ata
    75       WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = 0
    76     </sql>
    77     <description>
    78       A Hibernate query that deletes all any-to-any links leading in to
    79       an item that doesn't count as using the item.
    80       The default query use 'false' instead of '0' which doesn't work for MySQL.
    81     </description>
    82   </query>
    83  
    84   <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
    85     <sql>
    86       SELECT count(*)
    87       FROM AnyToAnyData ana
    88       WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = 1
    89     </sql>
    90     <description>
    91       A Hibernate query that counts the number of any-to-any links
    92       to a given item that counts as using the item.
    93       The default query use 'true' instead of '1' which doesn't work for MySQL.
    94     </description>
    95   </query>
    96  
    97   <query id="COPY_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
    98     <sql>
    99       INSERT INTO `VersionedPluginConfigurationValues`
    100       (`pluginconfiguration_id`, `name`, `parameter_version`, `value_id`)
    101       SELECT `pluginconfiguration_id`, `name`, 1, `value_id`
    102       FROM `PluginConfigurationValues`
    103     </sql>
    104     <description>
    105       A SQL query that creates versioned parameters from unversioned.
    106     </description>
    107   </query>
    108  
    109   <query id="DELETE_UNVERSIONED_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
    110     <sql>
    111       DELETE FROM `PluginConfigurationValues`
    112     </sql>
    113     <description>
    114       A SQL query that deletes unversioned plugin configuration parameters.
    115     </description>
    116   </query>
    117 
    118   <query id="CHANGE_FILE_DISCRIMINATOR" type="SQL">
    119     <sql>
    120       UPDATE `ParameterValues`
    121       SET `discriminator` = 10
    122       WHERE `discriminator` = 9
    123     </sql>
    124     <description>
    125       An SQL query that changes the discriminator for file
    126       parameters
    127     </description>
    128   </query>
    129 
    130   <query id="COPY_FILE_PARAMETERS" type="SQL">
    131     <sql>
    132       INSERT INTO `ItemValues` (`id`, `data_class`, `data_class_id`)
    133       SELECT `id`, 'net.sf.basedb.core.data.FileData', `value`
    134       FROM `FileValues`
    135     </sql>
    136     <description>
    137       An SQL query that copies file parameter values into
    138       the item parameter values table.
    139     </description>
    140   </query>
    141 
    142   <query id="DELETE_FILE_PARAMETERS" type="SQL">
    143     <sql>
    144       DELETE FROM `FileValues`
    145     </sql>
    146     <description>
    147       An SQL query that deletes old file parameter values (after they have been copied).
    148     </description>
    149   </query>
    150 
    151   <query id="UPDATE_PROPERTY_FILTER" type="SQL">
    152     <sql>
    153       UPDATE IGNORE [PropertyFilters]
    154       SET [property] = :newProperty
    155       WHERE [property] = :oldProperty
    156     </sql>
    157     <description>
    158       An SQL query that changes the property for all PropertyFilters
    159       which filters on a given property. It must ignore any filter that 
    160       causes a duplicate key violation if a filter with the new
    161       property already exists for any context.
    162     </description>
    163   </query>
    164 
    165   <query id="CHANGE_DATEVALUES_VALUE_COLUMN" type="SQL">
    166     <sql>
    167       ALTER TABLE [DateValues]
    168       MODIFY COLUMN [value] date NOT NULL
    169     </sql>
    170     <description>
    171       An SQL query that changes the 'DateValues.value'
    172       column to a date-only column type.
    173     </description>
    174   </query>
    17530
    17631</predefined-queries>
  • trunk/config/dist/postgres-queries.xml

    r5422 r5621  
    2828-->
    2929<predefined-queries>
    30   <query id="CHANGE_DATEVALUES_VALUE_COLUMN" type="SQL">
    31     <sql>
    32       ALTER TABLE [DateValues]
    33       ALTER COLUMN [value] TYPE date
    34     </sql>
    35     <description>
    36       An SQL query that changes the 'DateValues.value'
    37       column to a date-only column type.
    38     </description>
    39   </query>
    4030
    4131</predefined-queries>
  • trunk/src/core/common-queries.xml

    r5615 r5621  
    285285  </query>
    286286
    287   <query id="GET_PERMISSION_FOR_USER_IN_PROJECT" type="HQL">
    288     <sql>
    289       SELECT up.permission
    290       FROM UserProjects up
    291       WHERE up.userId = :userId
    292       AND up.projectId = :projectId
    293     </sql>
    294     <description>
    295       Load the permission for the given user in the given project.
    296     </description>
    297   </query>
    298 
    299   <query id="GET_PERMISSIONS_FOR_GROUPS_IN_PROJECT" type="HQL">
    300     <sql>
    301       SELECT gp.permission
    302       FROM GroupProjects gp
    303       WHERE gp.groupId IN (:groups)
    304       AND gp.projectId = :projectId
    305     </sql>
    306     <description>
    307       Load the permissions for the given groups in the given project.
    308     </description>
    309   </query>
    310 
    311287  <query id="GET_PROJECTKEY_IDS_FOR_COUNT" type="HQL">
    312288    <sql>
     
    452428  </query>
    453429 
    454   <query id="GET_SHARED_ITEMS" type="HQL">
    455     <sql>
    456       SELECT s
    457       FROM net.sf.basedb.core.data.ShareableData s
    458     </sql>
    459     <description>
    460       Get all shared items.
    461     </description>
    462   </query>
    463 
    464430  <query id="GET_OWNABLE_ITEMS_FOR_USER" type="HQL">
    465431    <sql>
     
    472438    </description>
    473439  </query>
    474  
    475   <query id="GET_DISKCONSUMABLE_ITEMS_FOR_USER" type="HQL">
    476     <sql>
    477       SELECT o
    478       FROM net.sf.basedb.core.data.DiskConsumableData o
    479       WHERE o.owner = :user
    480     </sql>
    481     <description>
    482       Get all diskconsumable items that are owned by the specified user.
    483     </description>
    484   </query>
    485 
    486440 
    487441  <query id="LOAD_USER_CLIENT_SETTINGS" type="HQL">
     
    840794  </query>
    841795 
    842   <query id="GET_PLATE_GEOMETRY_WITH_NAME" type="HQL">
    843     <sql>
    844       SELECT pg
    845       FROM PlateGeometryData pg
    846       WHERE pg.name = :name
    847     </sql>
    848     <description>
    849       A Hibernate query that returns the plate geometry with the specified
    850       name.
    851     </description>
    852   </query>
    853 
    854796  <query id="GET_PLATE_GEOMETRY_WITH_SIZE" type="HQL">
    855797    <sql>
     
    864806  </query>
    865807
    866   <query id="GET_PLATE_MAPPING_WITH_NAME" type="HQL">
    867     <sql>
    868       SELECT pm
    869       FROM PlateMappingData pm
    870       WHERE pm.name = :name
    871     </sql>
    872     <description>
    873       A Hibernate query that returns the plate mapping with the specified
    874       name.
    875     </description>
    876   </query>
    877  
    878808  <query id="GET_PLATE_MAPPING_WITH_PROPERTIES" type="HQL">
    879809    <sql>
     
    12651195  </query>
    12661196
    1267   <query id="GET_CREATION_EVENT_FOR_BIOMATERIAL" type="HQL">
    1268     <sql>
    1269       SELECT evt
    1270       FROM BioMaterialEventData evt
    1271       WHERE evt.bioMaterial = :bioMaterial
    1272       AND evt.eventType = 1
    1273     </sql>
    1274     <description>
    1275       A Hibernate query that returns the creation event for
    1276       a biomaterial.
    1277     </description>
    1278   </query>
    1279  
    12801197  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
    12811198    <sql>
     
    15831500  </query>
    15841501
    1585   <query id="GET_FEATURE_BY_ALL_COORDINATES" type="HQL">
    1586     <sql>
    1587       SELECT f
    1588       FROM FeatureData f
    1589       WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
    1590       AND f.row = :row
    1591       AND f.column = :column
    1592       AND
    1593       (
    1594         (f.arrayDesignBlock.blockNumber = :block AND :block &lt;&gt; 0)
    1595         OR
    1596         (:block = 0 AND f.arrayDesignBlock.metaGridX = :metaGridX
    1597         AND f.arrayDesignBlock.metaGridY = :metaGridY)
    1598       )
    1599     </sql>
    1600     <description>
    1601       A Hibernate query that finds a feature on a given array design
    1602       with specified block and coordinates.
    1603     </description>
    1604   </query>
    1605  
    16061502  <query id="PRELOAD_FEATURES" type="HQL">
    16071503    <sql>
     
    20461942  </query>
    20471943 
    2048   <query id="SET_PROJECT_ID_FOR_JOBS" type="HQL">
    2049     <sql>
    2050       UPDATE JobData job
    2051       SET job.activeProjectId = 0
    2052       WHERE job.activeProjectId IS NULL
    2053     </sql>
    2054     <description>
    2055       A Hibernate query that sets the active project ID for all
    2056       jobs to 0 if they have a null value.
    2057     </description>
    2058   </query>
    2059 
    20601944  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
    20611945    <sql>
     
    21472031  </query>
    21482032
    2149   <query id="SET_REMAINING_QUANTITY" type="HQL">
    2150     <sql>
    2151       UPDATE MeasuredBioMaterialData mbm
    2152       SET mbm.remainingQuantity = :remain
    2153       WHERE mbm = :bioMaterial
    2154     </sql>
    2155     <description>
    2156       A Hibernate query that sets the remaining quantity on a
    2157       measuered biomaterial.
    2158     </description>
    2159   </query>
    2160 
    2161 
    21622033  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
    21632034    <sql>
     
    21952066  </query>
    21962067
    2197   <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
    2198     <sql>
    2199       DELETE FROM AnyToAnyData ata
    2200       WHERE ata.toId = :toId AND ata.toType = :toType
    2201     </sql>
    2202     <description>
    2203       A Hibernate query that deletes all any-to-any links leading in to
    2204       an item.
    2205     </description>
    2206   </query>
    2207  
    22082068  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
    22092069    <sql>
     
    22142074      A Hibernate query that deletes all any-to-any links leading in to
    22152075      an item that doesn't count as using the item.
    2216     </description>
    2217   </query>
    2218 
    2219   <query id="COUNT_ANYTOANY_FROM" type="HQL">
    2220     <sql>
    2221       SELECT count(*)
    2222       FROM AnyToAnyData ata
    2223       WHERE ata.fromId = :fromId AND ata.fromType = :fromType
    2224     </sql>
    2225     <description>
    2226       A Hibernate query that counts the number of any-to-any links
    2227       from a given item.
    2228     </description>
    2229   </query>
    2230 
    2231   <query id="COUNT_ANYTOANY_TO" type="HQL">
    2232     <sql>
    2233       SELECT count(*)
    2234       FROM AnyToAnyData ana
    2235       WHERE ana.toId = :toId AND ana.toType = :toType
    2236     </sql>
    2237     <description>
    2238       A Hibernate query that counts the number of any-to-any links
    2239       to a given item.
    22402076    </description>
    22412077  </query>
     
    23862222  </query>
    23872223
    2388   <query id="SET_HAS_DATA_FOR_RAWBIOASSAYS" type="HQL">
    2389     <sql>
    2390       UPDATE RawBioAssayData rba
    2391       SET rba.hasData = CASE
    2392         WHEN rba.spots > 0 THEN true
    2393         ELSE false
    2394         END
    2395       WHERE rba.hasData IS NULL
    2396     </sql>
    2397     <description>
    2398       A Hibernate query that sets the hasData property for a
    2399       raw bioassay depending on if it has spots or not.
    2400     </description>
    2401   </query>
    2402  
    2403   <query id="SET_REMOVED_FOR_HARDWARETYPES" type="HQL">
    2404     <sql>
    2405       UPDATE HardwareTypeData hwd
    2406       SET hwd.removed = false
    2407       WHERE hwd.removed IS NULL
    2408     </sql>
    2409     <description>
    2410       A Hibernate query that sets the removed property to false for a
    2411       HardwareTypeData if it has NULL value.
    2412     </description>
    2413   </query>
    2414 
    2415   <query id="SET_CONFIG_FOR_PLUGINS" type="HQL">
    2416     <sql>
    2417       UPDATE PluginDefinitionData pd
    2418       SET pd.supportsConfigurations = true, pd.requiresConfiguration = false
    2419       WHERE pd.supportsConfigurations IS NULL OR pd.requiresConfiguration IS NULL
    2420     </sql>
    2421     <description>
    2422       A Hibernate query that sets the supportsConfigurations and requiresConfiguration
    2423       properties of PluginDefinitionData items if any of them is null.
    2424     </description>
    2425   </query>
    2426 
    2427   <query id="GET_INCORRECT_PLATEMAPPINGS" type="HQL">
    2428     <sql>
    2429       SELECT pm
    2430       FROM PlateMappingData pm
    2431       WHERE pm.sourceCount = 4 AND pm.destinationCount = 1
    2432       AND
    2433       (
    2434         (pm.sourceGeometry.rows = 8 AND pm.sourceGeometry.columns = 12)
    2435         OR
    2436         (pm.sourceGeometry.rows = 16 AND pm.sourceGeometry.columns = 24)
    2437       )
    2438     </sql>
    2439     <description>
    2440       A Hibernate query that finds incorrect plate mappings.
    2441     </description>
    2442   </query>
    2443  
    2444   <query id="GET_PLATES_WITH_MAPPING" type="HQL">
    2445     <sql>
    2446       SELECT p
    2447       FROM PlateData p
    2448       WHERE p.plateMapping = :plateMapping
    2449     </sql>
    2450     <description>
    2451       A Hibernate query that loads all plates with a specific plate mapping.
    2452     </description>
    2453   </query>
    2454  
    24552224  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
    24562225    <sql>
     
    24642233  </query>
    24652234
    2466   <query id="SET_TRUSTED_FOR_PLUGINDEFINITIONS" type="HQL">
    2467     <sql>
    2468       UPDATE PluginDefinitionData pd
    2469       SET pd.trusted = true
    2470       WHERE pd.trusted IS NULL
    2471     </sql>
    2472     <description>
    2473       A Hibernate query that sets the trusted flag for all plugins with a null value
    2474       to TRUE.
    2475     </description>
    2476   </query>
    2477  
    2478   <query id="SET_USE_PERMISSION_FOR_PLUGINDEFINITIONS" type="HQL">
    2479     <sql>
    2480       UPDATE PluginDefinitionData pd
    2481       SET pd.usePermissions = false
    2482       WHERE pd.usePermissions IS NULL
    2483     </sql>
    2484     <description>
    2485       A Hibernate query that sets the use permission flag to false
    2486       for all plugins with a null value.
    2487     </description>
    2488   </query>
    2489  
    24902235  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
    24912236    <sql>
     
    25002245  </query>
    25012246 
    2502   <query id="SET_SENDMESSAGE_FOR_JOBS" type="HQL">
    2503     <sql>
    2504       UPDATE JobData job
    2505       SET job.sendMessage = true
    2506       WHERE job.sendMessage IS NULL
    2507     </sql>
    2508     <description>
    2509       A Hibernate query that sets the send message flag for all jobs with a null value.
    2510     </description>
    2511   </query>
    2512 
    2513   <query id="SET_PARAMETER_VERSION_FOR_PLUGINCONFIGURATIONS" type="HQL">
    2514     <sql>
    2515       UPDATE PluginConfigurationData pc
    2516       SET pc.parameterVersion = 1
    2517       WHERE pc.parameterVersion IS NULL
    2518     </sql>
    2519     <description>
    2520       A Hibernate query that sets the parameter version to 1 for all
    2521       configurations with a null value.
    2522     </description>
    2523   </query>
    2524 
    2525   <query id="SET_PARAMETER_VERSION_FOR_JOBS" type="HQL">
    2526     <sql>
    2527       UPDATE JobData job
    2528       SET job.parameterVersion = 1
    2529       WHERE job.parameterVersion IS NULL
    2530     </sql>
    2531     <description>
    2532       A Hibernate query that sets the parameter version to 1 for all
    2533       jobs with a null value.
    2534     </description>
    2535   </query>
    2536 
    2537   <query id="COPY_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
    2538     <sql>
    2539       INSERT INTO "VersionedPluginConfigurationValues"
    2540       ("pluginconfiguration_id", "name", "parameter_version", "value_id")
    2541       SELECT "pluginconfiguration_id", "name", 1, "value_id"
    2542       FROM "PluginConfigurationValues"
    2543     </sql>
    2544     <description>
    2545       An SQL query that creates versioned parameters from unversioned.
    2546     </description>
    2547   </query>
    2548  
    2549   <query id="DELETE_UNVERSIONED_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
    2550     <sql>
    2551       DELETE FROM "PluginConfigurationValues"
    2552     </sql>
    2553     <description>
    2554       An SQL query that deletes unversioned plugin configuration parameters.
    2555     </description>
    2556   </query>
    2557 
    2558   <query id="SET_COLORING_FOR_FORMULAS" type="HQL">
    2559     <sql>
    2560         UPDATE FormulaData frm
    2561         SET
    2562           frm.coloring.usingColors = false,
    2563           frm.coloring.logarithmic = false
    2564         WHERE frm.coloring.usingColors IS NULL
    2565     </sql>
    2566     <description>
    2567       A HQL query that sets the usingColors and logarithmic to false
    2568       for all formulas with null values.
    2569     </description>
    2570   </query>
    2571  
    2572   <query id="SET_COLORING_FOR_EXTRAVALUETYPES" type="HQL">
    2573     <sql>
    2574       UPDATE ExtraValueTypeData evt
    2575       SET
    2576         evt.coloring.usingColors = false,
    2577         evt.coloring.logarithmic = false
    2578         WHERE evt.coloring.usingColors IS NULL
    2579     </sql>
    2580     <description>
    2581       A HQL query that sets the usingColors and logarithmic to false
    2582       for all extra value types with null values.
    2583     </description>
    2584   </query>
    2585  
    2586   <query id="SET_IMMEDIATE_EXECUTION_FOR_PLUGINS" type="HQL">
    2587     <sql>
    2588       UPDATE PluginDefinitionData plg
    2589       SET plg.allowImmediateExecution = false
    2590       WHERE plg.allowImmediateExecution IS NULL
    2591     </sql>
    2592     <description>
    2593       A HQL query that sets the allowImmediateExecution to false
    2594       for all plugins which has a null value.
    2595     </description>
    2596   </query>
    2597  
    2598   <query id="SET_PROTOCOL_PARAMETER_FOR_ANNOTATION_TYPES" type="HQL">
    2599     <sql>
    2600       UPDATE AnnotationTypeData at
    2601       SET at.protocolParameter = false
    2602       WHERE at.protocolParameter IS NULL
    2603     </sql>
    2604     <description>
    2605       A HQL query that sets the protocolParameter flag to false
    2606       for all annotation types with a null value.
    2607     </description>
    2608   </query>
    2609 
    2610   <query id="CHANGE_FILE_DISCRIMINATOR" type="SQL">
    2611     <sql>
    2612       UPDATE "ParameterValues"
    2613       SET "discriminator" = 10
    2614       WHERE "discriminator" = 9
    2615     </sql>
    2616     <description>
    2617       An SQL query that changes the discriminator for file
    2618       parameters
    2619     </description>
    2620   </query>
    2621 
    2622   <query id="COPY_FILE_PARAMETERS" type="SQL">
    2623     <sql>
    2624       INSERT INTO "ItemValues" ("id", "data_class", "data_class_id")
    2625       SELECT "id", 'net.sf.basedb.core.data.FileData', "value"
    2626       FROM "FileValues"
    2627     </sql>
    2628     <description>
    2629       An SQL query that copies file parameter values into
    2630       the item parameter values table.
    2631     </description>
    2632   </query>
    2633 
    2634   <query id="DELETE_FILE_PARAMETERS" type="SQL">
    2635     <sql>
    2636       DELETE FROM "FileValues"
    2637     </sql>
    2638     <description>
    2639       An SQL query that deletes old file parameter values (after they have been copied).
    2640     </description>
    2641   </query>
    2642 
    2643   <query id="SET_ITEMTYPE_ON_DISKUSAGE" type="HQL">
    2644     <sql>
    2645       UPDATE DiskUsageData du
    2646       SET du.itemType = :itemType
    2647       WHERE du.id IN (:itemList)
    2648       AND du.itemType IS NULL
    2649     </sql>
    2650     <description>
    2651       A HQL query that sets the item type for disk usage items.
    2652     </description>
    2653   </query>
    2654 
    2655   <query id="LOAD_DISKUSAGEID_FOR_FILES" type="HQL">
    2656     <sql>
    2657       SELECT f.diskUsage.id
    2658       FROM FileData f
    2659     </sql>
    2660     <description>
    2661       A HQL query that loads the disk usage ID for all files.
    2662     </description>
    2663   </query>
    2664  
    2665   <query id="LOAD_DISKUSAGEID_FOR_EXPERIMENTS" type="HQL">
    2666     <sql>
    2667       SELECT xp.diskUsage.id
    2668       FROM ExperimentData xp
    2669     </sql>
    2670     <description>
    2671       A HQL query that loads the disk usage ID for all experiments.
    2672     </description>
    2673   </query>
    2674  
    2675   <query id="LOAD_DISKUSAGEID_FOR_RAWBIOASSAYS" type="HQL">
    2676     <sql>
    2677       SELECT rba.diskUsage.id
    2678       FROM RawBioAssayData rba
    2679     </sql>
    2680     <description>
    2681       A HQL query that loads the disk usage ID for all raw bioassays.
    2682     </description>
    2683   </query>
    2684 
    2685   <query id="SET_MAX_MAPPING_ON_DATACUBES" type="HQL">
    2686     <sql>
    2687       UPDATE DataCubeData dcd
    2688       SET dcd.maxRawMappingsForSpot = -1
    2689       WHERE dcd.maxRawMappingsForSpot IS NULL
    2690     </sql>
    2691     <description>
    2692       A HQL query that sets the maxRawMappingsForSpot on all data cubes with a
    2693       null value to -1. This is required so we can load them by Hibernate.
    2694     </description>
    2695   </query>
    2696 
    2697   <query id="SET_MAX_MAPPING_ON_DATACUBE" type="HQL">
    2698     <sql>
    2699       UPDATE DataCubeData dcd
    2700       SET dcd.maxRawMappingsForSpot = :mapCount
    2701       WHERE dcd.id = :dataCube
    2702     </sql>
    2703     <description>
    2704       A HQL query that sets the maxRawMappingsForSpot on a data cube.
    2705     </description>
    2706   </query>
    2707 
    2708   <query id="GET_USED_QUANTITY_EVENTS" type="HQL">
    2709     <sql>
    2710       SELECT evt.bioMaterial, evt.usedQuantity
    2711       FROM BioMaterialEventData evt
    2712     </sql>
    2713     <description>
    2714       A HQL query that loads the biomaterial and the used quantity
    2715       for all BioMaterialEvent:s.
    2716     </description>
    2717   </query>
    2718  
    2719   <query id="GET_USED_QUANTITY_SOURCES" type="HQL">
    2720     <sql>
    2721       SELECT index(src), src.usedQuantity
    2722       FROM BioMaterialEventData evt
    2723       JOIN evt.sources src
    2724     </sql>
    2725     <description>
    2726       A HQL query that loads the used quantity
    2727       for all sources to BioMaterialEvent:s.
    2728     </description>
    2729   </query>
    2730 
    2731   <query id="SET_WRITE_PROTECTED_ON_FILES" type="HQL">
    2732     <sql>
    2733       UPDATE FileData f
    2734       SET f.writeProtected = false
    2735       WHERE f.writeProtected IS NULL
    2736     </sql>
    2737     <description>
    2738       A HQL query that sets the writeProtected on all files with a
    2739       null value to false.
    2740     </description>
    2741   </query>
    2742  
    2743   <query id="SET_REMOVE_JOB_ON_JOBS" type="HQL">
    2744     <sql>
    2745       UPDATE JobData j
    2746       SET j.removeJobWhenFinished = false
    2747       WHERE j.removeJobWhenFinished IS NULL
    2748     </sql>
    2749     <description>
    2750       A HQL query that sets the deleteJobWhenFinished to false
    2751       on all jobs with a null value.
    2752     </description>
    2753   </query> 
    2754  
    2755   <query id="GET_INTERNAL_FILES_WITH_NO_LAST_UPDATE" type="HQL">
    2756     <sql>
    2757       SELECT f
    2758       FROM FileData f
    2759       WHERE f.lastUpdate IS NULL AND NOT f.internalName IS NULL
    2760     </sql>
    2761     <description>
    2762       A HQL query that sets the writeProtected on all files with a
    2763       null value to false.
    2764     </description>
    2765   </query>
    2766  
    27672247  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
    27682248    <sql>
     
    27892269  </query>
    27902270 
    2791   <query id="SET_DEFAULT_ON_GROUPS" type="HQL">
    2792     <sql>
    2793       UPDATE GroupData grp
    2794       SET grp.default = false
    2795       WHERE grp.default IS NULL
    2796     </sql>
    2797     <description>
    2798       A HQL query that sets the isDefault flag to false for all
    2799       groups with a null value.
    2800     </description>
    2801   </query>
    2802  
    2803   <query id="SET_DEFAULT_ON_ROLES" type="HQL">
    2804     <sql>
    2805       UPDATE RoleData rle
    2806       SET rle.default = false
    2807       WHERE rle.default IS NULL
    2808     </sql>
    2809     <description>
    2810       A HQL query that sets the isDefault flag to false for all
    2811       roles with a null value.
    2812     </description>
    2813   </query>
    2814  
    2815   <query id="SET_ITEM_ID_ON_CONTEXTS" type="HQL">
    2816     <sql>
    2817       UPDATE ContextData ctx
    2818       SET ctx.itemId = 0
    2819       WHERE ctx.itemId IS NULL
    2820     </sql>
    2821     <description>
    2822       A HQL query that sets the itemId to 0 for all
    2823       contexts with a null value.
    2824     </description>
    2825   </query>
    2826  
    2827   <query id="SET_AVERAGE_METHOD_ON_FORMULAS" type="HQL">
    2828     <sql>
    2829       UPDATE FormulaData f
    2830       SET f.averageMethod = 2
    2831       WHERE f.averageMethod IS NULL
    2832     </sql>
    2833     <description>
    2834       A HQL query that sets the averageMethod to arithmetic mean for all
    2835       formulas with a null value.
    2836     </description>
    2837   </query>
    2838  
    2839   <query id="SET_AVERAGE_METHOD_ON_EXTRAVALUETYPES" type="HQL">
    2840     <sql>
    2841       UPDATE ExtraValueTypeData evt
    2842       SET evt.averageMethod = 2
    2843       WHERE evt.averageMethod IS NULL
    2844     </sql>
    2845     <description>
    2846       A HQL query that sets the averageMethod to arithmetic mean for all
    2847       extra value types with a null value.
    2848     </description>
    2849   </query>
    2850  
    2851   <query id="UPDATE_PROPERTY_FILTER" type="SQL">
    2852     <sql>
    2853       UPDATE [PropertyFilters]
    2854       SET [property] = :newProperty
    2855       WHERE [property] = :oldProperty
    2856       AND [context_id] NOT IN
    2857       (
    2858          SELECT [context_id]
    2859          FROM [PropertyFilters]
    2860          WHERE [property] = :newProperty
    2861       )
    2862     </sql>
    2863     <description>
    2864       An SQL query that changes the property for all PropertyFilters
    2865       which filters on a given property. It must ignore any filter that 
    2866       causes a duplicate key violation if a filter with the new
    2867       property already exists for any context.
    2868     </description>
    2869   </query>
    2870  
    2871   <query id="UPDATE_PROPERTY_FILTER_VALUE" type="SQL">
    2872     <sql>
    2873       UPDATE [PropertyFilters]
    2874       SET [value] = :newValue
    2875       WHERE [property] = :property AND [value] = :oldValue
    2876     </sql>
    2877     <description>
    2878       An SQL query that changes the property for all PropertyFilters
    2879       with a given value.
    2880     </description>
    2881   </query>
    2882  
    2883   <query id="SET_AUTOCOMPRESS_ON_MIMETYPES" type="HQL">
    2884     <sql>
    2885       UPDATE MimeTypeData mt
    2886       SET mt.autoCompress = false
    2887       WHERE mt.autoCompress IS NULL
    2888     </sql>
    2889     <description>
    2890       A HQL query that sets the autoCompress property to false for all
    2891       MIME types with a null value.
    2892     </description>
    2893   </query>
    2894  
    2895   <query id="SET_AUTOCOMPRESS_ON_DIRECTORIES" type="HQL">
    2896     <sql>
    2897       UPDATE DirectoryData dir
    2898       SET dir.autoCompress = false
    2899       WHERE dir.autoCompress IS NULL
    2900     </sql>
    2901     <description>
    2902       A HQL query that sets the autoCompress property to false for all
    2903       directories with a null value.
    2904     </description>
    2905   </query>
    2906 
    2907   <query id="SET_COMPRESSED_ON_FILES" type="HQL">
    2908     <sql>
    2909       UPDATE FileData f
    2910       SET
    2911         f.compressed = false,
    2912         f.compressedSize = f.size
    2913       WHERE f.compressed IS NULL
    2914     </sql>
    2915     <description>
    2916       A HQL query that sets the compressed property to false and the
    2917       compressedSize to size for all files with a null value.
    2918     </description>
    2919   </query>
    2920  
    2921   <query id="SET_NUMFEATURES_ON_ARRAYDESIGNS" type="HQL">
    2922     <sql>
    2923       UPDATE ArrayDesignData ad
    2924       SET ad.numDbFeatures = 0, ad.numFileFeatures = 0
    2925       WHERE ad.numDbFeatures IS NULL OR ad.numFileFeatures IS NULL
    2926     </sql>
    2927     <description>
    2928       A HQL query that sets the number of file and db features to 0
    2929       on all array designs with a null value.
    2930     </description>
    2931   </query>
    2932  
    2933   <query id="SET_NUMFILESPOTS_ON_RAWBIOASSAY" type="HQL">
    2934     <sql>
    2935       UPDATE RawBioAssayData rbd
    2936       SET rbd.numFileSpots = 0
    2937       WHERE rbd.numFileSpots IS NULL
    2938     </sql>
    2939     <description>
    2940       A HQL query that sets the number of file aspots to 0
    2941       on all raw bioassays with a null value.
    2942     </description>
    2943   </query>
    2944 
    29452271  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
    29462272    <sql>
     
    30612387  </query>
    30622388
    3063  
    3064   <query id="DELETE_PROPERTY_FILTER" type="SQL">
    3065     <sql>
    3066       DELETE FROM [PropertyFilters]
    3067       WHERE [property] = :property
    3068     </sql>
    3069     <description>
    3070       An SQL query that delete all PropertyFilters
    3071       which filter on a given property.
    3072     </description>
    3073   </query>
    3074  
    3075   <query id="GET_PLUGINS_WITH_KEYS" type="HQL">
    3076     <sql>
    3077       SELECT DISTINCT pk.pluginDefinitionId
    3078       FROM PluginKeys pk WHERE pk.keyId IN (:keys)
    3079     </sql>
    3080     <description>
    3081       A HQL query that has been granted a specific permission. Used by
    3082       update scripts when new item types are added to make sure existing
    3083       plug-ins can continue to work.
    3084     </description>
    3085   </query>
    3086 
    3087   <query id="CHANGE_EXPERIMENT_RAWDATATYPE" type="HQL">
    3088     <sql>
    3089       UPDATE ExperimentData
    3090       SET rawDataType = :newRawDataType
    3091       WHERE rawDataType = :oldRawDataType
    3092     </sql>
    3093     <description>
    3094       A HQL query that changes all raw data type for experiments from
    3095       an old value to a new value.
    3096     </description>
    3097   </query>
    3098 
    3099   <query id="GET_PROJECTS_WITH_DEFAULT" type="HQL">
    3100     <sql>
    3101       SELECT prj
    3102       FROM ProjectData prj
    3103       WHERE prj.projectDefaults[:name] = :value
    3104     </sql>
    3105     <description>
    3106       A HQL query that loads all projects which has a given default value
    3107       for a setting.
    3108     </description>
    3109   </query>
    3110 
    3111   <query id="SET_USEJOBQUEUE_ON_PLUGINS" type="HQL">
    3112     <sql>
    3113       UPDATE PluginDefinitionData pld
    3114       SET pld.useInternalJobQueue = true
    3115       WHERE pld.useInternalJobQueue IS NULL
    3116     </sql>
    3117     <description>
    3118       A HQL query that set the useInternalJobQueue property to true
    3119       for all plug-ins.
    3120     </description>
    3121   </query>
    3122  
    3123   <query id="SET_FEATUREIDENTIFICATIONMETHOD_ON_ARRAYDESIGNS" type="HQL">
    3124     <sql>
    3125       UPDATE ArrayDesignData ad
    3126       SET ad.featureIdentificationMethod = :method
    3127       WHERE ad.featureIdentificationMethod IS NULL
    3128     </sql>
    3129     <description>
    3130       A HQL query that set the featureIdentificationMethod property
    3131       on all array designs with a null value.
    3132     </description>
    3133   </query>
    31342389 
    31352390  <query id="UPDATE_JOB_STATUS" type="HQL">
     
    31582413  </query>
    31592414
    3160   <query id="SET_NUMARRAYS_ON_ARRAYDESIGNS" type="HQL">
    3161     <sql>
    3162       UPDATE ArrayDesignData ad
    3163       SET ad.numArrays = :numArrays
    3164       WHERE ad.numArrays IS NULL
    3165     </sql>
    3166     <description>
    3167       A HQL query that set the numArrays property
    3168       on all array designs with a null value.
    3169     </description>
    3170   </query>
    3171  
    3172   <query id="SET_NUMARRAYS_ON_HYBRIDIZATIONS" type="HQL">
    3173     <sql>
    3174       UPDATE HybridizationData hyb
    3175       SET hyb.numArrays = :numArrays
    3176       WHERE hyb.numArrays IS NULL
    3177     </sql>
    3178     <description>
    3179       A HQL query that set the numArrays property
    3180       on all hybridizations with a null value.
    3181     </description>
    3182   </query>
    3183  
    3184   <query id="SET_ARRAYNUM_ON_RAWBIOASSAYS" type="HQL">
    3185     <sql>
    3186       UPDATE RawBioAssayData rba
    3187       SET rba.arrayNum = :arrayNum
    3188       WHERE rba.arrayNum IS NULL
    3189     </sql>
    3190     <description>
    3191       A HQL query that set the arrayNum property
    3192       on all raw bioassays with a null value.
    3193     </description>
    3194   </query>
    3195  
    3196   <query id="SET_FEATUREDIAMETER_ON_ARRAYDESIGNBLOCKS" type="HQL">
    3197     <sql>
    3198       UPDATE ArrayDesignBlockData adb
    3199       SET adb.featureDiameter = :featureDiameter
    3200       WHERE adb.featureDiameter IS NULL
    3201     </sql>
    3202     <description>
    3203       A HQL query that set the featureDiameter property
    3204       on all array design blocks with a null value.
    3205     </description>
    3206   </query>
    3207  
    32082415  <query id="LOAD_RAWBIOASSAY_JOBS_IN_EXPERIMENT" type="HQL">
    32092416    <sql>
     
    32412448      A HQL query that set the experiment property to null for
    32422449      a given set of jobs.
    3243     </description>
    3244   </query>
    3245  
    3246   <query id="SET_REPORTERLIST_SIZE" type="HQL">
    3247     <sql>
    3248       UPDATE ReporterListData rl
    3249       SET rl.size = size(rl.reporterListScores)
    3250       WHERE rl.size IS NULL
    3251     </sql>
    3252     <description>
    3253       A HQL query that set the size of a reporter list
    3254       that is missing this information.
    3255     </description>
    3256   </query>
    3257 
    3258   <query id="SET_AUTOSHARE_ON_DIRECTORIES" type="HQL">
    3259     <sql>
    3260       UPDATE DirectoryData dir
    3261       SET dir.autoShare = :autoShare
    3262       WHERE dir.autoShare IS NULL
    3263     </sql>
    3264     <description>
    3265       A HQL query that set the autoShare property on all
    3266       directories witha  null value.
    3267     </description>
    3268   </query>
    3269 
    3270   <query id="SET_NUMFILEVALUES_ON_BIOASSAYSETS" type="HQL">
    3271     <sql>
    3272       UPDATE BioAssaySetData bas
    3273       SET bas.numFileReporters = 0, bas.numFileSpots = 0
    3274       WHERE bas.numFileReporters IS NULL OR bas.numFileSpots IS NULL
    3275     </sql>
    3276     <description>
    3277       A HQL query that set the numFileReporters and numFileSpots properties
    3278       to 0 on all bioassay sets with a null value.
    3279     </description>
    3280   </query>
    3281  
    3282   <query id="SET_NUMFILEVALUES_ON_BIOASSAYS" type="HQL">
    3283     <sql>
    3284       UPDATE BioAssayData ba
    3285       SET ba.numFileSpots = 0
    3286       WHERE ba.numFileSpots IS NULL
    3287     </sql>
    3288     <description>
    3289       A HQL query that set the numFileSpots property
    3290       to 0 on all bioassay with a null value.
    3291     </description>
    3292   </query>
    3293  
    3294   <query id="SET_NUMFILEVALUES_ON_EXTRAVALUES" type="HQL">
    3295     <sql>
    3296       UPDATE ExtraValueData ev
    3297       SET ev.numFileValues = 0
    3298       WHERE ev.numFileValues IS NULL
    3299     </sql>
    3300     <description>
    3301       A HQL query that set the numFileValues property
    3302       to 0 on all extra values with a null value.
    3303     </description>
    3304   </query>
    3305  
    3306   <query id="SET_DRYRUN_ON_JOBS" type="HQL">
    3307     <sql>
    3308       UPDATE JobData job
    3309       SET job.dryRun = false
    3310       WHERE job.dryRun IS NULL
    3311     </sql>
    3312     <description>
    3313       A HQL query that set the dryRun property
    3314       to false on all jobs with a null value.
    33152450    </description>
    33162451  </query>
     
    35012636    </description>
    35022637  </query>
    3503   <query id="GET_CHILD_PLATES_FOR_PLATE" type="HQL">
    3504     <sql>
    3505       SELECT {1}
    3506       FROM BioPlateData bp
    3507       JOIN bp.creationEvent ce
    3508       WHERE ce.sourcePlate = :bioPlate
    3509     </sql>
    3510     <description>
    3511       A HQL query that gets BioPlates that are children
    3512       to a given bioplate.
    3513     </description>
    3514   </query>
    3515   <query id="SET_AUTOPERMISSION_ON_PROJECTS" type="HQL">
    3516     <sql>
    3517       UPDATE ProjectData prj
    3518       SET prj.autoPermission = :permission
    3519       WHERE prj.autoPermission IS NULL
    3520     </sql>
    3521     <description>
    3522       An update query that sets the autoPermission on all
    3523       projects that doesn't have a value.
    3524     </description>
    3525   </query>
    3526   <query id="SET_INTENSITYTRANSFORM_ON_BIOASSAYSETS" type="HQL">
    3527     <sql>
    3528       UPDATE BioAssaySetData bas
    3529       SET bas.intensityTransform = :transform
    3530       WHERE bas.intensityTransform IS NULL
    3531     </sql>
    3532     <description>
    3533       An update query that sets the intensityTransform on all
    3534       bioassay sets that doesn't have a value.
    3535     </description>
    3536   </query>
    35372638  <query id="FIND_USED_TYPES_IN_ANYTOANY" type="SQL">
    35382639    <sql>
     
    36832784    </description>
    36842785  </query>
    3685   <query id="SET_HIDDENMEMBERS_ON_GROUPS" type="HQL">
    3686     <sql>
    3687       UPDATE GroupData grp
    3688       SET grp.hiddenMembers = :hiddenMembers
    3689       WHERE grp.hiddenMembers IS NULL
    3690     </sql>
    3691     <description>
    3692       An HQL query that sets the hiddenMembers flag on all
    3693       groups with a null value.
    3694     </description>
    3695   </query>
    36962786  <query id="GET_GROUPS_WITH_NONHIDDENMEMBERS" type="HQL">
    36972787    <sql>
     
    37062796    </description>
    37072797  </query>
    3708   <query id="FIX_NULL_IN_CONTEXTS_SORT_PROPERTY" type="SQL">
    3709     <sql>
    3710       update [Contexts]
    3711       set [sort_property] = null
    3712       where [sort_property] like '%null%'
    3713     </sql>
    3714     <description>
    3715       An SQL query that replaces all 'null' strings in Context.sort_property with
    3716       null values.
    3717     </description>
    3718   </query>
    37192798  <query id="GET_BIOPLATES_FOR_BIOPLATETYPE" type="HQL">
    37202799    <sql>
     
    37502829  </query>
    37512830
    3752   <query id="SET_PLATETYPE_ON_BIOPLATES" type="HQL">
    3753     <sql>
    3754       UPDATE BioPlateData bpl
    3755       SET bpl.bioPlateType = :plateType
    3756       WHERE bpl.bioPlateType IS NULL
    3757     </sql>
    3758     <description>
    3759       An update query that sets the plate type on all
    3760       bioplates that doesn't have a value.
    3761     </description>
    3762   </query>
    3763  
    37642831  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
    37652832    <sql>
     
    37712838      An HQL update-query that sets group to null on all
    37722839      diskusage that are associated with a given group.
    3773     </description>
    3774   </query>
    3775 
    3776   <query id="SET_SCHEDULED_FOR_JOBS" type="HQL">
    3777     <sql>
    3778       UPDATE JobData job
    3779       SET job.scheduled = job.created
    3780       WHERE job.status > 1 AND job.scheduled IS NULL
    3781     </sql>
    3782     <description>
    3783       An HQL update-query that sets the scheduled date
    3784       to the creation date for existing jobs that have been
    3785       scheduled and doesn't have a scheduled date.
    3786     </description>
    3787   </query>
    3788 
    3789   <query id="DELETE_CONTEXTSETTING_BY_NAME_AND_VALUE" type="SQL">
    3790     <sql>
    3791       DELETE FROM [ContextSettings]
    3792       WHERE [name] LIKE :name AND [value] LIKE :value
    3793     </sql>
    3794     <description>
    3795       An SQL-query that delete context-related settings with
    3796       name and value mathing a given pattern.
    3797     </description>
    3798   </query>
    3799 
    3800   <query id="SET_SEND_MESSAGES_AS_EMAIL_FOR_USERS" type="HQL">
    3801     <sql>
    3802       UPDATE UserData usr
    3803       SET usr.sendMessagesAsEmail = :sendMessagesAsEmail
    3804       WHERE usr.sendMessagesAsEmail IS NULL
    3805     </sql>
    3806     <description>
    3807       An HQL update-query that sets the 'sendMessagesAsEmail' flag
    3808       for all users where it is null.
    3809     </description>
    3810   </query>
    3811 
    3812   <query id="SET_DESTROYED_FOR_BIOPLATES" type="HQL">
    3813     <sql>
    3814       UPDATE BioPlateData bp
    3815       SET bp.destroyed = false
    3816       WHERE bp.destroyed IS NULL
    3817     </sql>
    3818     <description>
    3819       An HQL update-query that sets the 'destroyed' flag
    3820       for all bioplates where it is null.
    38212840    </description>
    38222841  </query>
     
    38882907    </description>
    38892908  </query>
    3890 
    3891   <query id="COUNT_FREE_WELLS_ON_BIOPLATE" type="HQL">
    3892     <sql>
    3893       SELECT pg.rows * pg.columns - COUNT(bm.id)
    3894       FROM BioPlateData bpl JOIN bpl.bioWells w
    3895       JOIN bpl.plateGeometry pg
    3896       LEFT JOIN w.bioMaterial bm
    3897       WHERE bpl.id = :bioPlateId
    3898       GROUP BY pg.rows, pg.columns
    3899     </sql>
    3900     <description>
    3901       A HQL query that counts the number of free wells on a given bioplate.
    3902     </description>
    3903   </query>
    3904 
    3905   <query id="SET_FREE_WELLS_ON_BIOPLATE" type="HQL">
    3906     <sql>
    3907       UPDATE BioPlateData bpl
    3908       SET bpl.freeWells = :freeWells
    3909       WHERE bpl.id = :bioPlateId
    3910     </sql>
    3911     <description>
    3912       A HQL update query that sets the number of free wells for a given bioplate.
    3913     </description>
    3914   </query>
    3915 
     2909 
     2910  <query id="GET_JAR_PATH_FROM_TABLE" type="SQL">
     2911    <sql>
     2912      SELECT [id], [jar_path] FROM [{1}] [t]
     2913      where [t].[jar_file] IS NULL AND NOT [t].[jar_path] IS NULL
     2914    </sql>
     2915    <description>
     2916      An SQL query that selects the ID and JAR_PATH column from a given table
     2917      where the existing JAR_PATH has a value and the existing JAR_FILE is
     2918      null.
     2919    </description>
     2920  </query>
     2921
     2922  <query id="SET_JAR_FILE_IN_TABLE" type="SQL">
     2923    <sql>
     2924      UPDATE [{1}] SET [jar_file] = :file WHERE id = :id
     2925    </sql>
     2926    <description>
     2927      An SQL query that updates the JAR_FILE with the given value.
     2928    </description>
     2929  </query>
     2930 
     2931  <query id="DROP_COLUMN" type="SQL">
     2932    <sql>
     2933      ALTER TABLE [{1}] DROP COLUMN [{2}]
     2934    </sql>
     2935    <description>
     2936      An SQL query that drops a column from a table.
     2937    </description>
     2938  </query>
     2939 
    39162940</predefined-queries>
  • trunk/src/core/net/sf/basedb/core/Application.java

    r5617 r5621  
    715715    ExtendedProperties.unload();
    716716    Config.unload();
     717    schemaVersion = -2;
    717718    log.info("BASE has been stopped");
    718719   
  • trunk/src/core/net/sf/basedb/core/HibernateUtil.java

    r5477 r5621  
    590590    Create the all tables in the database. The database must exists and we
    591591    recommend that it is empty to begin with.
    592   */
    593   static void createStaticTables(boolean update, ProgressReporter progress)
     592    @return The schemaVersion that is currently installed
     593  */
     594  static int createStaticTables(boolean update, ProgressReporter progress)
    594595    throws BaseException
    595596  {
    596597    assert sf != null : "HibernateUtil has not been initialised";
    597598
     599    int currentSchemaVersion = Install.NEW_SCHEMA_VERSION;
    598600    if (update)
    599601    {
    600       int currentSchemaVersion = Application.getSchemaVersion();       
     602      currentSchemaVersion = Application.getSchemaVersion();       
    601603      if (currentSchemaVersion < 0)
    602604      {
     
    608610            " of database, cause you already have schema version " + currentSchemaVersion + " installed");
    609611      }
     612      else if (currentSchemaVersion < 90)
     613      {
     614        throw new BaseException("This update script can only update a BASE 2.17 database.");
     615      }
    610616    }
    611617    else
     
    636642      if (session != null) HibernateUtil.close(session);
    637643    }
     644    return currentSchemaVersion;
    638645  }
    639646
  • trunk/src/core/net/sf/basedb/core/Install.java

    r5617 r5621  
    119119    method.
    120120  */
    121   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(90).intValue();
    122  
    123   public static synchronized void createTables(boolean update, final ProgressReporter progress)
     121  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(100).intValue();
     122 
     123  public static synchronized int createTables(boolean update, final ProgressReporter progress)
    124124    throws BaseException
    125125  {
    126126    String message = "";
     127    int schemaVersion = NEW_SCHEMA_VERSION;
    127128    try
    128129    {
    129130      Application.start(true, false, false);
    130131      if (progress != null) progress.display(0, "Building database...");
    131       HibernateUtil.createStaticTables(update, progress);
     132      schemaVersion = HibernateUtil.createStaticTables(update, progress);
    132133      message = "Database built successfully.";
    133134    }
     
    145146      Application.stop();
    146147    }
     148    return schemaVersion;
    147149  }
    148150 
  • trunk/src/core/net/sf/basedb/core/Update.java

    r5617 r5621  
    2323package net.sf.basedb.core;
    2424
     25import java.util.ArrayList;
     26import java.util.Arrays;
     27import java.util.List;
     28import java.util.Map;
     29
     30
     31import net.sf.basedb.core.data.ContextData;
     32import net.sf.basedb.core.data.PropertyFilterData;
    2533import net.sf.basedb.core.data.SchemaVersionData;
     34import net.sf.basedb.util.Values;
    2635
    2736/**
     
    4150    </td>
    4251  </tr>
     52 
     53  <tr>
     54    <td>100</td>
     55    <td>
     56      The schema as released in BASE 3.0. We don't list all changes here.
     57    </td>
     58  </tr>
     59 
    4360  </table>
    4461
     
    86103      session = HibernateUtil.newSession();
    87104      int schemaVersion = getSchemaVersion(session);
    88      
    89       if (schemaVersion < 90)
    90       {
    91         throw new BaseException("This update script can only update a BASE 2.17 database.");
    92       }
    93      
     105       
    94106      sc.logout();
    95107      if (progress != null) progress.display(100, "Database updated successfully.");
     
    195207        Config.setProperty("extensions.disabled", "true");
    196208        Application.start(false, false, false);
    197  
     209
    198210        // Test root user account
    199211        SessionControl sc = Application.newSessionControl(null, null, null);
     
    226238    }
    227239  }
     240 
     241  public static synchronized void updateToBase3(ProgressReporter progress, String rootLogin, String rootPassword)
     242    throws BaseException
     243  {
     244
     245    org.hibernate.Session session = null;
     246    org.hibernate.Query query = null;
     247    try
     248    {
     249      progress.display(0, "Updating to BASE 3.0...");
     250      Config.setProperty("extensions.disabled", "true");
     251      Application.start(false, false, false);
     252
     253      // Test root user account
     254      SessionControl sc = Application.newSessionControl(null, null, null);
     255      sc.login(rootLogin, rootPassword, null, false);
     256      if (sc.getLoggedInUserId() != SystemItems.getId(User.ROOT))
     257      {
     258        throw new PermissionDeniedException("User '" + rootLogin + "' is not the root account.");
     259      }
     260     
     261      session = HibernateUtil.newSession();
     262      int schemaVersion = getSchemaVersion(session);
     263     
     264      // 1: copy data to new tables/columns
     265
     266      // PluginDefinitions and PluginTypes jar_path should be copied to jar_file but only keep filename
     267      progress.display(10, "--Updating plug-in paths");
     268      copyJarPathToJarFile(session, "PluginDefinitions");
     269      copyJarPathToJarFile(session, "PluginTypes");
     270      cleanContextFromProperty(session, Item.PLUGINDEFINITION, "jarPath", "jarFile");
     271      cleanContextFromProperty(session, Item.PLUGINTYPE, "jarPath", "jarFile");
     272 
     273     
     274      // 2: remove unused columns/tables
     275      progress.display(90, "--Dropping old database objects");
     276      dropColumn(session, "PluginDefinitions", "jar_path", progress);
     277      dropColumn(session, "PluginTypes", "jar_path", progress);
     278      dropColumn(session, "JobAgentSettings", "jar_path", progress);
     279      dropColumn(session, "ArrayDesigns", "affy_chip", progress);
     280     
     281      setSchemaVersionInTransaction(session, 100);
     282      log.info("updateToBase3: OK");
     283    }
     284    catch (BaseException ex)
     285    {
     286      progress.display(100, "Update to BASE 3 failed: " + ex.getMessage()+"\n");
     287      log.info("updateToBase3: FAILED");
     288      throw ex;
     289    }
     290    finally
     291    {
     292      if (session != null) HibernateUtil.close(session);
     293      Application.stop();
     294    }
     295  }
     296
     297 
     298  private static void copyJarPathToJarFile(org.hibernate.Session session, String tableName)
     299  {
     300    org.hibernate.Transaction tx = null;
     301    org.hibernate.Query query = null;
     302    try
     303    {
     304      tx = HibernateUtil.newTransaction(session);
     305      log.debug("Copy JAR path in table: " + tableName);
     306
     307      query = HibernateUtil.getPredefinedSQLQuery(session, "GET_JAR_PATH_FROM_TABLE", tableName);
     308      @SuppressWarnings("unchecked")
     309      List<Object[]> result = query.list();
     310      query = HibernateUtil.getPredefinedSQLQuery(session, "SET_JAR_FILE_IN_TABLE", tableName);
     311      for (Object[] o : result)
     312      {
     313        int id = (Integer)o[0];
     314        String jarPath = (String)o[1];
     315        int lastSlash = jarPath.lastIndexOf('/');
     316        String jarFile = jarPath.substring(lastSlash+1);
     317        log.debug("Setting JAR file: " + jarFile + "; id=" + id);
     318        query.setInteger("id", id);
     319        query.setString("file", jarFile);
     320        query.executeUpdate();
     321      }
     322      HibernateUtil.commit(tx);
     323    }
     324    catch (BaseException ex)
     325    {
     326      if (tx != null) HibernateUtil.rollback(tx);
     327      throw ex;
     328    }
     329   
     330  }
     331
     332  private static void dropColumn(org.hibernate.Session session, String tableName, String columnName, ProgressReporter progress)
     333  {
     334    org.hibernate.Transaction tx = null;
     335    org.hibernate.Query query = null;
     336    try
     337    {
     338      log.debug("Dropping column: " + tableName + "." + columnName);
     339      progress.display(90, "  --alter table " + tableName + " drop column " + columnName);
     340      tx = HibernateUtil.newTransaction(session);
     341      query = HibernateUtil.getPredefinedSQLQuery(session, "DROP_COLUMN", tableName, columnName);
     342      query.executeUpdate();
     343      HibernateUtil.commit(tx);
     344    }
     345    catch (BaseException ex)
     346    {
     347      if (tx != null) HibernateUtil.rollback(tx);
     348      throw ex;
     349    }
     350  }
     351
     352  private static void cleanContextFromProperty(org.hibernate.Session session, Item itemType, String propertyName, String replacementPropertyName)
     353  {
     354    org.hibernate.Transaction tx = null;
     355    org.hibernate.Query query = null;
     356    try
     357    {
     358      log.debug("Cleaning context for item: " + itemType + "; property=" + propertyName + "; replacement=" + replacementPropertyName);
     359      tx = HibernateUtil.newTransaction(session);
     360     
     361      query = HibernateUtil.createQuery(session, "select ctx from ContextData ctx where ctx.itemType = " + itemType.getValue());
     362      List<ContextData> contexts = HibernateUtil.loadList(ContextData.class, query, null);
     363     
     364      for (ContextData ctx : contexts)
     365      {
     366        // Sort property
     367        if (ctx.getSortProperty() != null)
     368        {
     369          ctx.setSortProperty(replaceInCommaSeparatedList(ctx.getSortProperty(), propertyName, replacementPropertyName));
     370        }
     371       
     372        // "columns" settings
     373        Map<String, String> settings = ctx.getSettings();
     374        String columns = settings.get("columns");
     375        if (columns != null)
     376        {
     377          columns = replaceInCommaSeparatedList(columns, propertyName, replacementPropertyName);
     378          if (columns == null)
     379          {
     380            settings.remove("columns");
     381          }
     382          else
     383          {
     384            settings.put("columns", columns);
     385          }
     386        }
     387       
     388        // Filter
     389        Map<String, PropertyFilterData> filters = ctx.getPropertyFilters();
     390        PropertyFilterData propertyFilter = filters.remove(propertyName);
     391        if (propertyFilter != null) filters.put(replacementPropertyName, propertyFilter);
     392       
     393      }
     394     
     395     
     396      HibernateUtil.commit(tx);
     397    }
     398    catch (BaseException ex)
     399    {
     400      if (tx != null) HibernateUtil.rollback(tx);
     401      throw ex;
     402    }
     403   
     404  }
     405 
     406 
     407  private static String replaceInCommaSeparatedList(String list, String find, String replacement)
     408  {
     409    List<String> elements = new ArrayList<String>(Arrays.asList(list.split(",")));
     410    String result = list;
     411    int pos = elements.indexOf(find);
     412    if (pos >= 0)
     413    {
     414      if (replacement != null)
     415      {
     416        elements.set(pos, replacement);
     417      }
     418      else
     419      {
     420        elements.remove(pos);
     421      }
     422      if (elements.size() == 0)
     423      {
     424        result = null;
     425      }
     426      else
     427      {
     428        result = Values.getString(elements, ",", true);
     429      }
     430    }
     431    return result;
     432  }
     433 
    228434}
  • trunk/src/install/net/sf/basedb/install/InitDB.java

    r4889 r5621  
    3434import net.sf.basedb.core.ProgressReporter;
    3535import net.sf.basedb.core.Update;
     36import net.sf.basedb.core.Version;
    3637import net.sf.basedb.util.ConsoleProgressReporter;
    3738import net.sf.basedb.util.ChainedProgressReporter;
     
    6970        progress.setRange(0, 30);
    7071        showDbInfo(progress);
    71         Install.createTables(update, progress);
    72         progress.setRange(35, 70);
    73         Update.adjustExistingItems(update, progress, rootLogin, rootPassword);
     72        int schemaVersion = Install.createTables(update, progress);
     73        progress.setRange(30, 50);
     74        if (update)
     75        {
     76          if (schemaVersion == 90)
     77          {
     78            Update.updateToBase3(progress, rootLogin, rootPassword);
     79          }
     80          else
     81          {
     82            Update.adjustExistingItems(update, progress, rootLogin, rootPassword);
     83          }
     84        }
     85        progress.setRange(50, 75);
    7486        Install.initDatabase(update, progress, rootLogin, rootPassword);
    7587        progress.setRange(75, 90);
    76         Update.updateDatabase(progress, rootLogin, rootPassword);
     88        if (update) Update.updateDatabase(progress, rootLogin, rootPassword);
    7789        progress.setRange(95, 100);
    7890        progress.display(0, "Installing web application...");
     
    157169    String message =
    158170      "--System information-----------------------------\n" +
    159       "BASE     : " + Application.getMajorVersion() + "." +
    160         Application.getMinorVersion() + "." +
    161         Application.getMaintenanceVersion() + "\n" +
     171      "BASE     : " + Version.getVersion() + "\n" +
    162172      "Database : " + Config.getString("db.url") + "\n" +
    163173      "Dialect  : " + Config.getString("db.dialect") + "\n" +
Note: See TracChangeset for help on using the changeset viewer.