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.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.query.MatchMode;
40
import eu.etaxonomy.cdm.persistence.query.OrderHint;
41

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

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

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

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

    
79

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

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

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

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

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

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

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

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

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

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

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

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

    
235

    
236
    /**
237
     * @param limit
238
     * @param start
239
     * @return
240
     */
241
    public List<Taxon> getAllTaxa(Integer limit, Integer start);
242

    
243
    /**
244
     * @param limit
245
     * @param start
246
     * @return
247
     */
248
    public List<Synonym> getAllSynonyms(Integer limit, Integer start);
249

    
250
    public List<RelationshipBase> getAllRelationships(Integer limit, Integer start);
251

    
252
    public int countAllRelationships();
253

    
254
    /**
255
     * @param queryString
256
     * @param matchMode
257
     * @param onlyAcccepted
258
     * @return
259
     */
260
    public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted);
261

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

    
271
    /**
272
     * Returns a count of the TaxonRelationships (of where relationship.type ==
273
     * type, if this argument is supplied) where the supplied taxon either is
274
     * relatedFrom or relatedTo depending on the <code>direction</code>
275
     * parameter.
276
     *
277
     * @param taxon
278
     *            The taxon that is relatedFrom
279
     * @param type
280
     *            The type of TaxonRelationship (can be null)
281
     * @param direction
282
     *            specifies the direction of the relationship
283
     * @return the number of TaxonRelationship instances
284
     */
285
    public int countTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
286
            Direction direction);
287

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

    
319
    /**
320
     * Returns a count of the SynonymRelationships (of where relationship.type == type,
321
     *  if this arguement is supplied) where the supplied taxon is relatedTo.
322
     *
323
     * @param taxon The taxon that is relatedTo
324
     * @param type The type of SynonymRelationship (can be null)
325
     * @return the number of SynonymRelationship instances
326
     */
327
    public int countSynonyms(Taxon taxon, SynonymRelationshipType type);
328

    
329
    /**
330
     * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
331
     * where the supplied taxon is relatedTo.
332
     *
333
     * @param taxon The taxon that is relatedTo
334
     * @param type The type of SynonymRelationship (can be null)
335
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
336
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
337
     * * @param orderHints Properties to order by
338
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
339
     * @return a List of SynonymRelationship instances
340
     */
341
    public List<SynonymRelationship> getSynonyms(Taxon taxon, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
342

    
343
    /**
344
     * Returns a count of the SynonymRelationships (of where relationship.type == type,
345
     *  if this arguement is supplied) where the supplied synonym is relatedFrom.
346
     *
347
     * @param taxon The synonym that is relatedFrom
348
     * @param type The type of SynonymRelationship (can be null)
349
     * @return the number of SynonymRelationship instances
350
     */
351
    public int countSynonyms(Synonym synonym, SynonymRelationshipType type);
352

    
353
    /**
354
     * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
355
     * where the supplied synonym is relatedFrom.
356
     *
357
     * @param taxon The synonym that is relatedFrom
358
     * @param type The type of SynonymRelationship (can be null)
359
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
360
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
361
     * * @param orderHints Properties to order by
362
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
363
     * @return a List of SynonymRelationship instances
364
     */
365
    public List<SynonymRelationship> getSynonyms(Synonym synoynm, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
366

    
367

    
368
    /**
369
     * Creates all inferred synonyms for the species in the tree and insert it to the database
370
     * @param tree
371
     * @return List of inferred synonyms
372
     */
373
    //public List<Synonym> insertAllInferredSynonymy(Classification tree);
374

    
375

    
376

    
377
    public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
378
    public String getPhylumName(TaxonNameBase name);
379

    
380
    public long countTaxaByCommonName(String searchString,
381
            Classification classification, MatchMode matchMode,
382
            Set<NamedArea> namedAreas);
383

    
384
    /**
385
     * Deletes all synonym relationships of a given synonym.
386
     * If taxon is given only those relationships to the taxon
387
     * are deleted.
388
     * @param synonym the synonym
389
     * @param taxon the taxon, may be <code>null</code>
390
     * @return
391
     * @deprecated This method must no longer being used since the
392
     *             SynonymRelationship is annotated at the {@link Taxon} and at
393
     *             the {@link Synonym} with <code>orphanDelete=true</code>. Just
394
     *             remove the from and to entities from the relationship and
395
     *             hibernate will care for the deletion. Using this method can cause
396
     *             <code>StaleStateException</code> (see http://dev.e-taxonomy.eu/trac/ticket/3797)
397
     */
398
    @Deprecated
399
    public long deleteSynonymRelationships(Synonym syn, Taxon taxon);
400

    
401
    public List<UUID> findIdenticalTaxonNameIds(List<String> propertyPath);
402

    
403
    public List<TaxonNameBase> findIdenticalNamesNew(List <String> propertyPaths);
404

    
405

    
406
    public Integer countSynonymRelationships(TaxonBase taxonBase,
407
            SynonymRelationshipType type, Direction relatedfrom);
408

    
409
    public List<SynonymRelationship> getSynonymRelationships(TaxonBase taxonBase,
410
            SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
411
            List<OrderHint> orderHints, List<String> propertyPaths,
412
            Direction relatedfrom);
413

    
414
    /**
415
     * @return
416
     */
417
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
418

    
419
    /**
420
     * @return
421
     */
422
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
423

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

    
427
    public List<String> taxaByNameNotInDB(List<String> taxonNames);
428

    
429
    public List<Taxon> listAcceptedTaxaFor(Synonym synonym, Classification classificationFilter, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
430
            List<String> propertyPaths);
431

    
432
    public long countAcceptedTaxaFor(Synonym synonym, Classification classificationFilter);
433

    
434
	public List<UuidAndTitleCache<IdentifiableEntity>> getTaxaByCommonNameForEditor(
435
			String titleSearchStringSqlized, Classification classification,
436
			MatchMode matchMode, Set namedAreas);
437

    
438
	public <S extends TaxonBase> List<Object[]> findByIdentifier(Class<S> clazz, String identifier,
439
			DefinedTerm identifierType, TaxonNode subtreeFilter, MatchMode matchmode,
440
			boolean includeEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
441

    
442
	public <S extends TaxonBase> int countByIdentifier(Class<S> clazz,
443
			String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter, MatchMode matchmode);
444

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

    
455
}
(2-2/3)