Changeset 1285


Ignore:
Timestamp:
Feb 8, 2011, 2:49:25 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #292: Check/create annotation types, etc. required by reggie

Added ReasonIfNoSpecimen annotation type to installation.

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

    r1284 r1285  
    6666  */
    6767  public static final String ANNOTATION_LATERALITY = "Laterality";
     68
     69  /**
     70    The name of the "ReasonIfNoSpecimen" annotation type, used
     71    for samples (Case). It is a multi-valued string annotation.
     72  */
     73  public static final String ANNOTATION_REASON_IF_NO_SPECIMEN = "ReasonIfNoSpecimen";
     74
    6875 
    6976  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r1284 r1285  
    7979       
    8080        // Annotation type checks
    81         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PERSONAL_NUMBER, Item.BIOSOURCE, Type.STRING,
     81        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PERSONAL_NUMBER, Item.BIOSOURCE, Type.STRING, 1,
    8282            null, sharedToPatientCurator, createIfMissing));
    83         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_FAMILY_NAME, Item.BIOSOURCE, Type.STRING,
     83        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_FAMILY_NAME, Item.BIOSOURCE, Type.STRING, 1,
    8484            null, sharedToPatientCurator, createIfMissing));
    85         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_ALL_FIRST_NAMES, Item.BIOSOURCE, Type.STRING,
     85        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_ALL_FIRST_NAMES, Item.BIOSOURCE, Type.STRING, 1,
    8686            null, sharedToPatientCurator, createIfMissing));
    87         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_DATE_OF_BIRTH, Item.BIOSOURCE, Type.DATE,
     87        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_DATE_OF_BIRTH, Item.BIOSOURCE, Type.DATE, 1,
    8888            null, sharedToPatientCurator, createIfMissing));
    89         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_GENDER, Item.BIOSOURCE, Type.STRING,
     89        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_GENDER, Item.BIOSOURCE, Type.STRING, 1,
    9090            new EnumerationOptions("F", "M"), sharedToPatientCurator, createIfMissing));
    91         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_LATERALITY, Item.SAMPLE, Type.STRING,
     91        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_LATERALITY, Item.SAMPLE, Type.STRING, 1,
    9292            new EnumerationOptions("LEFT", "RIGHT"), sharedToPatientCurator, createIfMissing));
     93        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, Item.SAMPLE, Type.STRING, 0,
     94            null, sharedToPatientCurator, createIfMissing));
    9395       
    9496        json.put("checks", jsonChecks);
     
    117119  */
    118120  public AnnotationType createAnnotationType(SessionControl sc, String name, Item itemType, Type valueType,
    119       EnumerationOptions enumOptions, PermissionOptions permissions)
     121      int multiplicity, EnumerationOptions enumOptions, PermissionOptions permissions)
    120122  {
    121123    AnnotationType at = null;
     
    126128      at.setName(name);
    127129      at.enableForItem(itemType);
     130      at.setMultiplicity(multiplicity);
    128131      if (enumOptions != null)
    129132      {
     
    155158  @SuppressWarnings("unchecked")
    156159  public JSONObject checkAnnotationType(DbControl dc, String name, Item itemType, Type valueType,
    157       EnumerationOptions enumOptions, PermissionOptions permissions, boolean createIfMissing)
     160      int multiplicity, EnumerationOptions enumOptions, PermissionOptions permissions,
     161      boolean createIfMissing)
    158162  {
    159163    JSONObject json = new JSONObject();
     
    166170      if (createIfMissing)
    167171      {
    168         AnnotationType at = createAnnotationType(dc.getSessionControl(), name, itemType, valueType, enumOptions, permissions);
     172        AnnotationType at = createAnnotationType(dc.getSessionControl(), name, itemType, valueType, multiplicity, enumOptions, permissions);
    169173        json.put("id", at.getId());
    170174        json.put("status", "ok");
     
    202206        json.put("status", "error");
    203207        json.put("message", "Found, but is not a " + valueType.name() + " type");
     208      }
     209      else if (at.getMultiplicity() != multiplicity)
     210      {
     211        json.put("status", "error");
     212        json.put("message", "Found, but should have multiplicity=" + (multiplicity == 0 ? "unlimited" : multiplicity));
    204213      }
    205214      else if (at.isEnumeration() && enumOptions == null)
Note: See TracChangeset for help on using the changeset viewer.