Changeset 6981


Ignore:
Timestamp:
Oct 8, 2015, 9:05:54 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

Merged pre-3.6-releases to the trunk.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/config/dist/mysql-queries.xml

    r6330 r6981  
    2828-->
    2929<predefined-queries>
     30  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
     31    <sql>
     32      ALTER TABLE [{1}] MODIFY [{2}] {3} NULL
     33    </sql>
     34    <description>
     35      An SQL query that drops a NOT NULL contraint from column (2) with data type (3)
     36      in a table (1).
     37    </description>
     38  </query>
    3039
    3140</predefined-queries>
  • trunk/credits.txt

    r6818 r6981  
    11$Id$
    22
    3 The current BASE team is (at BASE 3.5 release)
     3The current BASE team is (at BASE 3.6 release)
    44{{{
    55Jari Häkkinen
  • trunk/doc/src/docbook/user/annotations.xml

    r6961 r6981  
    807807        </para>
    808808       
     809        <para>
     810          Use the <guibutton>Inherit</guibutton> button to inherit the selected
     811          annotations by reference, and the <guibutton>Clone</guibutton> button
     812          to clone the values of the selected annotations.
     813        </para>
     814       
    809815        <note>
    810816          <itemizedlist>
    811817          <listitem>
    812818            <para>
    813             Already inherited annotations are not shown in the dialog.
    814             </para>
    815           </listitem>
    816           <listitem>
    817             <para>
    818             By default, the inheritance is implemented by reference. To convert
    819             it to a cloned annotation select it in the list and click on <guilabel>clone</guilabel>.
     819            Already inherited or cloned annotations are not shown in the dialog.
     820            </para>
     821          </listitem>
     822          <listitem>
     823            <para>
     824            Annotations that are inherited by reference can easily be converted to
     825            cloned annotations. Select the annotation in the list and click on the
     826            <guilabel>clone</guilabel> link.
    820827            <nohelp>
    821828            <figure>
     
    831838            </figure>
    832839            </nohelp>
    833 
    834840            </para>
    835841          </listitem>
  • trunk/src/core/net/sf/basedb/core/Update.java

    r6941 r6981  
    13371337     
    13381338      // Drop NOT NULL on Annotations.value_id
    1339       dropNotNullConstraint(session, "Annotations", "value_id");
     1339      dropNotNullConstraint(session, "Annotations", "value_id", "int");
    13401340
    13411341      // Drop UNIQUE constraint on Annotations.annotationset_id/annotationtype_id
     
    16571657      TableInfo info = getTableInfo(session, tableName);
    16581658      String indexName = info.findIndexName(null, new HashSet<String>(Arrays.asList(columnNames)));
     1659
    16591660      if (indexName != null)
    16601661      {
    16611662        DbEngine engine = HibernateUtil.getDbEngine();
     1663
     1664        // Drop foreign keys using any of the column names in the index
     1665        List<ForeignKeyInfo> dropped = new ArrayList<ForeignKeyInfo>();
     1666        if (engine.dropForeignKeysUsedInIndex())
     1667        {
     1668          for (ForeignKeyInfo fk : info.getForeignKeys())
     1669          {
     1670            for (String colName : columnNames)
     1671            {
     1672              if (fk.getFkColumns().contains(colName))
     1673              {
     1674                dropped.add(fk);
     1675                String fkSql = engine.getDropForeignKeySql(null, null, tableName, fk.getName());
     1676                query = HibernateUtil.createSqlQuery(session, fkSql);
     1677                query.executeUpdate();
     1678                break;
     1679              }
     1680            }
     1681          }
     1682        }
     1683       
    16621684        String sql = engine.getDropIndexSql(null, null, tableName, indexName, unique);
    16631685        query = HibernateUtil.createSqlQuery(session, sql);
    16641686        query.executeUpdate();
     1687       
     1688        // Re-created dropped foreign keys
     1689        for (ForeignKeyInfo fk : dropped)
     1690        {
     1691          String fkSql = engine.getCreateForeignKeySql(null, null, tableName, fk.getName(), fk.getFkColumns(), fk.getRefName(), fk.getRefColumns());
     1692          query = HibernateUtil.createSqlQuery(session, fkSql);
     1693          query.executeUpdate();
     1694        }
     1695
    16651696      }
    16661697      // Only commit if we started a new transaction
     
    16961727  }
    16971728
    1698   private static void dropNotNullConstraint(org.hibernate.Session session, String tableName, String columnName)
     1729  private static void dropNotNullConstraint(org.hibernate.Session session, String tableName, String columnName, String mySqlDataType)
    16991730  {
    17001731    org.hibernate.Transaction tx = null;
     
    17051736      tx = session.getTransaction().isActive() ? null : HibernateUtil.newTransaction(session);
    17061737     
    1707       query = HibernateUtil.getPredefinedSQLQuery(session, "DROP_NOT_NULL_CONSTRAINT", tableName, columnName);
     1738      query = HibernateUtil.getPredefinedSQLQuery(session, "DROP_NOT_NULL_CONSTRAINT", tableName, columnName, mySqlDataType);
    17081739      query.executeUpdate();
    17091740     
  • trunk/src/core/net/sf/basedb/core/dbengine/AbstractDbEngine.java

    r6721 r6981  
    7575  }
    7676
    77  
     77  /**
     78    @return FALSE
     79    @since 3.6
     80  */
     81  @Override
     82  public boolean dropForeignKeysUsedInIndex()
     83  {
     84    return false;
     85  }
     86
    7887  /**
    7988    Return the SQL unmodified.
  • trunk/src/core/net/sf/basedb/core/dbengine/DbEngine.java

    r6880 r6981  
    123123  */
    124124  public String getDropIndexSql(String catalog, String schema, String table, String name, boolean unique);
     125 
     126  /**
     127    When dropping an index, must foreign keys that uses the same columns also be
     128    dropped (before dropping the index)? Default is FALSE, but MySQL need TRUE.
     129    @since 3.6
     130  */
     131  public boolean dropForeignKeysUsedInIndex();
    125132 
    126133  /**
  • trunk/src/core/net/sf/basedb/core/dbengine/MySQLEngine.java

    r6684 r6981  
    114114    sql.append(")");
    115115    return sql.toString();
     116  }
     117 
     118  /**
     119    @return TRUE
     120    @since 3.6
     121  */
     122  @Override
     123  public boolean dropForeignKeysUsedInIndex()
     124  {
     125    return true;
    116126  }
    117127 
  • trunk/src/core/net/sf/basedb/core/log/db/AnnotationLogger.java

    r6968 r6981  
    4040import net.sf.basedb.core.log.EntityLogger;
    4141import net.sf.basedb.core.log.LogManager;
    42 import net.sf.basedb.core.plugin.ParameterValues;
    4342import net.sf.basedb.util.Values;
    4443import net.sf.basedb.util.formatter.Formatter;
  • trunk/www/common/annotations/annotate.js

    r6955 r6981  
    468468    {
    469469      var unit = units[unitNo];
    470       var option = new Option(unit.symbol, unit.id, selected == unit.id);
     470      var option = new Option(unit.symbol, unit.id, false, selected == unit.id);
    471471      option.title = unit.description;
    472472      unitList[unitList.length] = option;
     
    683683  annotate.valueOnBlur = function(event)
    684684  {
    685     if (!selectedAnnotation && selectedMultiIndex < 0) return;
     685    if (!selectedAnnotation || selectedMultiIndex < 0) return;
    686686   
    687687    var frm = document.forms['annotations'];
     
    981981    Doc.show('inherited-list');
    982982    var inheritedId = event.detail.id;
     983    var clone = event.detail.clone;
    983984   
    984985    // Check if we have info about this annotation already
     
    989990      {
    990991        entry.modified = INHERITED;
     992        if (clone && entry.source != 'CLONED')
     993        {
     994          annotate.convertToCloned(entry);
     995        }
     996        else if (!clone && entry.source != 'INHERITED')
     997        {
     998          annotate.convertToInherited(entry);
     999        }
    9911000        Doc.show(entry.id);
    9921001        return;
     
    10021011    request.open("GET", url, true);
    10031012    request.send(null);
    1004     Ajax.setReadyStateHandler(request, annotate.inheritInfoLoaded, annotate.inheritInfoLoaded);
     1013    var callback = clone ? annotate.inheritInfoLoadedAndClone : annotate.inheritInfoLoaded;
     1014    Ajax.setReadyStateHandler(request, callback, callback);
     1015  }
     1016 
     1017  /**
     1018    Callback that converts the inherited annotation to a cloned
     1019    annotation.
     1020  */
     1021  annotate.inheritInfoLoadedAndClone = function(request)
     1022  {
     1023    var entry = annotate.inheritInfoLoaded(request);
     1024    annotate.convertToCloned(entry);
    10051025  }
    10061026 
     
    10231043    annotations[annotations.length] = entry;
    10241044    annotate.createAnnotationEntryInList(entry, true);
     1045    return entry;
    10251046  }
    10261047 
  • trunk/www/common/annotations/inherit.js

    r6947 r6981  
    3232    // Buttons (on standalone dialog)
    3333    Buttons.addClickHandler('close', App.closeWindow);
    34     Buttons.addClickHandler('btnOk', inherit.save);
     34    Buttons.addClickHandler('btnInherit', inherit.save);
     35    Buttons.addClickHandler('btnClone', inherit.save);
    3536   
    3637    Events.addEventHandler('quickFilter', 'keyup', inherit.quickFilter);
     
    8081  }
    8182 
    82   inherit.saveInheritedAnnotations = function()
     83  inherit.saveInheritedAnnotations = function(clone)
    8384  {
    8485    var tree = Doc.element('joust');
     
    100101          var detail = {};
    101102          detail.id = menuItem.externalId;
     103          detail.clone = clone;
    102104          if (isInherited)
    103105          {
     
    140142    Save the annotations in standalone mode.
    141143  */
    142   inherit.save = function()
     144  inherit.save = function(event)
    143145  {
    144     inherit.saveInheritedAnnotations();
     146    var clone = Data.int(event.currentTarget, 'clone', 0);
     147    inherit.saveInheritedAnnotations(clone);
    145148    App.closeWindow();
    146149  }
  • trunk/www/common/annotations/inherit.jsp

    r6947 r6981  
    371371
    372372  <base:buttongroup subclass="dialogbuttons">
    373     <base:button id="btnOk" title="Ok" />
     373    <base:button id="btnClone" title="Clone" image="copy.png" data-clone="1" />
     374    <base:button id="btnInherit" title="Inherit" image="inherit.png" />
    374375    <base:button id="close" title="Cancel" />
    375376  </base:buttongroup>
  • trunk/www/common/close_popup.js

    r6218 r6981  
    5454      if (notifyTarget)
    5555      {
    56         var evt = document.createEvent('Event');
     56        var evt = myOpener.document.createEvent('CustomEvent');
    5757        evt.initEvent('base-notify', false, true);
    5858        notifyTarget.dispatchEvent(evt);
Note: See TracChangeset for help on using the changeset viewer.