View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.manage.program.programs;
2   
3   /*
4    * #%L
5    * Reef DB :: 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 fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
27  import fr.ifremer.reefdb.dto.ErrorDTO;
28  import fr.ifremer.reefdb.dto.ReefDbBeanFactory;
29  import fr.ifremer.reefdb.dto.ReefDbBeans;
30  import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
31  import fr.ifremer.reefdb.dto.configuration.programStrategy.StrategyDTO;
32  import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
33  import fr.ifremer.reefdb.dto.referential.LocationDTO;
34  import fr.ifremer.reefdb.dto.referential.PersonDTO;
35  import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbRowUIModel;
36  import org.nuiton.util.beans.Binder;
37  import org.nuiton.util.beans.BinderFactory;
38  
39  import java.util.Collection;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * Modele pour le tableau de programmes.
45   */
46  public class ProgramsTableRowModel extends AbstractReefDbRowUIModel<ProgramDTO, ProgramsTableRowModel> implements ProgramDTO {
47  
48      private static final Binder<ProgramDTO, ProgramsTableRowModel> FROM_BEAN_BINDER =
49              BinderFactory.newBinder(ProgramDTO.class, ProgramsTableRowModel.class);
50      private static final Binder<ProgramsTableRowModel, ProgramDTO> TO_BEAN_BINDER =
51              BinderFactory.newBinder(ProgramsTableRowModel.class, ProgramDTO.class);
52      private boolean currentUserIsManager;
53      private boolean strategiesValid = true;
54      private boolean locationsValid = true;
55  
56      /**
57       * Constructor.
58       */
59      public ProgramsTableRowModel() {
60          super(FROM_BEAN_BINDER, TO_BEAN_BINDER);
61      }
62  
63      /**
64       * <p>isCurrentUserIsManager.</p>
65       *
66       * @return a boolean.
67       */
68      public boolean isCurrentUserIsManager() {
69          return currentUserIsManager;
70      }
71  
72      /**
73       * <p>Setter for the field <code>currentUserIsManager</code>.</p>
74       *
75       * @param currentUserIsManager a boolean.
76       */
77      public void setCurrentUserIsManager(boolean currentUserIsManager) {
78          this.currentUserIsManager = currentUserIsManager;
79      }
80  
81      /**
82       * <p>isStrategiesValid.</p>
83       *
84       * @return a boolean.
85       */
86      public boolean isStrategiesValid() {
87          return strategiesValid;
88      }
89  
90      /**
91       * <p>Setter for the field <code>strategiesValid</code>.</p>
92       *
93       * @param strategiesValid a boolean.
94       */
95      public void setStrategiesValid(boolean strategiesValid) {
96          this.strategiesValid = strategiesValid;
97      }
98  
99      /**
100      * <p>isLocationsValid.</p>
101      *
102      * @return a boolean.
103      */
104     public boolean isLocationsValid() {
105         return locationsValid;
106     }
107 
108     /**
109      * <p>Setter for the field <code>locationsValid</code>.</p>
110      *
111      * @param locationsValid a boolean.
112      */
113     public void setLocationsValid(boolean locationsValid) {
114         this.locationsValid = locationsValid;
115     }
116 
117     /** {@inheritDoc} */
118     @Override
119     public boolean isEditable() {
120         return super.isEditable() && !isReadOnly() && isCurrentUserIsManager();
121     }
122 
123     /**
124      * <p>isLocal.</p>
125      *
126      * @return a boolean.
127      */
128     public boolean isLocal() {
129         return ReefDbBeans.isLocalStatus(getStatus());
130     }
131 
132     /** {@inheritDoc} */
133     @Override
134     protected ProgramDTO newBean() {
135         return ReefDbBeanFactory.newProgramDTO();
136     }
137 
138     /** {@inheritDoc} */
139     @Override
140     public StatusDTO getStatus() {
141         return delegateObject.getStatus();
142     }
143 
144     /** {@inheritDoc} */
145     @Override
146     public void setStatus(StatusDTO status) {
147         delegateObject.setStatus(status);
148     }
149 
150     /** {@inheritDoc} */
151     @Override
152     public String getCode() {
153         return delegateObject.getCode();
154     }
155 
156     /** {@inheritDoc} */
157     @Override
158     public void setCode(String code) {
159         delegateObject.setCode(code);
160     }
161 
162     @Override
163     public String getDescription() {
164         return delegateObject.getDescription();
165     }
166 
167     @Override
168     public void setDescription(String description) {
169         delegateObject.setDescription(description);
170     }
171 
172     /** {@inheritDoc} */
173     @Override
174     public String getName() {
175         return delegateObject.getName();
176     }
177 
178     /** {@inheritDoc} */
179     @Override
180     public void setName(String name) {
181         delegateObject.setName(name);
182     }
183 
184     /** {@inheritDoc} */
185     @Override
186     public String getComment() {
187         return delegateObject.getComment();
188     }
189 
190     /** {@inheritDoc} */
191     @Override
192     public void setComment(String comment) {
193         delegateObject.setComment(comment);
194     }
195 
196     /** {@inheritDoc} */
197     @Override
198     public StrategyDTO getStrategies(int index) {
199         return delegateObject.getStrategies(index);
200     }
201 
202     /** {@inheritDoc} */
203     @Override
204     public boolean isStrategiesEmpty() {
205         return delegateObject.isStrategiesEmpty();
206     }
207 
208     /** {@inheritDoc} */
209     @Override
210     public int sizeStrategies() {
211         return delegateObject.sizeStrategies();
212     }
213 
214     /** {@inheritDoc} */
215     @Override
216     public void addStrategies(StrategyDTO strategy) {
217         delegateObject.addStrategies(strategy);
218     }
219 
220     /** {@inheritDoc} */
221     @Override
222     public void addAllStrategies(Collection<StrategyDTO> strategy) {
223         delegateObject.addAllStrategies(strategy);
224     }
225 
226     /** {@inheritDoc} */
227     @Override
228     public boolean removeStrategies(StrategyDTO strategy) {
229         return delegateObject.removeStrategies(strategy);
230     }
231 
232     /** {@inheritDoc} */
233     @Override
234     public boolean removeAllStrategies(Collection<StrategyDTO> strategy) {
235         return delegateObject.removeAllStrategies(strategy);
236     }
237 
238     /** {@inheritDoc} */
239     @Override
240     public boolean containsStrategies(StrategyDTO strategy) {
241         return delegateObject.containsStrategies(strategy);
242     }
243 
244     /** {@inheritDoc} */
245     @Override
246     public boolean containsAllStrategies(Collection<StrategyDTO> strategy) {
247         return delegateObject.containsAllStrategies(strategy);
248     }
249 
250     /** {@inheritDoc} */
251     @Override
252     public Collection<StrategyDTO> getStrategies() {
253         return delegateObject.getStrategies();
254     }
255 
256     /** {@inheritDoc} */
257     @Override
258     public void setStrategies(Collection<StrategyDTO> strategy) {
259         delegateObject.setStrategies(strategy);
260     }
261 
262     /** {@inheritDoc} */
263     @Override
264     public LocationDTO getLocations(int index) {
265         return delegateObject.getLocations(index);
266     }
267 
268     /** {@inheritDoc} */
269     @Override
270     public boolean isLocationsEmpty() {
271         return delegateObject.isLocationsEmpty();
272     }
273 
274     /** {@inheritDoc} */
275     @Override
276     public int sizeLocations() {
277         return delegateObject.sizeLocations();
278     }
279 
280     /** {@inheritDoc} */
281     @Override
282     public void addLocations(LocationDTO location) {
283         delegateObject.addLocations(location);
284     }
285 
286     /** {@inheritDoc} */
287     @Override
288     public void addAllLocations(Collection<LocationDTO> location) {
289         delegateObject.addAllLocations(location);
290     }
291 
292     /** {@inheritDoc} */
293     @Override
294     public boolean removeLocations(LocationDTO location) {
295         return delegateObject.removeLocations(location);
296     }
297 
298     /** {@inheritDoc} */
299     @Override
300     public boolean removeAllLocations(Collection<LocationDTO> location) {
301         return delegateObject.removeAllLocations(location);
302     }
303 
304     /** {@inheritDoc} */
305     @Override
306     public boolean containsLocations(LocationDTO location) {
307         return delegateObject.containsLocations(location);
308     }
309 
310     /** {@inheritDoc} */
311     @Override
312     public boolean containsAllLocations(Collection<LocationDTO> location) {
313         return delegateObject.containsAllLocations(location);
314     }
315 
316     /** {@inheritDoc} */
317     @Override
318     public List<LocationDTO> getLocations() {
319         return delegateObject.getLocations();
320     }
321 
322     /** {@inheritDoc} */
323     @Override
324     public void setLocations(List<LocationDTO> location) {
325         delegateObject.setLocations(location);
326     }
327 
328     /** {@inheritDoc} */
329     @Override
330     public ErrorDTO getErrors(int index) {
331         return delegateObject.getErrors(index);
332     }
333 
334     /** {@inheritDoc} */
335     @Override
336     public boolean isErrorsEmpty() {
337         return delegateObject.isErrorsEmpty();
338     }
339 
340     /** {@inheritDoc} */
341     @Override
342     public int sizeErrors() {
343         return delegateObject.sizeErrors();
344     }
345 
346     /** {@inheritDoc} */
347     @Override
348     public void addErrors(ErrorDTO errors) {
349         delegateObject.addErrors(errors);
350     }
351 
352     /** {@inheritDoc} */
353     @Override
354     public void addAllErrors(Collection<ErrorDTO> errors) {
355         delegateObject.addAllErrors(errors);
356     }
357 
358     /** {@inheritDoc} */
359     @Override
360     public boolean removeErrors(ErrorDTO errors) {
361         return delegateObject.removeErrors(errors);
362     }
363 
364     /** {@inheritDoc} */
365     @Override
366     public boolean removeAllErrors(Collection<ErrorDTO> errors) {
367         return delegateObject.removeAllErrors(errors);
368     }
369 
370     /** {@inheritDoc} */
371     @Override
372     public boolean containsErrors(ErrorDTO errors) {
373         return delegateObject.containsErrors(errors);
374     }
375 
376     /** {@inheritDoc} */
377     @Override
378     public boolean containsAllErrors(Collection<ErrorDTO> errors) {
379         return delegateObject.containsAllErrors(errors);
380     }
381 
382     /** {@inheritDoc} */
383     @Override
384     public Collection<ErrorDTO> getErrors() {
385         return delegateObject.getErrors();
386     }
387 
388     /** {@inheritDoc} */
389     @Override
390     public void setErrors(Collection<ErrorDTO> errors) {
391         delegateObject.setErrors(errors);
392     }
393 
394     /** {@inheritDoc} */
395     @Override
396     public PersonDTO getManagerPersons(int index) {
397         return delegateObject.getManagerPersons(index);
398     }
399 
400     /** {@inheritDoc} */
401     @Override
402     public boolean isManagerPersonsEmpty() {
403         return delegateObject.isManagerPersonsEmpty();
404     }
405 
406     /** {@inheritDoc} */
407     @Override
408     public int sizeManagerPersons() {
409         return delegateObject.sizeManagerPersons();
410     }
411 
412     /** {@inheritDoc} */
413     @Override
414     public void addManagerPersons(PersonDTO managerPersons) {
415         delegateObject.addManagerPersons(managerPersons);
416     }
417 
418     /** {@inheritDoc} */
419     @Override
420     public void addAllManagerPersons(Collection<PersonDTO> managerPersons) {
421         delegateObject.addAllManagerPersons(managerPersons);
422     }
423 
424     /** {@inheritDoc} */
425     @Override
426     public boolean removeManagerPersons(PersonDTO managerPersons) {
427         return delegateObject.removeManagerPersons(managerPersons);
428     }
429 
430     /** {@inheritDoc} */
431     @Override
432     public boolean removeAllManagerPersons(Collection<PersonDTO> managerPersons) {
433         return delegateObject.removeAllManagerPersons(managerPersons);
434     }
435 
436     /** {@inheritDoc} */
437     @Override
438     public boolean containsManagerPersons(PersonDTO managerPersons) {
439         return delegateObject.containsManagerPersons(managerPersons);
440     }
441 
442     /** {@inheritDoc} */
443     @Override
444     public boolean containsAllManagerPersons(Collection<PersonDTO> managerPersons) {
445         return delegateObject.containsAllManagerPersons(managerPersons);
446     }
447 
448     /** {@inheritDoc} */
449     @Override
450     public Collection<PersonDTO> getManagerPersons() {
451         return delegateObject.getManagerPersons();
452     }
453 
454     /** {@inheritDoc} */
455     @Override
456     public void setManagerPersons(Collection<PersonDTO> managerPersons) {
457         delegateObject.setManagerPersons(managerPersons);
458     }
459 
460     /** {@inheritDoc} */
461     @Override
462     public PersonDTO getRecorderPersons(int index) {
463         return delegateObject.getRecorderPersons(index);
464     }
465 
466     /** {@inheritDoc} */
467     @Override
468     public boolean isRecorderPersonsEmpty() {
469         return delegateObject.isRecorderPersonsEmpty();
470     }
471 
472     /** {@inheritDoc} */
473     @Override
474     public int sizeRecorderPersons() {
475         return delegateObject.sizeRecorderPersons();
476     }
477 
478     /** {@inheritDoc} */
479     @Override
480     public void addRecorderPersons(PersonDTO recorderPersons) {
481         delegateObject.addRecorderPersons(recorderPersons);
482     }
483 
484     /** {@inheritDoc} */
485     @Override
486     public void addAllRecorderPersons(Collection<PersonDTO> recorderPersons) {
487         delegateObject.addAllRecorderPersons(recorderPersons);
488     }
489 
490     /** {@inheritDoc} */
491     @Override
492     public boolean removeRecorderPersons(PersonDTO recorderPersons) {
493         return delegateObject.removeRecorderPersons(recorderPersons);
494     }
495 
496     /** {@inheritDoc} */
497     @Override
498     public boolean removeAllRecorderPersons(Collection<PersonDTO> recorderPersons) {
499         return delegateObject.removeAllRecorderPersons(recorderPersons);
500     }
501 
502     /** {@inheritDoc} */
503     @Override
504     public boolean containsRecorderPersons(PersonDTO recorderPersons) {
505         return delegateObject.containsRecorderPersons(recorderPersons);
506     }
507 
508     /** {@inheritDoc} */
509     @Override
510     public boolean containsAllRecorderPersons(Collection<PersonDTO> recorderPersons) {
511         return delegateObject.containsAllRecorderPersons(recorderPersons);
512     }
513 
514     /** {@inheritDoc} */
515     @Override
516     public Collection<PersonDTO> getRecorderPersons() {
517         return delegateObject.getRecorderPersons();
518     }
519 
520     /** {@inheritDoc} */
521     @Override
522     public void setRecorderPersons(Collection<PersonDTO> recorderPersons) {
523         delegateObject.setRecorderPersons(recorderPersons);
524     }
525 
526     /** {@inheritDoc} */
527     @Override
528     public DepartmentDTO getRecorderDepartments(int index) {
529         return delegateObject.getRecorderDepartments(index);
530     }
531 
532     /** {@inheritDoc} */
533     @Override
534     public boolean isRecorderDepartmentsEmpty() {
535         return delegateObject.isRecorderDepartmentsEmpty();
536     }
537 
538     /** {@inheritDoc} */
539     @Override
540     public int sizeRecorderDepartments() {
541         return delegateObject.sizeRecorderDepartments();
542     }
543 
544     /** {@inheritDoc} */
545     @Override
546     public void addRecorderDepartments(DepartmentDTO recorderDepartments) {
547         delegateObject.addRecorderDepartments(recorderDepartments);
548     }
549 
550     /** {@inheritDoc} */
551     @Override
552     public void addAllRecorderDepartments(Collection<DepartmentDTO> recorderDepartments) {
553         delegateObject.addAllRecorderDepartments(recorderDepartments);
554     }
555 
556     /** {@inheritDoc} */
557     @Override
558     public boolean removeRecorderDepartments(DepartmentDTO recorderDepartments) {
559         return delegateObject.removeRecorderDepartments(recorderDepartments);
560     }
561 
562     /** {@inheritDoc} */
563     @Override
564     public boolean removeAllRecorderDepartments(Collection<DepartmentDTO> recorderDepartments) {
565         return delegateObject.removeAllRecorderDepartments(recorderDepartments);
566     }
567 
568     /** {@inheritDoc} */
569     @Override
570     public boolean containsRecorderDepartments(DepartmentDTO recorderDepartments) {
571         return delegateObject.containsRecorderDepartments(recorderDepartments);
572     }
573 
574     /** {@inheritDoc} */
575     @Override
576     public boolean containsAllRecorderDepartments(Collection<DepartmentDTO> recorderDepartments) {
577         return delegateObject.containsAllRecorderDepartments(recorderDepartments);
578     }
579 
580     /** {@inheritDoc} */
581     @Override
582     public Collection<DepartmentDTO> getRecorderDepartments() {
583         return delegateObject.getRecorderDepartments();
584     }
585 
586     /** {@inheritDoc} */
587     @Override
588     public void setRecorderDepartments(Collection<DepartmentDTO> recorderDepartments) {
589         delegateObject.setRecorderDepartments(recorderDepartments);
590     }
591 
592     /** {@inheritDoc} */
593     @Override
594     public boolean isStrategiesLoaded() {
595         return delegateObject.isStrategiesLoaded();
596     }
597 
598     /** {@inheritDoc} */
599     @Override
600     public void setStrategiesLoaded(boolean strategiesLoaded) {
601         delegateObject.setStrategiesLoaded(strategiesLoaded);
602     }
603 
604     /** {@inheritDoc} */
605     @Override
606     public boolean isLocationsLoaded() {
607         return delegateObject.isLocationsLoaded();
608     }
609 
610     /** {@inheritDoc} */
611     @Override
612     public void setLocationsLoaded(boolean locationsLoaded) {
613         delegateObject.setLocationsLoaded(locationsLoaded);
614     }
615 
616     /** {@inheritDoc} */
617     @Override
618     public boolean isDirty() {
619         return delegateObject.isDirty();
620     }
621 
622     /** {@inheritDoc} */
623     @Override
624     public void setDirty(boolean dirty) {
625         delegateObject.setDirty(dirty);
626     }
627 
628     @Override
629     public boolean isReadOnly() {
630         return delegateObject.isReadOnly();
631     }
632 
633     @Override
634     public void setReadOnly(boolean readOnly) {
635         delegateObject.setReadOnly(readOnly);
636     }
637 
638     /** {@inheritDoc} */
639     @Override
640     public boolean isNewCode() {
641         return delegateObject.isNewCode();
642     }
643 
644     /** {@inheritDoc} */
645     @Override
646     public void setNewCode(boolean newCode) {
647         delegateObject.setNewCode(newCode);
648     }
649 
650     @Override
651     public boolean isDepartmentHermetic() {
652         return delegateObject.isDepartmentHermetic();
653     }
654 
655     @Override
656     public void setDepartmentHermetic(boolean departmentHermetic) {
657         delegateObject.setDepartmentHermetic(departmentHermetic);
658     }
659 
660     @Override
661     public Date getCreationDate() {
662         return delegateObject.getCreationDate();
663     }
664 
665     @Override
666     public void setCreationDate(Date date) {
667         delegateObject.setCreationDate(date);
668     }
669 
670     @Override
671     public Date getUpdateDate() {
672         return delegateObject.getUpdateDate();
673     }
674 
675     @Override
676     public void setUpdateDate(Date date) {
677         delegateObject.setUpdateDate(date);
678     }
679 
680 
681 }