1 // license-header java merge-point 2 // 3 // Attention: Generated code! Do not modify by hand! 4 // Generated by: hibernate/HibernateEntity.vsl in andromda-hibernate-cartridge. 5 // 6 package fr.ifremer.quadrige2.core.dao.referential.taxon; 7 8 /*- 9 * #%L 10 * Quadrige2 Core :: Server API 11 * %% 12 * Copyright (C) 2017 Ifremer 13 * %% 14 * This program is free software: you can redistribute it and/or modify 15 * it under the terms of the GNU Affero General Public License as published by 16 * the Free Software Foundation, either version 3 of the License, or 17 * (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU Affero General Public License 25 * along with this program. If not, see <http://www.gnu.org/licenses/>. 26 * #L% 27 */ 28 29 import fr.ifremer.quadrige2.core.dao.sandre.SandreTaxonExp; 30 import fr.ifremer.quadrige2.core.dao.sandre.SandreTaxonImp; 31 import java.io.Serializable; 32 import java.sql.Timestamp; 33 import java.util.Collection; 34 import java.util.HashSet; 35 36 /** 37 * Liste des taxons qui sont la référence. 38 * l'ID référent est indépendant des ID taxon car les taxons peuvent être référents à un moment et 39 * ne plus l'être par la suite. 40 * Toutes les données du système doivent donc être reliées au référent et non au taxon qui sont 41 * référents à un moment mais ne peuvent plus l'être par la suite. 42 * Le fonctionnement dans la table TAXON_NAME est le suivant : 43 * - REF_TAXON_ID est toujours renseigné 44 * - si TAXON_NAME_IS_REFER est à vrai, il s'agit d'un taxon référent (toujours le cas s'il s'agit 45 * d'un taxon virtuel) 46 * - sinon c'est un synonyme 47 * Un taxon référent qui devient synonyme voit donc son statut TAXON_NAME_IS_REFER changer et le 48 * nouveau taxon référent qui le remplace récupère l'information REF_TAXON_ID 49 * NB : c'était le comportement initialement prévu. 50 * En réalité, lorsqu'un taxon référent T1-R1 devient synonyme d'un nouveau taxon référent T2, le 51 * taxon T2 prend un nouveau code référent R2 et donc le taxon T1 est lié à R2 (et tous les 52 * synonymes et les résultats qu'il pouvait avoir). 53 * Ce mécanisme a été adopté car il fallait distinguer 2 cas : 54 * 1- cas d'un taxon référent T1-R1 qui devient synonyme d'un référent qu'on crée T2 : on aurait 55 * alors pu utiliser le même REF_TAXON_ID R1 au lieu d'en créer un et ne pas mettre à jour les 56 * autres synonymes, résultats... 57 * 2- cas d'un taxon référent T1-R1 qui devient synonyme d'un référent qui existe déjà T2-R2 (et qui 58 * aurait déjà d'autres synonymes, résultats...), dans ce cas le remplacement de la référence R1 59 * pour R2 est nécessaire 60 * La modélisation pourrait être revue car la table REFENCE_TAXON ne se justifie alors plus, on 61 * pourrait directement utiliser une référence à la colonne TAXON_NAME_ID pour désigner les 62 * référents 63 */ 64 // HibernateEntity.vsl annotations merge-point 65 public abstract class ReferenceTaxon 66 implements Serializable, Comparable<ReferenceTaxon> 67 { 68 /** 69 * The serial version UID of this class. Needed for serialization. 70 */ 71 private static final long serialVersionUID = 9178266362854772000L; 72 73 // Generate 2 attributes 74 private Integer refTaxonId; 75 76 /** 77 * Identifiant interne du taxon référent. 78 * @return this.refTaxonId Integer 79 */ 80 public Integer getRefTaxonId() 81 { 82 return this.refTaxonId; 83 } 84 85 /** 86 * Identifiant interne du taxon référent. 87 * @param refTaxonIdIn Integer 88 */ 89 public void setRefTaxonId(Integer refTaxonIdIn) 90 { 91 this.refTaxonId = refTaxonIdIn; 92 } 93 94 private Timestamp updateDt; 95 96 /** 97 * Date de modification de l'objet, mise à jour par le système 98 * @return this.updateDt Timestamp 99 */ 100 public Timestamp getUpdateDt() 101 { 102 return this.updateDt; 103 } 104 105 /** 106 * Date de modification de l'objet, mise à jour par le système 107 * @param updateDtIn Timestamp 108 */ 109 public void setUpdateDt(Timestamp updateDtIn) 110 { 111 this.updateDt = updateDtIn; 112 } 113 114 // Generate 10 associations 115 private Collection<SandreTaxonExp> sandreTaxonExpIds = new HashSet<SandreTaxonExp>(); 116 117 /** 118 * Taxons sandre pour les exports de données 119 * @return this.sandreTaxonExpIds Collection<SandreTaxonExp> 120 */ 121 public Collection<SandreTaxonExp> getSandreTaxonExpIds() 122 { 123 return this.sandreTaxonExpIds; 124 } 125 126 /** 127 * Taxons sandre pour les exports de données 128 * @param sandreTaxonExpIdsIn Collection<SandreTaxonExp> 129 */ 130 public void setSandreTaxonExpIds(Collection<SandreTaxonExp> sandreTaxonExpIdsIn) 131 { 132 this.sandreTaxonExpIds = sandreTaxonExpIdsIn; 133 } 134 135 /** 136 * Taxons sandre pour les exports de données 137 * @param elementToAdd SandreTaxonExp 138 * @return <tt>true</tt> if this collection changed as a result of the 139 * call 140 */ 141 public boolean addSandreTaxonExpIds(SandreTaxonExp elementToAdd) 142 { 143 return this.sandreTaxonExpIds.add(elementToAdd); 144 } 145 146 /** 147 * Taxons sandre pour les exports de données 148 * @param elementToRemove SandreTaxonExp 149 * @return <tt>true</tt> if this collection changed as a result of the 150 * call 151 */ 152 public boolean removeSandreTaxonExpIds(SandreTaxonExp elementToRemove) 153 { 154 return this.sandreTaxonExpIds.remove(elementToRemove); 155 } 156 157 private Collection<SandreTaxonImp> sandreTaxonImpIds = new HashSet<SandreTaxonImp>(); 158 159 /** 160 * Taxons sandre pour les imports de données 161 * @return this.sandreTaxonImpIds Collection<SandreTaxonImp> 162 */ 163 public Collection<SandreTaxonImp> getSandreTaxonImpIds() 164 { 165 return this.sandreTaxonImpIds; 166 } 167 168 /** 169 * Taxons sandre pour les imports de données 170 * @param sandreTaxonImpIdsIn Collection<SandreTaxonImp> 171 */ 172 public void setSandreTaxonImpIds(Collection<SandreTaxonImp> sandreTaxonImpIdsIn) 173 { 174 this.sandreTaxonImpIds = sandreTaxonImpIdsIn; 175 } 176 177 /** 178 * Taxons sandre pour les imports de données 179 * @param elementToAdd SandreTaxonImp 180 * @return <tt>true</tt> if this collection changed as a result of the 181 * call 182 */ 183 public boolean addSandreTaxonImpIds(SandreTaxonImp elementToAdd) 184 { 185 return this.sandreTaxonImpIds.add(elementToAdd); 186 } 187 188 /** 189 * Taxons sandre pour les imports de données 190 * @param elementToRemove SandreTaxonImp 191 * @return <tt>true</tt> if this collection changed as a result of the 192 * call 193 */ 194 public boolean removeSandreTaxonImpIds(SandreTaxonImp elementToRemove) 195 { 196 return this.sandreTaxonImpIds.remove(elementToRemove); 197 } 198 199 private Collection<VirtualComponent> virtualComponents = new HashSet<VirtualComponent>(); 200 201 /** 202 * 203 * @return this.virtualComponents Collection<VirtualComponent> 204 */ 205 public Collection<VirtualComponent> getVirtualComponents() 206 { 207 return this.virtualComponents; 208 } 209 210 /** 211 * 212 * @param virtualComponentsIn Collection<VirtualComponent> 213 */ 214 public void setVirtualComponents(Collection<VirtualComponent> virtualComponentsIn) 215 { 216 this.virtualComponents = virtualComponentsIn; 217 } 218 219 /** 220 * 221 * @param elementToAdd VirtualComponent 222 * @return <tt>true</tt> if this collection changed as a result of the 223 * call 224 */ 225 public boolean addVirtualComponents(VirtualComponent elementToAdd) 226 { 227 return this.virtualComponents.add(elementToAdd); 228 } 229 230 /** 231 * 232 * @param elementToRemove VirtualComponent 233 * @return <tt>true</tt> if this collection changed as a result of the 234 * call 235 */ 236 public boolean removeVirtualComponents(VirtualComponent elementToRemove) 237 { 238 return this.virtualComponents.remove(elementToRemove); 239 } 240 241 /** 242 * Returns <code>true</code> if the argument is an ReferenceTaxon instance and all identifiers for this entity 243 * equal the identifiers of the argument entity. Returns <code>false</code> otherwise. 244 */ 245 @Override 246 public boolean equals(Object object) 247 { 248 if (this == object) 249 { 250 return true; 251 } 252 if (!(object instanceof ReferenceTaxon)) 253 { 254 return false; 255 } 256 final ReferenceTaxon that = (ReferenceTaxon)object; 257 if (this.refTaxonId == null || that.getRefTaxonId() == null || !this.refTaxonId.equals(that.getRefTaxonId())) 258 { 259 return false; 260 } 261 return true; 262 } 263 264 /** 265 * Returns a hash code based on this entity's identifiers. 266 */ 267 @Override 268 public int hashCode() 269 { 270 int hashCode = 0; 271 hashCode = 29 * hashCode + (this.refTaxonId == null ? 0 : this.refTaxonId.hashCode()); 272 273 return hashCode; 274 } 275 276 /** 277 * Constructs new instances of {@link ReferenceTaxon}. 278 */ 279 public static final class Factory 280 { 281 /** 282 * Constructs a new instance of {@link ReferenceTaxon}. 283 * @return new ReferenceTaxonImpl() 284 */ 285 public static ReferenceTaxon newInstance() 286 { 287 return new ReferenceTaxonImpl(); 288 } 289 290 /** 291 * Constructs a new instance of {@link ReferenceTaxon}, taking all required and/or 292 * read-only properties as arguments, except for identifiers. 293 * @param updateDt Timestamp 294 * @return newInstance 295 */ 296 public static ReferenceTaxon newInstance(Timestamp updateDt) 297 { 298 final ReferenceTaxon entity = new ReferenceTaxonImpl(); 299 entity.setUpdateDt(updateDt); 300 return entity; 301 } 302 303 /** 304 * Constructs a new instance of {@link ReferenceTaxon}, taking all possible properties 305 * (except the identifier(s))as arguments. 306 * @param updateDt Timestamp 307 * @param sandreTaxonExpIds Collection<SandreTaxonExp> 308 * @param sandreTaxonImpIds Collection<SandreTaxonImp> 309 * @param virtualComponents Collection<VirtualComponent> 310 * @return newInstance ReferenceTaxon 311 */ 312 public static ReferenceTaxon newInstance(Timestamp updateDt, Collection<SandreTaxonExp> sandreTaxonExpIds, Collection<SandreTaxonImp> sandreTaxonImpIds, Collection<VirtualComponent> virtualComponents) 313 { 314 final ReferenceTaxon entity = new ReferenceTaxonImpl(); 315 entity.setUpdateDt(updateDt); 316 entity.setSandreTaxonExpIds(sandreTaxonExpIds); 317 entity.setSandreTaxonImpIds(sandreTaxonImpIds); 318 entity.setVirtualComponents(virtualComponents); 319 return entity; 320 } 321 } 322 323 /** 324 * @see Comparable#compareTo 325 */ 326 public int compareTo(ReferenceTaxon o) 327 { 328 int cmp = 0; 329 if (this.getRefTaxonId() != null) 330 { 331 cmp = this.getRefTaxonId().compareTo(o.getRefTaxonId()); 332 } 333 else 334 { 335 if (this.getUpdateDt() != null) 336 { 337 cmp = (cmp != 0 ? cmp : this.getUpdateDt().compareTo(o.getUpdateDt())); 338 } 339 } 340 return cmp; 341 } 342 // HibernateEntity.vsl merge-point 343 // ReferenceTaxon.java merge-point 344 }