Changeset 7386


Ignore:
Timestamp:
Jun 2, 2017, 11:43:30 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2088: Moving a biomaterial causes the free wells counter on the old plate to become incorrect

Implemented and documentated a one-time-fix script for re-calculating the free wells information.

After updating to BASE 3.11.1 an extra command should be executed:

./onetimefix.sh free_wells -u <root login> -p <root pwd>
Location:
branches/3.11-stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.11-stable/doc/src/docbook/admin/installation.xml

    r7221 r7386  
    4747
    4848    <important id="installation.upgrade.important">
    49       <title>Important information for upgrading to BASE 3.10</title>
     49      <title>Important information for upgrading to BASE 3.11.1</title>
    5050      <para>
    5151        This section list some important information that may or may not
    5252        apply when upgrading from the <emphasis>previous</emphasis> BASE
    53         release to the current release (eg. 3.9 to 3.10). If you are
    54         upgrading from a BASE installation that is older (3.0-3.8)
     53        release to the current release (eg. 3.10 to 3.11). If you are
     54        upgrading from a BASE installation that is older (3.0-3.9)
    5555        you should also read <xref linkend="appendix.update_warnings" />.
    5656      </para>
    5757
    58       <bridgehead>Changed permissions for annotating items</bridgehead>
     58      <bridgehead>Free wells on bioplates</bridgehead>
    5959      <para>
    60         Before BASE 3.10 a user was able to create/change/delete annotations on
    61         an item if the user has <code>WRITE</code> permission on the item and
    62         <code>READ</code> permission on the  annotation type.
    63         In BASE 3.10 several changes has been made:
     60        A bug that affected the free wells information on bioplates
     61        has been fixed. Existing bioplates may have incorrect number of
     62        free wells and can be fixed by running a special script.
     63       
     64        After installing the BASE 3.11.1 update, change directory to
     65        <filename class="directory">&lt;base-dir&gt;/bin/</filename>
     66        and issue
     67  <programlisting>
     68  ./onetimefix.sh free_wells -u &lt;root login&gt; -p &lt;root pwd&gt;
     69  </programlisting>
    6470      </para>
    65      
    66       <itemizedlist>
    67         <listitem>
    68           <para>
    69             <code>USE</code> permission is required on the annotation type to be able
    70             to create/change/delete annotations of that type. This may cause user to no
    71             longer be able to annotate certain items, unless their permissions
    72             are upgraded to <code>USE</code>. Users with <code>READ</code> permission
    73             can only read the annotation values.
    74           </para>
    75         </listitem>
    76        
    77         <listitem>
    78           <para>
    79             A new permission level, <code>ANNOTATE</code>, has been introduced.
    80             In the permission hierarchy this sits between the <code>READ</code>
    81             and <code>WRITE</code> permission and can be used to give users
    82             permissions to manage annotations but not other properties of an item.
    83             All users with <code>WRITE</code> permission automatically get
    84             <code>ANNOTATE</code> permission so this change should not affect current
    85             users.
    86           </para>
    87         </listitem>
    88       </itemizedlist>
    8971    </important>
    9072   
  • branches/3.11-stable/doc/src/docbook/appendix/update_warnings.xml

    r7221 r7386  
    3535    to the current version.
    3636  </para>
     37 
     38  <sect1 id="appendix.update_warnings.3.11.1">
     39    <title>BASE 3.11.1</title>
     40 
     41    <bridgehead>Free wells on bioplates</bridgehead>
     42    <para>
     43      A bug that affected the free wells information on bioplates
     44      has been fixed. Existing bioplates may have incorrect number of
     45      free wells and can be fixed by running a special script.
     46     
     47      After installing the BASE 3.11.1 update, change directory to
     48      <filename class="directory">&lt;base-dir&gt;/bin/</filename>
     49      and issue
     50<programlisting>
     51./onetimefix.sh free_wells -u &lt;root login&gt; -p &lt;root pwd&gt;
     52</programlisting>
     53    </para>
     54   
     55  </sect1>
    3756 
    3857  <sect1 id="appendix.update_warnings.3.10">
  • branches/3.11-stable/src/core/net/sf/basedb/core/Update.java

    r7332 r7386  
    20492049  }
    20502050
    2051  
     2051  /**
     2052    Vefify and update the free wells of all bioplates.
     2053    @return The number of bioplates fixed
     2054  */
     2055  public static int recalculateFreeWells(ProgressReporter progress)
     2056    throws BaseException
     2057  {
     2058    org.hibernate.Session session = null;
     2059    org.hibernate.Transaction tx = null;
     2060    int numUpdated = 0;
     2061    try
     2062    {
     2063      session = HibernateUtil.newSession();
     2064      tx = HibernateUtil.newTransaction(session);
     2065     
     2066      progress.display(10, "Updating bioplates...\n");
     2067     
     2068      // Subquery that counts the number of free wells on
     2069      // a bioplate by checking the "BioMaterials.biowell_id" column
     2070      String countSql =
     2071        "select count(*) from [BioWells] bw " +
     2072        "left join [BioMaterials] bm on bm.[biowell_id]=bw.[id] " +
     2073        "where bw.[bioplate_id] = bp.[id] and bm.[id] is null";
     2074     
     2075      // Query to update the free wells on plates that have an incorrect value
     2076      org.hibernate.Query updateQuery = HibernateUtil.createSqlQuery(session,
     2077        "update [BioPlates] bp "+
     2078        "set [free_wells] = (" + countSql + ") "+
     2079        "where bp.[free_wells] <> ("+countSql+")");
     2080     
     2081      numUpdated = updateQuery.executeUpdate();
     2082      if (numUpdated == 0)
     2083      {
     2084        progress.display(100, "Found " + numUpdated + " bioplates to fix\n");
     2085      }
     2086      else
     2087      {
     2088        progress.display(95, "Found " + numUpdated + " bioplates to fix. Comitting transaction...\n");
     2089        // Commit the changes
     2090        HibernateUtil.commit(tx);
     2091        progress.display(100, "Completed update of " + numUpdated + " bioplates\n");
     2092      }
     2093    }
     2094    catch (BaseException ex)
     2095    {
     2096      if (tx != null) HibernateUtil.rollback(tx);
     2097      throw ex;
     2098    }
     2099    return numUpdated;
     2100  }
     2101
    20522102
    20532103  private static TableInfo getTableInfo(org.hibernate.Session session, final String tableName)
  • branches/3.11-stable/src/install/net/sf/basedb/install/OneTimeFix.java

    r6600 r7386  
    8888        Application.stop();
    8989      }
     90      else if ("free_wells".equals(cmd))
     91      {
     92        String login = getOption(args, "-u", "root");
     93        String pwd = getOption(args, "-p", "root");
     94       
     95        String msg =
     96          "-------------------------------------------------------------------\n" +
     97          "This script re-calculates the free wells on all bioplate items\n" +
     98          "since it may have become incorrect due to a bug.\n" +
     99          "For more information see: http://base.thep.lu.se/ticket/2088\n\n" +
     100          "Press ENTER to continue or CTRL+C to abort\n" +
     101          "-------------------------------------------------------------------";
     102        System.out.println(msg);
     103        waitForEnter();
     104        showDbInfo(null);
     105        System.out.println("Starting BASE. Please wait...");
     106        Application.start(false);
     107        SessionControl sc = Application.newSessionControl(null, null, null);
     108        sc.login(new LoginRequest(login, pwd));
     109        int numModified = Update.recalculateFreeWells(new ConsoleProgressReporter(false));
     110        sc.logout();
     111        sc.close();
     112        Application.stop();
     113      }
    90114      else
    91115      {
     
    106130    System.out.println("    -u <login>    : Login name for the root user account; (root)");
    107131    System.out.println("    -p <password> : Password for the root user account; (root)");
     132    System.out.println("cmd:");
     133    System.out.println("    remaining_quantity: Re-calculate remaining quantity of biomaterials");
     134    System.out.println("    free_wells: Re-calculate free wells on all bioplates");
    108135  }
    109136
Note: See TracChangeset for help on using the changeset viewer.