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   * Extraction filter enum.
33   */
34  public enum ExtractionFilterTypeValues {
35  
36      PERIOD(null, n("dali.core.enums.extractionFilter.period"), false),
37      PROGRAM(FilterTypeId.PROGRAM, n("dali.core.enums.extractionFilter.program"), false),
38      LOCATION(FilterTypeId.MONITORING_LOCATION, n("dali.core.enums.extractionFilter.location"), false),
39      CAMPAIGN(FilterTypeId.CAMPAIGN, n("dali.core.enums.extractionFilter.campaign"), false),
40      TAXON(FilterTypeId.TAXON_NAME, n("dali.core.enums.extractionFilter.taxon"), false),
41      TAXON_GROUP(FilterTypeId.TAXON_GROUP, n("dali.core.enums.extractionFilter.taxonGroup"), false),
42      SAMPLING_EQUIPMENT(FilterTypeId.SAMPLING_EQUIPMENT, n("dali.core.enums.extractionFilter.samplingEquipment"), false),
43      DEPARTMENT(FilterTypeId.DEPARTMENT, n("dali.core.enums.extractionFilter.department"), false),
44      PMFM(FilterTypeId.PMFM, n("dali.core.enums.extractionFilter.pmfm"), false),
45      ORDER_ITEM_TYPE(FilterTypeId.ORDER_ITEM_TYPE, n("dali.core.enums.extractionFilter.orderItemType"), true);
46  
47      private final FilterTypeId filterTypeId;
48      private final String keyLabel;
49      private final boolean hidden;
50  
51      ExtractionFilterTypeValues(FilterTypeId filterType, String keyLabel, boolean hidden) {
52          this.filterTypeId = filterType;
53          this.keyLabel = keyLabel;
54          this.hidden = hidden;
55      }
56  
57      /**
58       * <p>getLabel.</p>
59       *
60       * @return a {@link java.lang.String} object.
61       */
62      public String getLabel() {
63          return t(this.keyLabel);
64      }
65  
66      /**
67       * <p>Getter for the field <code>filterTypeId</code>.</p>
68       *
69       * @return a {@link java.lang.Integer} object.
70       */
71      public Integer getFilterTypeId() {
72          return this.filterTypeId != null ? this.filterTypeId.getValue() : -1;
73      }
74  
75      /**
76       * <p>isHidden.</p>
77       *
78       * @return a boolean.
79       */
80      public boolean isHidden() {
81          return this.hidden;
82      }
83  
84      /**
85       * <p>getExtractionFilter.</p>
86       *
87       * @param filterTypeId a {@link java.lang.Integer} object.
88       * @return a {@link ExtractionFilterTypeValues} object.
89       */
90      public static ExtractionFilterTypeValues getExtractionFilterType(final Integer filterTypeId) {
91          for (final ExtractionFilterTypeValues value : values()) {
92              if (value.getFilterTypeId().equals(filterTypeId)) {
93                  return value;
94              }
95          }
96          return null;
97      }
98  }