Changeset 1565


Ignore:
Timestamp:
Mar 16, 2012, 10:25:01 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #368: Clearing the PAD field in the registration wizard should clear the PAD on specimen

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

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r1560 r1565  
    479479
    480480  /**
    481     Set a (single) annotation value on an item.
     481    Set a (single) annotation value on an item. If the value is null the annotation
     482    will be removed,
    482483  */
    483484  public static void setAnnotationValue(Annotatable item, AnnotationType at, Object value)
    484485  {
    485     item.getAnnotationSet().getAnnotation(at).setValue(value);
     486    if (value == null)
     487    {
     488      if (item.isAnnotated() && item.getAnnotationSet().hasAnnotation(at))
     489      {
     490        item.getAnnotationSet().removeAnnotation(at);
     491      }
     492    }
     493    else
     494    {
     495      item.getAnnotationSet().getAnnotation(at).setValue(value);
     496    }
    486497  }
    487498
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1533 r1565  
    356356            // Update the specimen annotations
    357357            if (laterality != null) Reggie.setAnnotationValue(specimen, lateralityType, laterality);
    358             if (pad != null) Reggie.setAnnotationValue(specimen, padType, pad);
     358            Reggie.setAnnotationValue(specimen, padType, pad);
    359359            if (samplingDate != null) Reggie.setAnnotationValue(specimen, samplingDateType, samplingDate);
    360360            if (rnaLaterDate != null) Reggie.setAnnotationValue(specimen, rnaLaterType, rnaLaterDate);
     
    388388        // If the 'laterality' value is a number, then it hasn't changed
    389389        boolean updateLaterality = Values.getInt(laterality, -1) == -1;
    390         String pad = Values.getString((String)jsonCase.get("pad"));
    391         String oldPad = Values.getString((String)jsonCase.get("oldPad"));
     390        String pad = Values.getStringOrNull((String)jsonCase.get("pad"));
     391        String oldPad = Values.getStringOrNull((String)jsonCase.get("oldPad"));
    392392        JSONArray jsonSpecimen = (JSONArray)jsonCase.get("specimen");
    393393     
     
    399399          Reggie.setAnnotationValue(theCase, lateralityType, laterality);
    400400        }
    401         if (pad != null)
    402         {
    403           if (oldPad != null) Reggie.removeAnnotationValue(theCase, padCaseType, oldPad);
    404           Reggie.appendAnnotationValueIfUnique(theCase, padCaseType, pad);
    405         }
     401
     402        if (oldPad != null) Reggie.removeAnnotationValue(theCase, padCaseType, oldPad);
     403        if (pad != null) Reggie.appendAnnotationValueIfUnique(theCase, padCaseType, pad);
     404       
    406405        jsonMessages.add("Case '" + originalCaseName + "' updated successfully.");
    407406       
     
    423422            // Update the specimen annotations
    424423            if (updateLaterality) Reggie.setAnnotationValue(specimen, lateralityType, laterality);
    425             if (pad != null) Reggie.setAnnotationValue(specimen, padType, pad);
     424            Reggie.setAnnotationValue(specimen, padType, pad);
    426425            if (samplingDate != null) Reggie.setAnnotationValue(specimen, samplingDateType, samplingDate);
    427426            if (rnaLaterDate != null) Reggie.setAnnotationValue(specimen, rnaLaterType, rnaLaterDate);
Note: See TracChangeset for help on using the changeset viewer.