| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.student.core.organization.assembly.data.server.org; | 
  | 17 |  |   | 
  | 18 |  |   | 
  | 19 |  |  import java.text.DateFormat; | 
  | 20 |  |  import java.text.SimpleDateFormat; | 
  | 21 |  |  import java.util.Date; | 
  | 22 |  |   | 
  | 23 |  |  import org.apache.log4j.Logger; | 
  | 24 |  |  import org.kuali.student.common.assembly.data.Data; | 
  | 25 |  |  import org.kuali.student.common.assembly.helper.PropertyEnum; | 
  | 26 |  |  import org.kuali.student.core.organization.assembly.data.client.RuntimeDataHelper; | 
  | 27 |  |   | 
  | 28 |  |  public class OrgHelper{ | 
  | 29 | 0 |          final Logger LOG = Logger.getLogger(OrgHelper.class); | 
  | 30 |  |          private static final long serialVersionUID = 1L; | 
  | 31 |  |   | 
  | 32 | 0 |          public enum Properties implements PropertyEnum{ | 
  | 33 | 0 |                  ID("id"),TYPE("type"),NAME("longName"),ABBREVIATION("shortName"),DESCRIPTION("longDesc"), | 
  | 34 | 0 |                                  EFFECTIVE_DATE("effectiveDate"), EXPIRATION_DATE("expirationDate"),_RUNTIME_DATA ("_runtimeData"), | 
  | 35 | 0 |                                  VERSION_CODES("versionCodes"); | 
  | 36 |  |   | 
  | 37 |  |                  private final String key; | 
  | 38 |  |   | 
  | 39 | 0 |                  private Properties(final String key) { | 
  | 40 | 0 |                          this.key = key; | 
  | 41 | 0 |                  } | 
  | 42 |  |   | 
  | 43 |  |                  @Override | 
  | 44 |  |                  public String getKey() { | 
  | 45 | 0 |                          return this.key; | 
  | 46 |  |                  } | 
  | 47 |  |          } | 
  | 48 |  |   | 
  | 49 |  |          private Data data; | 
  | 50 |  |       | 
  | 51 | 0 |      private OrgHelper(Data data){ | 
  | 52 | 0 |          this.data=data; | 
  | 53 | 0 |      } | 
  | 54 |  |   | 
  | 55 |  |      public static OrgHelper wrap (Data data) | 
  | 56 |  |      { | 
  | 57 | 0 |          if (data == null) | 
  | 58 |  |          { | 
  | 59 | 0 |               return null; | 
  | 60 |  |          } | 
  | 61 | 0 |          return new OrgHelper(data); | 
  | 62 |  |      } | 
  | 63 |  |       | 
  | 64 |  |      public Data getData(){ | 
  | 65 | 0 |          return data; | 
  | 66 |  |      } | 
  | 67 |  |           | 
  | 68 |  |          public void setId(String id){ | 
  | 69 | 0 |              data.set(Properties.ID.getKey(), id); | 
  | 70 | 0 |          } | 
  | 71 |  |           | 
  | 72 |  |      public String getId() { | 
  | 73 | 0 |          return data.get(Properties.ID.getKey()); | 
  | 74 |  |      } | 
  | 75 |  |       | 
  | 76 |  |          public void setType(String type) { | 
  | 77 | 0 |              data.set(Properties.TYPE.getKey(), type); | 
  | 78 | 0 |      } | 
  | 79 |  |       | 
  | 80 |  |      public String getType() { | 
  | 81 | 0 |          return data.get(Properties.TYPE.getKey()); | 
  | 82 |  |      } | 
  | 83 |  |   | 
  | 84 |  |      public void setName(String name) { | 
  | 85 | 0 |          data.set(Properties.NAME.getKey(), name); | 
  | 86 | 0 |      } | 
  | 87 |  |       | 
  | 88 |  |      public String getName() { | 
  | 89 | 0 |          return data.get(Properties.NAME.getKey()); | 
  | 90 |  |      } | 
  | 91 |  |       | 
  | 92 |  |      public void setAbbreviation(String abbr) { | 
  | 93 | 0 |          data.set(Properties.ABBREVIATION.getKey(), abbr); | 
  | 94 | 0 |      } | 
  | 95 |  |       | 
  | 96 |  |      public String getAbbreviation() { | 
  | 97 | 0 |          return data.get(Properties.ABBREVIATION.getKey()); | 
  | 98 |  |      } | 
  | 99 |  |       | 
  | 100 |  |      public void setDescription(String description) { | 
  | 101 | 0 |          data.set(Properties.DESCRIPTION.getKey(), description); | 
  | 102 | 0 |      } | 
  | 103 |  |       | 
  | 104 |  |      public String getDescription() { | 
  | 105 | 0 |          return data.get(Properties.DESCRIPTION.getKey()); | 
  | 106 |  |      } | 
  | 107 |  |       | 
  | 108 |  |      public Date getEffectiveDate() { | 
  | 109 | 0 |          if(data.get(Properties.EFFECTIVE_DATE.getKey()) instanceof String){ | 
  | 110 | 0 |              DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); | 
  | 111 |  |              try { | 
  | 112 | 0 |                  return df.parse((String) data.get(Properties.EFFECTIVE_DATE.getKey())); | 
  | 113 | 0 |              } catch (Exception e) { | 
  | 114 | 0 |                  LOG.error(e); | 
  | 115 |  |              } | 
  | 116 |  |          } | 
  | 117 | 0 |          return data.get(Properties.EFFECTIVE_DATE.getKey()); | 
  | 118 |  |      } | 
  | 119 |  |       | 
  | 120 |  |      public void setEffectiveDate(Date value)  { | 
  | 121 | 0 |          data.set(Properties.EFFECTIVE_DATE.getKey(), value); | 
  | 122 | 0 |      } | 
  | 123 |  |       | 
  | 124 |  |      public Date getExpirationDate() { | 
  | 125 | 0 |          if(data.get(Properties.EXPIRATION_DATE.getKey()) instanceof String){ | 
  | 126 | 0 |              DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); | 
  | 127 |  |              try { | 
  | 128 | 0 |                  return df.parse((String) data.get(Properties.EXPIRATION_DATE.getKey())); | 
  | 129 | 0 |              } catch (Exception e) { | 
  | 130 | 0 |                  LOG.error(e); | 
  | 131 |  |              } | 
  | 132 |  |          } | 
  | 133 | 0 |          return data.get(Properties.EXPIRATION_DATE.getKey()); | 
  | 134 |  |      } | 
  | 135 |  |       | 
  | 136 |  |      public void setExpirationDate(Date value)  { | 
  | 137 | 0 |          data.set(Properties.EXPIRATION_DATE.getKey(), value); | 
  | 138 | 0 |      } | 
  | 139 |  |       | 
  | 140 |  |      public void set_runtimeData (RuntimeDataHelper value) | 
  | 141 |  |      { | 
  | 142 | 0 |          data.set (Properties._RUNTIME_DATA.getKey (), (value == null) ? null : value.getData ()); | 
  | 143 | 0 |      } | 
  | 144 |  |       | 
  | 145 |  |       | 
  | 146 |  |      public RuntimeDataHelper get_runtimeData () | 
  | 147 |  |      { | 
  | 148 | 0 |          return RuntimeDataHelper.wrap ((Data) data.get (Properties._RUNTIME_DATA.getKey ())); | 
  | 149 |  |      } | 
  | 150 |  |   | 
  | 151 |  |           | 
  | 152 |  |  } |