Changeset 3594


Ignore:
Timestamp:
Jul 24, 2007, 10:57:44 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #626: Remove base1executor any to any links

Location:
trunk/src/core/net/sf/basedb/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Install.java

    r3593 r3594  
    101101    method.
    102102  */
    103   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(38).intValue();
     103  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(39).intValue();
    104104 
    105105  public static synchronized void createTables(boolean update, final ProgressReporter progress)
  • trunk/src/core/net/sf/basedb/core/Update.java

    r3593 r3594  
    4646import net.sf.basedb.core.data.PlateData;
    4747import net.sf.basedb.core.data.PlateMappingData;
     48import net.sf.basedb.core.data.PluginConfigurationData;
     49import net.sf.basedb.core.data.PluginDefinitionData;
    4850import net.sf.basedb.core.data.SchemaVersionData;
    4951import net.sf.basedb.core.data.TransformationData;
     
    453455      The update sets the experiment for jobs that belong to a single
    454456      transformation.
     457    </td>
     458  </tr>
     459 
     460  <tr>
     461    <td>39</td>
     462    <td>
     463      Remove AnyToAny links created by older versions of the
     464      Base1PluginExecuter plug-in.
    455465    </td>
    456466  </tr>
     
    646656      }
    647657     
     658      if (schemaVersion < 39)
     659      {
     660        if (progress != null) progress.display((int)(38*progress_factor), "--Updating schema version: " + schemaVersion + " -> 39...");       
     661        schemaVersion = updateToSchemaVersion39(session);
     662      }
     663     
    648664      /*
    649665      if (schemaVersion < 39)
    650666      {
    651         if (progress != null) progress.display((int)(38*progress_factor), "--Updating schema version: " + schemaVersion + " -> 39...");
    652         schemaVersion = setSchemaVersionInTransaction(session, 39);
     667        if (progress != null) progress.display((int)(39*progress_factor), "--Updating schema version: " + schemaVersion + " -> 40...");
     668        schemaVersion = setSchemaVersionInTransaction(session, 40);
    653669        - or -
    654         schemaVersion = updateToSchemaVersion39(session);
     670        schemaVersion = updateToSchemaVersion40(session);
    655671      }
    656672      ... etc...
     
    14391455        {
    14401456          job.setExperiment(jobExperiments.iterator().next());
    1441           System.out.println("Setting experiment '" + job.getExperiment().getName() + "' to job " + job.getName());
    14421457        }
    14431458      }
     
    14541469      if (tx != null) HibernateUtil.rollback(tx);
    14551470      log.error("updateToSchemaVersion38: FAILED", ex);
     1471      throw ex;
     1472    }
     1473    return schemaVersion;   
     1474  }
     1475  /**
     1476    Remove AnyToAny links created by older versions of Base1PluginExecuter
     1477    @return The new schema version (=39)
     1478  */
     1479  private static int updateToSchemaVersion39(org.hibernate.Session session)
     1480  {
     1481    final int schemaVersion = 39;
     1482    org.hibernate.Transaction tx = null;
     1483    try
     1484    {
     1485      tx = HibernateUtil.newTransaction(session);
     1486 
     1487      // Load Base1PluginExecuter
     1488      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     1489          "GET_PLUGINDEFINITION_FOR_CLASSNAME");
     1490      /*
     1491        SELECT pd
     1492        FROM PluginDefinitionData pd
     1493        WHERE pd.className = :className
     1494      */
     1495      query.setString("className", "net.sf.basedb.plugins.Base1PluginExecuter");
     1496      PluginDefinitionData base1Executer = HibernateUtil.loadData(PluginDefinitionData.class, query);
     1497     
     1498      // Load all plugin configurations for net.sf.basedb.plugins.Base1PluginExecuter
     1499      query = HibernateUtil.getPredefinedQuery(session,
     1500        "GET_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION", "pc");
     1501      /*
     1502        SELECT {1}
     1503        FROM PluginConfigurationData pc
     1504        WHERE pc.pluginDefinition = :pluginDefinition
     1505      */
     1506      query.setEntity("pluginDefinition", base1Executer);
     1507      List<PluginConfigurationData> configurations =
     1508        HibernateUtil.loadList(PluginConfigurationData.class, query);
     1509
     1510      // Delete AnyToAny for each configuration
     1511      query = HibernateUtil.getPredefinedQuery(session, "DELETE_ALL_ANYTOANY_FROM");
     1512      /*
     1513        DELETE FROM AnyToAnyData ata
     1514        WHERE ata.fromId = :fromId AND ata.fromType = :fromType
     1515      */
     1516      query.setInteger("fromType", Item.PLUGINCONFIGURATION.getValue());
     1517      for (PluginConfigurationData pc : configurations)
     1518      {
     1519        query.setInteger("fromId", pc.getId());
     1520        HibernateUtil.executeUpdate(query);
     1521      }
     1522     
     1523      // Update the schema version number
     1524      setSchemaVersion(session, schemaVersion);
     1525 
     1526      // Commit the changes
     1527      HibernateUtil.commit(tx);
     1528      log.info("updateToSchemaVersion39: OK");
     1529    }
     1530    catch (BaseException ex)
     1531    {
     1532      if (tx != null) HibernateUtil.rollback(tx);
     1533      log.error("updateToSchemaVersion39: FAILED", ex);
    14561534      throw ex;
    14571535    }
Note: See TracChangeset for help on using the changeset viewer.