Changeset 5518


Ignore:
Timestamp:
Nov 22, 2010, 9:02:13 AM (11 years ago)
Author:
Nicklas Nordborg
Message:

Merged patch release 2.16.1 to the trunk

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r5474 r5518  
    2525
    2626import net.sf.basedb.core.AnnotatableProxy;
     27import net.sf.basedb.core.AnyToAny;
    2728import net.sf.basedb.core.BioMaterialList;
    2829import net.sf.basedb.core.Coloring;
     
    502503     
    503504      // Record this in the list of recently view items
    504       if (itemId != null && Nameable.class.isAssignableFrom(itemType.getItemClass()))
     505      Class itemClass = itemType.getItemClass();
     506      if (itemId != null && itemClass != null && Nameable.class.isAssignableFrom(itemClass) && itemClass != AnyToAny.class)
    505507      {
    506508        String recent = sc.getUserClientSetting("menu.mostRecent.viewed");
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/ToolbarUtil.java

    r5048 r5518  
    6363      Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT,
    6464      Item.LABELEDEXTRACT, Item.LABEL, Item.BIOMATERIALEVENT,
    65       Item.BIOMATERIALLIST, Item.BIOPLATE, Item.BIOWELL,
     65      Item.BIOMATERIALLIST, Item.BIOPLATE, Item.BIOWELL, Item.BIOPLATETYPE,
    6666      Item.PLATE, Item.WELL, Item.PLATEEVENT,
    6767      Item.PLATETYPE, Item.PLATEEVENTTYPE,
     
    7676      Item.MIMETYPE, Item.REPORTERTYPE, Item.EXTRAVALUETYPE,
    7777      Item.ANNOTATIONTYPE, Item.ANNOTATIONTYPECATEGORY, Item.QUANTITY, Item.UNIT,
    78       Item.SESSION, Item.JOB, Item.MESSAGE, Item.PROJECT, Item.FILE,
    79       Item.CHANGEHISTORY
     78      Item.SESSION, Item.JOB, Item.MESSAGE, Item.PROJECT, Item.FILE, Item.FILESERVER,
     79      Item.CHANGEHISTORY, Item.PERMISSIONTEMPLATE
    8080    };
    8181
  • trunk/src/clients/web/net/sf/basedb/clients/web/resources/common.properties

    r5474 r5518  
    8686item.scan Scan
    8787item.scan+  Scans
     88item.image  Image
     89item.image+ Images
    8890item.rawbioassay  Raw bioassay
    8991item.rawbioassay+ Raw bioassays
     
    120122item.platetype  Plate type
    121123item.platetype+ Plate types
     124item.plateeventtype   Plate event type
     125item.plateeventtype + Plate event types
    122126item.plate  Plate
    123127item.plate+ Plates
     
    196200item.bioassayset  Bioassay set
    197201item.bioassayset+ Bioassay sets
     202item.bioassay Bioassay
     203item.bioassay+  Bioassays
    198204item.transformation Transformation
    199205item.transformation+  Transformations
    200206item.directory  Directory
    201207item.directory+ Directories
     208item.anytoany Any to any link
     209item.anytoany+ Any to any links
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Cell.java

    r5384 r5518  
    166166  private transient Formatter formatter;
    167167 
     168  private boolean isHidden;
     169 
    168170  private int maxCharacters = 50;
    169171  private boolean autoShow = true;
     
    267269  {
    268270    table = (Table)findAncestorWithClass(this, Table.class);
    269     if (!isVisible() || !table.isColumnVisible(columnId)) return SKIP_BODY;
     271    isHidden = !isVisible() || !table.isColumnVisible(columnId);
     272    if (isHidden) return SKIP_BODY;
    270273    formatter = table.getFormatter(columnId);
    271274    return EVAL_BODY_BUFFERED;
     
    276279    throws JspException
    277280  {
    278     if (!isVisible()) return EVAL_PAGE;
     281    if (isHidden) return EVAL_PAGE;
    279282    String content = bodyContent == null ? "" : bodyContent.getString();
    280283    content = content == null ? "" : content.trim();
  • trunk/src/core/common-queries.xml

    r5456 r5518  
    34193419  <query id="RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="SQL">
    34203420    <sql>
    3421       UPDATE {1}
    3422       SET value = value * :factor + :offset
    3423       WHERE id IN
     3421      UPDATE [{1}]
     3422      SET [value] = [value] * :factor + :offset
     3423      WHERE [id] IN
    34243424      (
    34253425        SELECT [value_id]
     
    34483448  <query id="RECALCULATE_ANNOTATIONS_FOR_UNIT" type="SQL">
    34493449    <sql>
    3450       UPDATE {1} SET value = value * :factor + :offset
    3451       WHERE id IN
     3450      UPDATE [{1}] SET [value] = [value] * :factor + :offset
     3451      WHERE [id] IN
    34523452      (
    34533453        SELECT [a].[value_id]
  • trunk/src/core/net/sf/basedb/core/AnnotationType.java

    r5121 r5518  
    408408              "RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE", tableName);
    409409            /*
    410               UPDATE {1} SET value = value * :factor + :offset
     410              UPDATE [{1}] SET [value] = [value] * :factor + :offset
    411411              WHERE id IN
    412412              (
  • trunk/src/core/net/sf/basedb/core/Unit.java

    r5014 r5518  
    455455  /**
    456456    Changes the factor and offset used for converting values in this
    457     unit into the reference unit. Calling this method will result
    458     in a re-calculation of all annotation values that has used this
    459     unit to make sure that the actual values stays the same.
     457    unit into the reference unit. Calling this method with values that
     458    are different from the old ones will result in a re-calculation of all
     459    annotation values that has used this unit to make sure that the actual
     460    values stays the same.
    460461    @param factor The new factor
    461462    @param offset The new offset
     
    472473      throw new NumberOutOfRangeException("NaN is not allowed for 'offset'");
    473474    }
     475    UnitData data = getData();
    474476    if (isInDatabase())
    475477    {
    476       /*
    477         Need to recalculate annotation values for existing annotations
    478         using this unit. There are two cases. Both are re-calculated
    479         with newValue = aFactor * oldValue + anOffset:
    480         1. Annotations with this unit with an annotation type of a different
    481            default unit.
    482            aFactor = newFactor / oldFactor
    483            anOffset = newOffset - oldOffset * aFactor
    484         2. Annotation with a different unit that has an annotation type with
    485            this unit as default unit.
    486            aFactor = oldFactor / newFactor;
    487            anOffset = (oldOffset - newOffset) / newFactor
    488         We need to execute all SQL:s on all numerical value
    489         tables.
    490       */
    491       double case1Factor = factor / getReferenceFactor();
    492       double case2Factor = getReferenceFactor() / factor;
    493       double case1Offset = offset - getReferenceOffset() * case1Factor;
    494       double case2Offset = (getReferenceOffset() - offset) / factor;
    495      
    496       for (Type valueType : Type.values())
     478      boolean sameFactor = Double.compare(data.getReferenceFactor(), factor) == 0;
     479      boolean sameOffset = Double.compare(data.getReferenceOffset(), offset) == 0;
     480      if (!sameFactor || !sameOffset)
    497481      {
    498         if (!valueType.isNumerical())
     482        /*
     483          Need to recalculate annotation values for existing annotations
     484          using this unit. There are two cases. Both are re-calculated
     485          with newValue = aFactor * oldValue + anOffset:
     486          1. Annotations with this unit with an annotation type of a different
     487             default unit.
     488             aFactor = newFactor / oldFactor
     489             anOffset = newOffset - oldOffset * aFactor
     490          2. Annotation with a different unit that has an annotation type with
     491             this unit as default unit.
     492             aFactor = oldFactor / newFactor;
     493             anOffset = (oldOffset - newOffset) / newFactor
     494          We need to execute all SQL:s on all numerical value
     495          tables.
     496        */
     497        double case1Factor = factor / getReferenceFactor();
     498        double case2Factor = getReferenceFactor() / factor;
     499        double case1Offset = offset - getReferenceOffset() * case1Factor;
     500        double case2Offset = (getReferenceOffset() - offset) / factor;
     501       
     502        for (Type valueType : Type.values())
    499503        {
    500           /* #### CONTINUE-STATEMENT #### */
    501           continue;
     504          if (!valueType.isNumerical())
     505          {
     506            /* #### CONTINUE-STATEMENT #### */
     507            continue;
     508          }
     509         
     510          String tableName = valueType.getTableName();
     511          org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(
     512            getDbControl().getHibernateSession(),
     513            "RECALCULATE_ANNOTATIONS_FOR_UNIT", tableName);
     514          /*
     515            UPDATE [{1}] SET [value] = [value] * :factor + :offset
     516            WHERE [id] IN
     517            (
     518              SELECT [a].[value_id]
     519              FROM [Annotations] [a]
     520              JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
     521              WHERE [at].[value_type] = :valueType
     522              AND
     523              (
     524                (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] <> :unit)
     525                OR
     526                (:case = 2 AND [a].[unit_id] <> :unit AND [at].[default_unit_id] = :unit)
     527              )
     528            )
     529          */
     530          query.setInteger("unit", getId());
     531          query.setInteger("valueType", valueType.getValue());
     532         
     533          // Case 1
     534          query.setInteger("case", 1);
     535          query.setDouble("factor", case1Factor);
     536          query.setDouble("offset", case1Offset);
     537          HibernateUtil.executeUpdate(query);
     538         
     539          // Case 2
     540          query.setInteger("case", 2);
     541          query.setDouble("factor", case2Factor);
     542          query.setDouble("offset", case2Offset);
     543          HibernateUtil.executeUpdate(query);
    502544        }
    503        
    504         String tableName = valueType.getTableName();
    505         org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(
    506           getDbControl().getHibernateSession(),
    507           "RECALCULATE_ANNOTATIONS_FOR_UNIT", tableName);
    508         /*
    509           UPDATE {1} SET value = value * :factor + :offset
    510           WHERE id IN
    511           (
    512             SELECT [a].[value_id]
    513             FROM [Annotations] [a]
    514             JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
    515             WHERE [at].[value_type] = :valueType
    516             AND
    517             (
    518               (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] <> :unit)
    519               OR
    520               (:case = 2 AND [a].[unit_id] <> :unit AND [at].[default_unit_id] = :unit)
    521             )
    522           )
    523         */
    524         query.setInteger("unit", getId());
    525         query.setInteger("valueType", valueType.getValue());
    526        
    527         // Case 1
    528         query.setInteger("case", 1);
    529         query.setDouble("factor", case1Factor);
    530         query.setDouble("offset", case1Offset);
    531         HibernateUtil.executeUpdate(query);
    532        
    533         // Case 2
    534         query.setInteger("case", 2);
    535         query.setDouble("factor", case2Factor);
    536         query.setDouble("offset", case2Offset);
    537         HibernateUtil.executeUpdate(query);
    538545      }
    539546    }
    540     getData().setReferenceFactor(factor);
    541     getData().setReferenceOffset(offset);
     547    data.setReferenceFactor(factor);
     548    data.setReferenceOffset(offset);
    542549  }
    543550
  • trunk/src/core/net/sf/basedb/util/overview/Validator.java

    r5500 r5518  
    196196      "missing.labeledextract", "Missing labeled extract",
    197197      "Checks if at least one labeled extract has been specified as parent to a " +
    198       "pooled labeled extract",
     198      "pooled labeled extract or a hybridization",
    199199      "Missing labeled extract", Severity.WARNING
    200200    );
  • trunk/src/core/net/sf/basedb/util/overview/loader/LabeledExtractLoader.java

    r5500 r5518  
    229229      createItemNode(nf, extract, extract, false, folderNode, ChildNodeDirection.REVERSE);
    230230    }
    231     postValidateFolder(nf, folderNode, parentNode, true);
     231    postValidateFolder(nf, folderNode, parentNode, rbaNode == null);
    232232    return folderNode;
    233233  }
  • trunk/src/core/net/sf/basedb/util/overview/validator/LabeledExtractValidator.java

    r4764 r5518  
    3030import net.sf.basedb.core.BioMaterialEvent;
    3131import net.sf.basedb.core.DbControl;
    32 import net.sf.basedb.core.Experiment;
    3332import net.sf.basedb.core.Hybridization;
    3433import net.sf.basedb.core.Item;
     
    3635import net.sf.basedb.core.LabeledExtract;
    3736import net.sf.basedb.core.PermissionDeniedException;
     37import net.sf.basedb.core.RawBioAssay;
    3838import net.sf.basedb.util.overview.Failure;
    3939import net.sf.basedb.util.overview.Fix;
     
    120120    int maxArrayIndex = 0;
    121121    int numExtracts = 0;
    122     for (Node leNode : folderNode.getChildren())
    123     {
    124       numExtracts++;
    125       LabeledExtract extract = (LabeledExtract)leNode.getItem(dc);
    126       try
     122    if (folderNode != null)
     123    {
     124      for (Node leNode : folderNode.getChildren())
    127125      {
    128         Label label = extract.getLabel();
    129         int arrayIndex = creationEvent.getSourceGroup(extract);
    130         if (arrayIndex < minArrayIndex) minArrayIndex = arrayIndex;
    131         if (arrayIndex > maxArrayIndex) maxArrayIndex = arrayIndex;
    132         String labelIndex = label.getId() + ":" + arrayIndex;
    133         if (usedLabelIndexes.containsKey(labelIndex))
     126        numExtracts++;
     127        LabeledExtract extract = (LabeledExtract)leNode.getItem(dc);
     128        try
    134129        {
    135           duplicates.add(extract);
    136           duplicates.add(usedLabelIndexes.get(labelIndex));
     130          Label label = extract.getLabel();
     131          int arrayIndex = creationEvent.getSourceGroup(extract);
     132          if (arrayIndex < minArrayIndex) minArrayIndex = arrayIndex;
     133          if (arrayIndex > maxArrayIndex) maxArrayIndex = arrayIndex;
     134          String labelIndex = label.getId() + ":" + arrayIndex;
     135          if (usedLabelIndexes.containsKey(labelIndex))
     136          {
     137            duplicates.add(extract);
     138            duplicates.add(usedLabelIndexes.get(labelIndex));
     139          }
     140          else
     141          {
     142            usedLabelIndexes.put(labelIndex, extract);
     143          }
    137144        }
    138         else
    139         {
    140           usedLabelIndexes.put(labelIndex, extract);
    141         }
     145        catch (PermissionDeniedException ex)
     146        {}
    142147      }
    143       catch (PermissionDeniedException ex)
    144       {}
    145148    }
    146149    if (duplicates.size() > 0)
     
    159162   
    160163    // Check that the number of labeled extracts per array-index matches
    161     // the number of channels if we are descending from an experiment
    162     Node experimentNode = parentNode.getFirstParent(new ItemTypeFilter(Item.EXPERIMENT));
    163     if (experimentNode != null)
    164     {
    165       Experiment exp = (Experiment)experimentNode.getItem();
    166       int numChannels = exp.getRawDataType().getChannels();
     164    // the number of channels if we are descending from at least a raw bioassay
     165    Node rbaNode = parentNode.getFirstParent(new ItemTypeFilter(Item.RAWBIOASSAY));
     166    if (rbaNode != null)
     167    {
     168      RawBioAssay rba = (RawBioAssay)rbaNode.getItem();
     169      int numChannels = rba.getRawDataType().getChannels();
    167170      if (numExtracts != numChannels)
    168171      {
Note: See TracChangeset for help on using the changeset viewer.