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.quadrige3.core.dao.referential.taxon; 7 8 /*- 9 * #%L 10 * Quadrige3 Core :: Client API 11 * %% 12 * Copyright (C) 2017 - 2024 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 import java.io.Serializable; 29 import java.sql.Timestamp; 30 import java.util.Collection; 31 import java.util.HashSet; 32 33 /** 34 * Liste des taxons qui sont la référence. 35 * l'ID référent est indépendant des ID taxon car les taxons peuvent être référents à un moment et 36 * ne plus l'être par la suite. 37 * Toutes les données du système doivent donc être reliées au référent et non au taxon qui sont 38 * référents à un moment mais ne peuvent plus l'être par la suite. 39 * Le fonctionnement dans la table TAXON_NAME est le suivant : 40 * - REF_TAXON_ID est toujours renseigné 41 * - si TAXON_NAME_IS_REFER est à vrai, il s'agit d'un taxon référent (toujours le cas s'il s'agit 42 * d'un taxon virtuel) 43 * - sinon c'est un synonyme 44 * Un taxon référent qui devient synonyme voit donc son statut TAXON_NAME_IS_REFER changer et le 45 * nouveau taxon référent qui le remplace récupère l'information REF_TAXON_ID 46 * NB : c'était le comportement initialement prévu. 47 * En réalité, lorsqu'un taxon référent T1-R1 devient synonyme d'un nouveau taxon référent T2, le 48 * taxon T2 prend un nouveau code référent R2 et donc le taxon T1 est lié à R2 (et tous les 49 * synonymes et les résultats qu'il pouvait avoir). 50 * Ce mécanisme a été adopté car il fallait distinguer 2 cas : 51 * 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 52 * alors pu utiliser le même REF_TAXON_ID R1 au lieu d'en créer un et ne pas mettre à jour les 53 * autres synonymes, résultats... 54 * 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 55 * aurait déjà d'autres synonymes, résultats...), dans ce cas le remplacement de la référence R1 56 * pour R2 est nécessaire 57 * La modélisation pourrait être revue car la table REFENCE_TAXON ne se justifie alors plus, on 58 * pourrait directement utiliser une référence à la colonne TAXON_NAME_ID pour désigner les 59 * référents 60 */ 61 // HibernateEntity.vsl annotations merge-point 62 public abstract class ReferenceTaxon 63 implements Serializable, Comparable<ReferenceTaxon> 64 { 65 /** 66 * The serial version UID of this class. Needed for serialization. 67 */ 68 private static final long serialVersionUID = 9178266362854772000L; 69 70 // Generate 2 attributes 71 private Integer refTaxonId; 72 73 /** 74 * Identifiant interne du taxon référent. 75 * @return this.refTaxonId Integer 76 */ 77 public Integer getRefTaxonId() 78 { 79 return this.refTaxonId; 80 } 81 82 /** 83 * Identifiant interne du taxon référent. 84 * @param refTaxonIdIn Integer 85 */ 86 public void setRefTaxonId(Integer refTaxonIdIn) 87 { 88 this.refTaxonId = refTaxonIdIn; 89 } 90 91 private Timestamp updateDt; 92 93 /** 94 * Date de modification de l'objet, mise à jour par le système 95 * @return this.updateDt Timestamp 96 */ 97 public Timestamp getUpdateDt() 98 { 99 return this.updateDt; 100 } 101 102 /** 103 * Date de modification de l'objet, mise à jour par le système 104 * @param updateDtIn Timestamp 105 */ 106 public void setUpdateDt(Timestamp updateDtIn) 107 { 108 this.updateDt = updateDtIn; 109 } 110 111 // Generate 8 associations 112 private Collection<VirtualComponent> virtualComponents = new HashSet<VirtualComponent>(); 113 114 /** 115 * 116 * @return this.virtualComponents Collection<VirtualComponent> 117 */ 118 public Collection<VirtualComponent> getVirtualComponents() 119 { 120 return this.virtualComponents; 121 } 122 123 /** 124 * 125 * @param virtualComponentsIn Collection<VirtualComponent> 126 */ 127 public void setVirtualComponents(Collection<VirtualComponent> virtualComponentsIn) 128 { 129 this.virtualComponents = virtualComponentsIn; 130 } 131 132 /** 133 * 134 * @param elementToAdd VirtualComponent 135 * @return <tt>true</tt> if this collection changed as a result of the 136 * call 137 */ 138 public boolean addVirtualComponents(VirtualComponent elementToAdd) 139 { 140 return this.virtualComponents.add(elementToAdd); 141 } 142 143 /** 144 * 145 * @param elementToRemove VirtualComponent 146 * @return <tt>true</tt> if this collection changed as a result of the 147 * call 148 */ 149 public boolean removeVirtualComponents(VirtualComponent elementToRemove) 150 { 151 return this.virtualComponents.remove(elementToRemove); 152 } 153 154 /** 155 * Returns <code>true</code> if the argument is an ReferenceTaxon instance and all identifiers for this entity 156 * equal the identifiers of the argument entity. Returns <code>false</code> otherwise. 157 */ 158 @Override 159 public boolean equals(Object object) 160 { 161 if (this == object) 162 { 163 return true; 164 } 165 if (!(object instanceof ReferenceTaxon)) 166 { 167 return false; 168 } 169 final ReferenceTaxon that = (ReferenceTaxon)object; 170 if (this.refTaxonId == null || that.getRefTaxonId() == null || !this.refTaxonId.equals(that.getRefTaxonId())) 171 { 172 return false; 173 } 174 return true; 175 } 176 177 /** 178 * Returns a hash code based on this entity's identifiers. 179 */ 180 @Override 181 public int hashCode() 182 { 183 int hashCode = 0; 184 hashCode = 29 * hashCode + (this.refTaxonId == null ? 0 : this.refTaxonId.hashCode()); 185 186 return hashCode; 187 } 188 189 /** 190 * Constructs new instances of {@link ReferenceTaxon}. 191 */ 192 public static final class Factory 193 { 194 /** 195 * Constructs a new instance of {@link ReferenceTaxon}. 196 * @return new ReferenceTaxonImpl() 197 */ 198 public static ReferenceTaxon newInstance() 199 { 200 return new ReferenceTaxonImpl(); 201 } 202 203 204 /** 205 * Constructs a new instance of {@link ReferenceTaxon}, taking all possible properties 206 * (except the identifier(s))as arguments. 207 * @param updateDt Timestamp 208 * @param virtualComponents Collection<VirtualComponent> 209 * @return newInstance ReferenceTaxon 210 */ 211 public static ReferenceTaxon newInstance(Timestamp updateDt, Collection<VirtualComponent> virtualComponents) 212 { 213 final ReferenceTaxon entity = new ReferenceTaxonImpl(); 214 entity.setUpdateDt(updateDt); 215 entity.setVirtualComponents(virtualComponents); 216 return entity; 217 } 218 } 219 220 /** 221 * @see Comparable#compareTo 222 */ 223 public int compareTo(ReferenceTaxon o) 224 { 225 int cmp = 0; 226 if (this.getRefTaxonId() != null) 227 { 228 cmp = this.getRefTaxonId().compareTo(o.getRefTaxonId()); 229 } 230 else 231 { 232 if (this.getUpdateDt() != null) 233 { 234 cmp = (cmp != 0 ? cmp : this.getUpdateDt().compareTo(o.getUpdateDt())); 235 } 236 } 237 return cmp; 238 } 239 // HibernateEntity.vsl merge-point 240 // ReferenceTaxon.java merge-point 241 }