extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/ReferenceDateSource.java

Code
Comments
Other
Rev Date Author Line
4458 21 Apr 17 nicklas 1 package net.sf.basedb.reggie.dao;
4458 21 Apr 17 nicklas 2
4458 21 Apr 17 nicklas 3 import net.sf.basedb.core.InvalidDataException;
4458 21 Apr 17 nicklas 4
4458 21 Apr 17 nicklas 5 /**
4458 21 Apr 17 nicklas 6   Enum indicating the source of the ReferenceDate annotation.
4458 21 Apr 17 nicklas 7   The order of the constants are important since that decide
4458 21 Apr 17 nicklas 8   which type of date that is allowed to replace another date.
4458 21 Apr 17 nicklas 9   
4458 21 Apr 17 nicklas 10   @author nicklas
4458 21 Apr 17 nicklas 11   @since 4.10
4458 21 Apr 17 nicklas 12 */
4458 21 Apr 17 nicklas 13 public enum ReferenceDateSource 
4458 21 Apr 17 nicklas 14 {
4458 21 Apr 17 nicklas 15   /**
4458 21 Apr 17 nicklas 16     The date the diagnosis was made according to date imported from INCA.
4458 21 Apr 17 nicklas 17   */
4458 21 Apr 17 nicklas 18   INCA_DIAGNOSIS_DATE("IncaDiagnosisDate"),
4458 21 Apr 17 nicklas 19   
4458 21 Apr 17 nicklas 20   /**
4458 21 Apr 17 nicklas 21     The "SamplingDate" from the Specimen/NoSpecimen item.
4458 21 Apr 17 nicklas 22   */
4458 21 Apr 17 nicklas 23   SAMPLING_DATE("SamplingDate"),
4458 21 Apr 17 nicklas 24   
4458 21 Apr 17 nicklas 25   /**
4458 21 Apr 17 nicklas 26     The "ConsentDate" annotation on the case.
4458 21 Apr 17 nicklas 27   */
4458 21 Apr 17 nicklas 28   CONSENT_DATE("ConsentDate"),
4458 21 Apr 17 nicklas 29   
4458 21 Apr 17 nicklas 30   /**
4458 21 Apr 17 nicklas 31     The registration date of the case.
4458 21 Apr 17 nicklas 32   */
4458 21 Apr 17 nicklas 33   REGISTRATION_DATE("RegistrationDate");
4458 21 Apr 17 nicklas 34   
4458 21 Apr 17 nicklas 35   
4458 21 Apr 17 nicklas 36   /**
4458 21 Apr 17 nicklas 37     Convert the "title" stored as an annotation to an enum constant.
4458 21 Apr 17 nicklas 38     An exception is thrown if no source is found.
4458 21 Apr 17 nicklas 39   */
4458 21 Apr 17 nicklas 40   public static ReferenceDateSource fromTitle(String title)
4458 21 Apr 17 nicklas 41   {
4458 21 Apr 17 nicklas 42     for (ReferenceDateSource source : values())
4458 21 Apr 17 nicklas 43     {
4458 21 Apr 17 nicklas 44       if (source.getTitle().equals(title)) return source;
4458 21 Apr 17 nicklas 45     }
4458 21 Apr 17 nicklas 46     throw new InvalidDataException("ReferenceDateSource '" + title + "' is not a known source");
4458 21 Apr 17 nicklas 47   }
4458 21 Apr 17 nicklas 48   
4458 21 Apr 17 nicklas 49   private final String title;
4458 21 Apr 17 nicklas 50   
4458 21 Apr 17 nicklas 51   private ReferenceDateSource(String title)
4458 21 Apr 17 nicklas 52   {
4458 21 Apr 17 nicklas 53     this.title = title;
4458 21 Apr 17 nicklas 54   }
4458 21 Apr 17 nicklas 55   
4458 21 Apr 17 nicklas 56   /**
4458 21 Apr 17 nicklas 57     The title for this reference date source. Used when stored as the
4458 21 Apr 17 nicklas 58     {@link Annotationtype#REFERENCE_DATE_SOURCE} annotation.
4458 21 Apr 17 nicklas 59   */
4458 21 Apr 17 nicklas 60   public String getTitle()
4458 21 Apr 17 nicklas 61   {
4458 21 Apr 17 nicklas 62     return title;
4458 21 Apr 17 nicklas 63   }
4458 21 Apr 17 nicklas 64 }