Major changes to the cdmlib default term loading and initialization, plus free-text...
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IDescriptionService.java
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.api.service;
11
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Set;
16 import java.util.UUID;
17
18 import eu.etaxonomy.cdm.api.service.pager.Pager;
19 import eu.etaxonomy.cdm.model.common.TermVocabulary;
20 import eu.etaxonomy.cdm.model.common.VersionableEntity;
21 import eu.etaxonomy.cdm.model.description.DescriptionBase;
22 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
23 import eu.etaxonomy.cdm.model.description.Feature;
24 import eu.etaxonomy.cdm.model.description.FeatureNode;
25 import eu.etaxonomy.cdm.model.description.FeatureTree;
26 import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;
27 import eu.etaxonomy.cdm.model.description.Scope;
28 import eu.etaxonomy.cdm.model.description.TaxonDescription;
29 import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
30 import eu.etaxonomy.cdm.model.description.TextData;
31 import eu.etaxonomy.cdm.model.location.NamedArea;
32 import eu.etaxonomy.cdm.model.media.Media;
33 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
34 import eu.etaxonomy.cdm.model.taxon.Taxon;
35
36 public interface IDescriptionService extends IIdentifiableEntityService<DescriptionBase> {
37
38 /**
39 * @param uuid
40 * @return
41 */
42 public abstract DescriptionBase getDescriptionBaseByUuid(UUID uuid);
43
44 /**
45 * Persists a <code>Description</code>
46 * @param description
47 * @return
48 */
49 public abstract UUID saveDescription(DescriptionBase description);
50
51 /**
52 * Persists a <code>FeatureTree</code>
53 * @param tree
54 * @return
55 */
56 public abstract UUID saveFeatureTree(FeatureTree tree);
57 // FIXME could you handle the feature data elements using @Cascade?
58 public abstract void saveFeatureDataAll(Collection<VersionableEntity> featureData);
59 public abstract Map<UUID, FeatureTree> saveFeatureTreeAll(Collection<FeatureTree> trees);
60 public abstract Map<UUID, FeatureNode> saveFeatureNodeAll(Collection<FeatureNode> nodes);
61
62 public abstract List<FeatureTree> getFeatureTreesAll();
63 public abstract List<FeatureNode> getFeatureNodesAll();
64
65 public abstract TermVocabulary<Feature> getDefaultFeatureVocabulary();
66 public abstract TermVocabulary<Feature> getFeatureVocabulary(UUID uuid);
67
68 /**
69 * List the descriptions of type <TYPE>, filtered using the following parameters
70 *
71 * @param type The type of description returned (Taxon, TaxonName, or Specimen)
72 * @param hasMedia Restrict the description to those that do (true) or don't (false) contain <i>elements</i> that have one or more media (can be null)
73 * @param hasText Restrict the description to those that do (true) or don't (false) contain TextData <i>elements</i> that have some textual content (can be null)
74 * @param feature Restrict the description to those <i>elements</i> which are scoped by one of the Features passed (can be null or empty)
75 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
76 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
77 * @return a Pager containing DescriptionBase instances
78 */
79 public <TYPE extends DescriptionBase> Pager<TYPE> listDescriptions(Class<TYPE> type, Boolean hasMedia, Boolean hasText, Set<Feature> feature, Integer pageSize, Integer pageNumber);
80
81 /**
82 * Count the descriptions of type <TYPE>, filtered using the following parameters
83 *
84 * @param type The type of description returned (Taxon, TaxonName, or Specimen)
85 * @param hasMedia Restrict the description to those that do (true) or don't (false) contain <i>elements</i> that have one or more media (can be null)
86 * @param hasText Restrict the description to those that do (true) or don't (false) contain TextData <i>elements</i> that have some textual content (can be null)
87 * @param feature Restrict the description to those <i>elements</i> which are scoped by one of the Features passed (can be null or empty)
88 * @return a count of DescriptionBase instances
89 */
90 public <TYPE extends DescriptionBase> int countDescriptions(Class<TYPE> type, Boolean hasImages, Boolean hasText, Set<Feature> feature);
91
92 /**
93 * Returns description elements of type <TYPE>, belonging to a given description, optionally filtered by one or more features
94 *
95 * @param description The description which these description elements belong to (can be null to count all description elements)
96 * @param features Restrict the results to those description elements which are scoped by one of the Features passed (can be null or empty)
97 * @param type The type of description
98 * @param pageSize The maximum number of description elements returned (can be null for all description elements)
99 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
100 * @return a Pager containing DescriptionElementBase instances
101 */
102 public <TYPE extends DescriptionElementBase> Pager<TYPE> getDescriptionElements(DescriptionBase description,Set<Feature> features, Class<TYPE> type, Integer pageSize, Integer pageNumber);
103
104 /**
105 * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
106 *
107 * @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)
108 * @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)
109 * @param geographicalScope Restrict the results to those descriptions which have a geographical scope that overlaps with the NamedArea instances passed (can be null or empty)
110 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
111 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
112 * @return a Pager containing TaxonDescription instances
113 */
114 public Pager<TaxonDescription> getTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Integer pageSize, Integer pageNumber);
115
116 /**
117 * Returns a List of TaxonNameDescription instances, optionally filtered by the name which they refer to
118 *
119 * @param name Restrict the results to those descriptions that refer to a specific name (can be null for all TaxonNameDescription instances)
120 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
121 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
122 * @return a Pager containing TaxonNameBase instances
123 */
124 public Pager<TaxonNameDescription> getTaxonNameDescriptions(TaxonNameBase name, Integer pageSize, Integer pageNumber);
125
126 /**
127 * Returns a List of distinct TaxonDescription instances which have Distribution elements that refer to one of the NamedArea instances passed (optionally
128 * filtered by a type of PresenceAbsenceTerm e.g. PRESENT / ABSENT / NATIVE / CULTIVATED etc)
129 *
130 * @param namedAreas The set of NamedArea instances
131 * @param presence Restrict the descriptions to those which have Distribution elements are of this status (can be null)
132 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
133 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
134 * @return a Pager containing TaxonDescription instances
135 */
136 public Pager<TaxonDescription> searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTermBase presence, Integer pageSize, Integer pageNumber);
137
138 /**
139 * Returns a List of TextData elements that match a given queryString provided.
140 *
141 * @param queryString
142 * @param pageSize
143 * @param pageNumber
144 * @return
145 * @throws QueryParseException
146 */
147 public Pager<TextData> searchTextData(String queryString, Integer pageSize, Integer pageNumber);
148
149 /**
150 * Returns a List of Media that are associated with a given description element
151 *
152 * @param descriptionElement the description element associated with these media
153 * @param pageSize The maximum number of media returned (can be null for all related media)
154 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
155 * @return a Pager containing media instances
156 */
157 public Pager<Media> getMedia(DescriptionElementBase descriptionElement, Integer pageSize, Integer pageNumber);
158
159 }