View Javadoc
1   package fr.ifremer.tutti.service.pupitri;
2   
3   /*
4    * #%L
5    * Tutti :: Service
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId;
26  import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId;
27  import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
28  import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
29  import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues;
30  
31  import java.util.Map;
32  
33  /**
34   * Created on 5/14/14.
35   *
36   * @author Tony Chemit - chemit@codelutin.com
37   * @since 3.4.2
38   */
39  public enum Signs {
40  
41      MALE("1", PmfmId.SEX, QualitativeValueId.SEX_MALE),
42      FEMALE("2", PmfmId.SEX, QualitativeValueId.SEX_FEMALE),
43      SMALL("P", PmfmId.SIZE_CATEGORY, QualitativeValueId.SIZE_SMALL),
44      MEDIUM("M", PmfmId.SIZE_CATEGORY, QualitativeValueId.SIZE_MEDIUM),
45      BIG("G", PmfmId.SIZE_CATEGORY, QualitativeValueId.SIZE_BIG),
46      DEFAULT("0", PmfmId.SEX, QualitativeValueId.SEX_UNDEFINED),
47      UNSORTED("H", null, null),
48      MELAG("T", null, null);
49  
50      private final String sign;
51      private final Integer category;
52      private final Integer qualitativeValue;
53  
54      Signs(String sign, PmfmId pmfmId, QualitativeValueId qualitativeValueId) {
55          this.sign = sign;
56          this.category = pmfmId == null ? null : pmfmId.getValue();
57          this.qualitativeValue = qualitativeValueId == null ? null : qualitativeValueId.getValue();
58      }
59  
60      public String getSign() {
61          return sign;
62      }
63  
64      public static Signs getSign(String sign) {
65          Signs result = null;
66          for (Signs s : values()) {
67              if (s.sign.equals(sign)) {
68                  result = s;
69                  break;
70              }
71          }
72          return result;
73      }
74  
75      public Integer getCategory() {
76          return category;
77      }
78  
79  
80      public Integer getQualitativeValue() {
81          return qualitativeValue;
82      }
83  
84      public void registerSign(Caracteristic caracteristic, Map<Signs, CaracteristicQualitativeValue> map) {
85          CaracteristicQualitativeValue result = CaracteristicQualitativeValues.getQualitativeValue(caracteristic, qualitativeValue);
86          map.put(this, result);
87      }
88  }