View Javadoc
1   package fr.ifremer.dali.ui.swing.content.observation.operation.measurement.ungrouped;
2   
3   /*
4    * #%L
5    * Dali :: UI
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 com.google.common.collect.Lists;
27  import fr.ifremer.dali.dto.data.measurement.MeasurementDTO;
28  import fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO;
29  import fr.ifremer.dali.ui.swing.content.observation.ObservationUIModel;
30  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableUIModel;
31  
32  import java.util.List;
33  
34  /**
35   * Modele pour le tableau du haut (Psfm) pour l onglet des mesures des prelevements.
36   */
37  public class OperationMeasurementsUngroupedTableUIModel extends AbstractDaliTableUIModel<SamplingOperationDTO, OperationMeasurementsUngroupedRowModel, OperationMeasurementsUngroupedTableUIModel> {
38  
39      /** Constant <code>PROPERTY_SURVEY="survey"</code> */
40      public static final String PROPERTY_SURVEY = "survey";
41      /** Constant <code>PROPERTY_SAMPLING_FILTER="samplingFilter"</code> */
42      public static final String PROPERTY_SAMPLING_FILTER = "samplingFilter";
43      private ObservationUIModel survey;
44      private SamplingOperationDTO samplingFilter;
45  
46      /**
47       * Constructor.
48       */
49      public OperationMeasurementsUngroupedTableUIModel() {
50          super();
51      }
52  
53      /**
54       * <p>Getter for the field <code>survey</code>.</p>
55       *
56       * @return a {@link fr.ifremer.dali.ui.swing.content.observation.ObservationUIModel} object.
57       */
58      public ObservationUIModel getSurvey() {
59          return survey;
60      }
61  
62      /**
63       * <p>Setter for the field <code>survey</code>.</p>
64       *
65       * @param survey a {@link fr.ifremer.dali.ui.swing.content.observation.ObservationUIModel} object.
66       */
67      public void setSurvey(ObservationUIModel survey) {
68          this.survey = survey;
69          firePropertyChange(PROPERTY_SURVEY, null, survey);
70      }
71  
72      /**
73       * <p>getSamplingOperations.</p>
74       *
75       * @return a {@link java.util.List} object.
76       */
77      public List<SamplingOperationDTO> getSamplingOperations() {
78          return survey == null ? null : (List<SamplingOperationDTO>) survey.getSamplingOperations();
79      }
80  
81      /**
82       * <p>Getter for the field <code>samplingFilter</code>.</p>
83       *
84       * @return a {@link fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO} object.
85       */
86      public SamplingOperationDTO getSamplingFilter() {
87          return samplingFilter;
88      }
89  
90      /**
91       * <p>Setter for the field <code>samplingFilter</code>.</p>
92       *
93       * @param samplingFilter a {@link fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO} object.
94       */
95      public void setSamplingFilter(SamplingOperationDTO samplingFilter) {
96          Object oldFilter = getSamplingFilter();
97          this.samplingFilter = samplingFilter;
98          firePropertyChange(PROPERTY_SAMPLING_FILTER, oldFilter, samplingFilter);
99      }
100 
101     /**
102      * <p>getAllMeasurements.</p>
103      *
104      * @return a {@link java.util.List} object.
105      */
106     public List<MeasurementDTO> getAllMeasurements() {
107         List<MeasurementDTO> measurements = Lists.newArrayList();
108         if (getSamplingOperations() != null) {
109             for (SamplingOperationDTO samplingOperation : getSamplingOperations()) {
110                 measurements.addAll(samplingOperation.getMeasurements());
111             }
112         }
113         return measurements;
114     }
115 }