Project

General

Profile

Download (18 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.MarkerType;
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.SynonymType;
29
import eu.etaxonomy.cdm.model.taxon.Taxon;
30
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
31
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
32
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
33
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
34
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
35
import eu.etaxonomy.cdm.persistence.dao.common.ITitledDao;
36
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
37
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
38
import eu.etaxonomy.cdm.persistence.query.MatchMode;
39
import eu.etaxonomy.cdm.persistence.query.NameSearchOrder;
40
import eu.etaxonomy.cdm.persistence.query.OrderHint;
41
import eu.etaxonomy.cdm.persistence.query.TaxonTitleType;
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, boolean doCommonNames,
96
            boolean includeAuthors, String queryString, Classification classification,
97
            MatchMode matchMode, Set<NamedArea> namedAreas,
98
            NameSearchOrder order, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
99

    
100
    /**
101
     * @param doTaxa
102
     * @param doSynonyms
103
     * @param queryString
104
     * @param classification TODO
105
     * @param matchMode
106
     * @param namedAreas
107
     * @param pageSize
108
     * @param pageNumber
109
     * @param propertyPaths
110
     * @return
111
     */
112
    public long countTaxaByName(boolean doTaxa, boolean doSynonyms, boolean doMisappliedNames, boolean doCommonNames,
113
            boolean doIncludeAuthors, String queryString, Classification classification,
114
            MatchMode matchMode, Set<NamedArea> namedAreas);
115

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

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

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

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

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

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

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

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

    
231
    /**
232
     * TODO necessary?
233
     * @param pagesize max maximum number of returned taxa
234
     * @param page page to start, with 0 being first page
235
     * @return
236
     */
237
    public List<TaxonBase> getAllTaxonBases(Integer pagesize, Integer page);
238

    
239

    
240
    /**
241
     * @param limit
242
     * @param start
243
     * @return
244
     */
245
    public List<Taxon> getAllTaxa(Integer limit, Integer start);
246

    
247
    /**
248
     * @param limit
249
     * @param start
250
     * @return
251
     */
252
    public List<Synonym> getAllSynonyms(Integer limit, Integer start);
253

    
254
    /**
255
     * Counts the number of synonyms
256
     * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
257
     * an accepted taxon are counted
258
     * @return the number of synonyms
259
     */
260
    public int countSynonyms(boolean onlyAttachedToTaxon);
261

    
262
    /**
263
     * @param queryString
264
     * @param matchMode
265
     * @param onlyAcccepted
266
     * @return
267
     */
268
    public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted);
269

    
270
    /**
271
     * @param queryString
272
     * @param matchMode
273
     * @param onlyAcccepted
274
     * @param criteria
275
     * @return
276
     */
277
    public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted, List<Criterion> criteria);
278

    
279
    /**
280
     * Returns a count of the TaxonRelationships (of where relationship.type ==
281
     * type, if this argument is supplied) where the supplied taxon either is
282
     * relatedFrom or relatedTo depending on the <code>direction</code>
283
     * parameter.
284
     *
285
     * @param taxon
286
     *            The taxon that is relatedFrom
287
     * @param type
288
     *            The type of TaxonRelationship (can be null)
289
     * @param direction
290
     *            specifies the direction of the relationship
291
     * @return the number of TaxonRelationship instances
292
     */
293
    public int countTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
294
            Direction direction);
295

    
296
    /**
297
     * Returns the TaxonRelationships (of where relationship.type == type, if
298
     * this argument is supplied) where the supplied taxon either is
299
     * relatedFrom or relatedTo depending on the <code>direction</code>
300
     * parameter.
301
     *
302
     * @param taxon
303
     *            The taxon that is relatedTo
304
     * @param type
305
     *            The type of TaxonRelationship (can be null)
306
     * @param pageSize
307
     *            The maximum number of relationships returned (can be null for
308
     *            all relationships)
309
     * @param pageNumber
310
     *            The offset (in pageSize chunks) from the start of the result
311
     *            set (0 - based)
312
     * @param orderHints
313
     *            Properties to order by
314
     * @param propertyPaths
315
     *            Properties to initialize in the returned entities, following
316
     *            the syntax described in
317
     *            {@link IBeanInitializer#initialize(Object, List)}
318
     * @param direction
319
     *            specifies the direction of the relationship
320
     * @return a List of TaxonRelationship instances
321
     */
322
    public List<TaxonRelationship> getTaxonRelationships(Taxon taxon,
323
            TaxonRelationshipType type, Integer pageSize, Integer pageNumber,
324
            List<OrderHint> orderHints, List<String> propertyPaths,
325
            Direction direction);
326

    
327
    /**
328
     * Returns a count of the Synonyms (where relationship.type == type,
329
     *  if this argument is supplied) where the supplied taxon is relatedTo.
330
     *
331
     * @param taxon The taxon that is relatedTo
332
     * @param type The type of Synonym (can be null)
333
     * @return the number of Synonym instances
334
     */
335
    public long countSynonyms(Taxon taxon, SynonymType type);
336

    
337
    /**
338
     * Returns the Synonyms (of where relationship.type == type, if this argument is supplied)
339
     * that do have the supplied taxon as accepted taxon.
340
     *
341
     * @param taxon The accepted taxon
342
     * @param type The type of synonym (can be null)
343
     * @param pageSize The maximum number of synonyms returned (can be null for all synonyms)
344
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
345
     * * @param orderHints Properties to order by
346
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
347
     * @return a {@link List} of {@link Synonym} instances
348
     */
349
    public List<Synonym> getSynonyms(Taxon taxon, SynonymType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
350

    
351
    /**
352
     * Returns a count of the synonyms (where relationship.type == type,
353
     * if this argument is supplied) which do have an accepted taxon.
354
     *
355
     * @param synonym The synonym that is relatedFrom
356
     * @param type The type of Synonym (can be null)
357
     * @return the number of Synonym instances
358
     */
359
    public int countSynonyms(Synonym synonym, SynonymType type);
360

    
361
    public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
362

    
363
    public long countTaxaByCommonName(String searchString,
364
            Classification classification, MatchMode matchMode,
365
            Set<NamedArea> namedAreas);
366

    
367
    public List<UUID> findIdenticalTaxonNameIds(List<String> propertyPath);
368

    
369
    public List<TaxonNameBase> findIdenticalNamesNew(List <String> propertyPaths);
370

    
371
    public List<UuidAndTitleCache<IdentifiableEntity>> getTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doNamesWithoutTaxa,
372
            boolean doMisappliedNames, boolean doCommonNames,
373
            String queryString, Classification classification,
374
            MatchMode matchMode, Set<NamedArea> namedAreas);
375

    
376
    public List<String> taxaByNameNotInDB(List<String> taxonNames);
377

    
378
    /**
379
     * This method was originally required when synonyms still had a synonym relationship
380
     * to taxa and could belong to multiple taxa. Now the method might be obsolete.
381
     * @param synonym
382
     * @param classificationFilter
383
     * @param propertyPaths
384
     * @see #countAcceptedTaxonFor(Synonym, Classification)
385
     */
386
    public Taxon acceptedTaxonFor(Synonym synonym, Classification classificationFilter, List<String> propertyPaths);
387

    
388
    /**
389
     * This method was originally required when synonyms still had a synonym relationship
390
     * to taxa and could belong to multiple taxa. Now the method might be obsolete.@param synonym
391
     * @param classificationFilter
392
     *
393
     * @see #acceptedTaxonFor(Synonym, Classification, Integer, Integer, List, List)
394
     */
395
    public long countAcceptedTaxonFor(Synonym synonym, Classification classificationFilter);
396

    
397
	public List<UuidAndTitleCache<IdentifiableEntity>> getTaxaByCommonNameForEditor(
398
			String titleSearchStringSqlized, Classification classification,
399
			MatchMode matchMode, Set namedAreas);
400

    
401
	public <S extends TaxonBase> List<Object[]> findByIdentifier(Class<S> clazz, String identifier,
402
			DefinedTerm identifierType, TaxonNode subtreeFilter, MatchMode matchmode,
403
			boolean includeEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
404

    
405
	/**
406
	 * Counts all taxa which match the given identifier (identifier type, identifier string and match mode).
407
	 * Optionally a subtreefilter can be defined.
408
	 *
409
	 * @param clazz optional, the TaxonBase subclass
410
	 * @param identifier the identifier string
411
	 * @param identifierType the identifier type
412
     * @param matchmode the match mode for the identifier string
413
	 * @param subtreeFilter the subtree filter as taxon node
414
	 * @return
415
	 */
416
	public <S extends TaxonBase> int countByIdentifier(Class<S> clazz,
417
			String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter, MatchMode matchmode);
418

    
419
	/**
420
     * Counts all taxa which have the given marker of type markerType and with value markerValue.
421
     * Additionally an optional subtreefilter can be defined.
422
     *
423
     * @param clazz
424
     * @param markerType
425
     * @param markerValue
426
     * @param subtreeFilter
427
     * @return
428
     */
429
    public <S extends TaxonBase> long countByMarker(Class<S> clazz, MarkerType markerType,
430
            Boolean markerValue, TaxonNode subtreeFilter);
431

    
432
    /**
433
     * @param clazz
434
     * @param markerType
435
     * @param markerValue
436
     * @param subtreeFilter
437
     * @param includeEntity
438
     * @param pageSize
439
     * @param pageNumber
440
     * @param propertyPaths
441
     * @return
442
     */
443
    public <S extends TaxonBase> List<Object[]> findByMarker(Class<S> clazz, MarkerType markerType,
444
            Boolean markerValue, TaxonNode subtreeFilter, boolean includeEntity, TaxonTitleType titleType,
445
            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
446

    
447
    /**
448
     * @param classification
449
     * @param excludeUuid
450
     * @param limit
451
     * @param pattern
452
     * @return
453
     */
454
	public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
455
            Classification classification, Integer limit, String pattern);
456

    
457
    /**
458
     * @param types
459
     * @return
460
     */
461
    public long countTaxonRelationships(Set<TaxonRelationshipType> types);
462

    
463
    /**
464
     * @param types
465
     * @param pageSize
466
     * @param pageNumber
467
     * @param orderHints
468
     * @param propertyPaths
469
     * @return
470
     */
471
    public List<TaxonRelationship> getTaxonRelationships(Set<TaxonRelationshipType> types,
472
            Integer pageSize, Integer pageNumber,
473
            List<OrderHint> orderHints, List<String> propertyPaths);
474

    
475
}
(2-2/3)