Changeset 6943


Ignore:
Timestamp:
Sep 1, 2015, 1:53:20 PM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #1941: Store experimental factor values as part experiments

Adding support for synchronizing a cloned annotation that has been modified, and for converting between cloned/inherited annotation.

Location:
trunk
Files:
3 edited

Legend:

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

    r6938 r6943  
    14461446        Number annotationTypeId = (Number)jsonA.get("annotationTypeId");
    14471447        JSONArray jsonValues = (JSONArray)jsonA.get("values");
     1448        Annotation.Source source = Annotation.Source.valueOf((String)jsonA.get("source"));
     1449        String modifyType = (String)jsonA.get("modified");
    14481450       
    14491451        AnnotationType at = AnnotationType.getById(dc, annotationTypeId.intValue());
     
    14521454        {
    14531455          a = Annotation.getById(dc, annotationId.intValue());
     1456         
     1457          if (a.getSource() != source)
     1458          {
     1459            // Convert between inherited<->cloned
     1460            a = a.getAnnotationSet().inheritAnnotation(a.getInheritedFrom(), source == Annotation.Source.CLONED);
     1461            if ("CONVERTED".equals(modifyType)) continue; // Only converted between types
     1462          }
     1463          else if (source == Annotation.Source.CLONED && "SYNCED".equals(modifyType))
     1464          {
     1465            // Sync a cloned annotation
     1466            a.resyncCloned();
     1467            continue;
     1468          }
     1469         
    14541470        }
    14551471        else if (jsonValues != null && jsonValues.size() > 0)
  • trunk/www/common/annotations/annotate.js

    r6942 r6943  
    2727  var annotate = {};
    2828
     29  var MODIFIED = 'MODIFIED';
     30  var SYNCED = 'SYNCED';
     31  var CONVERTED = 'CONVERTED';
     32 
    2933  var annotations;
    3034  var selectedAnnotation;
     
    9397    Events.addEventHandler('unit', 'change', annotate.unitOnChange);
    9498   
     99    // Sync modified clone
     100    Events.addEventHandler('sync-modified', 'click', annotate.syncClone);
     101    // Convert inherited annotation to cloned
     102    Events.addEventHandler('convert-to-cloned', 'click', annotate.convertToCloned);
     103    Events.addEventHandler('convert-to-inherited', 'click', annotate.convertToInherited);
     104   
    95105    // Select the initial annotation
    96106    var annotationTypeId = Data.int('page-data', 'annotation-type-id');
     
    132142   
    133143    var html = '';
    134     var icon = ann.values.length > 0 ? 'notrequired_values.png' : 'notrequired_novalues.png';
     144    var icon = entry.source != 'PRIMARY' || ann.values.length > 0 ? 'notrequired_values.png' : 'notrequired_novalues.png';
     145   
    135146    html += '<span class="icon">';
    136147    html += '<img id="icon.'+entry.id+'" src="../../images/'+icon+'">';
     
    259270     
    260271      annotate.showNameAndOtherInfo(at);
    261       classes.push('selected');
     272      classes.push('has-selected');
    262273      classes.push(selectedAnnotation.source);
    263274      if (at.description) classes.push('has-description');
     
    269280        {
    270281          var symbol = inherited.unitSymbol ? ' ' + inherited.unitSymbol : '';
     282         
    271283          Doc.element('inherited-values').innerHTML = Strings.encodeTags(inherited.values.join(symbol+', ')+symbol);
    272           Doc.element('inherited-item').innerHTML = Strings.encodeTags(inherited.from.name) + ' <span class="itemsubtype">('+inherited.from.type+')</span>';
     284          Doc.element('inherited-item').innerHTML = (selectedAnnotation.source == 'CLONED' ? 'Cloned from ' : 'Inherited from ') + Strings.encodeTags(inherited.from.name) + ' <span class="itemsubtype">('+inherited.from.type+')</span>';
     285         
     286          if (selectedAnnotation.source == 'CLONED' && inherited.lastUpdate > ann.lastUpdate)
     287          {
     288            classes.push('modified');
     289          }
     290         
    273291        }
    274292        else
     
    293311          classes.push(at.multiplicity == 1 ? 'ENUM-SINGLE' : 'ENUM-MULTIPLE');
    294312          var list = Doc.element(at.multiplicity == 1 ? 'ENUM-SINGLE-input' : 'ENUM-MULTIPLE-input');
    295           annotate.initEnumList(list, at.enumeration, at.multiplicity == 1, symbol);
     313          annotate.initEnumList(list, at.enumeration, at.multiplicity == 1 && selectedAnnotation.source == 'PRIMARY', symbol);
    296314          valueElement = list;         
    297315        }
     
    299317        {
    300318          classes.push('ENUM-RADIO-CHECKBOX');
    301           var tmp = annotate.initEnumCheckboxes(at.enumeration, at.multiplicity == 1, symbol);
     319          var tmp = annotate.initEnumCheckboxes(at.enumeration, at.multiplicity == 1, symbol, selectedAnnotation.source == 'PRIMARY');
    302320          Doc.element('ENUM-RADIO-CHECKBOX').innerHTML = '';
    303321          Doc.element('ENUM-RADIO-CHECKBOX').appendChild(tmp);
     
    466484    annotation.
    467485  */
    468   annotate.initEnumCheckboxes = function(values, radio, unit)
     486  annotate.initEnumCheckboxes = function(values, radio, unit, includeNotSpecified)
    469487  {
    470488    var tmp = document.createDocumentFragment();
    471489    var ctlType = radio ? 'radio' : 'checkbox';
    472     if (radio)
     490    if (includeNotSpecified)
    473491    {
    474492      var noop = annotate.createRadioOrCheckBox(ctlType, '', '- not specified -');
     
    539557    }
    540558    ann.values = values;
     559    annotation.modified = MODIFIED;
     560    annotate.updateIcon(annotation);
     561  }
     562 
     563  /**
     564    Update/add/remove a single value in a multi-valued annotation. If the value
     565    is not accepted an exception is thrown.
     566  */
     567  /*
     568  annotate.setIndexedValue = function(annotation, index, value)
     569  {
     570    if (!value)
     571    {
     572      if (index < annotation.values.length)
     573      {
     574        annotation.values.splice(index, 1);
     575      }
     576    }
     577    else
     578    {
     579      if (index >= annotation.values.length)
     580      {
     581        // Add a new value
     582        if (annotation.multiplicity > 0 && annotation.values.length >= annotation.multiplicity)
     583        {
     584          throw 'Max '+annotation.multiplicity+' values allowed';
     585        }
     586        index = annotation.values.length;
     587      }
     588      annotation.values[index] = value;
     589    }
    541590    annotation.modified = true;
    542591    annotate.updateIcon(annotation);
    543592  }
    544  
    545   /**
    546     Update/add/remove a single value in a multi-valued annotation. If the value
    547     is not accepted an exception is thrown.
    548   */
    549   /*
    550   annotate.setIndexedValue = function(annotation, index, value)
    551   {
    552     if (!value)
    553     {
    554       if (index < annotation.values.length)
    555       {
    556         annotation.values.splice(index, 1);
    557       }
    558     }
    559     else
    560     {
    561       if (index >= annotation.values.length)
    562       {
    563         // Add a new value
    564         if (annotation.multiplicity > 0 && annotation.values.length >= annotation.multiplicity)
    565         {
    566           throw 'Max '+annotation.multiplicity+' values allowed';
    567         }
    568         index = annotation.values.length;
    569       }
    570       annotation.values[index] = value;
    571     }
    572     annotation.modified = true;
    573     annotate.updateIcon(annotation);
    574   }
    575593  */
    576594 
     
    581599  {
    582600    annotation.annotation.unit = unit;
    583     annotation.modified = true;
     601    annotation.modified = MODIFIED;
    584602  }
    585603 
     
    655673  }
    656674
     675  /**
     676    Syncs a cloned value with the parent items value.
     677  */
     678  annotate.syncClone = function()
     679  {
     680    if (!selectedAnnotation || selectedAnnotation.source != 'CLONED') return;
     681   
     682    annotate.setMultipleValues(selectedAnnotation, selectedAnnotation.inherited.values);
     683    annotate.setUnit(selectedAnnotation, selectedAnnotation.inherited.unit);
     684    selectedAnnotation.annotation.lastUpdate = selectedAnnotation.inherited.lastUpdate;
     685    selectedAnnotation.modified = SYNCED;
     686   
     687    annotate.selectAnnotation(selectedAnnotation.id);
     688  }
     689 
     690  /**
     691    Converts an INHERITED annotation to a CLONED annotation.
     692  */
     693  annotate.convertToCloned = function()
     694  {
     695    if (!selectedAnnotation || selectedAnnotation.source != 'INHERITED') return;
     696   
     697    var ann = selectedAnnotation.annotation;
     698    var inherited = selectedAnnotation.inherited;
     699   
     700    selectedAnnotation.source = 'CLONED';
     701    selectedAnnotation.modified = CONVERTED;
     702    ann.values = inherited.values;
     703    ann.unit = inherited.unit;
     704    annotate.selectAnnotation(selectedAnnotation.id);
     705  }
     706
     707  /**
     708    Converts a CLONED annotation to an INHERITED annotation.
     709  */
     710  annotate.convertToInherited = function()
     711  {
     712    if (!selectedAnnotation || selectedAnnotation.source != 'CLONED') return;
     713   
     714    var ann = selectedAnnotation.annotation;
     715    var inherited = selectedAnnotation.inherited;
     716   
     717    selectedAnnotation.source = 'INHERITED';
     718    selectedAnnotation.modified = CONVERTED;
     719    ann.values = [];
     720    ann.unit = null;
     721    annotate.selectAnnotation(selectedAnnotation.id);
     722  }
     723
     724 
    657725  /*
    658726  annotate.addMultiValue = function(event)
     
    737805    var ann = entry.annotation;
    738806   
    739     if (ann && ann.values.length > 0)
     807    if (entry.source != 'PRIMARY' || (ann && ann.values.length > 0))
    740808    {
    741809      icon = ann.required ? 'required_values.png' : 'notrequired_values.png';
     
    780848    {
    781849      var entry = annotations[entryNo];
    782       if (entry.modified && entry.source != 'INHERITED')
     850      if (entry.modified)
    783851      {
    784852        var tmp = {};
    785853        modified[modified.length] = tmp;
     854        tmp.source = entry.source;
     855        tmp.modified = entry.modified;
    786856        tmp.values = entry.annotation.values;
    787857        tmp.annotationId = entry.annotation.id;
     
    791861    }
    792862   
     863    //alert(JSON.stringify(modified));
     864   
    793865    if (frm.modifiedAnnotations)
    794866    {
  • trunk/www/common/annotations/annotate.jsp

    r6938 r6943  
    7474<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    7575<%!
    76 
    77 
    7876private JSONObject makeJSON(DbControl dc, AnnotationType at, Annotation a, boolean isProtocolParameter, Set<AnnotationTypeCategory> allCategories)
    7977{
     
    214212{
    215213  json.put("id", a.getId());
     214  Date lastUpdate = a.getLastUpdate();
     215  if (lastUpdate != null) json.put("lastUpdate",  lastUpdate.getTime());
    216216 
    217217  Unit currentUnit = a.getUnit();
     
    392392  annotationTypes.addAll(annotationTypeQuery.list(dc));
    393393  annotationTypes.addAll(primary.keySet());
    394   if (annotationTypeId != 0)
    395   {
    396     annotationTypes.add(AnnotationType.getById(dc, annotationTypeId));
    397   }
    398394  if (parameterQuery != null)
    399395  {
     
    471467  }
    472468 
    473   #selected-container.selected #info-container
     469  #selected-container.has-selected #info-container
    474470  {
    475471    display: block;
     
    485481  {
    486482    display: block;
     483    border-left-width: 2px;
     484    padding: 2px 5px;
     485    margin: 0.5em 0;
    487486  }
    488487
     
    490489  {
    491490    display: block;
     491    border-left-width: 2px;
     492    padding: 2px 5px;
     493    margin: 0.5em 0;
    492494  }
    493495  #selected-container.inherited-missing #inherited-container
    494496  {
    495497    display: none;
     498  }
     499 
     500  #inherited-item
     501  {
     502    font-style: italic;
     503  }
     504 
     505  #inherited-modified, #inherited-clone, #cloned-inherit
     506  {
     507    display: none;
     508  }
     509
     510  #selected-container.modified #inherited-modified
     511  {
     512    display: inline;
     513  }
     514 
     515  #selected-container.INHERITED #inherited-clone
     516  {
     517    display: inline;
     518  }
     519
     520  #selected-container.CLONED #cloned-inherit
     521  {
     522    display: inline;
    496523  }
    497524 
     
    680707          </div>
    681708         
    682           <div id="inherited-container">
    683             <span id="inherited-values"></span><br>
    684             Inherited from <span id="inherited-item"></span>
     709          <div id="inherited-container" class="bg-filled-100">
     710            <span id="inherited-item"></span><br>
     711            <span id="inherited-values"></span>
     712            <span id="inherited-modified">(modified; <span id="sync-modified" class="link" title="Synchronize the annotation values with the parent item">sync</span>)</span>
     713            <span id="inherited-clone">(<span id="convert-to-cloned" class="link" title="Clone the annotation values from the parent">clone</span>)</span>
     714            <span id="cloned-inherit">(<span id="convert-to-inherited" class="link" title="Removed the cloned values from this item">remove clone</span>)</span>
    685715          </div>
    686          
     716                   
    687717          <div id="inherited-missing">
    688718            Cloned from an unknown item.
Note: See TracChangeset for help on using the changeset viewer.