ref #5458 Remove unnecessary method parameters
[cdm-vaadin.git] / src / main / java / eu / etaxonomy / cdm / vaadin / model / CdmTaxonTableCollection.java
1 package eu.etaxonomy.cdm.vaadin.model;
2
3 import java.util.Collection;
4 import java.util.UUID;
5
6 import eu.etaxonomy.cdm.model.common.CdmBase;
7 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
8 import eu.etaxonomy.cdm.model.description.Distribution;
9 import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
10 import eu.etaxonomy.cdm.model.name.Rank;
11 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
12 import eu.etaxonomy.cdm.model.taxon.Taxon;
13
14 public class CdmTaxonTableCollection{
15
16
17 private Taxon taxon;
18
19 private Collection<DescriptionElementBase> listTaxonDescription;
20
21
22 private String fullTitleCache;
23
24 private Rank rank;
25
26
27 public CdmTaxonTableCollection(Taxon taxon, Collection<DescriptionElementBase> listTaxonDescription){
28 this.taxon = CdmBase.deproxy(taxon, Taxon.class);
29 this.listTaxonDescription = listTaxonDescription;
30 }
31
32 public CdmTaxonTableCollection(Taxon taxon){
33 this.taxon = CdmBase.deproxy(taxon, Taxon.class);
34 }
35
36 //----Getter - Setter - methods ----//
37 /**
38 *
39 * @return
40 */
41 public String getFullTitleCache() {
42 TaxonNameBase name = taxon.getName();
43 name = CdmBase.deproxy(name, TaxonNameBase.class);
44 if(name == null){
45 return "-";
46 }
47 return name.getFullTitleCache();
48 }
49 /**
50 *
51 * @param fullTitleCache
52 */
53 public void setFullTitleCache(String fullTitleCache) {
54 taxon.getName().setFullTitleCache(fullTitleCache, true);
55 taxon.setTitleCache(fullTitleCache, true);
56 }
57 /**
58 *
59 * @return
60 */
61 public Taxon getTaxon() {
62 return taxon;
63 }
64
65 public void setTaxon(Taxon taxon){
66 this.taxon = taxon;
67 }
68
69
70
71 /**
72 * Returns the taxonomic {@link Rank rank} of <i>this</i> taxon name.
73 *
74 * @see Rank
75 */
76 public String getRank(){
77 rank = taxon.getName().getRank();
78 if(rank == null){
79 return "-";
80 }
81 return rank.toString();
82 }
83
84 public UUID getUUID(){
85 return taxon.getUuid();
86 }
87
88 /**
89 * @see #getRank()
90 */
91 public void setRank(Rank rank){
92 taxon.getName().setRank(rank);
93 }
94 /**
95 *
96 * @return
97 */
98 public PresenceAbsenceTerm getDistributionStatus(String distribution){
99 Distribution db = getDistribution(distribution);
100 if(db != null){
101 return db.getStatus();
102 }
103 return null;
104 }
105
106 // public ComboBox getDistributionComboBox(){
107 // if(getDistributionStatus() != null && termList != null){
108 // BeanItemContainer<PresenceAbsenceTermBase> container = new BeanItemContainer<PresenceAbsenceTermBase>(PresenceAbsenceTermBase.class);
109 // container.addAll(termList);
110 // final ComboBox box = new ComboBox();
111 // box.setContainerDataSource(container);
112 // box.setImmediate(true);
113 //// setValueChangeListener(box);
114 // if(getDistributionStatus() != null){
115 // box.setValue(getDistributionStatus());
116 // }
117 // return box;
118 // }else{
119 // return null;
120 // }
121 // }
122
123
124
125 // private void setValueChangeListener(final ComboBox box){
126 // box.addValueChangeListener(new ValueChangeListener() {
127 // private static final long serialVersionUID = 1L;
128 // @Override
129 // public void valueChange(ValueChangeEvent event) {
130 // logger.info("Value Change: "+ box.getValue());
131 // setDistributionStatus((PresenceAbsenceTermBase<?>)box.getValue());
132 // }
133 // });
134 // }
135
136 /**
137 *
138 * @param status
139 */
140 public void setDistributionStatus(String distribution, PresenceAbsenceTerm status){
141 Distribution db = getDistribution(distribution);
142 if(db != null){
143 db.setStatus(status);
144 // DescriptionServiceImpl desc = new DescriptionServiceImpl();
145 // desc.saveDescriptionElement(db);
146 // descriptionService.saveDescriptionElement(db);
147 }
148 }
149 /**
150 *
151 * @return
152 */
153 public Distribution getDistribution(String distribution){
154 if(listTaxonDescription != null){
155 for(DescriptionElementBase deb : listTaxonDescription){
156 if(deb instanceof Distribution){
157 //FIXME HOW TO IMPLEMENT A FILTER ???
158 Distribution db = (Distribution)deb;
159 if(db.getArea().getTitleCache().equalsIgnoreCase(distribution)){
160 return db;
161 }
162 }
163 }
164 }
165 return null;
166 }
167
168
169 //----------- Detail View ------------------//
170
171 /**
172 *
173 * @return
174 */
175 public String getTaxonNameCache(){
176 return taxon.getName().getTitleCache();
177 }
178
179 public void setTaxonNameCache(String titlecache){
180 taxon.getName().setTitleCache(titlecache, true);
181 }
182 /**
183 *
184 * @return
185 */
186 public String getNomenclaturalCode(){
187 return taxon.getName().getNomenclaturalCode().getTitleCache();
188 }
189 /**
190 *
191 * @return
192 */
193 public String getSecundum(){
194 return taxon.getSec().toString();
195 }
196
197
198 }