1 // license-header java merge-point
2 //
3 // Attention: Generated code! Do not modify by hand!
4 // Generated by: SpringDao.vsl in andromda-spring-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.Search;
30 import java.sql.Timestamp;
31 import java.util.Collection;
32 import java.util.Set;
33 import org.andromda.spring.PaginationResult;
34
35 /**
36 * Liste des taxons qui sont la référence.
37 * l'ID référent est indépendant des ID taxon car les taxons peuvent être référents à un moment et
38 * ne plus l'être par la suite.
39 * Toutes les données du système doivent donc être reliées au référent et non au taxon qui sont
40 * référents à un moment mais ne peuvent plus l'être par la suite.
41 * Le fonctionnement dans la table TAXON_NAME est le suivant :
42 * - REF_TAXON_ID est toujours renseigné
43 * - si TAXON_NAME_IS_REFER est à vrai, il s'agit d'un taxon référent (toujours le cas s'il s'agit
44 * d'un taxon virtuel)
45 * - sinon c'est un synonyme
46 * Un taxon référent qui devient synonyme voit donc son statut TAXON_NAME_IS_REFER changer et le
47 * nouveau taxon référent qui le remplace récupère l'information REF_TAXON_ID
48 * NB : c'était le comportement initialement prévu.
49 * En réalité, lorsqu'un taxon référent T1-R1 devient synonyme d'un nouveau taxon référent T2, le
50 * taxon T2 prend un nouveau code référent R2 et donc le taxon T1 est lié à R2 (et tous les
51 * synonymes et les résultats qu'il pouvait avoir).
52 * Ce mécanisme a été adopté car il fallait distinguer 2 cas :
53 * 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
54 * alors pu utiliser le même REF_TAXON_ID R1 au lieu d'en créer un et ne pas mettre à jour les
55 * autres synonymes, résultats...
56 * 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
57 * aurait déjà d'autres synonymes, résultats...), dans ce cas le remplacement de la référence R1
58 * pour R2 est nécessaire
59 * La modélisation pourrait être revue car la table REFENCE_TAXON ne se justifie alors plus, on
60 * pourrait directement utiliser une référence à la colonne TAXON_NAME_ID pour désigner les
61 * référents
62 * @see ReferenceTaxon
63 */
64 public interface ReferenceTaxonDao
65 {
66 /**
67 * This constant is used as a transformation flag; entities can be converted automatically into value objects
68 * or other types, different methods in a class implementing this interface support this feature: look for
69 * an <code>int</code> parameter called <code>transform</code>.
70 * <p>
71 * This specific flag denotes no transformation will occur.
72 */
73 public static final int TRANSFORM_NONE = 0;
74
75
76 /**
77 * Transforms the given results to a collection of {@link ReferenceTaxon}
78 * instances (this is useful when the returned results contains a row of data and you want just entities only).
79 *
80 * @param results the query results.
81 */
82 public void toEntities(final Collection<?> results);
83
84 /**
85 * Gets an instance of ReferenceTaxon from the persistent store.
86 * @param refTaxonId
87 * @return ReferenceTaxon
88 */
89 public ReferenceTaxon get(Integer refTaxonId);
90
91 /**
92 * <p>
93 * Does the same thing as {@link #get(Integer)} with an
94 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
95 * the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants
96 * defined in this class then the result <strong>WILL BE</strong> passed through an operation which can
97 * optionally transform the entity (into a value object for example). By default, transformation does
98 * not occur.
99 * </p>
100 *
101 * @param transform flag to determine transformation type.
102 * @param refTaxonId the identifier of the entity to get.
103 * @return either the entity or the object transformed from the entity.
104 */
105 public Object get(int transform, Integer refTaxonId);
106
107 /**
108 * Loads an instance of ReferenceTaxon from the persistent store.
109 * @param refTaxonId
110 * @return ReferenceTaxon
111 */
112 public ReferenceTaxon load(Integer refTaxonId);
113
114 /**
115 * <p>
116 * Does the same thing as {@link #load(Integer)} with an
117 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
118 * the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants
119 * defined in this class then the result <strong>WILL BE</strong> passed through an operation which can
120 * optionally transform the entity (into a value object for example). By default, transformation does
121 * not occur.
122 * </p>
123 *
124 * @param transform flag to determine transformation type.
125 * @param refTaxonId the identifier of the entity to load.
126 * @return either the entity or the object transformed from the entity.
127 */
128 public Object load(int transform, Integer refTaxonId);
129
130 /**
131 * Loads all entities of type {@link ReferenceTaxon}.
132 *
133 * @return the loaded entities.
134 */
135 public Collection<ReferenceTaxon> loadAll();
136
137 /**
138 * <p>
139 * Does the same thing as {@link #loadAll()} with an
140 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
141 * the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants
142 * defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally
143 * transform the entity (into a value object for example). By default, transformation does
144 * not occur.
145 * </p>
146 *
147 * @param transform the flag indicating what transformation to use.
148 * @return the loaded entities.
149 */
150 public Collection<?> loadAll(final int transform);
151
152 /**
153 * <p>
154 * Does the same thing as {@link #loadAll()} with an
155 * additional two arguments called <code>pageNumber</code> and <code>pageSize</code>. The <code>pageNumber</code>
156 * argument allows you to specify the page number when you are paging the results and the pageSize allows you to specify the size of the
157 * page retrieved.
158 * </p>
159 *
160 * @param pageNumber the page number to retrieve when paging results.
161 * @param pageSize the size of the page to retrieve when paging results.
162 * @return the loaded entities.
163 */
164 public Collection<?> loadAll(final int pageNumber, final int pageSize);
165
166 /**
167 * <p>
168 * Does the same thing as {@link #loadAll(int)} with an
169 * additional two arguments called <code>pageNumber</code> and <code>pageSize</code>. The <code>pageNumber</code>
170 * argument allows you to specify the page number when you are paging the results and the pageSize allows you to specify the size of the
171 * page retrieved.
172 * </p>
173 *
174 * @param transform the flag indicating what transformation to use.
175 * @param pageNumber the page number to retrieve when paging results.
176 * @param pageSize the size of the page to retrieve when paging results.
177 * @return the loaded entities.
178 */
179 public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize);
180
181 /**
182 * Creates an instance of ReferenceTaxon and adds it to the persistent store.
183 * @param referenceTaxon
184 * @return ReferenceTaxon
185 */
186 public ReferenceTaxon create(ReferenceTaxon referenceTaxon);
187
188 /**
189 * <p>
190 * Does the same thing as {@link #create(ReferenceTaxon)} with an
191 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
192 * the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants
193 * defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally
194 * transform the entity (into a value object for example). By default, transformation does
195 * not occur.
196 * </p>
197 * @param transform
198 * @param referenceTaxon
199 * @return Object
200 */
201 public Object create(int transform, ReferenceTaxon referenceTaxon);
202
203 /**
204 * Creates a new instance of ReferenceTaxon and adds
205 * from the passed in <code>entities</code> collection
206 *
207 * @param entities the collection of ReferenceTaxon
208 * instances to create.
209 *
210 * @return the created instances.
211 */
212 public Collection<ReferenceTaxon> create(Collection<ReferenceTaxon> entities);
213
214 /**
215 * <p>
216 * Does the same thing as {@link #create(ReferenceTaxon)} with an
217 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
218 * the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants
219 * defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally
220 * transform the entities (into value objects for example). By default, transformation does
221 * not occur.
222 * </p>
223 * @param transform
224 * @param entities
225 * @return Collection
226 */
227 public Collection<?> create(int transform, Collection<ReferenceTaxon> entities);
228
229 /**
230 * <p>
231 * Creates a new <code>ReferenceTaxon</code>
232 * instance from <strong>all</strong> attributes and adds it to
233 * the persistent store.
234 * </p>
235 * @param updateDt Date de modification de l'objet, mise à jour par le système
236 * @return ReferenceTaxon
237 */
238 public ReferenceTaxon create(
239 Timestamp updateDt);
240
241 /**
242 * <p>
243 * Does the same thing as {@link #create(Timestamp)} with an
244 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
245 * the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants
246 * defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally
247 * transform the entity (into a value object for example). By default, transformation does
248 * not occur.
249 * </p>
250 * @param transform
251 * @param updateDt Date de modification de l'objet, mise à jour par le système
252 * @return ReferenceTaxon
253 */
254 public Object create(
255 int transform,
256 Timestamp updateDt);
257
258
259 /**
260 * Updates the <code>referenceTaxon</code> instance in the persistent store.
261 * @param referenceTaxon
262 */
263 public void update(ReferenceTaxon referenceTaxon);
264
265 /**
266 * Updates all instances in the <code>entities</code> collection in the persistent store.
267 * @param entities
268 */
269 public void update(Collection<ReferenceTaxon> entities);
270
271 /**
272 * Removes the instance of ReferenceTaxon from the persistent store.
273 * @param referenceTaxon
274 */
275 public void remove(ReferenceTaxon referenceTaxon);
276
277 /**
278 * Removes the instance of ReferenceTaxon having the given
279 * <code>identifier</code> from the persistent store.
280 * @param refTaxonId
281 */
282 public void remove(Integer refTaxonId);
283
284 /**
285 * Removes all entities in the given <code>entities</code> collection.
286 * @param entities
287 */
288 public void remove(Collection<ReferenceTaxon> entities);
289
290
291 /**
292 * Does the same thing as {@link #search(int, Search)} but with an
293 * additional two flags called <code>pageNumber</code> and <code>pageSize</code>. These flags allow you to
294 * limit your data to a specified page number and size.
295 *
296 * @param transform the transformation flag.
297 * @param pageNumber the page number in the data to retrieve
298 * @param pageSize the size of the page to retrieve.
299 * @param search the search object which provides the search parameters and pagination specification.
300 * @return any found results from the search wrapped in a {@link PaginationResult} instance.
301 */
302 public PaginationResult search(final int transform, final int pageNumber, final int pageSize, final Search search);
303
304 /**
305 * Does the same thing as {@link #search(Search)} but with an
306 * additional two flags called <code>pageNumber</code> and <code>pageSize</code>. These flags allow you to
307 * limit your data to a specified page number and size.
308 *
309 * @param pageNumber the page number in the data to retrieve
310 * @param pageSize the size of the page to retrieve.
311 * @param search the search object which provides the search parameters and pagination specification.
312 * @return any found results from the search wrapped in a {@link PaginationResult} instance.
313 */
314 public PaginationResult search(final int pageNumber, final int pageSize, final Search search);
315
316 /**
317 * Does the same thing as {@link #search(Search)} but with an
318 * additional flag called <code>transform</code>. If this flag is set to <code>TRANSFORM_NONE</code> then
319 * finder results will <strong>NOT</strong> be transformed during retrieval.
320 * If this flag is any of the other constants defined here
321 * then results <strong>WILL BE</strong> passed through an operation which can optionally
322 * transform the entities (into value objects for example). By default, transformation does
323 * not occur.
324 *
325 * @param transform the transformation flag.
326 * @param search the search object which provides the search parameters and pagination specification.
327 * @return any found results from the search.
328 */
329 public Set<?> search(final int transform, final Search search);
330
331 /**
332 * Performs a search using the parameters specified in the given <code>search</code> object.
333 *
334 * @param search the search object which provides the search parameters and pagination specification.
335 * @return any found results from the search.
336 */
337 public Set<ReferenceTaxon> search(final Search search);
338
339 /**
340 * Allows transformation of entities into value objects
341 * (or something else for that matter), when the <code>transform</code>
342 * flag is set to one of the constants defined in <code>fr.ifremer.quadrige2.core.dao.referential.taxon.ReferenceTaxonDao</code>, please note
343 * that the {@link #TRANSFORM_NONE} constant denotes no transformation, so the entity itself
344 * will be returned.
345 *
346 * If the integer argument value is unknown {@link #TRANSFORM_NONE} is assumed.
347 *
348 * @param transform one of the constants declared in {@link fr.ifremer.quadrige2.core.dao.referential.taxon.ReferenceTaxonDao}
349 * @param entity an entity that was found
350 * @return the transformed entity (i.e. new value object, etc)
351 * @see #transformEntities(int,Collection)
352 */
353 public Object transformEntity(final int transform, final ReferenceTaxon entity);
354
355 /**
356 * Transforms a collection of entities using the
357 * {@link #transformEntity(int,ReferenceTaxon)}
358 * method. This method does not instantiate a new collection.
359 * <p>
360 * This method is to be used internally only.
361 *
362 * @param transform one of the constants declared in <code>fr.ifremer.quadrige2.core.dao.referential.taxon.ReferenceTaxonDao</code>
363 * @param entities the collection of entities to transform
364 * @see #transformEntity(int,ReferenceTaxon)
365 */
366 public void transformEntities(final int transform, final Collection<?> entities);
367
368 // spring-dao merge-point
369 }