Changeset 7461


Ignore:
Timestamp:
Mar 14, 2018, 2:17:56 PM (4 years ago)
Author:
Nicklas Nordborg
Message:

Merge pre-3.12 changes to the trunk.

Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/build.xml

    r7454 r7461  
    6969  <property name="base.minorversion" value="13" />
    7070  <property name="base.maintenanceversion" value="0" />
    71   <property name="base.versionsuffix" value="-dev" />
     71  <property name="base.versionsuffix" value="" />
    7272  <property name="base.version"
    7373    value="${base.majorversion}.${base.minorversion}.${base.maintenanceversion}" />
  • trunk/doc/src/docbook/admin/installation.xml

    r7390 r7461  
    4747
    4848    <important id="installation.upgrade.important">
    49       <title>Important information for upgrading to BASE 3.11.1</title>
     49      <title>Important information for upgrading to BASE 3.12</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.10 to 3.11). If you are
    54         upgrading from a BASE installation that is older (3.0-3.9)
     53        release to the current release (eg. 3.11 to 3.12). If you are
     54        upgrading from a BASE installation that is older (3.0-3.10)
    5555        you should also read <xref linkend="appendix.update_warnings" />.
    5656      </para>
    5757
    58       <bridgehead>Free wells on bioplates</bridgehead>
     58      <bridgehead>BASE 3.12</bridgehead>
    5959      <para>
    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>
     60        There are no special instructions for this update.
    7061      </para>
    7162    </important>
  • trunk/src/core/net/sf/basedb/core/AbstractHqlQuery.java

    r7381 r7461  
    4646  class can be used to build and manage just about any type of HQL
    4747  query. It has no function for executing the query or returning
    48   the result. Subclasses may use {@link #getMainHqlQuery(DbControl)}
     48  the result. Subclasses may use {@link #getMainHqlQuery(DbControl, Class)}
    4949  to generate a Hibernate Query object that is ready to be executed.
    5050
  • trunk/src/core/net/sf/basedb/core/Annotation.java

    r7381 r7461  
    745745    <p>
    746746    An exception to the above (since BASE 3.11) is if the annotation was loaded with
    747     {@link AnnotationSet#getProjectAnnotation(AnnotationType, int)} in
     747    {@link AnnotationSet#getProjectAnnotation(AnnotationType, Project)} in
    748748    which case currently active project is ignored and the values are
    749749    always changed on this annotation (eg. the same as if this annotation
  • trunk/src/core/net/sf/basedb/core/AnnotationBetweenRestriction.java

    r7381 r7461  
    7070  /**
    7171    @since 3.5
    72     @deprecated In 3.11, use {@link #AnnotationBetweenRestriction(String, AnnotationType, Object, Object, Options)} instead
     72    @deprecated In 3.11, use {@link #AnnotationBetweenRestriction(String, AnnotationType, Object, Object, AnnotationRestriction.Options)} instead
    7373  */
    7474  @Deprecated
     
    8383  /**
    8484    @since 3.5
    85     @deprecated In 3.11, use {@link #AnnotationBetweenRestriction(String, AnnotationType, Object, Object, Options)} instead
     85    @deprecated In 3.11, use {@link #AnnotationBetweenRestriction(String, AnnotationType, Object, Object, AnnotationRestriction.Options)} instead
    8686  */
    8787  @Deprecated
  • trunk/src/core/net/sf/basedb/core/AnnotationInRestriction.java

    r7381 r7461  
    5858  /**
    5959    @since 3.5
    60     @deprecated In 3.11, use {@link #AnnotationInRestriction(String, AnnotationType, Options, Object...)} instead
     60    @deprecated In 3.11, use {@link #AnnotationInRestriction(String, AnnotationType, AnnotationRestriction.Options, Object...)} instead
    6161  */
    6262  @Deprecated
  • trunk/src/core/net/sf/basedb/core/AnnotationRestriction.java

    r7381 r7461  
    3939  Base class for creating restrictions based on annotations.
    4040  Subclasses must implent the {@link #getRestrictionSql(Query, DbControl)}
    41   and {@link #setRestrictionParameters(SQLQuery)}
     41  and {@link #setRestrictionParameters(NativeQuery)}
    4242  method.
    4343 
     
    316316    @param query The query object we are about to execute
    317317    @return An SQL fragment, or null if no additional restriction is required
    318     @see #setRestrictionParameters(SQLQuery)
     318    @see #setRestrictionParameters(NativeQuery)
    319319  */
    320320  abstract String getRestrictionSql(Query query, DbControl dc)
  • trunk/src/core/net/sf/basedb/core/AnnotationSimpleRestriction.java

    r7381 r7461  
    6464  /**
    6565    @since 3.5
    66     @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, Options)} instead
     66    @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, AnnotationRestriction.Options)} instead
    6767  */
    6868  @Deprecated
     
    125125  /**
    126126    @since 3.5
    127     @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, Options)} instead
     127    @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, AnnotationRestriction.Options)} instead
    128128  */
    129129  @Deprecated
     
    163163  /**
    164164    @since 3.5
    165     @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, List, Options)} instead
     165    @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, AnnotationRestriction.Options)} instead
    166166  */
    167167  @Deprecated
  • trunk/src/core/net/sf/basedb/core/HasAnnotationRestriction.java

    r7381 r7461  
    7676      by the query or not
    7777    @since 3.5
    78     @deprecated In 3.11, use {@link #HasAnnotationRestriction(String, AnnotationType, boolean, Options)} instead
     78    @deprecated In 3.11, use {@link #HasAnnotationRestriction(String, AnnotationType, boolean, AnnotationRestriction.Options)} instead
    7979  */
    8080  @Deprecated
     
    106106 
    107107  /**
    108     @see #HasAnnotationRestriction(String, AnnotationType, boolean, boolean, boolean)
     108    @see #HasAnnotationRestriction(String, AnnotationType, boolean, AnnotationRestriction.Options)
    109109    @since 3.5
    110     @deprecated In 3.11, use {@link #HasAnnotationRestriction(String, AnnotationType, boolean, Options)} instead
     110    @deprecated In 3.11, use {@link #HasAnnotationRestriction(String, AnnotationType, boolean, AnnotationRestriction.Options)} instead
    111111  */
    112112  @Deprecated
  • trunk/src/core/net/sf/basedb/core/HibernateUtil.java

    r7416 r7461  
    20472047    using a query.
    20482048   
    2049     @param clazz The list should contain objects of this class
    20502049    @param query The query to execute
    20512050    @param sc A optional SessionControl that is automatically protected from
     
    20742073  /**
    20752074    Scroll through the result of a query using an iterator.
    2076     @param clazz The iterator returns objects of this class
    20772075    @param query The query to execute
    20782076    @param sc A optional SessionControl that is automatically protected from
  • trunk/src/core/net/sf/basedb/core/Job.java

    r7381 r7461  
    11171117 
    11181118  /**
    1119     @see {@link #start(String, String, String, JobAgent, Date)}
     1119    @see #start(String, String, String, JobAgent, Date)
    11201120    @since 3.3
    11211121  */
     
    15171517 
    15181518  /**
    1519     @see {@link #execute(ProgressReporter, String, String, JobAgentSettings)}
     1519    @see #execute(ProgressReporter, String, String, JobAgentSettings)
    15201520  */
    15211521  public PluginExecutionRequest execute(ProgressReporter progress, String server, JobAgentSettings settings)
  • trunk/src/core/net/sf/basedb/core/QueryExecutor.java

    r7381 r7461  
    112112  /**
    113113    Executes a Hibernate query that returns an iterator on a stateless session.
    114     @param clazz The class of items returned by the iterator
    115114    @param query The query to execute
    116115    @param session The stateless session, this must be the same session
  • trunk/src/core/net/sf/basedb/core/ServiceSessionControl.java

    r7396 r7461  
    346346       
    347347        // Check if the schema exists or not
    348         boolean schemaExists = HibernateUtil.doReturningWork(session, new SchemaExistsWork(catalog, schema));
     348        boolean schemaExists = HibernateUtil.doReturningWork(session, new SchemaExistsWork(actualCatalog, actualSchema));
    349349        installMode = schemaExists ? SchemaGenerator.Mode.UPDATE : SchemaGenerator.Mode.INSTALL;
    350350        if (log.isDebugEnabled()) log.debug("Mode: " +installMode);
  • trunk/src/core/net/sf/basedb/core/Update.java

    r7413 r7461  
    5858import net.sf.basedb.core.data.KitData;
    5959import net.sf.basedb.core.data.MeasuredBioMaterialData;
     60import net.sf.basedb.core.data.NewsData;
    6061import net.sf.basedb.core.data.ParameterValueData;
    6162import net.sf.basedb.core.data.PropertyFilterData;
  • trunk/src/core/net/sf/basedb/core/User.java

    r7452 r7461  
    599599    enable this feature by itself, the email address must first
    600600    be verified.
    601     @see #sendEmailVerificationCode()
     601    @see #sendEmailVerificationCode(String)
    602602    @see #enableDeviceVerification(String)
    603603    @since 3.12
     
    616616    Send a verification code to the currently registered email address.
    617617    The client application should ask the user to enter the verification
    618     code and then call {@link #verifyEmail(String)}. The verification must
     618    code and then call {@link #enableDeviceVerification(String)}. The verification must
    619619    be done with the same User instance since the verification code
    620620    is only temporarily stored inside this instance.
     
    666666    Verify the email and enables device verification.
    667667    @param code The code that was sent by email to the user
    668     @see #sendEmailVerificationCode()
     668    @see #sendEmailVerificationCode(String)
    669669    @since 3.12
    670670  */
  • trunk/src/core/net/sf/basedb/core/data/UserDeviceData.java

    r7414 r7461  
    172172  /**
    173173    The maximum length of the remote ID that can be stored in the database.
    174     @see #setRemoteId(String)
     174    @see #setLastRemoteId(String)
    175175  */
    176176  public static final int MAX_REMOTE_ID_LENGTH = 255;
  • trunk/src/core/net/sf/basedb/core/hibernate/SchemaGenerator.java

    r7397 r7461  
    2222package net.sf.basedb.core.hibernate;
    2323
    24 import java.lang.reflect.Field;
    2524import java.sql.Connection;
     25import java.sql.DatabaseMetaData;
    2626import java.sql.SQLException;
    2727import java.sql.Statement;
     
    3030import java.util.EnumSet;
    3131import java.util.HashMap;
     32import java.util.Iterator;
    3233import java.util.List;
    3334import java.util.Map;
    3435
     36import net.sf.basedb.core.DatabaseException;
    3537import net.sf.basedb.core.ProgressReporter;
    3638import net.sf.basedb.core.StringUtil;
    3739import net.sf.basedb.core.dbengine.DbEngine;
     40import net.sf.basedb.core.dbengine.TableInfo;
    3841import net.sf.basedb.util.EqualsHelper;
    3942
    4043import org.hibernate.boot.Metadata;
    4144import org.hibernate.boot.model.naming.Identifier;
    42 import org.hibernate.boot.model.relational.QualifiedName;
    43 import org.hibernate.boot.model.relational.QualifiedSequenceName;
    4445import org.hibernate.boot.model.relational.QualifiedTableName;
    4546import org.hibernate.boot.spi.MetadataImplementor;
    4647import org.hibernate.dialect.Dialect;
    47 import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl;
     48import org.hibernate.engine.jdbc.env.internal.QualifiedObjectNameFormatterStandardImpl;
    4849import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
    4950import org.hibernate.engine.jdbc.env.spi.QualifiedObjectNameFormatter;
    5051import org.hibernate.jdbc.Work;
     52import org.hibernate.mapping.Table;
    5153import org.hibernate.service.ServiceRegistry;
    5254import org.hibernate.service.spi.ServiceRegistryImplementor;
    5355import org.hibernate.tool.schema.SourceType;
    5456import org.hibernate.tool.schema.TargetType;
     57import org.hibernate.tool.schema.extract.spi.DatabaseInformation;
     58import org.hibernate.tool.schema.extract.spi.TableInformation;
    5559import org.hibernate.tool.schema.internal.SchemaCreatorImpl;
     60import org.hibernate.tool.schema.internal.exec.JdbcContext;
    5661import org.hibernate.tool.schema.internal.ExceptionHandlerHaltImpl;
     62import org.hibernate.tool.schema.internal.Helper;
    5763import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
    58 import org.hibernate.tool.schema.internal.IndividuallySchemaMigratorImpl;
    5964import org.hibernate.tool.schema.spi.ExceptionHandler;
    6065import org.hibernate.tool.schema.spi.ExecutionOptions;
    6166import org.hibernate.tool.schema.spi.SchemaCreator;
    62 import org.hibernate.tool.schema.spi.SchemaMigrator;
    6367import org.hibernate.tool.schema.spi.ScriptSourceInput;
    6468import org.hibernate.tool.schema.spi.ScriptTargetOutput;
     
    117121    -----------------------
    118122  */
     123  @SuppressWarnings("unchecked")
    119124  @Override
    120125  public void execute(Connection connection)
     
    131136    String currentSql = null;
    132137    boolean autoCommit = connection.getAutoCommit();
    133     ForceQuotedTableNameFormatter tableNameFormatter = new ForceQuotedTableNameFormatter(metadata);
     138
    134139    try
    135140    {
     
    144149      {
    145150        log.info("Generating schema update script");
    146         tableNameFormatter.applyWorkaroundForHibernateBug();
    147         SchemaMigrator schemaMigrator = new IndividuallySchemaMigratorImpl(tool, null);
    148         schemaMigrator.doMigration(metadata, schemaUpdates, schemaUpdates);
     151       
     152        DatabaseMetaData jdbcMetaData = connection.getMetaData();
     153        JdbcContext jdbcContext = tool.resolveJdbcContext(schemaUpdates.getConfigurationValues());
     154        JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
     155       
     156        QualifiedObjectNameFormatter tableNameFormatter = new QualifiedObjectNameFormatterStandardImpl(jdbcEnvironment.getNameQualifierSupport());
     157       
     158        DatabaseInformation hibernateDbInfo = Helper.buildDatabaseInformation(serviceRegistry,
     159            tool.getDdlTransactionIsolator(jdbcContext),
     160            metadata.getDatabase().getDefaultNamespace().getName());
     161       
     162        Iterator<Table> tables = metadata.collectTableMappings().iterator();
     163        while (tables.hasNext())
     164        {
     165          Table table = tables.next();
     166          TableInfo jdbcTableInfo = new TableInfo(table, jdbcMetaData);
     167         
     168          log.debug("Table: " + table + (jdbcTableInfo.existsInDb() ? " EXISTS" : "NOT FOUND"));
     169         
     170          if (jdbcTableInfo.existsInDb())
     171          {
     172            // This table exists in the database, we need to force Hibernate to check and ALTER it if needed
     173            QualifiedTableName qft = table.getQualifiedTableName();
     174           
     175            // First try: let Hibernate use the default settings to find the table
     176            TableInformation hibernateTableInfo = hibernateDbInfo.getTableInformation(qft);
     177           
     178            if (log.isDebugEnabled()) log.debug(qft + ": " + hibernateTableInfo);
     179           
     180            if (hibernateTableInfo == null)
     181            {
     182              // If that fails, we need to try again with unquoted table name
     183              qft = new QualifiedTableName(qft.getCatalogName(), qft.getSchemaName(), Identifier.toIdentifier(table.getName(), false));
     184              hibernateTableInfo = hibernateDbInfo.getTableInformation(qft);
     185              if (log.isDebugEnabled()) log.debug(qft + ": " + hibernateTableInfo);
     186             
     187              // If this is null here we are in trouble!!!
     188              if (hibernateTableInfo == null)
     189              {
     190                throw new DatabaseException("Table '" + table.getName() + "' exists, but Hibernate can't find any information about it. "+
     191                    "Please report as a bug to the BASE developers");
     192              }
     193            }
     194           
     195            // To get the quoting, upper- and lower-case correct we need to re-create a new instance
     196            // and do a search-and-replace in the SQL generated by Hibernate
     197            qft = new QualifiedTableName(hibernateTableInfo.getName().getCatalogName(), hibernateTableInfo.getName().getSchemaName(), table.getNameIdentifier());
     198            String correctTableName = tableNameFormatter.format(qft, dialect);
     199            String tableNameGeneratedByHibernate = tableNameFormatter.format(hibernateTableInfo.getName(), dialect);
     200            if (log.isDebugEnabled())
     201            {
     202              log.debug("Search-and-replace: " + tableNameGeneratedByHibernate + "-->" + correctTableName);
     203            }
     204            Iterator<String> it = (Iterator<String>)table.sqlAlterStrings(dialect, metadata, hibernateTableInfo, null, null);
     205            while (it.hasNext())
     206            {
     207              String sql = it.next();
     208              String modifiedSql = sql.replace(tableNameGeneratedByHibernate, correctTableName);
     209              if (!sql.equals(modifiedSql))
     210              {
     211                log.debug("Hibernate SQL: " + sql);
     212                log.debug("Modified  SQL: " + modifiedSql);
     213              }
     214              schemaUpdates.accept(modifiedSql);
     215            }
     216          }
     217          else
     218          {
     219            String[] sql = dialect.getTableExporter().getSqlCreateStrings(table, metadata);
     220            for (String s : sql)
     221            {
     222              schemaUpdates.accept(s);
     223            }
     224          }
     225        }
    149226      }
    150227      else if (mode == Mode.INSTALL)
     
    223300    {
    224301      if (autoCommit != connection.getAutoCommit()) connection.setAutoCommit(autoCommit);
    225       tableNameFormatter.resetWorkaroundForHibernateBug();
    226302      if (stmt != null)
    227303      {
     
    416492  }
    417493 
    418 
    419   /**
    420     Replace the 'QualifiedObjectNameFormatter' with an implementation that forces
    421     all table names to be flagged as quoted. This is a hack to work around a bug
    422     in Hibernate which generates "alter table table-name add column ..."
    423     statements without quotes around the table-name which causes an error
    424    
    425     TODO - When (if?) this issue is fixed in Hibernate we can remove this workaround
    426   */
    427   static class ForceQuotedTableNameFormatter
    428     implements QualifiedObjectNameFormatter
    429   {
    430 
    431     private final Metadata metadata;
    432     private final JdbcEnvironment jdbc;
    433     private QualifiedObjectNameFormatter originalFormatter;
    434    
    435     ForceQuotedTableNameFormatter(Metadata metadata)
    436     {
    437       this.metadata = metadata;
    438       this.jdbc = metadata.getDatabase().getJdbcEnvironment();
    439     }
    440    
    441     @Override
    442     public String format(QualifiedTableName tableName, Dialect dialect)
    443     {
    444       QualifiedTableName quotedTableName = new QualifiedTableName(
    445         tableName.getCatalogName(),
    446         tableName.getSchemaName(),
    447         Identifier.toIdentifier(tableName.getTableName().getText(), true)
    448       );
    449       return originalFormatter.format(quotedTableName, dialect);
    450     }
    451 
    452     @Override
    453     public String format(QualifiedSequenceName sequenceName, Dialect dialect)
    454     {
    455       return originalFormatter.format(sequenceName, dialect);
    456     }
    457 
    458     @Override
    459     public String format(QualifiedName name, Dialect dialect)
    460     {
    461       return originalFormatter.format(name, dialect);
    462     }
    463    
    464     void applyWorkaroundForHibernateBug()
    465     {
    466       this.originalFormatter = jdbc.getQualifiedObjectNameFormatter();
    467       setFormatter(this);
    468     }
    469    
    470     void resetWorkaroundForHibernateBug()
    471     {
    472       if (originalFormatter != null) setFormatter(originalFormatter);
    473     }
    474    
    475     private void setFormatter(QualifiedObjectNameFormatter formatter)
    476     {
    477       try
    478       {
    479         Field f = JdbcEnvironmentImpl.class.getDeclaredField("qualifiedObjectNameFormatter");
    480         f.setAccessible(true);
    481         f.set(jdbc, formatter);
    482       }
    483       catch (Exception ex)
    484       {
    485         throw new RuntimeException(ex);
    486       }
    487     }
    488    
    489   }
    490494 
    491495}
  • trunk/src/core/net/sf/basedb/util/HttpUtil.java

    r7411 r7461  
    139139    Parse the User-Agent string from a HTTP request and return
    140140    information about what it actually means.
    141     @see https://github.com/nielsbasjes/yauaa
     141    @see <a href="https://github.com/nielsbasjes/yauaa">https://github.com/nielsbasjes/yauaa</a>
    142142    @since 3.12
    143143  */
  • trunk/src/core/net/sf/basedb/util/ProgressInputStream.java

    r7168 r7461  
    8181  /**
    8282    Send a progress report with the given message. This method is called
    83     autoamtically at the given intervals. The default message is the number
     83    automatically at the given intervals. The default message is the number
    8484    of bytes read so far (formatted as a string with
    8585    {@link Values#formatBytes(Long, int)}). Subclasses may override this
    8686    method to generate a different message.
    87    
    88     @param message
    8987  */
    9088  protected void progressReport(String message)
  • trunk/src/core/net/sf/basedb/util/extensions/ActionIterator.java

    r7275 r7461  
    173173  /**
    174174    Send the event to event handlers registered in the registry.
    175     @see Registry#handleEvent(EventType, ExtensionPoint, Extension)}
     175    @see Registry#handleEvent(EventType, ExtensionPoint, Extension)
    176176    @since 3.10
    177177  */
  • trunk/src/core/net/sf/basedb/util/extensions/manager/processor/IgnoreFileProcessor.java

    r7233 r7461  
    100100    it happend when the {@link #done(ExtensionsManager)} method is
    101101    called by the manager. If this flag is set the
    102     {@link #finalizeRegistration(ExtensionsManager, boolean)}
     102    {@link #finalizeRegistration(ExtensionsManager)}
    103103    method must be explicitely called.
    104104  */
  • trunk/src/core/net/sf/basedb/util/overview/loader/BasicItemNodeLoaderFactory.java

    r7004 r7461  
    123123    Register a node loader implementation. The implementation must have a
    124124    public no-argument constructor. The given class is checked with
    125     {@link ClassUtil#checkAndLoadClass(ClassLoader, String, boolean, Class...)}
     125    {@link ClassUtil#checkAndLoadClass(ClassLoader, String, boolean, Class, Class...)}
    126126   
    127127    @param key The item type the node loader handles
  • trunk/src/core/net/sf/basedb/util/overview/validator/BasicItemNodeValidatorFactory.java

    r7005 r7461  
    149149    Register a node validator implementation. The implementation must have a
    150150    public no-argument constructor. The given class is checked with
    151     {@link ClassUtil#checkAndLoadClass(ClassLoader, String, boolean, Class...)}
     151    {@link ClassUtil#checkAndLoadClass(ClassLoader, String, boolean, Class, Class...)}
    152152   
    153153    @param key The item type the node validator handles
  • trunk/www/lims/arrayslides/wizard.js

    r7439 r7461  
    118118    var frm = document.forms['WizardStep2'];
    119119    var quantity = parseInt(frm.quantity.value);
    120     for (i = 0; i < quantity; i++)
     120    for (var i = 0; i < quantity; i++)
    121121    {
    122122      var name = frm['name'+i];
Note: See TracChangeset for help on using the changeset viewer.