View Javadoc
1   package fr.ifremer.dali.dto.enums;
2   
3   /*
4    * #%L
5    * Dali :: Core
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2015 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import fr.ifremer.quadrige3.core.dao.system.filter.FilterTypeId;
27  
28  import static org.nuiton.i18n.I18n.n;
29  import static org.nuiton.i18n.I18n.t;
30  
31  /**
32   * Context filter enum.
33   */
34  public enum FilterTypeValues {
35  
36      ANALYSIS_INSTRUMENT(FilterTypeId.ANALYSIS_INSTRUMENT, n("dali.core.enums.contextFilter.analysisInstrument")),
37      SAMPLING_EQUIPMENT(FilterTypeId.SAMPLING_EQUIPMENT, n("dali.core.enums.contextFilter.samplingEquipment")),
38      TAXON_GROUP(FilterTypeId.TAXON_GROUP, n("dali.core.enums.contextFilter.taxonGroup")),
39      LOCATION(FilterTypeId.MONITORING_LOCATION, n("dali.core.enums.contextFilter.location")),
40      PROGRAM(FilterTypeId.PROGRAM, n("dali.core.enums.contextFilter.program")),
41      PMFM(FilterTypeId.PMFM, n("dali.core.enums.contextFilter.pmfm")),
42      DEPARTMENT(FilterTypeId.DEPARTMENT, n("dali.core.enums.contextFilter.department")),
43      TAXON(FilterTypeId.TAXON_NAME, n("dali.core.enums.contextFilter.taxon")),
44      USER(FilterTypeId.QUSER, n("dali.core.enums.contextFilter.user")),
45      CAMPAIGN(FilterTypeId.CAMPAIGN, n("dali.core.enums.contextFilter.campaign"));
46  
47      private final FilterTypeId filterTypeId;
48      private final String keyLabel;
49  
50      FilterTypeValues(FilterTypeId filterType, String keyLabel) {
51          this.filterTypeId = filterType;
52          this.keyLabel = keyLabel;
53      }
54  
55      /**
56       * <p>getLabel.</p>
57       *
58       * @return a {@link java.lang.String} object.
59       */
60      public String getLabel() {
61          return t(this.keyLabel);
62      }
63  
64      /**
65       * <p>Getter for the field <code>filterTypeId</code>.</p>
66       *
67       * @return a {@link java.lang.Integer} object.
68       */
69      public Integer getFilterTypeId() {
70          return this.filterTypeId != null ? this.filterTypeId.getValue() : -1;
71      }
72  
73      /**
74       * <p>getFilterType.</p>
75       *
76       * @param filterTypeId a {@link java.lang.Integer} object.
77       * @return a {@link FilterTypeValues} object.
78       */
79      public static FilterTypeValues getFilterType(final Integer filterTypeId) {
80          for (final FilterTypeValues filterType : values()) {
81              if (filterType.getFilterTypeId().equals(filterTypeId)) {
82                  return filterType;
83              }
84          }
85          return null;
86      }
87  }