Changeset 5734


Ignore:
Timestamp:
Sep 13, 2011, 11:41:48 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

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

  • The file for an image can be null, skip those when updating
  • Deprecated batch importers that have been replaced with new ones (labeled extract, hybridization and scan importer). The update will disable the old plug-ins.
  • Disable BioAssaySetExporter? if it is still present in the database. The plug-in no longer exists in the api.
  • Remove role keys and plug-in keys for item types that no longer exists (labeled extract, hyb, scan, software type, hardware type, etc.)
Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r5733 r5734  
    32673267
    32683268
    3269   <query id="DELETE_PLUGINGUICONTEXTS_ITEMTYPE" type="SQL">
    3270     <sql>
    3271       DELETE FROM PluginDefinitionGuiContexts
    3272       WHERE item_type={1}
     3269  <query id="DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE" type="SQL">
     3270    <sql>
     3271      DELETE FROM [PluginDefinitionGuiContexts]
     3272      WHERE [item_type] = :itemType
    32733273    </sql>
    32743274    <description>
     
    32773277    </description>
    32783278  </query>
     3279
     3280  <query id="DELETE_PLUGINKEYS_FOR_ITEMTYPE" type="SQL">
     3281    <sql>
     3282      DELETE FROM [PluginKeys]
     3283      WHERE [key_id] IN (
     3284        SELECT k.[id]
     3285        FROM [Keys] k
     3286        WHERE k.[item_type] = :itemType
     3287      )
     3288    </sql>
     3289    <description>
     3290      An SQL query that delete plug-in keys referencing keys
     3291      for a given item type.
     3292    </description>
     3293  </query>
     3294
    32793295
    32803296  <query id="GET_SUBTYPABLE_ITEMS_FOR_SUBTYPE_OF_CLASS" type="HQL">
  • trunk/src/core/net/sf/basedb/core/Install.java

    r5733 r5734  
    23562356      dc = sessionControl.newDbControl();
    23572357      plugin = PluginDefinition.installOrUpdate(dc, info, null, shareToEveryone);
    2358       boolean isNew = !plugin.isInDatabase();
    2359      
    2360       if (isNew)
    2361       {
    2362         plugin.setTrusted(true);
    2363       }
    2364       dc.commit();
    2365      
    2366       if (isNew)
    2367       {
    2368         log.info("createPluginDefinition: OK [class="+className+"]");
     2358      if (plugin != null)
     2359      {
     2360        boolean isNew = !plugin.isInDatabase();
     2361        if (isNew)
     2362        {
     2363          plugin.setTrusted(true);
     2364        }
     2365        dc.commit();
     2366        if (isNew)
     2367        {
     2368          log.info("createPluginDefinition: OK [class="+className+"]");
     2369        }
     2370        else
     2371        {
     2372          log.info("createPluginDefinition: UPDATED [class="+className+"]");
     2373        }
    23692374      }
    23702375      else
    23712376      {
    2372         log.info("createPluginDefinition: UPDATED [class="+className+"]");
     2377        log.info("createPluginDefinition: SKIPPED [class="+className+"]");
    23732378      }
    23742379    }
     
    26492654      {
    26502655        log.info("createDataFileType: EXISTS [externalId="+externalId+"]");
    2651         /*
    2652         TODO #1591: Make sure that updating create proper file type links
    2653         if (itemSubtypes != null && schemaVersion.getSchemaVersion() < 100)
    2654         {
    2655           for (ItemSubtypeFT sft : itemSubtypes)
    2656           {
    2657             ItemSubtypeFileTypeData subtypeFile = new ItemSubtypeFileTypeData();
    2658             subtypeFile.setItemSubtype(sft.subtype);
    2659             subtypeFile.setDataFileType(fileType);
    2660             subtypeFile.setRequired(sft.required);
    2661             subtypeFile.setAllowMultiple(sft.multiple);
    2662             HibernateUtil.saveData(session, subtypeFile);
    2663           }
    2664         }
    2665         */
    26662656        HibernateUtil.commit(tx);
    26672657      }
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r5616 r5734  
    376376  /**
    377377    Install or update the plug-in definition with information from the info
    378     object. Existing plug-ins will be updated and the disabled flag is cleared.
     378    object. Existing plug-ins will be updated and the disabled flag is cleared
     379    (unless it is deprecated).
    379380    New plug-ins are configured with additional options from the info object:
    380381    <ul>
     
    383384    <li>immediate-execution: If the plug-in is allowed to bypass the job queue.
    384385    <li>everyone-use: If the plug-in should be shared with USE permission to everyone.
     386    <li>deprecated: Disable the plug-in if it is already installed, do not install
     387      if it is missing
    385388    </ul>
     389    @return The plugin definition or null if no plug-in was installed
    386390    @since 3.0
    387391  */
     
    390394    PluginDefinition plugin = null;
    391395    String className = info.getClassName();
     396    boolean deprecated = Values.getBoolean(info.getProperty("deprecated"));
    392397    try
    393398    {
     
    397402    catch (ItemNotFoundException ex)
    398403    {
    399       plugin = PluginDefinition.getNew(dc, className, jarFile, true);
    400       plugin.setMaxMemory(Values.getLong(info.getProperty("max-memory"), null));
    401       plugin.setAllowImmediateExecution(Values.getBoolean(info.getProperty("immediate-execution")));
    402       if (Values.getBoolean(info.getProperty("everyone-use")))
     404      if (!deprecated)
    403405      {
    404         plugin.setItemKey(shareToEveryone);
     406        plugin = PluginDefinition.getNew(dc, className, jarFile, true);
     407        plugin.setMaxMemory(Values.getLong(info.getProperty("max-memory"), null));
     408        plugin.setAllowImmediateExecution(Values.getBoolean(info.getProperty("immediate-execution")));
     409        if (Values.getBoolean(info.getProperty("everyone-use")))
     410        {
     411          plugin.setItemKey(shareToEveryone);
     412        }
     413        dc.saveItem(plugin);
     414        plugin.info = info; // So that we can set an ID on the info object after commit.
    405415      }
    406       dc.saveItem(plugin);
    407       plugin.info = info; // So that we can set an ID on the info object after commit.
    408     }
    409     plugin.setAbout(info.getAbout(), true);
    410     plugin.setDisabled(false);
     416    }
     417    if (plugin != null)
     418    {
     419      plugin.setAbout(info.getAbout(), true);
     420      plugin.setDisabled(deprecated);
     421    }
    411422    return plugin;
    412423  }
     
    801812    Checks if this plugin is disabled or not. A disabled plugin
    802813    can't be used.
    803     @return
     814    @since 3.0
    804815  */
    805816  public boolean isDisabled()
     
    809820 
    810821  /**
    811     Disabled or enabled this plugin.
     822    Disabled or enable this plugin.
     823    @since 3.0
    812824  */
    813825  public void setDisabled(boolean disabled)
  • trunk/src/core/net/sf/basedb/core/Update.java

    r5733 r5734  
    5050import net.sf.basedb.core.data.ItemSubtypeData;
    5151import net.sf.basedb.core.data.PhysicalBioAssayData;
     52import net.sf.basedb.core.data.PluginDefinitionData;
    5253import net.sf.basedb.core.data.ProjectKeyData;
    5354import net.sf.basedb.core.data.PropertyFilterData;
    5455import net.sf.basedb.core.data.ProtocolData;
     56import net.sf.basedb.core.data.RoleKeyData;
    5557import net.sf.basedb.core.data.SchemaVersionData;
    5658import net.sf.basedb.core.data.UserData;
     
    333335      session.delete(tmpType);
    334336     
    335       // Update the shcema version number
     337      // Disable the 'BioAssaySetExporter' plug-in since it is no longer included in the code
     338      query = HibernateUtil.getPredefinedQuery(session, "GET_PLUGINDEFINITION_FOR_CLASSNAME");
     339      query.setString("className", "net.sf.basedb.plugins.BioAssaySetExporter");
     340      PluginDefinitionData plugin = HibernateUtil.loadData(PluginDefinitionData.class, query);
     341      if (plugin != null)
     342      {
     343        plugin.setDisabled(true);
     344      }
     345     
     346      // Update the schema version number
    336347      setSchemaVersion(session, schemaVersion);
    337348 
     
    411422      progress.display(30, "--Converting hybridizations to bioassays");
    412423      Map<Integer, Integer> hybMap = copyHybridizations(session);
     424      cleanContextFromProperty(session, Item.ARRAYSLIDE, "hybridization", "physicalBioAssay", false);     
    413425      removeContext(session, HYBRIDIZATION);
    414       cleanContextFromProperty(session, Item.ARRAYSLIDE, "hybridization", "physicalBioAssay", false);     
    415426     
    416427      progress.display(35, "--Converting scans to bioassays");
     
    446457      cleanContextFromProperty(session, Item.DATAFILETYPE, "genericType", "genericType", true);
    447458      removeContext(session, FILETYPE);
    448      
     459   
    449460      // 2: remove unused columns/tables
    450461      progress.display(80, "--Dropping old database objects");
     
    646657    }
    647658  }
    648 
     659 
     660  /**
     661    Remove context-related information for the given item type.
     662  */
    649663  private static void removeContext(org.hibernate.Session session, int itemType)
    650664  {
     
    661675      {
    662676        session.delete(ctx);
     677      }
     678
     679      // DELETE FROM PluginDefinitionGuiContexts WHERE item_type=?
     680      query = HibernateUtil.getPredefinedSQLQuery(session,
     681        "DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE");
     682      query.setInteger("itemType", itemType);
     683      query.executeUpdate();
     684     
     685      log.debug("Removing role key for item: " + itemType);
     686      // DELETE FROM PluginKeys WHERE item_type=?
     687      query = HibernateUtil.getPredefinedSQLQuery(session,
     688        "DELETE_PLUGINKEYS_FOR_ITEMTYPE");
     689      query.setInteger("itemType", itemType);
     690      query.executeUpdate();
     691
     692      query = HibernateUtil.createQuery(session, "SELECT key FROM RoleKeyData key WHERE key.itemType = :itemType");
     693      query.setInteger("itemType", itemType);
     694      for (RoleKeyData key : HibernateUtil.loadList(RoleKeyData.class, query, null))
     695      {
     696        session.delete(key);
    663697      }
    664698     
     
    913947        {
    914948          Object[] imgRow = (Object[])it2.next();
    915          
    916           if (fileSet == null)
     949          Integer fileId = (Integer)imgRow[2];
     950          if (fileId != null)
    917951          {
    918             fileSet = new FileSetData();
    919             fileSet.setItemType(Item.DERIVEDBIOASSAY.getValue());
    920             session.save(fileSet);
    921             bioAssay.setFileSet(fileSet);
     952            if (fileSet == null)
     953            {
     954              fileSet = new FileSetData();
     955              fileSet.setItemType(Item.DERIVEDBIOASSAY.getValue());
     956              session.save(fileSet);
     957              bioAssay.setFileSet(fileSet);
     958            }
     959            if (fileType == null)
     960            {
     961              // Create a temporary file type, which will be removed
     962              // once the install has created the correct one
     963              fileType = new DataFileTypeData();
     964              fileType.setName("Temporary file type for scanned images");
     965              fileType.setExternalId("tmp.image");
     966              fileType.setItemType(Item.DERIVEDBIOASSAY.getValue());
     967              session.save(fileType);
     968            }
     969           
     970            FileSetMemberData member = new FileSetMemberData();
     971            member.setFile(load(session, FileData.class, fileId));
     972            member.setFileSet(fileSet);
     973            member.setDataFileType(fileType);
     974            session.save(member);
    922975          }
    923           if (fileType == null)
    924           {
    925             // Create a temporary file type, which will be removed
    926             // once the install has created the correct one
    927             fileType = new DataFileTypeData();
    928             fileType.setName("Temporary file type for scanned images");
    929             fileType.setExternalId("tmp.image");
    930             fileType.setItemType(Item.DERIVEDBIOASSAY.getValue());
    931             session.save(fileType);
    932           }
    933          
    934           FileSetMemberData member = new FileSetMemberData();
    935           member.setFile(load(session, FileData.class, imgRow[2]));
    936           member.setFileSet(fileSet);
    937           member.setDataFileType(fileType);
    938           session.save(member);
    939976        }
    940977       
     
    14561493    HibernateUtil.getPredefinedSQLQuery(session, "UPDATE_ITEMTYPE",
    14571494      "BioPlateTypes", "biomaterial_type", oldTypeS, newTypeS).executeUpdate();
    1458     // DELETE FROM PluginDefinitionGuiContexts WHERE item_type={1}
    1459     HibernateUtil.getPredefinedSQLQuery(session,
    1460       "DELETE_PLUGINGUICONTEXTS_ITEMTYPE", oldTypeS).executeUpdate();
    14611495   
    14621496  }
  • trunk/src/core/net/sf/basedb/core/data/PluginDefinitionData.java

    r5615 r5734  
    292292    If the plugin is enabled or disabled.
    293293    // Mapped in hibernate-properties-PluginDefinitionData.xml since annotation doesn't support a default value
     294    @since 3.0
    294295  */
    295296  public boolean isDisabled()
  • trunk/src/core/net/sf/basedb/util/extensions/manager/processor/PluginInstallationProcessor.java

    r5617 r5734  
    137137          {
    138138            PluginDefinition plugin = PluginDefinition.installOrUpdate(dc, info, jarFile, shareToEveryone);
    139             allPlugins.put(info.getClassName(), plugin);
    140             if (plugin.isInDatabase())
     139            if (plugin != null)
    141140            {
    142               numUpdated++;
    143             }
    144             else
    145             {
    146               numInstalled++;
     141              allPlugins.put(info.getClassName(), plugin);
     142              if (plugin.isInDatabase())
     143              {
     144                numUpdated++;
     145              }
     146              else
     147              {
     148                numInstalled++;
     149              }
    147150            }
    148151          }
  • trunk/src/plugins/core/core-plugins.xml

    r5729 r5734  
    555555  </plugin-definition>
    556556
    557   <!--
    558   Used for backwards compatibility with older server installations
     557  <!-- Used for backwards compatibility with older server installations -->
    559558  <plugin-definition id="LabeledExtractImporter">
    560559    <about>
    561       <name>Labeled extract importer</name>
     560      <name>Labeled extract importer (deprecated)</name>
    562561      <description>
    563562        Imports and updates labeled extracts in a batch.
     
    567566    <settings>
    568567      <property name="everyone-use">1</property>
    569     </settings>
    570   </plugin-definition>
    571   -->
    572   <!--
    573   Used for backwards compatibility with older server installations
     568      <property name="deprecated">1</property>
     569    </settings>
     570  </plugin-definition>
     571
     572  <!-- Used for backwards compatibility with older server installations -->
    574573  <plugin-definition id="HybridizationImporter">
    575574    <about>
    576       <name>Hybridization importer</name>
     575      <name>Hybridization importer (deprecated)</name>
    577576      <description>
    578577        Imports and updates hybridizations in a batch.
     
    582581    <settings>
    583582      <property name="everyone-use">1</property>
    584     </settings>
    585   </plugin-definition>
    586   -->
     583      <property name="deprecated">1</property>
     584    </settings>
     585  </plugin-definition>
     586
    587587  <plugin-definition id="PhysicalBioAssayImporter">
    588588    <about>
     
    598598  </plugin-definition>
    599599 
    600   <!--
    601   Used for backwards compatibility with older server installations
     600  <!-- Used for backwards compatibility with older server installations -->
    602601  <plugin-definition id="ScanImporter">
    603602    <about>
    604       <name>Scan importer</name>
     603      <name>Scan importer (deprecated)</name>
    605604      <description>
    606605        Imports and updates scans in a batch.
     
    610609    <settings>
    611610      <property name="everyone-use">1</property>
    612     </settings>
    613   </plugin-definition>
    614   -->
     611      <property name="deprecated">1</property>
     612    </settings>
     613  </plugin-definition>
    615614 
    616615  <plugin-definition id="DerivedBioAssayImporter">
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/HybridizationImporter.java

    r5662 r5734  
    5858  @version 2.8
    5959  @base.modified $Date$
     60  @deprecated In 3.0, use {@link PhysicalBioAssayImporter} instead
    6061*/
     62@Deprecated
    6163public class HybridizationImporter
    6264  extends AbstractItemImporter<PhysicalBioAssay>
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/LabeledExtractImporter.java

    r5667 r5734  
    5353  @version 2.8
    5454  @base.modified $Date$
     55  @deprecated In 3.0, use {@link ExtractImporter} instead
    5556*/
     57@Deprecated
    5658public class LabeledExtractImporter
    5759  extends AbstractItemImporter<Extract>
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ScanImporter.java

    r5729 r5734  
    5454  @version 2.8
    5555  @base.modified $Date$
     56  @deprecated In 3.0, use {@link DerivedBioAssayImporter} instead
    5657*/
     58@Deprecated
    5759public class ScanImporter
    5860  extends AbstractItemImporter<DerivedBioAssay>
Note: See TracChangeset for help on using the changeset viewer.