Revision 933e5ac3
Added by Cherian Mathew over 9 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ICommonService.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
18 | 18 |
import org.hibernate.Session; |
19 | 19 |
import org.hibernate.collection.spi.PersistentCollection; |
20 | 20 |
|
21 |
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase; |
|
22 |
import eu.etaxonomy.cdm.database.DatabaseSchemaMismatchException; |
|
23 | 21 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
24 | 22 |
import eu.etaxonomy.cdm.model.common.ISourceable; |
25 | 23 |
import eu.etaxonomy.cdm.model.common.OriginalSourceBase; |
26 | 24 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData; |
27 | 25 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName; |
28 |
import eu.etaxonomy.cdm.model.reference.IGeneric; |
|
29 | 26 |
import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao; |
30 | 27 |
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy; |
31 | 28 |
import eu.etaxonomy.cdm.strategy.match.IMatchable; |
32 | 29 |
import eu.etaxonomy.cdm.strategy.match.MatchException; |
30 |
import eu.etaxonomy.cdm.strategy.match.MatchStrategyConfigurator; |
|
33 | 31 |
import eu.etaxonomy.cdm.strategy.merge.IMergable; |
34 | 32 |
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy; |
35 | 33 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
36 | 34 |
|
37 | 35 |
|
38 | 36 |
public interface ICommonService extends IService<OriginalSourceBase>{ |
39 |
//
|
|
37 |
// |
|
40 | 38 |
// /** find cdmBase by UUID**/ |
41 | 39 |
// public abstract CdmBase getCdmBaseByUuid(UUID uuid); |
42 | 40 |
// |
... | ... | |
48 | 46 |
* @param metaData |
49 | 47 |
*/ |
50 | 48 |
public void saveAllMetaData(Collection<CdmMetaData> metaData); |
51 |
|
|
49 |
|
|
52 | 50 |
/** |
53 | 51 |
* Returns all meta data. |
54 | 52 |
* @return |
55 | 53 |
*/ |
56 | 54 |
public Map<MetaDataPropertyName, CdmMetaData> getCdmMetaData(); |
57 |
|
|
58 |
|
|
55 |
|
|
56 |
|
|
59 | 57 |
/** |
60 |
* Returns a map of identifiable entities of class <code>clazz</code> which have an original source of
|
|
58 |
* Returns a map of identifiable entities of class <code>clazz</code> which have an original source of |
|
61 | 59 |
* with namespace <code>idNamespace</code> and with an idInSource in <code>idInSourceSet</code> <BR> |
62 | 60 |
* The key of the map is the idInSource. If there are multiple objects that have the same id an arbitrary one is chosen. |
63 | 61 |
* @param clazz |
... | ... | |
66 | 64 |
* @return |
67 | 65 |
*/ |
68 | 66 |
public Map<String, ? extends ISourceable> getSourcedObjectsByIdInSource(Class clazz, Set<String> idInSourceSet, String idNamespace); |
69 |
|
|
67 |
|
|
70 | 68 |
/** |
71 | 69 |
* Returns a list of identifiable entities according to their class, idInSource and idNamespace |
72 | 70 |
* @param clazz |
... | ... | |
76 | 74 |
*/ |
77 | 75 |
public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace); |
78 | 76 |
|
79 |
|
|
77 |
|
|
80 | 78 |
/** |
81 | 79 |
* Returns all CdmBase objects that reference the referencedCdmBase. |
82 | 80 |
* For example, if referencedCdmBase is an agent it may return all taxon names |
83 |
* that have this person as an author but also all books, articles, etc. that have
|
|
81 |
* that have this person as an author but also all books, articles, etc. that have |
|
84 | 82 |
* this person as an author |
85 | 83 |
* @param referencedCdmBase |
86 | 84 |
* @return |
87 | 85 |
*/ |
88 | 86 |
public Set<CdmBase> getReferencingObjects(CdmBase referencedCdmBase); |
89 |
|
|
87 |
|
|
90 | 88 |
/** |
91 | 89 |
* Merges mergeSecond into mergeFirst. All references to mergeSecond will be replaced by references |
92 | 90 |
* to merge first. If no merge strategy is defined (null), the DefaultMergeStrategy will be taken as default. |
... | ... | |
97 | 95 |
* @throws MergeException |
98 | 96 |
*/ |
99 | 97 |
public <T extends IMergable> void merge(T mergeFirst, T mergeSecond, IMergeStrategy mergeStrategy) throws MergeException; |
100 |
|
|
98 |
|
|
101 | 99 |
/** |
102 | 100 |
* Returns all objects that match the object to match according to the given match strategy. |
103 | 101 |
* If no match strategy is defined the default match strategy is taken. |
... | ... | |
108 | 106 |
* @throws MatchException |
109 | 107 |
*/ |
110 | 108 |
public <T extends IMatchable> List<T> findMatching(T objectToMatch, IMatchStrategy matchStrategy) throws MatchException; |
111 |
|
|
109 |
|
|
110 |
public <T extends IMatchable> List<T> findMatching(T objectToMatch, MatchStrategyConfigurator.MatchStrategy strategy) throws MatchException; |
|
111 |
|
|
112 | 112 |
/** |
113 | 113 |
* A generic method to retrieve any CdmBase object by its id and class.<BR> |
114 | 114 |
* @see ICdmGenericDao#find(Class, int) |
... | ... | |
123 | 123 |
|
124 | 124 |
/** |
125 | 125 |
* Initializes a lazy loaded persistent collection. |
126 |
*
|
|
126 |
* |
|
127 | 127 |
* @param col the persistent collection to initialize |
128 | 128 |
* @return the initialized persistent collection |
129 | 129 |
*/ |
130 | 130 |
public PersistentCollection initializeCollection(PersistentCollection col); |
131 |
|
|
131 |
|
|
132 | 132 |
/** |
133 | 133 |
* Checks if a lazy loaded persistent collection is empty. |
134 |
*
|
|
135 |
* @param col the persistent collection
|
|
134 |
* |
|
135 |
* @param col the persistent collection |
|
136 | 136 |
* @return the initialized persistent collection |
137 | 137 |
*/ |
138 | 138 |
public boolean isEmpty(PersistentCollection col); |
139 |
|
|
139 |
|
|
140 | 140 |
/** |
141 | 141 |
* Returns the size of a persistent collection. |
142 |
*
|
|
142 |
* |
|
143 | 143 |
* @param col the persistent collection to initialize |
144 | 144 |
* @return the size of the persistent collection |
145 | 145 |
*/ |
146 | 146 |
public int size(PersistentCollection col); |
147 |
|
|
147 |
|
|
148 | 148 |
/** |
149 | 149 |
* Returns the object contained in a persistent collection at the given index. |
150 |
*
|
|
151 |
* @param col the persistent collection
|
|
150 |
* |
|
151 |
* @param col the persistent collection |
|
152 | 152 |
* @param index the index of the requested element |
153 | 153 |
* @return the object at the requested index |
154 | 154 |
*/ |
155 | 155 |
public Object get(PersistentCollection col, int index); |
156 |
|
|
156 |
|
|
157 | 157 |
/** |
158 | 158 |
* checks whether an object is contained within a persistent collection. |
159 |
*
|
|
160 |
* @param col the persistent collection
|
|
159 |
* |
|
160 |
* @param col the persistent collection |
|
161 | 161 |
* @param element the element to check for |
162 | 162 |
* @return true if the element exists in the collection, false o/w |
163 | 163 |
*/ |
164 | 164 |
public boolean contains(PersistentCollection col, Object element); |
165 |
|
|
165 |
|
|
166 | 166 |
/** |
167 | 167 |
* checks whether an index object exists within a persistent collection |
168 | 168 |
* (usually a map) |
169 |
*
|
|
170 |
* @param col the persistent collection
|
|
169 |
* |
|
170 |
* @param col the persistent collection |
|
171 | 171 |
* @param key the index object to look for. |
172 | 172 |
* @return true if the index object exists in the collection, false o/w |
173 | 173 |
*/ |
174 | 174 |
public boolean containsKey(PersistentCollection col, Object key); |
175 |
|
|
175 |
|
|
176 | 176 |
/** |
177 | 177 |
* checks whether an value object exists within a persistent collection |
178 | 178 |
* (usually a map) |
179 |
*
|
|
180 |
* @param col the persistent collection
|
|
179 |
* |
|
180 |
* @param col the persistent collection |
|
181 | 181 |
* @param key the value object to look for. |
182 | 182 |
* @return true if the value object exists in the collection, false o/w |
183 | 183 |
*/ |
184 | 184 |
public boolean containsValue(PersistentCollection col, Object element); |
185 | 185 |
|
186 | 186 |
public Set<CdmBase> getReferencingObjectsForDeletion(CdmBase referencedCdmBase); |
187 |
|
|
187 |
|
|
188 | 188 |
/** |
189 | 189 |
* Preliminary, may be moved to test later |
190 | 190 |
*/ |
191 | 191 |
@Deprecated |
192 | 192 |
public void createFullSampleData(); |
193 |
|
|
194 |
|
|
193 |
|
|
194 |
|
|
195 | 195 |
} |
Also available in: Unified diff
ICdmCacher, ICdmUuidCacher, CdmCacher, CdmTermCacher : refactored and added load method
Language, NameRelationshipType, Rank : now uses cacher only if termap is null or empty and only when class matches the specific term type
MockCdmCacher: not required anymore
DefaultTermInitializer : removed acall to mock cacher
MatchStrategyConfigurator : moved from editor to cdmlib
CdmDataChangeEvent : added constructor
CommonServiceImpl, ICommonService : added call to findMatchingStrategy with enum instead of object
DescriptionServiceImpl, IDescriptionService, PolytomousKeyNodeServiceImpl, IPolytomousKeyNodeService, TaxonNodeServiceImpl, ITaxonNodeService, TaxonServiceImpl: added uuid methods