Project

General

Profile

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

    
11
package eu.etaxonomy.cdm.api.service;
12

    
13
import java.io.IOException;
14
import java.util.Collection;
15
import java.util.List;
16
import java.util.Set;
17
import java.util.UUID;
18

    
19
import org.apache.lucene.index.CorruptIndexException;
20
import org.apache.lucene.queryParser.ParseException;
21
import org.hibernate.search.spatial.impl.Rectangle;
22

    
23
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
24
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
25
import eu.etaxonomy.cdm.api.service.pager.Pager;
26
import eu.etaxonomy.cdm.api.service.search.SearchResult;
27
import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;
28
import eu.etaxonomy.cdm.model.common.Language;
29
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
30
import eu.etaxonomy.cdm.model.description.DescriptionBase;
31
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
32
import eu.etaxonomy.cdm.model.description.TaxonDescription;
33
import eu.etaxonomy.cdm.model.location.Country;
34
import eu.etaxonomy.cdm.model.media.Media;
35
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
36
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
37
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
38
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
39
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
40
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
41
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
42
import eu.etaxonomy.cdm.model.taxon.Taxon;
43
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
44
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
45
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
46
import eu.etaxonomy.cdm.persistence.query.OrderHint;
47

    
48
/**
49
 * @author a.babadshanjan
50
 * @created 01.09.2008
51
 */
52
public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenOrObservationBase> {
53

    
54
    public Country getCountryByIso(String iso639);
55

    
56
    public List<Country> getCountryByName(String name);
57

    
58
    /**
59
     * Returns a paged list of occurrences that have been determined to belong
60
     * to the taxon concept determinedAs, optionally restricted to objects
61
     * belonging to a class that that extends SpecimenOrObservationBase.
62
     * <p>
63
     * In contrast to {@link #listByAnyAssociation(Class, Taxon, List)} this
64
     * method only takes SpecimenOrObservationBase instances into account which
65
     * are actually determined as the taxon specified by
66
     * <code>determinedAs</code>.
67
     *
68
     * @param type
69
     *            The type of entities to return (can be null to count all
70
     *            entities of type <T>)
71
     * @param determinedAs
72
     *            the taxon concept that the occurrences have been determined to
73
     *            belong to
74
     * @param pageSize
75
     *            The maximum number of objects returned (can be null for all
76
     *            matching objects)
77
     * @param pageNumber
78
     *            The offset (in pageSize chunks) from the start of the result
79
     *            set (0 - based, can be null, equivalent of starting at the
80
     *            beginning of the recordset)
81
     * @param orderHints
82
     *            Supports path like <code>orderHints.propertyNames</code> which
83
     *            include *-to-one properties like createdBy.username or
84
     *            authorTeam.persistentTitleCache
85
     * @param propertyPaths
86
     *            properties to be initialized
87
     * @return
88
     */
89
    public Pager<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonBase determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
90

    
91
    /**
92
     * Returns a List of Media that are associated with a given occurence
93
     *
94
     * @param occurence the occurence associated with these media
95
     * @param pageSize The maximum number of media returned (can be null for all related media)
96
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
97
     * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
98
     * @return a Pager of media instances
99
     */
100
    public Pager<Media> getMedia(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
101

    
102
    /**
103
     * Returns a List of determinations that have been made for a given occurence
104
     *
105
     * @param occurence the occurence associated with these determinations (can be null for all occurrences)
106
     * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
107
     * @param pageSize The maximum number of determinations returned (can be null for all related determinations)
108
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
109
     * @return a Pager of determination instances
110
     */
111
    public Pager<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence, TaxonBase taxonBase, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
112

    
113
    /**
114
     * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
115
     *
116
     * @param occurence the occurence that was a source of these derivation events
117
     * @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
118
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
119
     * @return a Pager of derivation events
120
     */
121
    public Pager<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
122

    
123
    /**
124
     * Returns a Paged List of SpecimenOrObservationBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
125
     *
126
     * @param clazz filter the results by class (or pass null to return all SpecimenOrObservationBase instances)
127
     * @param queryString
128
     * @param pageSize The maximum number of occurrences returned (can be null for all matching occurrences)
129
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
130
     * @param orderHints
131
     *            Supports path like <code>orderHints.propertyNames</code> which
132
     *            include *-to-one properties like createdBy.username or
133
     *            authorTeam.persistentTitleCache
134
     * @param propertyPaths properties to be initialized
135
     * @return a Pager SpecimenOrObservationBase instances
136
     * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
137
     */
138
    @Override
139
    public Pager<SpecimenOrObservationBase> search(Class<? extends SpecimenOrObservationBase> clazz, String query, Integer pageSize,Integer pageNumber, List<OrderHint> orderHints,List<String> propertyPaths);
140

    
141
    /**
142
     * Retrieves the {@link UUID} and the string representation (title cache) of all
143
     * {@link FieldUnit}s found in the data base.
144
     * @return a list of {@link UuidAndTitleCache}
145
     */
146
    public List<UuidAndTitleCache<FieldUnit>> getFieldUnitUuidAndTitleCache();
147

    
148
    /**
149
     * Retrieves the {@link UUID} and the string representation (title cache) of all
150
     * {@link DerivedUnit}s found in the data base.
151
     * @return a list of {@link UuidAndTitleCache}
152
     */
153
    public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache();
154

    
155
    public DerivedUnitFacade getDerivedUnitFacade(DerivedUnit derivedUnit, List<String> propertyPaths) throws DerivedUnitFacadeNotSupportedException;
156

    
157
    public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, List<String> propertyPaths);
158

    
159
    /**
160
     * Lists all instances of {@link SpecimenOrObservationBase} which are
161
     * associated with the <code>taxon</code> specified as parameter.
162
     * SpecimenOrObservationBase instances can be associated to taxa in multiple
163
     * ways, all these possible relations are taken into account:
164
     * <ul>
165
     * <li>The {@link IndividualsAssociation} elements in a
166
     * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
167
     * <li>{@link SpecimenTypeDesignation}s may be associated with any
168
     * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
169
     * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
170
     * of the {@link SpecimenOrObservationBase}</li>
171
     * </ul>
172
     * Further more there also can be taxa which are associated with the taxon
173
     * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
174
     * the parameter <code>includeRelationships</code> is containing elements,
175
     * these according {@TaxonRelationshipType}s and
176
     * directional information will be used to collect further
177
     * {@link SpecimenOrObservationBase} instances found this way.
178
     *
179
     * @param <T>
180
     * @param type
181
     * @param associatedTaxon
182
     * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
183
     * @param maxDepth TODO
184
     * @param pageSize
185
     * @param pageNumber
186
     * @param orderHints
187
     * @param propertyPaths
188
     * @return
189
     */
190
    public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
191
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
192

    
193
    /**
194
     * See {@link #listByAssociatedTaxon(Class, Set, Taxon, Integer, Integer, Integer, List, List)}
195
     *
196
     * @param type
197
     * @param includeRelationships
198
     * @param associatedTaxon
199
     * @param maxDepth
200
     * @param pageSize
201
     * @param pageNumber
202
     * @param orderHints
203
     * @param propertyPaths
204
     * @return a Pager
205
     */
206
    public <T extends SpecimenOrObservationBase> Pager<T> pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
207
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
208

    
209
    /**
210
     * Retrieves all {@link FieldUnit}s for the {@link DerivedUnit} with the given {@link UUID}.<br>
211
     * @param derivedUnitUuid the UUID of the derived unit
212
     * @return a collection of FieldUnits this DerivedUnit was derived from or an empty collection if no FieldUnits were found
213
     */
214
    public Collection<FieldUnit> getFieldUnits(UUID derivedUnitUuid);
215

    
216
    /**
217
     * @param clazz
218
     * @param queryString
219
     * @param languages
220
     * @param highlightFragments
221
     * @param pageSize
222
     * @param pageNumber
223
     * @param orderHints
224
     * @param propertyPaths
225
     * @return
226
     * @throws CorruptIndexException
227
     * @throws IOException
228
     * @throws ParseException
229
     */
230
    Pager<SearchResult<SpecimenOrObservationBase>> findByFullText(Class<? extends SpecimenOrObservationBase> clazz,
231
            String queryString, Rectangle boundingBox, List<Language> languages, boolean highlightFragments, Integer pageSize,
232
            Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws CorruptIndexException,
233
            IOException, ParseException;
234
    /**
235
     * See {@link #listByAssociatedTaxon(Class, Set, String, Integer, Integer, Integer, List, List)}
236
     *
237
     * @param type
238
     * @param includeRelationships
239
     * @param associatedTaxon
240
     * @param maxDepth
241
     * @param pageSize
242
     * @param pageNumber
243
     * @param orderHints
244
     * @param propertyPaths
245
     * @return a Pager
246
     */
247
    public <T extends SpecimenOrObservationBase> Pager<T>  pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
248
            String taxonUUID, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
249

    
250

    
251
}
(46-46/86)