Changeset 1409


Ignore:
Timestamp:
Oct 18, 2011, 3:49:05 PM (10 years ago)
Author:
Martin Svensson
Message:

References #330 The partition wizard is now ready for testing. No more known bugs/issues exists.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/partitionform.jsp

    r1406 r1409  
    134134      nofPiecesTitle = '';
    135135     
    136       var doOnTab = i==(tubes.length-1) ? 'doOnTab(event, goCreate)' : '';
     136      var doOnTab = i==(tubes.length-1) ? 'doOnTab(event, goCreate)' : 'focusOnEnter(event, \'spWeight'+(i+1)+'\')';
    137137      inputWeightHtml += '<tr>';
    138138      inputWeightHtml += '<td class="subprompt">'+caseInfo.name+'.'+(i+1)+' ['+tubes[i].box+'&nbsp;'+tubes[i].row+tubes[i].column+']</td>';
     
    140140      inputWeightHtml += '<table style=width:90%>';     
    141141      inputWeightHtml += '<tr>';
    142       inputWeightHtml += '<td>' + spInputTitle + '<input size=3 type="text" onChange="spWeightOnChange('+i+')" name="spWeight'+i+'" /></td>';
    143       inputWeightHtml += '<td>' + apInputTitle + '<input size=3 type="text" onChange="apWeightOnChange('+i+')" name="apWeight'+i+'" /></td>';
    144       inputWeightHtml += '<td>' + hisInputTitle + '<input size=3 type="text" onChange="hisWeightOnChange('+i+')" name="hisWeight'+i+'" /></td>';
     142      inputWeightHtml += '<td>' + spInputTitle + '<input size=3 type="text" onkeypress="focusOnEnter(event, \'apWeight'+i+'\')" onChange="spWeightOnChange('+i+')" name="spWeight'+i+'" /></td>';
     143      inputWeightHtml += '<td>' + apInputTitle + '<input size=3 type="text" onkeypress="focusOnEnter(event, \'hisWeight'+i+'\')" onChange="apWeightOnChange('+i+')" name="apWeight'+i+'" /></td>';
     144      inputWeightHtml += '<td>' + hisInputTitle + '<input size=3 type="text" onkeypress="focusOnEnter(event, \'nofPieces'+i+'\')" onChange="hisWeightOnChange('+i+')" name="hisWeight'+i+'" /></td>';
    145145      inputWeightHtml += '<td>' + nofPiecesTitle + '<input size=3 type="text" onkeypress="'+doOnTab+'" onChange="nofPiecesOnChange('+i+')" name="nofPieces'+i+'" /></td>';
    146146      inputWeightHtml += '</tr>';
     
    225225      frm.elements[inputName].value = '';
    226226    }
    227   } 
     227  }
    228228  apWeightsAreValid[tubeIndex] = true;
    229229  updateInputStatus(tubeIndex);
     
    292292      setInputStatus('partitionDate', 'Not a valid date', 'invalid');
    293293      return;
    294     }
    295     if (todaysDate < new Date(partitionDate.substring(0,4), partitionDate.substring(4,6), partitionDate.substring(6)))
     294    }   
     295    if (todaysDate < new Date(partitionDate.substring(0,4), new Number(partitionDate.substring(4,6)-1), partitionDate.substring(6)))
    296296    {
    297297      setInputStatus('partitionDate', 'Future dates are not valid','invalid');
     
    342342  var partitionCommentValue = frm.elements['partitionComment'].value;
    343343  caseInfo.partitionDate = partitionDateValue;
    344   if (partitionCommentValue != null) caseInfo.partitionComment = partitionCommentValue;
     344  if (partitionCommentValue != null) caseInfo.otherPartitionComment = partitionCommentValue;
    345345 
    346346  for (var i=0; i<nofTubes; i++)
  • extensions/net.sf.basedb.reggie/trunk/resources/specimentube.jsp

    r1406 r1409  
    300300  }
    301301  frm.nofTubes.focus();
     302  frm.nofTubes.setSelectionRange(0,1);
    302303  currentStep = 2;   
    303304}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r1406 r1409  
    174174  /**
    175175    The name of the "Partition date" annotation type, used for
    176     samples(His-sample). It is a date annotation type.
     176    samples(His-sample) and extracts(Lys-extract). It is a date annotation type.
    177177   */
    178   public static final String ANNOTATION_SAMPLE_PARTITION_DATE = "SamplePartitionDate";
    179  
    180   /**
    181     The name of the "Partition date" annotation type, used for
    182     extracts(Lys-extract). It is a date annotation type.
    183    */
    184   public static final String ANNOTATION_EXTRACT_PARTITION_DATE = "ExtractPartitionDate";
     178  public static final String ANNOTATION_PARTITION_DATE = "PartitionDate";
    185179 
    186180  /**
     
    238232  public static AnnotationType findAnnotationType(DbControl dc, Item itemType, String name, boolean exceptionIfNotFound)
    239233  {
    240     List<AnnotationType> result = listAnnotationTypes(dc, itemType, name);
     234    return findAnnotationType(dc, new Item[]{itemType}, name, exceptionIfNotFound);
     235  }
     236 
     237  /**
     238    Find a single annotation type with the given name. If exactly one is found it
     239    is returned, otherwise null is returned or an exception is thrown
     240    depending on the exceptionIfNotFound parameter.
     241    This method can find annotation type that is enabled for more then one type of item.
     242  */
     243  public static AnnotationType findAnnotationType(DbControl dc, Item[] itemTypes, String name, boolean exceptionIfNotFound)
     244  {
     245    Item firstItem = null;
     246    if (itemTypes != null && itemTypes.length>0) firstItem = itemTypes[0];
     247    List<AnnotationType> result = listAnnotationTypes(dc, firstItem, name);
    241248    AnnotationType at = null;
    242249    if (result.size() == 0)
     
    251258    {
    252259      at = result.get(0);
     260      for (Item it : itemTypes)
     261      {
     262        if (exceptionIfNotFound && !at.isEnabledForItem(it))
     263        {
     264          throw new ItemNotFoundException("AnnotationType["+name+"]");
     265        }
     266      }     
    253267    }
    254268    return at;
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r1406 r1409  
    22
    33import java.io.IOException;
     4import java.util.ArrayList;
    45import java.util.Arrays;
    56import java.util.Collections;
     
    142143            null, effectiveOptions, createIfMissing));
    143144        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_OTHER_PARTITION_COMMENT, Item.SAMPLE, Type.STRING, 1,
    144             null, effectiveOptions, createIfMissing));
    145         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_SAMPLE_PARTITION_DATE, Item.SAMPLE, Type.DATE, 1,
    146             null, effectiveOptions, createIfMissing));
    147         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_EXTRACT_PARTITION_DATE, Item.EXTRACT, Type.DATE, 1,
    148             null, effectiveOptions, createIfMissing));
    149                
     145            null, effectiveOptions, createIfMissing));       
     146        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PARTITION_DATE, new Item[]{Item.SAMPLE, Item.EXTRACT}, Type.DATE, 1,
     147            null, effectiveOptions, createIfMissing));
     148       
    150149        json.put("checks", jsonChecks);
    151150      }
     
    175174      int multiplicity, EnumerationOptions enumOptions, PermissionOptions permissions)
    176175  {
     176    return createAnnotationType(sc, name, new Item[]{itemType}, valueType, multiplicity, enumOptions, permissions);
     177  }
     178 
     179  /**
     180    Creates an annotation type with the given options. The annotation
     181    type is created in a separate transaction. The annotation can be enabled for
     182    one or more item-types.
     183   
     184    @since 1.6
     185   */
     186  public AnnotationType createAnnotationType(SessionControl sc, String name, Item[] itemTypes, Type valueType,
     187      int multiplicity, EnumerationOptions enumOptions, PermissionOptions permissions)
     188  {
    177189    AnnotationType at = null;
    178190    DbControl dc = sc.newDbControl();
     
    181193      at = AnnotationType.getNew(dc, valueType);
    182194      at.setName(name);
    183       at.enableForItem(itemType);
     195      for (Item it : itemTypes)
     196      {
     197        at.enableForItem(it);
     198      }
    184199      at.setMultiplicity(multiplicity);
    185200      if (enumOptions != null)
     
    210225    </ul>
    211226  */
     227  public JSONObject checkAnnotationType(DbControl dc, String name, Item itemType, Type valueType,
     228      int multiplicity, EnumerationOptions enumOptions, PermissionOptions permissions,
     229      boolean createIfMissing)
     230  {
     231    return checkAnnotationType(dc, name, new Item[]{itemType}, valueType,
     232        multiplicity, enumOptions, permissions, createIfMissing);
     233  }
     234 
     235  /**
     236    Check for an existing annotation type with the given options. A JSONObject is returned
     237    with the result. The following keys are used:
     238    <ul>
     239    <li>itemType: ANNOTATIONTYPE
     240    <li>name: The name of the annotation type
     241    <li>id: The id of the annotation type if it exists
     242    <li>status: ok, error, or missing
     243    <li>message: A descriptive message in case of an error
     244    </ul>
     245   
     246    @since 1.6
     247  */
    212248  @SuppressWarnings("unchecked")
    213   public JSONObject checkAnnotationType(DbControl dc, String name, Item itemType, Type valueType,
     249  public JSONObject checkAnnotationType(DbControl dc, String name, Item[] itemTypes, Type valueType,
    214250      int multiplicity, EnumerationOptions enumOptions, PermissionOptions permissions,
    215251      boolean createIfMissing)
     
    225261      if (createIfMissing)
    226262      {
    227         AnnotationType at = createAnnotationType(dc.getSessionControl(), name, itemType, valueType, multiplicity, enumOptions, permissions);
     263        AnnotationType at = createAnnotationType(dc.getSessionControl(), name, itemTypes, valueType,
     264            multiplicity, enumOptions, permissions);
    228265        json.put("id", at.getId());
    229266        json.put("status", "ok");
     
    251288        jsonMessages.add(permissions.getMessage());
    252289      }
    253       if (!at.isEnabledForItem(itemType))
    254       {
    255         json.put("status", "error");
    256         jsonMessages.add("Not enabled for " + itemType.name());
     290      for (Item it : itemTypes)
     291      {
     292        if (!at.isEnabledForItem(it))
     293        {
     294          json.put("status", "error");
     295          jsonMessages.add("Not enabled for " + it.name());
     296        }
    257297      }
    258298      if (at.getValueType() != valueType)
     
    288328    json.put("messages", jsonMessages);
    289329    return json;
    290 
    291330  }
    292331 
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PartitionRegistrationServlet.java

    r1406 r1409  
    150150        JSONArray jsonSpecimens = (JSONArray)jsonCase.get("specimen");
    151151       
    152         AnnotationType samplePartitionDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLE_PARTITION_DATE, true);
    153         AnnotationType extractPartitionDateType = Reggie.findAnnotationType(dc, Item.EXTRACT, Reggie.ANNOTATION_EXTRACT_PARTITION_DATE, true);
     152        AnnotationType partitionDateType = Reggie.findAnnotationType(dc, new Item[]{Item.EXTRACT, Item.SAMPLE}, Reggie.ANNOTATION_PARTITION_DATE, true);
    154153        AnnotationType partitionCommentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_OTHER_PARTITION_COMMENT, true);
    155154        AnnotationType nofPiecesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_PIECES, true);
     
    163162          for (int i=0; i<jsonSpecimens.size(); i++)
    164163          {
    165             List<String> subMessages = new ArrayList<String>();
    166            
    167164            Float originalQuantity = new Float(0);
    168165            JSONObject jsonSpecimen = (JSONObject)jsonSpecimens.get(i);
     
    175172            if (specimenWell != null) specimenBoxName = specimenWell.getPlate().getName();
    176173                       
    177             Float spWeight = Values.getFloat((String)jsonSpecimen.get("spWeight"), null)*1000;
    178             Float apWeight = Values.getFloat((String)jsonSpecimen.get("apWeight"), null)*1000;
    179             Float hisWeight = Values.getFloat((String)jsonSpecimen.get("hisWeight"), null)*1000;           
    180             Integer nofPieces = Values.getInteger((String)jsonSpecimen.get("nofPieces"), null);           
    181            
    182             Reggie.setAnnotationValue(specimen, samplePartitionDateType, partitionDate);
     174            Float spWeight = Values.getFloat((String)jsonSpecimen.get("spWeight"), null);
     175            Float apWeight = Values.getFloat((String)jsonSpecimen.get("apWeight"), null);
     176            Float hisWeight = Values.getFloat((String)jsonSpecimen.get("hisWeight"), null);           
     177            Integer nofPieces = Values.getInteger((String)jsonSpecimen.get("nofPieces"), null);
     178           
     179            if (spWeight != null) spWeight = spWeight *1000;
     180            if (apWeight != null) apWeight = apWeight *1000;
     181            if (hisWeight != null) hisWeight = hisWeight *1000;
     182                       
    183183            if (nofPieces != null) Reggie.setAnnotationValue(specimen, nofPiecesType, nofPieces);           
    184184            if (otherPartitionComment != null) Reggie.setAnnotationValue(specimen, partitionCommentType, otherPartitionComment);           
     
    195195                dc.saveItem(lysExtract);
    196196               
    197                 Reggie.setAnnotationValue(lysExtract, extractPartitionDateType, partitionDate);
     197                Reggie.setAnnotationValue(lysExtract, partitionDateType, partitionDate);               
    198198               
    199199                // Set box position
     
    222222                  }
    223223                  lysExtract.setBioWell(lysBox.getBioWell(specimenWell.getRow(), specimenWell.getColumn()));                 
    224                 }               
    225                 subMessages.add("--Lysate "+specimen.getName()+".l created successfully");
     224                }
    226225              }
    227226            }
     
    241240                creationEvent.addSource(specimen, hisWeight);
    242241               
     242                Reggie.setAnnotationValue(hisSample, partitionDateType, partitionDate);
     243               
    243244                // Set box position
    244245                if (specimenBoxName != null)
     
    265266                  }
    266267                  hisSample.setBioWell(hisBox.getBioWell(specimenWell.getRow(), specimenWell.getColumn()));                 
    267                 }
    268                 subMessages.add("--His sample "+specimen.getName() + ".his created successfully");
     268                }               
    269269              }
    270270            }
     
    272272            specimen.setOriginalQuantity(originalQuantity);
    273273           
    274             jsonMessages.add("Specimen tube " + specimen.getName() + " partitioned successfully");
    275             for(String m : subMessages)
    276             {
    277               jsonMessages.add(m);
    278             }
     274            jsonMessages.add("Specimen tube " + specimen.getName() + " partitioned successfully");           
    279275          }
    280276        }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SpecimenTubeServlet.java

    r1400 r1409  
    349349        String laterality = Values.getStringOrNull((String)jsonCase.get("laterality"));       
    350350        String padCase = Values.getStringOrNull((String)jsonCase.get("pad"));
    351         String otherPathNote = Values.getStringOrNull((String)jsonCase.get("pathNote"));
     351        String otherPathNote = Values.getStringOrNull((String)jsonCase.get("otherPathNote"));
    352352        StringToDateConverter dateTimeConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
    353353        StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd"));       
Note: See TracChangeset for help on using the changeset viewer.