Project

General

Profile

Download (20.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.persistence.dao.taxon;
11

    
12
import java.util.List;
13
import java.util.Set;
14
import java.util.UUID;
15

    
16
import org.hibernate.criterion.Criterion;
17

    
18
import eu.etaxonomy.cdm.model.common.DefinedTerm;
19
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
20
import eu.etaxonomy.cdm.model.common.RelationshipBase;
21
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
22
import eu.etaxonomy.cdm.model.location.NamedArea;
23
import eu.etaxonomy.cdm.model.name.Rank;
24
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
25
import eu.etaxonomy.cdm.model.reference.Reference;
26
import eu.etaxonomy.cdm.model.taxon.Classification;
27
import eu.etaxonomy.cdm.model.taxon.Synonym;
28
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
29
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
30
import eu.etaxonomy.cdm.model.taxon.Taxon;
31
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
32
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
33
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
34
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
35
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
36
import eu.etaxonomy.cdm.persistence.dao.common.ITitledDao;
37
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
38
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
39
import eu.etaxonomy.cdm.persistence.fetch.CdmFetch;
40
import eu.etaxonomy.cdm.persistence.query.MatchMode;
41
import eu.etaxonomy.cdm.persistence.query.OrderHint;
42

    
43
/**
44
 * @author a.mueller
45
 *
46
 */
47
public interface ITaxonDao extends IIdentifiableDao<TaxonBase>, ITitledDao<TaxonBase> {
48

    
49
    /**
50
     * Returns a list of TaxonBase instances where the taxon.titleCache property matches the name parameter,
51
     * and taxon.sec matches the sec parameter.
52
     * @param name
53
     * @param sec
54
     * @return
55
     */
56
    public List<TaxonBase> getTaxaByName(String name, Reference sec);
57

    
58
    /**
59
     * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
60
     * where the taxonBase.name.nameCache property matches the String queryString, and taxon.sec matches the sec parameter.
61
     * @param name
62
     * @param sec
63
     * @return
64
     */
65
    public List<TaxonBase> getTaxaByName(String queryString, Boolean accepted, Reference sec);
66

    
67
    /**
68
     * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
69
     * where the taxonBase.name.nameCache property matches the String queryString.
70
     * @param queryString
71
     * @param matchMode
72
     * @param accepted
73
     * @param pageSize
74
     * @param pageNumber
75
     * @return
76
     */
77
    public List<TaxonBase> getTaxaByName(String queryString, MatchMode matchMode,
78
            Boolean accepted, Integer pageSize, Integer pageNumber);
79

    
80

    
81
    /**
82
     * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
83
     * where the taxonBase.name.nameCache property matches the String queryString.
84
     * @param doTaxa
85
     * @param doSynonyms
86
     * @param queryString
87
     * @param classification TODO
88
     * @param matchMode
89
     * @param namedAreas TODO
90
     * @param pageSize
91
     * @param pageNumber
92
     * @param propertyPaths TODO
93
     * @return list of found taxa
94
     */
95
    public List<TaxonBase> getTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, String queryString, Classification classification,
96
            MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
97

    
98
    /**
99
     * @param doTaxa
100
     * @param doSynonyms
101
     * @param queryString
102
     * @param classification TODO
103
     * @param matchMode
104
     * @param namedAreas
105
     * @param pageSize
106
     * @param pageNumber
107
     * @param propertyPaths
108
     * @return
109
     */
110
    public long countTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, String queryString, Classification classification,
111

    
112
            MatchMode matchMode, Set<NamedArea> namedAreas);
113

    
114
//	/**
115
//	 * @param queryString
116
//	 * @param matchMode
117
//	 * @param accepted
118
//	 * @return
119
//	 */
120
//	public Integer countTaxaByName(String queryString, MatchMode matchMode,
121
//			Boolean accepted);
122

    
123
//	/**
124
//	 * Returns a count of TaxonBase instances where the
125
//	 * taxon.name properties match the parameters passed.
126
//	 *
127
//	 * @param queryString search string
128
//	 * @param matchMode way how search string shall be matched: exact, beginning, or anywhere
129
//	 * @param selectModel all taxon base, taxa, or synonyms
130
//	 */
131
//	public Integer countTaxaByName(String queryString, MatchMode matchMode, SelectMode selectMode);
132

    
133
    /**
134
     * Returns a count of TaxonBase instances where the
135
     * taxon.name properties match the parameters passed.
136
     *
137
     * @param doTaxa
138
     * @param doSynonyms
139
     * @param uninomial
140
     * @param infragenericEpithet
141
     * @param specificEpithet
142
     * @param infraspecificEpithet
143
     * @param rank
144
     * @return a count of TaxonBase instances
145
     */
146
    public int countTaxaByName(Class <? extends TaxonBase> clazz, String uninomial, String infragenericEpithet,String specificEpithet, String infraspecificEpithet, Rank rank);
147

    
148
    /**
149
     * Returns a list of TaxonBase instances where the
150
     * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
151
     * <i>null</i> will search for those taxa with a value of null in that field
152
     * <p>
153
     * Compare with
154
     * {@link #findByName(String, MatchMode, int, int, boolean)}
155
     * which searches for {@link TaxonNameBase}<strong><code>.titleCache</code>
156
     * </strong>
157
     *
158
     * @param doTaxa
159
     * @param doSynonyms
160
     * @param uninomial
161
     * @param infragenericEpithet
162
     * @param specificEpithet
163
     * @param infraspecificEpithet
164
     * @param rank
165
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
166
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
167
     * @return a list of TaxonBase instances
168
     */
169
    public List<TaxonBase> findTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
170

    
171
    /**
172
     * Find taxa by searching for Taxa and Synonyms where the
173
     * {@link TaxonNameBase}<strong><code>.titleCache</code></strong> matches
174
     * the name specified as queryString <code>taxonName</code>
175
     * <P>
176
     * Compare with
177
     * {@link #findTaxaByName(Class, String, String, String, String, Rank, Integer, Integer)}
178
     * which searches for {@link TaxonNameBase}<strong><code>.nameCache</code>
179
     * </strong>
180
     * @param queryString
181
     *            the taqxon Name to search for
182
     * @param classification TODO
183
     * @param matchMode
184
     * @param namedAreas TODO
185
     * @param pageNumber
186
     * @param pageSize
187
     * @param onlyAcccepted
188
     * @return
189
     */
190
    public List<TaxonBase> findByNameTitleCache(boolean doTaxa, boolean doSynonyms, String queryString, Classification classification, MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageNumber, Integer pageSize, List<String> propertyPaths) ;
191

    
192
    /**
193
     * Returns a taxon corresponding to the given uuid
194
     *
195
     * @param uuid
196
     * 			The uuid of the taxon requested
197
     * @param criteria
198
     * 			Custom criteria to be added to the default list of applied criteria.
199
     * @param propertyPaths
200
     *
201
     * @return
202
     */
203
    public TaxonBase findByUuid(UUID uuid, List<Criterion> criteria, List<String> propertyPaths);
204

    
205
    /**
206
     * Returns a list of Taxon entities corresponding to the given uuid list.
207
     * @param uuids
208
     * @param criteria
209
     * @param propertyPaths
210
     * @return
211
     */
212
    public List<? extends TaxonBase> findByUuids(List<UUID> uuids, List<Criterion> criteria, List<String> propertyPaths);
213

    
214
    /**
215
     * @param queryString
216
     * @param classification
217
     * @param matchMode
218
     * @param namedAreas
219
     * @param pageSize
220
     * @param pageNumber
221
     * @param propertyPaths
222
     * @return A List matching Taxa
223
     */
224
    public List<Taxon> getTaxaByCommonName(String queryString, Classification classification,
225
    MatchMode matchMode, Set<NamedArea> namedAreas, Integer pageSize,
226
    Integer pageNumber, List<String> propertyPaths);
227

    
228

    
229
    /**
230
     * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
231
     * @return The List<Taxon> of root taxa.
232
     * @deprecated obsolete when using classification
233
     */
234
    @Deprecated
235
    public List<Taxon> getRootTaxa(Reference sec);
236

    
237

    
238
    /**
239
     * Computes all Taxon instances that do not have a taxonomic parent.
240
     * @param sec The concept reference that the taxon belongs to
241
     * @param cdmFetch not used yet !! TODO
242
     * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
243
     * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
244
     * <Br>Default: true.
245
     * @return The List<Taxon> of root taxa.
246
     * @deprecated obsolete when using classification
247
     */
248
    @Deprecated
249
    public List<Taxon> getRootTaxa(Reference sec, CdmFetch cdmFetch, Boolean onlyWithChildren, Boolean withMisapplications);
250

    
251

    
252
    /**
253
     * Computes all Taxon instances which name is of a certain Rank.
254
     *
255
     * @param rank
256
     *            The rank of the taxon name
257
     * @param sec
258
     *            The concept reference that the taxon belongs to
259
     * @param cdmFetch
260
     *            not used yet !! TODO
261
     * @param onlyWithChildren
262
     *            if true only taxa are returned that have taxonomic children. <Br>
263
     *            Default: true.
264
     * @param withMisaplications
265
     *            if false only taxa are returned that have no
266
     *            isMisappliedNameFor relationship.
267
     * @param propertyPaths
268
     *            properties to be initialized, For detailed description and
269
     *            examples <b>please refer to:</b>
270
     *            {@link IBeanInitializer#initialize(Object, List)}. <Br>
271
     *            Default: true.
272
     * @return The List<Taxon> of root taxa.
273
     * @deprecated obsolete when using classification
274
     */
275
    @Deprecated
276
    public List<Taxon>
277
    getRootTaxa(Rank rank, Reference sec, CdmFetch cdmFetch, Boolean onlyWithChildren, Boolean withMisapplications, List<String> propertyPaths);
278

    
279
        /**
280
     * TODO necessary?
281
     * @param pagesize max maximum number of returned taxa
282
     * @param page page to start, with 0 being first page
283
     * @return
284
     */
285
    public List<TaxonBase> getAllTaxonBases(Integer pagesize, Integer page);
286

    
287

    
288
    /**
289
     * @param limit
290
     * @param start
291
     * @return
292
     */
293
    public List<Taxon> getAllTaxa(Integer limit, Integer start);
294

    
295
    /**
296
     * @param limit
297
     * @param start
298
     * @return
299
     */
300
    public List<Synonym> getAllSynonyms(Integer limit, Integer start);
301

    
302
    public List<RelationshipBase> getAllRelationships(Integer limit, Integer start);
303

    
304
    public int countAllRelationships();
305

    
306
    /**
307
     * @param queryString
308
     * @param matchMode
309
     * @param onlyAcccepted
310
     * @return
311
     */
312
    public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted);
313

    
314
    /**
315
     * @param queryString
316
     * @param matchMode
317
     * @param onlyAcccepted
318
     * @param criteria
319
     * @return
320
     */
321
    public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted, List<Criterion> criteria);
322

    
323
    /**
324
     * Returns a count of the TaxonRelationships (of where relationship.type ==
325
     * type, if this argument is supplied) where the supplied taxon either is
326
     * relatedFrom or relatedTo depending on the <code>direction</code>
327
     * parameter.
328
     *
329
     * @param taxon
330
     *            The taxon that is relatedFrom
331
     * @param type
332
     *            The type of TaxonRelationship (can be null)
333
     * @param direction
334
     *            specifies the direction of the relationship
335
     * @return the number of TaxonRelationship instances
336
     */
337
    public int countTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
338
            Direction direction);
339

    
340
    /**
341
     * Returns the TaxonRelationships (of where relationship.type == type, if
342
     * this argument is supplied) where the supplied taxon either is
343
     * relatedFrom or relatedTo depending on the <code>direction</code>
344
     * parameter.
345
     *
346
     * @param taxon
347
     *            The taxon that is relatedTo
348
     * @param type
349
     *            The type of TaxonRelationship (can be null)
350
     * @param pageSize
351
     *            The maximum number of relationships returned (can be null for
352
     *            all relationships)
353
     * @param pageNumber
354
     *            The offset (in pageSize chunks) from the start of the result
355
     *            set (0 - based)
356
     * @param orderHints
357
     *            Properties to order by
358
     * @param propertyPaths
359
     *            Properties to initialize in the returned entities, following
360
     *            the syntax described in
361
     *            {@link IBeanInitializer#initialize(Object, List)}
362
     * @param direction
363
     *            specifies the direction of the relationship
364
     * @return a List of TaxonRelationship instances
365
     */
366
    public List<TaxonRelationship> getTaxonRelationships(Taxon taxon,
367
            TaxonRelationshipType type, Integer pageSize, Integer pageNumber,
368
            List<OrderHint> orderHints, List<String> propertyPaths,
369
            Direction direction);
370

    
371
    /**
372
     * Returns a count of the SynonymRelationships (of where relationship.type == type,
373
     *  if this arguement is supplied) where the supplied taxon is relatedTo.
374
     *
375
     * @param taxon The taxon that is relatedTo
376
     * @param type The type of SynonymRelationship (can be null)
377
     * @return the number of SynonymRelationship instances
378
     */
379
    public int countSynonyms(Taxon taxon, SynonymRelationshipType type);
380

    
381
    /**
382
     * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
383
     * where the supplied taxon is relatedTo.
384
     *
385
     * @param taxon The taxon that is relatedTo
386
     * @param type The type of SynonymRelationship (can be null)
387
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
388
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
389
     * * @param orderHints Properties to order by
390
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
391
     * @return a List of SynonymRelationship instances
392
     */
393
    public List<SynonymRelationship> getSynonyms(Taxon taxon, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
394

    
395
    /**
396
     * Returns a count of the SynonymRelationships (of where relationship.type == type,
397
     *  if this arguement is supplied) where the supplied synonym is relatedFrom.
398
     *
399
     * @param taxon The synonym that is relatedFrom
400
     * @param type The type of SynonymRelationship (can be null)
401
     * @return the number of SynonymRelationship instances
402
     */
403
    public int countSynonyms(Synonym synonym, SynonymRelationshipType type);
404

    
405
    /**
406
     * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
407
     * where the supplied synonym is relatedFrom.
408
     *
409
     * @param taxon The synonym that is relatedFrom
410
     * @param type The type of SynonymRelationship (can be null)
411
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
412
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
413
     * * @param orderHints Properties to order by
414
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
415
     * @return a List of SynonymRelationship instances
416
     */
417
    public List<SynonymRelationship> getSynonyms(Synonym synoynm, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
418

    
419

    
420
    /**
421
     * Creates all inferred synonyms for the species in the tree and insert it to the database
422
     * @param tree
423
     * @return List of inferred synonyms
424
     */
425
    //public List<Synonym> insertAllInferredSynonymy(Classification tree);
426

    
427

    
428

    
429
    public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
430
    public String getPhylumName(TaxonNameBase name);
431

    
432
    public long countTaxaByCommonName(String searchString,
433
            Classification classification, MatchMode matchMode,
434
            Set<NamedArea> namedAreas);
435

    
436
    /**
437
     * Deletes all synonym relationships of a given synonym.
438
     * If taxon is given only those relationships to the taxon
439
     * are deleted.
440
     * @param synonym the synonym
441
     * @param taxon the taxon, may be <code>null</code>
442
     * @return
443
     * @deprecated This method must no longer being used since the
444
     *             SynonymRelationship is annotated at the {@link Taxon} and at
445
     *             the {@link Synonym} with <code>orphanDelete=true</code>. Just
446
     *             remove the from and to entities from the relationship and
447
     *             hibernate will care for the deletion. Using this method can cause
448
     *             <code>StaleStateException</code> (see http://dev.e-taxonomy.eu/trac/ticket/3797)
449
     */
450
    @Deprecated
451
    public long deleteSynonymRelationships(Synonym syn, Taxon taxon);
452

    
453
    public List<UUID> findIdenticalTaxonNameIds(List<String> propertyPath);
454

    
455
    public List<TaxonNameBase> findIdenticalNamesNew(List <String> propertyPaths);
456

    
457

    
458
    public Integer countSynonymRelationships(TaxonBase taxonBase,
459
            SynonymRelationshipType type, Direction relatedfrom);
460

    
461
    public List<SynonymRelationship> getSynonymRelationships(TaxonBase taxonBase,
462
            SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
463
            List<OrderHint> orderHints, List<String> propertyPaths,
464
            Direction relatedfrom);
465

    
466
    /**
467
     * @return
468
     */
469
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
470

    
471
    /**
472
     * @return
473
     */
474
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
475

    
476
    public List<UuidAndTitleCache<IdentifiableEntity>> getTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doNamesWithoutTaxa, boolean doMisappliedNames, String queryString, Classification classification,
477
            MatchMode matchMode, Set<NamedArea> namedAreas);
478

    
479
    public List<String> taxaByNameNotInDB(List<String> taxonNames);
480

    
481
    public List<Taxon> listAcceptedTaxaFor(Synonym synonym, Classification classificationFilter, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
482
            List<String> propertyPaths);
483

    
484
    public long countAcceptedTaxaFor(Synonym synonym, Classification classificationFilter);
485

    
486
	public List<UuidAndTitleCache<IdentifiableEntity>> getTaxaByCommonNameForEditor(
487
			String titleSearchStringSqlized, Classification classification,
488
			MatchMode matchMode, Set namedAreas);
489

    
490
	public <S extends TaxonBase> List<Object[]> findByIdentifier(Class<S> clazz, String identifier,
491
			DefinedTerm identifierType, TaxonNode subtreeFilter, MatchMode matchmode,
492
			boolean includeEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
493

    
494
	public <S extends TaxonBase> int countByIdentifier(Class<S> clazz,
495
			String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter, MatchMode matchmode);
496

    
497
    /**
498
     * @param classification
499
     * @param excludeUuid
500
     * @param limit
501
     * @param pattern
502
     * @return
503
     */
504
    List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
505
            Classification classification, List<UUID> excludeUuid, Integer limit, String pattern);
506

    
507
}
(2-2/3)