Revision 52c34f45
Added by Andreas Müller almost 8 years ago
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 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 |
package eu.etaxonomy.cdm.api.service; |
|
11 |
|
|
12 |
import static org.junit.Assert.assertEquals; |
|
13 |
import static org.junit.Assert.assertFalse; |
|
14 |
import static org.junit.Assert.assertNotEquals; |
|
15 |
import static org.junit.Assert.assertNotNull; |
|
16 |
import static org.junit.Assert.assertNull; |
|
17 |
import static org.junit.Assert.assertTrue; |
|
18 |
|
|
19 |
import java.io.FileNotFoundException; |
|
20 |
import java.util.List; |
|
21 |
import java.util.Set; |
|
22 |
import java.util.UUID; |
|
23 |
|
|
24 |
import org.apache.log4j.Logger; |
|
25 |
import org.junit.Test; |
|
26 |
import org.unitils.dbunit.annotation.DataSet; |
|
27 |
import org.unitils.spring.annotation.SpringBeanByType; |
|
28 |
|
|
29 |
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator; |
|
30 |
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator.AssignmentStatus; |
|
31 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator; |
|
32 |
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; |
|
33 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
34 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
35 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
36 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
37 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
38 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
39 |
import eu.etaxonomy.cdm.model.common.Identifier; |
|
40 |
import eu.etaxonomy.cdm.model.common.Language; |
|
41 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
42 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
43 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
44 |
import eu.etaxonomy.cdm.model.description.IndividualsAssociation; |
|
45 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
46 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
47 |
import eu.etaxonomy.cdm.model.location.Country; |
|
48 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
49 |
import eu.etaxonomy.cdm.model.location.Point; |
|
50 |
import eu.etaxonomy.cdm.model.location.ReferenceSystem; |
|
51 |
import eu.etaxonomy.cdm.model.molecular.DnaSample; |
|
52 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
|
53 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
54 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
55 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
56 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
57 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
|
58 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
|
59 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
|
60 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType; |
|
61 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
62 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; |
|
63 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
64 |
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent; |
|
65 |
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen; |
|
66 |
import eu.etaxonomy.cdm.model.occurrence.PreservationMethod; |
|
67 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
68 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
69 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
70 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
71 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
72 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
|
73 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
74 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
75 |
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest; |
|
76 |
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy; |
|
77 |
|
|
78 |
/** |
|
79 |
* @author pplitzner |
|
80 |
* @date 31.03.2014 |
|
81 |
* |
|
82 |
*/ |
|
83 |
public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest { |
|
84 |
|
|
85 |
@SuppressWarnings("unused") |
|
86 |
private static final Logger logger = Logger.getLogger(OccurrenceServiceTest.class); |
|
87 |
|
|
88 |
@SpringBeanByType |
|
89 |
private IOccurrenceService occurrenceService; |
|
90 |
|
|
91 |
@SpringBeanByType |
|
92 |
private ISequenceService sequenceService; |
|
93 |
|
|
94 |
@SpringBeanByType |
|
95 |
private ITaxonService taxonService; |
|
96 |
|
|
97 |
@SpringBeanByType |
|
98 |
private INameService nameService; |
|
99 |
|
|
100 |
@SpringBeanByType |
|
101 |
private ITermService termService; |
|
102 |
|
|
103 |
@SpringBeanByType |
|
104 |
private IDescriptionService descriptionService; |
|
105 |
|
|
106 |
@Test |
|
107 |
public void testGetNonCascadedAssociatedElements() { |
|
108 |
// Collection |
|
109 |
Collection collection = Collection.NewInstance(); |
|
110 |
Collection subCollection = Collection.NewInstance(); |
|
111 |
subCollection.setSuperCollection(collection); |
|
112 |
|
|
113 |
Institution institution = Institution.NewInstance(); |
|
114 |
institution |
|
115 |
.addType(DefinedTerm.NewInstitutionTypeInstance("Research and teaching", "botanical garden", "BGBM")); |
|
116 |
collection.setInstitute(institution); |
|
117 |
|
|
118 |
// Source |
|
119 |
Reference<?> article = ReferenceFactory.newArticle(getReference(), Person.NewInstance(), "title", "pages", |
|
120 |
"series", "volume", TimePeriod.NewInstance(2014)); |
|
121 |
IdentifiableSource source = IdentifiableSource.NewPrimarySourceInstance(article, "microCitation"); |
|
122 |
|
|
123 |
// FieldUnit |
|
124 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
125 |
Person primaryCollector = Person.NewInstance(); |
|
126 |
primaryCollector.setLifespan(TimePeriod.NewInstance(2014)); |
|
127 |
fieldUnit.setPrimaryCollector(primaryCollector); |
|
128 |
fieldUnit.addSource(source); |
|
129 |
|
|
130 |
// GatheringEvent |
|
131 |
GatheringEvent gatheringEvent = GatheringEvent.NewInstance(); |
|
132 |
fieldUnit.setGatheringEvent(gatheringEvent); |
|
133 |
gatheringEvent.putLocality(Language.ENGLISH(), "locality"); |
|
134 |
gatheringEvent.setExactLocation(Point.NewInstance(22.4, -34.2, |
|
135 |
ReferenceSystem.NewInstance("MyReferenceSystem", "label", "labelAbbrev"), 33)); |
|
136 |
gatheringEvent.setCountry(Country.GERMANY()); |
|
137 |
gatheringEvent.addCollectingArea(NamedArea.EUROPE()); |
|
138 |
|
|
139 |
// Derived Unit |
|
140 |
MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage); |
|
141 |
mediaSpecimen.setCollection(collection); |
|
142 |
BotanicalName storedUnder = BotanicalName.NewInstance(Rank.SPECIES()); |
|
143 |
mediaSpecimen.setStoredUnder(storedUnder); |
|
144 |
PreservationMethod preservation = PreservationMethod.NewInstance(null, "My preservation"); |
|
145 |
preservation.setMedium(DefinedTerm.NewDnaMarkerInstance("medium", "medium", "medium"));// dummy |
|
146 |
// defined |
|
147 |
// term |
|
148 |
mediaSpecimen.setPreservation(preservation); |
|
149 |
|
|
150 |
// DerivationEvent |
|
151 |
DerivationEvent event = DerivationEvent.NewInstance(DerivationEventType.ACCESSIONING()); |
|
152 |
event.addOriginal(fieldUnit); |
|
153 |
event.addDerivative(mediaSpecimen); |
|
154 |
|
|
155 |
// SpecOrObservationBase |
|
156 |
fieldUnit.setSex(DefinedTerm.SEX_FEMALE()); |
|
157 |
fieldUnit.setLifeStage(DefinedTerm.NewStageInstance("Live stage", "stage", null)); |
|
158 |
fieldUnit.setKindOfUnit(DefinedTerm.NewKindOfUnitInstance("Kind of unit", "Kind of unit", null)); |
|
159 |
fieldUnit.putDefinition(Language.ENGLISH(), "definition"); |
|
160 |
|
|
161 |
// Determination |
|
162 |
DeterminationEvent determinationEvent = DeterminationEvent.NewInstance(getTaxon(), mediaSpecimen); |
|
163 |
determinationEvent.setModifier(DefinedTerm.NewModifierInstance("modifierDescription", "modifierLabel", |
|
164 |
"mofifierLabelAbbrev")); |
|
165 |
determinationEvent.setPreferredFlag(true); |
|
166 |
Reference<?> reference = getReference(); |
|
167 |
determinationEvent.addReference(reference); |
|
168 |
|
|
169 |
/* |
|
170 |
* NonCascaded SOOB - sex (FEMALE) - stage (Live stage) - kindOfUnit |
|
171 |
* (Kind of unit) GatheringEvent - country (GERMANY) - collectingArea |
|
172 |
* (EUROPE) DerivedUnit - storedUnder (botanical name) DerivedUnit-> |
|
173 |
* Collection -> institiute - type (botanical garden) |
|
174 |
*/ |
|
175 |
|
|
176 |
assertEquals("Incorrect number of non cascaded CDM entities", 9, occurrenceService |
|
177 |
.getNonCascadedAssociatedElements(fieldUnit).size()); |
|
178 |
assertEquals("Incorrect number of non cascaded CDM entities", 9, occurrenceService |
|
179 |
.getNonCascadedAssociatedElements(mediaSpecimen).size()); |
|
180 |
|
|
181 |
} |
|
182 |
|
|
183 |
private Reference<?> getReference() { |
|
184 |
Reference<?> result = ReferenceFactory.newGeneric(); |
|
185 |
result.setTitle("some generic reference"); |
|
186 |
return result; |
|
187 |
} |
|
188 |
|
|
189 |
private Taxon getTaxon() { |
|
190 |
Reference<?> sec = getReference(); |
|
191 |
TaxonNameBase<?, ?> name = BotanicalName.NewInstance(Rank.GENUS()); |
|
192 |
Taxon taxon = Taxon.NewInstance(name, sec); |
|
193 |
return taxon; |
|
194 |
|
|
195 |
} |
|
196 |
|
|
197 |
@Test |
|
198 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurenceServiceTest.move.xml") |
|
199 |
public void testMoveDerivate() { |
|
200 |
DerivedUnit specimenA = (DerivedUnit) occurrenceService.load(UUID |
|
201 |
.fromString("35cfb0b3-588d-4eee-9db6-ac9caa44e39a")); |
|
202 |
DerivedUnit specimenB = (DerivedUnit) occurrenceService.load(UUID |
|
203 |
.fromString("09496534-efd0-44c8-b1ce-01a34a8a0229")); |
|
204 |
DerivedUnit dnaSample = (DnaSample) occurrenceService.load(UUID |
|
205 |
.fromString("5995f852-0e78-405c-b849-d923bd6781d9")); |
|
206 |
|
|
207 |
occurrenceService.saveOrUpdate(specimenA); |
|
208 |
occurrenceService.saveOrUpdate(specimenB); |
|
209 |
occurrenceService.saveOrUpdate(dnaSample); |
|
210 |
|
|
211 |
Person derivationActor = Person.NewTitledInstance("Derivation Actor"); |
|
212 |
String derivationDescription = "Derivation Description"; |
|
213 |
Institution derivationInstitution = Institution.NewInstance(); |
|
214 |
TimePeriod derivationTimePeriod = TimePeriod.NewInstance(2015); |
|
215 |
|
|
216 |
DerivationEvent originalDerivedFromEvent = DerivationEvent.NewSimpleInstance(specimenA, dnaSample, |
|
217 |
DerivationEventType.DNA_EXTRACTION()); |
|
218 |
|
|
219 |
originalDerivedFromEvent.setActor(derivationActor); |
|
220 |
originalDerivedFromEvent.setDescription(derivationDescription); |
|
221 |
originalDerivedFromEvent.setInstitution(derivationInstitution); |
|
222 |
originalDerivedFromEvent.setTimeperiod(derivationTimePeriod); |
|
223 |
|
|
224 |
occurrenceService.moveDerivate(specimenA, specimenB, dnaSample); |
|
225 |
assertTrue("DerivationEvent not removed from source!", specimenA.getDerivationEvents().isEmpty()); |
|
226 |
assertEquals("DerivationEvent not moved to source!", 1, specimenB.getDerivationEvents().size()); |
|
227 |
|
|
228 |
DerivationEvent derivationEvent = specimenB.getDerivationEvents().iterator().next(); |
|
229 |
assertEquals("Moved DerivationEvent not of same type!", DerivationEventType.DNA_EXTRACTION(), |
|
230 |
derivationEvent.getType()); |
|
231 |
assertEquals(derivationActor, derivationEvent.getActor()); |
|
232 |
assertEquals(derivationDescription, derivationEvent.getDescription()); |
|
233 |
assertEquals(derivationInstitution, derivationEvent.getInstitution()); |
|
234 |
assertEquals(derivationTimePeriod, derivationEvent.getTimeperiod()); |
|
235 |
assertEquals(DerivationEventType.DNA_EXTRACTION(), derivationEvent.getType()); |
|
236 |
|
|
237 |
assertEquals("Wrong number of derivation originals!", 1, derivationEvent.getOriginals().size()); |
|
238 |
SpecimenOrObservationBase<?> newOriginal = derivationEvent.getOriginals().iterator().next(); |
|
239 |
assertEquals("Target of moved object not correct", specimenB, newOriginal); |
|
240 |
assertEquals("Wrong number of derivatives!", 1, derivationEvent.getDerivatives().size()); |
|
241 |
|
|
242 |
DerivedUnit movedDerivate = derivationEvent.getDerivatives().iterator().next(); |
|
243 |
assertEquals("Moved derivate has wrong type", SpecimenOrObservationType.DnaSample, |
|
244 |
movedDerivate.getRecordBasis()); |
|
245 |
assertNotEquals("DerivationEvent 'derivedFrom' has not been changed after moving", originalDerivedFromEvent, |
|
246 |
movedDerivate.getDerivedFrom()); |
|
247 |
|
|
248 |
} |
|
249 |
|
|
250 |
@Test |
|
251 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "BlankDataSet.xml") |
|
252 |
public void testMoveDerivateNoParent() { |
|
253 |
DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
254 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
255 |
|
|
256 |
occurrenceService.saveOrUpdate(fieldUnit); |
|
257 |
occurrenceService.saveOrUpdate(derivedUnit); |
|
258 |
|
|
259 |
assertEquals("DerivationEvent not moved to source!", 0, fieldUnit.getDerivationEvents().size()); |
|
260 |
occurrenceService.moveDerivate(null, fieldUnit, derivedUnit); |
|
261 |
assertEquals("DerivationEvent not moved to source!", 1, fieldUnit.getDerivationEvents().size()); |
|
262 |
|
|
263 |
DerivationEvent derivationEvent = fieldUnit.getDerivationEvents().iterator().next(); |
|
264 |
assertNull(derivationEvent.getType()); |
|
265 |
|
|
266 |
assertEquals("Wrong number of derivation originals!", 1, derivationEvent.getOriginals().size()); |
|
267 |
SpecimenOrObservationBase<?> newOriginal = derivationEvent.getOriginals().iterator().next(); |
|
268 |
assertEquals("Target of moved object not correct", fieldUnit, newOriginal); |
|
269 |
assertEquals("Wrong number of derivatives!", 1, derivationEvent.getDerivatives().size()); |
|
270 |
} |
|
271 |
|
|
272 |
@Test |
|
273 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurenceServiceTest.move.xml") |
|
274 |
public void testMoveSequence() { |
|
275 |
DnaSample dnaSampleA = (DnaSample) occurrenceService.load(UUID |
|
276 |
.fromString("5995f852-0e78-405c-b849-d923bd6781d9")); |
|
277 |
DnaSample dnaSampleB = (DnaSample) occurrenceService.load(UUID |
|
278 |
.fromString("85fccc2f-c796-46b3-b2fc-6c9a4d68cfda")); |
|
279 |
String consensusSequence = "ATTCG"; |
|
280 |
Sequence sequence = sequenceService.load(UUID.fromString("6da4f378-9861-4338-861b-7b8073763e7a")); |
|
281 |
|
|
282 |
occurrenceService.saveOrUpdate(dnaSampleA); |
|
283 |
occurrenceService.saveOrUpdate(dnaSampleB); |
|
284 |
sequenceService.saveOrUpdate(sequence); |
|
285 |
|
|
286 |
dnaSampleA.addSequence(sequence); |
|
287 |
|
|
288 |
occurrenceService.moveSequence(dnaSampleA, dnaSampleB, sequence); |
|
289 |
assertEquals("Number of sequences is wrong", 0, dnaSampleA.getSequences().size()); |
|
290 |
assertEquals("Number of sequences is wrong", 1, dnaSampleB.getSequences().size()); |
|
291 |
Sequence next = dnaSampleB.getSequences().iterator().next(); |
|
292 |
assertEquals("Sequences are not equals", sequence, next); |
|
293 |
assertEquals("Sequences are not equals", consensusSequence, next.getSequenceString()); |
|
294 |
} |
|
295 |
|
|
296 |
@Test |
|
297 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testDeleteIndividualAssociatedAndTypeSpecimen.xml") |
|
298 |
public void testDeleteIndividualAssociatedAndTypeSpecimen() { |
|
299 |
final UUID taxonDEscriptionUuid = UUID.fromString("a87a893e-2ea8-427d-a26b-dbd2515d6b8a"); |
|
300 |
final UUID botanicalNameUuid = UUID.fromString("a604774e-d66a-4d47-b9d1-d0e38a8c787a"); |
|
301 |
final UUID fieldUnitUuid = UUID.fromString("67e81ca8-ff91-4df6-bf48-e4600c7f15a2"); |
|
302 |
final UUID derivedUnitUuid = UUID.fromString("d229713b-0123-4f15-bffc-76ae45c37564"); |
|
303 |
|
|
304 |
// //how the XML was generated |
|
305 |
// FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
306 |
// fieldUnit.setUuid(fieldUnitUuid); |
|
307 |
// //sub derivates (DerivedUnit, DnaSample) |
|
308 |
// DerivedUnit derivedUnit = |
|
309 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
310 |
// derivedUnit.setUuid(derivedUnitUuid); |
|
311 |
// |
|
312 |
// //derivation events |
|
313 |
// DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, |
|
314 |
// DerivationEventType.ACCESSIONING()); |
|
315 |
// |
|
316 |
// occurrenceService.save(fieldUnit); |
|
317 |
// occurrenceService.save(derivedUnit); |
|
318 |
// |
|
319 |
// //create name with type specimen |
|
320 |
// BotanicalName name = |
|
321 |
// BotanicalName.PARSED_NAME("Campanula patual sec L."); |
|
322 |
// name.setUuid(BOTANICAL_NAME_UUID); |
|
323 |
// SpecimenTypeDesignation typeDesignation = |
|
324 |
// SpecimenTypeDesignation.NewInstance(); |
|
325 |
// typeDesignation.setTypeSpecimen(derivedUnit); |
|
326 |
// //add type designation to name |
|
327 |
// name.addTypeDesignation(typeDesignation, false); |
|
328 |
// |
|
329 |
// // create taxon with name and two taxon descriptions (one with |
|
330 |
// // IndividualsAssociations and a "described" voucher specimen, and an |
|
331 |
// // empty one) |
|
332 |
// Taxon taxon = Taxon.NewInstance(name, null); |
|
333 |
// taxon.setUuid(taxonUuid); |
|
334 |
// TaxonDescription taxonDescription = TaxonDescription.NewInstance(); |
|
335 |
// taxonDescription.setUuid(TAXON_DESCRIPTION_UUID); |
|
336 |
// //add voucher |
|
337 |
// taxonDescription.addElement(IndividualsAssociation.NewInstance(fieldUnit)); |
|
338 |
// taxon.addDescription(taxonDescription); |
|
339 |
// //add another taxon description to taxon which is not associated with |
|
340 |
// a specimen thus should not be taken into account |
|
341 |
// taxon.addDescription(TaxonDescription.NewInstance()); |
|
342 |
// taxonService.saveOrUpdate(taxon); |
|
343 |
// |
|
344 |
// |
|
345 |
// commitAndStartNewTransaction(null); |
|
346 |
// |
|
347 |
// setComplete(); |
|
348 |
// endTransaction(); |
|
349 |
// |
|
350 |
// |
|
351 |
// try { |
|
352 |
// writeDbUnitDataSetFile(new String[] { |
|
353 |
// "SpecimenOrObservationBase", |
|
354 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
355 |
// "DerivationEvent", |
|
356 |
// "Sequence", |
|
357 |
// "Sequence_SingleRead", |
|
358 |
// "SingleRead", |
|
359 |
// "AmplificationResult", |
|
360 |
// "DescriptionElementBase", |
|
361 |
// "DescriptionBase", |
|
362 |
// "TaxonBase", |
|
363 |
// "TypeDesignationBase", |
|
364 |
// "TaxonNameBase", |
|
365 |
// "TaxonNameBase_TypeDesignationBase", |
|
366 |
// "HomotypicalGroup" |
|
367 |
// }, "testDeleteIndividualAssociatedAndTypeSpecimen"); |
|
368 |
// } catch (FileNotFoundException e) { |
|
369 |
// e.printStackTrace(); |
|
370 |
// } |
|
371 |
|
|
372 |
FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid); |
|
373 |
DerivedUnit typeSpecimen = (DerivedUnit) occurrenceService.load(derivedUnitUuid); |
|
374 |
BotanicalName name = (BotanicalName) nameService.load(botanicalNameUuid); |
|
375 |
TaxonDescription taxonDescription = (TaxonDescription) descriptionService.load(taxonDEscriptionUuid); |
|
376 |
// check initial state (IndividualsAssociation) |
|
377 |
DescriptionElementBase descriptionElement = taxonDescription.getElements().iterator().next(); |
|
378 |
assertTrue("wrong type of description element", descriptionElement.isInstanceOf(IndividualsAssociation.class)); |
|
379 |
assertEquals("associated specimen is incorrect", associatedFieldUnit, |
|
380 |
((IndividualsAssociation) descriptionElement).getAssociatedSpecimenOrObservation()); |
|
381 |
// check initial state (Type Designation) |
|
382 |
Set<TypeDesignationBase> typeDesignations = name.getTypeDesignations(); |
|
383 |
TypeDesignationBase<?> typeDesignation = typeDesignations.iterator().next(); |
|
384 |
assertTrue("wrong type of type designation", typeDesignation.isInstanceOf(SpecimenTypeDesignation.class)); |
|
385 |
assertEquals("type specimen is incorrect", typeSpecimen, |
|
386 |
((SpecimenTypeDesignation) typeDesignation).getTypeSpecimen()); |
|
387 |
|
|
388 |
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator(); |
|
389 |
// delete type specimen from type designation |
|
390 |
config.setDeleteFromTypeDesignation(true); |
|
391 |
occurrenceService.delete(typeSpecimen, config); |
|
392 |
assertTrue(((SpecimenTypeDesignation) typeDesignation).getTypeSpecimen() == null); |
|
393 |
|
|
394 |
// delete associated field unit from IndividualsAssociation |
|
395 |
config.setDeleteFromIndividualsAssociation(true); |
|
396 |
occurrenceService.delete(associatedFieldUnit, config); |
|
397 |
assertTrue(((IndividualsAssociation) descriptionElement).getAssociatedSpecimenOrObservation() == null); |
|
398 |
|
|
399 |
} |
|
400 |
|
|
401 |
@Test |
|
402 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceService.loadData.xml") |
|
403 |
public void testLoadData() { |
|
404 |
String fieldUnitUuid = "5a31df5a-2e4d-40b1-8d4e-5754736ae7ef"; |
|
405 |
String derivedUnitUuid = "18f70977-5d9c-400a-96c4-0cb7a2cd287e"; |
|
406 |
|
|
407 |
FieldUnit fieldUnit = (FieldUnit) occurrenceService.load(UUID.fromString(fieldUnitUuid)); |
|
408 |
DerivedUnit derivedUnit = (DerivedUnit) occurrenceService.load(UUID.fromString(derivedUnitUuid)); |
|
409 |
|
|
410 |
assertFalse(fieldUnit.getDerivationEvents().iterator().next().getDerivatives().isEmpty()); |
|
411 |
assertTrue(derivedUnit.getDerivedFrom() != null); |
|
412 |
} |
|
413 |
|
|
414 |
@Test |
|
415 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testListAssociatedAndTypedTaxa.xml") |
|
416 |
public void testListIndividualsAssociatensAndSpecimenTypeDesignations(){ |
|
417 |
UUID fieldUnitUuid = UUID.fromString("b359ff20-98de-46bf-aa43-3e10bb072cd4"); |
|
418 |
UUID typeSpecimenUuid = UUID.fromString("0f8608c7-ffe7-40e6-828c-cb3382580878"); |
|
419 |
UUID taxonDescriptionUuid = UUID.fromString("d77db2d4-45a1-4aa1-ab34-f33395f54965"); |
|
420 |
UUID taxonUuid = UUID.fromString("b0de794c-8cb7-4369-8f83-870ca37abbe0"); |
|
421 |
// //how the XML was generated |
|
422 |
// FieldUnit associatedFieldUnit = FieldUnit.NewInstance(); |
|
423 |
// associatedFieldUnit.setUuid(fieldUnitUuid); |
|
424 |
// //sub derivates (DerivedUnit, DnaSample) |
|
425 |
// DerivedUnit typeSpecimen = |
|
426 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
427 |
// typeSpecimen.setUuid(typeSpecimenUuid); |
|
428 |
// |
|
429 |
// //derivation events |
|
430 |
// DerivationEvent.NewSimpleInstance(associatedFieldUnit, typeSpecimen, |
|
431 |
// DerivationEventType.ACCESSIONING()); |
|
432 |
// |
|
433 |
// occurrenceService.save(associatedFieldUnit); |
|
434 |
// occurrenceService.save(typeSpecimen); |
|
435 |
// |
|
436 |
// //create name with type specimen |
|
437 |
// BotanicalName name = |
|
438 |
// BotanicalName.PARSED_NAME("Campanula patual sec L."); |
|
439 |
// SpecimenTypeDesignation typeDesignation = |
|
440 |
// SpecimenTypeDesignation.NewInstance(); |
|
441 |
// typeDesignation.setTypeSpecimen(typeSpecimen); |
|
442 |
// |
|
443 |
// // create taxon with name and two taxon descriptions (one with |
|
444 |
// // IndividualsAssociations and a "described" voucher specimen, and an |
|
445 |
// // empty one) |
|
446 |
// Taxon taxon = Taxon.NewInstance(name, null); |
|
447 |
// taxon.setUuid(taxonUuid); |
|
448 |
// TaxonDescription taxonDescription = TaxonDescription.NewInstance(); |
|
449 |
// taxonDescription.setUuid(taxonDescriptionUuid); |
|
450 |
// //add voucher |
|
451 |
// taxonDescription.addElement(IndividualsAssociation.NewInstance(associatedFieldUnit)); |
|
452 |
// taxon.addDescription(taxonDescription); |
|
453 |
// //add type designation to name |
|
454 |
// name.addTypeDesignation(typeDesignation, false); |
|
455 |
// //add another taxon description to taxon which is not associated with |
|
456 |
// a specimen thus should not be taken into account |
|
457 |
// taxon.addDescription(TaxonDescription.NewInstance()); |
|
458 |
// taxonService.saveOrUpdate(taxon); |
|
459 |
// |
|
460 |
// commitAndStartNewTransaction(null); |
|
461 |
// |
|
462 |
// setComplete(); |
|
463 |
// endTransaction(); |
|
464 |
// |
|
465 |
// try { |
|
466 |
// writeDbUnitDataSetFile(new String[]{ |
|
467 |
// "SpecimenOrObservationBase", |
|
468 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
469 |
// "DerivationEvent", |
|
470 |
// "Sequence", |
|
471 |
// "Sequence_SingleRead", |
|
472 |
// "SingleRead", |
|
473 |
// "AmplificationResult", |
|
474 |
// "DescriptionElementBase", |
|
475 |
// "DescriptionBase", |
|
476 |
// "TaxonBase", |
|
477 |
// "TypeDesignationBase", |
|
478 |
// "TaxonNameBase", |
|
479 |
// "TaxonNameBase_TypeDesignationBase", |
|
480 |
// "HomotypicalGroup"}, "testListAssociatedAndTypedTaxa"); |
|
481 |
// } catch (FileNotFoundException e) { |
|
482 |
// // TODO Auto-generated catch block |
|
483 |
// e.printStackTrace(); |
|
484 |
// } |
|
485 |
// |
|
486 |
// System.out.println("associatedFieldUnit.getUuid() " + |
|
487 |
// associatedFieldUnit.getUuid()); |
|
488 |
// System.out.println("typeSpecimen.getUuid() "+typeSpecimen.getUuid()); |
|
489 |
// System.out.println("taxonDescription.getUuid() "+taxonDescription.getUuid()); |
|
490 |
// System.out.println("taxon.getUuid() "+taxon.getUuid()); |
|
491 |
|
|
492 |
FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid); |
|
493 |
DerivedUnit typeSpecimen = (DerivedUnit) occurrenceService.load(typeSpecimenUuid); |
|
494 |
Taxon taxon = (Taxon) taxonService.load(taxonUuid); |
|
495 |
TaxonDescription taxonDescription = (TaxonDescription) descriptionService.load(taxonDescriptionUuid); |
|
496 |
// check for FieldUnit (IndividualsAssociation) |
|
497 |
java.util.Collection<IndividualsAssociation> individualsAssociations = occurrenceService |
|
498 |
.listIndividualsAssociations(associatedFieldUnit, null, null, null, null); |
|
499 |
assertEquals("Number of individuals associations is incorrect", 1, individualsAssociations.size()); |
|
500 |
IndividualsAssociation individualsAssociation = individualsAssociations.iterator().next(); |
|
501 |
assertTrue("association has wrong type", |
|
502 |
individualsAssociation.getInDescription().isInstanceOf(TaxonDescription.class)); |
|
503 |
TaxonDescription retrievedTaxonDescription = HibernateProxyHelper.deproxy( |
|
504 |
individualsAssociation.getInDescription(), TaxonDescription.class); |
|
505 |
assertEquals(taxonDescription, retrievedTaxonDescription); |
|
506 |
assertEquals("Associated taxon is incorrect", taxon, retrievedTaxonDescription.getTaxon()); |
|
507 |
|
|
508 |
// check for DerivedUnit (Type Designation should exist) |
|
509 |
java.util.Collection<SpecimenTypeDesignation> typeDesignations = occurrenceService.listTypeDesignations( |
|
510 |
typeSpecimen, null, null, null, null); |
|
511 |
assertEquals("Number of type designations is incorrect", 1, typeDesignations.size()); |
|
512 |
SpecimenTypeDesignation specimenTypeDesignation = typeDesignations.iterator().next(); |
|
513 |
Set<TaxonNameBase> typifiedNames = specimenTypeDesignation.getTypifiedNames(); |
|
514 |
assertEquals("number of typified names is incorrect", 1, typifiedNames.size()); |
|
515 |
Set<?> taxonBases = typifiedNames.iterator().next().getTaxonBases(); |
|
516 |
assertEquals("number of taxa incorrect", 1, taxonBases.size()); |
|
517 |
Object next = taxonBases.iterator().next(); |
|
518 |
assertTrue(next instanceof CdmBase && ((CdmBase) next).isInstanceOf(Taxon.class)); |
|
519 |
assertEquals("Typed taxon is incorrect", taxon, next); |
|
520 |
} |
|
521 |
|
|
522 |
@Test |
|
523 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithSpecimenDescription.xml") |
|
524 |
public void testIsDeletableWithSpecimenDescription() { |
|
525 |
UUID derivedUnitUuid = UUID.fromString("68095c8e-025d-49f0-8bb2-ed36378b75c3"); |
|
526 |
UUID specimenDescriptionUuid = UUID.fromString("4094f947-ce84-47b1-bad5-e57e33239d3c"); |
|
527 |
// //how the XML was generated |
|
528 |
// DerivedUnit derivedUnit = |
|
529 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
530 |
// derivedUnit.setUuid(derivedUnitUuid); |
|
531 |
// SpecimenDescription specimenDescription = |
|
532 |
// SpecimenDescription.NewInstance(); |
|
533 |
// specimenDescription.setUuid(specimenDescriptionUuid); |
|
534 |
// derivedUnit.addDescription(specimenDescription); |
|
535 |
// occurrenceService.save(derivedUnit); |
|
536 |
// |
|
537 |
// commitAndStartNewTransaction(null); |
|
538 |
// |
|
539 |
// setComplete(); |
|
540 |
// endTransaction(); |
|
541 |
// |
|
542 |
// try { |
|
543 |
// writeDbUnitDataSetFile(new String[] { |
|
544 |
// "SpecimenOrObservationBase", |
|
545 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
546 |
// "DerivationEvent", |
|
547 |
// "Sequence", |
|
548 |
// "Sequence_SingleRead", |
|
549 |
// "SingleRead", |
|
550 |
// "AmplificationResult", |
|
551 |
// "DescriptionElementBase", |
|
552 |
// "DescriptionBase", |
|
553 |
// "TaxonBase", |
|
554 |
// "TypeDesignationBase", |
|
555 |
// "TaxonNameBase", |
|
556 |
// "TaxonNameBase_TypeDesignationBase", |
|
557 |
// "HomotypicalGroup" |
|
558 |
// }, "testIsDeletableWithSpecimenDescription"); |
|
559 |
// } catch (FileNotFoundException e) { |
|
560 |
// e.printStackTrace(); |
|
561 |
// } |
|
562 |
|
|
563 |
DerivedUnit derivedUnit = (DerivedUnit) occurrenceService.load(derivedUnitUuid); |
|
564 |
SpecimenDescription specimenDescription = (SpecimenDescription) descriptionService |
|
565 |
.load(specimenDescriptionUuid); |
|
566 |
|
|
567 |
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator(); |
|
568 |
DeleteResult deleteResult = null; |
|
569 |
// delete derivedUnit1 |
|
570 |
deleteResult = occurrenceService.isDeletable(derivedUnit, config); |
|
571 |
//deletion of specimen description should always work because there are no |
|
572 |
//specimen description without a specimen |
|
573 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
574 |
occurrenceService.delete(derivedUnit, config); |
|
575 |
specimenDescription = (SpecimenDescription) descriptionService.find(specimenDescriptionUuid); |
|
576 |
|
|
577 |
assertNull(specimenDescription); |
|
578 |
} |
|
579 |
|
|
580 |
@Test |
|
581 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithDescribedSpecimenInTaxonDescription.xml") |
|
582 |
public void testIsDeletableWithDescribedSpecimenInTaxonDescription() { |
|
583 |
UUID fieldUnitUuid = UUID.fromString("d656a004-38ee-404c-810a-87ffb0ab16c2"); |
|
584 |
// //how the XML was generated |
|
585 |
// FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
586 |
// fieldUnit.setUuid(fieldUnitUuid); |
|
587 |
// DerivedUnit derivedUnit = |
|
588 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
589 |
// |
|
590 |
// //derivation events |
|
591 |
// DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, |
|
592 |
// DerivationEventType.ACCESSIONING()); |
|
593 |
// |
|
594 |
// occurrenceService.save(fieldUnit); |
|
595 |
// occurrenceService.save(derivedUnit); |
|
596 |
// |
|
597 |
// // create taxon with name and two taxon descriptions |
|
598 |
// //(one with a "described" voucher specimen, and an empty one) |
|
599 |
// Taxon taxon = |
|
600 |
// Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual sec L."), |
|
601 |
// null); |
|
602 |
// taxonDescription.setUuid(taxonDescriptionUuid); |
|
603 |
// //add voucher |
|
604 |
// taxonDescription.setDescribedSpecimenOrObservation(derivedUnit); |
|
605 |
// taxon.addDescription(taxonDescription); |
|
606 |
// //add another taxon description to taxon which is not associated with |
|
607 |
// a specimen thus should not be taken into account |
|
608 |
// taxon.addDescription(TaxonDescription.NewInstance()); |
|
609 |
// taxonService.saveOrUpdate(taxon); |
|
610 |
// |
|
611 |
// |
|
612 |
// commitAndStartNewTransaction(null); |
|
613 |
// |
|
614 |
// setComplete(); |
|
615 |
// endTransaction(); |
|
616 |
// |
|
617 |
// |
|
618 |
// try { |
|
619 |
// writeDbUnitDataSetFile(new String[] { |
|
620 |
// "SpecimenOrObservationBase", |
|
621 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
622 |
// "DerivationEvent", |
|
623 |
// "Sequence", |
|
624 |
// "Sequence_SingleRead", |
|
625 |
// "SingleRead", |
|
626 |
// "AmplificationResult", |
|
627 |
// "DescriptionElementBase", |
|
628 |
// "DescriptionBase", |
|
629 |
// "TaxonBase", |
|
630 |
// "TypeDesignationBase", |
|
631 |
// "TaxonNameBase", |
|
632 |
// "TaxonNameBase_TypeDesignationBase", |
|
633 |
// "HomotypicalGroup" |
|
634 |
// }, "testIsDeletableWithDescribedSpecimenInTaxonDescription"); |
|
635 |
// } catch (FileNotFoundException e) { |
|
636 |
// e.printStackTrace(); |
|
637 |
// } |
|
638 |
|
|
639 |
FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid); |
|
640 |
|
|
641 |
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator(); |
|
642 |
DeleteResult deleteResult = null; |
|
643 |
// check deletion of field unit -> should fail because of voucher |
|
644 |
// specimen (describedSpecimen) in TaxonDescription |
|
645 |
deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config); |
|
646 |
assertFalse(deleteResult.toString(), deleteResult.isOk()); |
|
647 |
|
|
648 |
// allow deletion from TaxonDescription and deletion of child derivates |
|
649 |
config.setDeleteFromDescription(true); |
|
650 |
config.setDeleteChildren(true); |
|
651 |
deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config); |
|
652 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
653 |
} |
|
654 |
|
|
655 |
@Test |
|
656 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithIndividualsAssociationTaxonDescription.xml") |
|
657 |
public void testIsDeletableWithIndividualsAssociationTaxonDescription() { |
|
658 |
UUID fieldUnitUuid = UUID.fromString("7978b978-5100-4c7a-82ef-3a23e0f3c723"); |
|
659 |
UUID taxonDescriptionUuid = UUID.fromString("d4b0d561-6e7e-4fd8-bf3c-925530f949eb"); |
|
660 |
// //how the XML was generated |
|
661 |
// FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
662 |
// fieldUnit.setUuid(fieldUnitUuid); |
|
663 |
// |
|
664 |
// occurrenceService.save(fieldUnit); |
|
665 |
// |
|
666 |
// // create taxon with name and two taxon descriptions (one with |
|
667 |
// // IndividualsAssociations and a "described" voucher specimen, and an |
|
668 |
// // empty one) |
|
669 |
// Taxon taxon = |
|
670 |
// Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual sec L."), |
|
671 |
// null); |
|
672 |
// TaxonDescription taxonDescription = TaxonDescription.NewInstance(); |
|
673 |
// taxonDescription.setUuid(taxonDescriptionUuid); |
|
674 |
// //add voucher |
|
675 |
// taxonDescription.addElement(IndividualsAssociation.NewInstance(fieldUnit)); |
|
676 |
// taxon.addDescription(taxonDescription); |
|
677 |
// //add another taxon description to taxon which is not associated with |
|
678 |
// a specimen thus should not be taken into account |
|
679 |
// taxon.addDescription(TaxonDescription.NewInstance()); |
|
680 |
// taxonService.saveOrUpdate(taxon); |
|
681 |
// |
|
682 |
// |
|
683 |
// commitAndStartNewTransaction(null); |
|
684 |
// |
|
685 |
// setComplete(); |
|
686 |
// endTransaction(); |
|
687 |
// |
|
688 |
// |
|
689 |
// try { |
|
690 |
// writeDbUnitDataSetFile(new String[] { |
|
691 |
// "SpecimenOrObservationBase", |
|
692 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
693 |
// "DerivationEvent", |
|
694 |
// "Sequence", |
|
695 |
// "Sequence_SingleRead", |
|
696 |
// "SingleRead", |
|
697 |
// "AmplificationResult", |
|
698 |
// "DescriptionElementBase", |
|
699 |
// "DescriptionBase", |
|
700 |
// "TaxonBase", |
|
701 |
// "TypeDesignationBase", |
|
702 |
// "TaxonNameBase", |
|
703 |
// "TaxonNameBase_TypeDesignationBase", |
|
704 |
// "HomotypicalGroup" |
|
705 |
// }, "testIsDeletableWithIndividualsAssociationTaxonDescription"); |
|
706 |
// } catch (FileNotFoundException e) { |
|
707 |
// e.printStackTrace(); |
|
708 |
// } |
|
709 |
|
|
710 |
FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid); |
|
711 |
TaxonDescription taxonDescription = (TaxonDescription) descriptionService.load(taxonDescriptionUuid); |
|
712 |
IndividualsAssociation individualsAssociation = (IndividualsAssociation) taxonDescription.getElements() |
|
713 |
.iterator().next(); |
|
714 |
|
|
715 |
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator(); |
|
716 |
DeleteResult deleteResult = null; |
|
717 |
// check deletion of field unit -> should fail because of |
|
718 |
// IndividualAssociation |
|
719 |
deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config); |
|
720 |
assertFalse(deleteResult.toString(), deleteResult.isOk()); |
|
721 |
assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(individualsAssociation)); |
|
722 |
|
|
723 |
// allow deletion of individuals association |
|
724 |
config.setDeleteFromIndividualsAssociation(true); |
|
725 |
deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config); |
|
726 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
727 |
|
|
728 |
} |
|
729 |
|
|
730 |
@Test |
|
731 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithTypeDesignation.xml") |
|
732 |
public void testIsDeletableWithTypeDesignation() { |
|
733 |
UUID derivedUnitUuid = UUID.fromString("f7fd1dc1-3c93-42a7-8279-cde5bfe37ea0"); |
|
734 |
UUID botanicalNameUuid = UUID.fromString("7396430c-c932-4dd3-a45a-40c2808b132e"); |
|
735 |
// DerivedUnit derivedUnit = |
|
736 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
737 |
// derivedUnit.setUuid(derivedUnitUuid); |
|
738 |
// |
|
739 |
// occurrenceService.save(derivedUnit); |
|
740 |
// |
|
741 |
// //create name with type specimen |
|
742 |
// BotanicalName name = |
|
743 |
// BotanicalName.PARSED_NAME("Campanula patual sec L."); |
|
744 |
// name.setUuid(botanicalNameUuid); |
|
745 |
// SpecimenTypeDesignation typeDesignation = |
|
746 |
// SpecimenTypeDesignation.NewInstance(); |
|
747 |
// typeDesignation.setTypeSpecimen(derivedUnit); |
|
748 |
// //add type designation to name |
|
749 |
// name.addTypeDesignation(typeDesignation, false); |
|
750 |
// |
|
751 |
// nameService.saveOrUpdate(name); |
|
752 |
// |
|
753 |
// commitAndStartNewTransaction(null); |
|
754 |
// |
|
755 |
// setComplete(); |
|
756 |
// endTransaction(); |
|
757 |
// |
|
758 |
// |
|
759 |
// try { |
|
760 |
// writeDbUnitDataSetFile(new String[] { |
|
761 |
// "SpecimenOrObservationBase", |
|
762 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
763 |
// "DerivationEvent", |
|
764 |
// "Sequence", |
|
765 |
// "Sequence_SingleRead", |
|
766 |
// "SingleRead", |
|
767 |
// "AmplificationResult", |
|
768 |
// "DescriptionElementBase", |
|
769 |
// "DescriptionBase", |
|
770 |
// "TaxonBase", |
|
771 |
// "TypeDesignationBase", |
|
772 |
// "TaxonNameBase", |
|
773 |
// "TaxonNameBase_TypeDesignationBase", |
|
774 |
// "HomotypicalGroup" |
|
775 |
// }, "testIsDeletableWithTypeDesignation"); |
|
776 |
// } catch (FileNotFoundException e) { |
|
777 |
// e.printStackTrace(); |
|
778 |
// } |
|
779 |
|
|
780 |
DerivedUnit typeSpecimen = (DerivedUnit) occurrenceService.load(derivedUnitUuid); |
|
781 |
|
|
782 |
// create name with type specimen |
|
783 |
BotanicalName name = (BotanicalName) nameService.load(botanicalNameUuid); |
|
784 |
SpecimenTypeDesignation typeDesignation = (SpecimenTypeDesignation) name.getTypeDesignations().iterator() |
|
785 |
.next(); |
|
786 |
|
|
787 |
// add type designation to name |
|
788 |
name.addTypeDesignation(typeDesignation, false); |
|
789 |
|
|
790 |
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator(); |
|
791 |
DeleteResult deleteResult = null; |
|
792 |
|
|
793 |
// check deletion of specimen |
|
794 |
deleteResult = occurrenceService.isDeletable(typeSpecimen, config); |
|
795 |
assertFalse(deleteResult.toString(), deleteResult.isOk()); |
|
796 |
assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(typeDesignation)); |
|
797 |
|
|
798 |
// allow deletion of type designation |
|
799 |
config.setDeleteFromTypeDesignation(true); |
|
800 |
|
|
801 |
deleteResult = occurrenceService.isDeletable(typeSpecimen, config); |
|
802 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
803 |
} |
|
804 |
|
|
805 |
@Test |
|
806 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithChildren.xml") |
|
807 |
public void testIsDeletableWithChildren() { |
|
808 |
UUID fieldUnitUuid = UUID.fromString("92ada058-4c14-4131-8ecd-b82dc1dd2882"); |
|
809 |
UUID derivedUnitUuid = UUID.fromString("896dffdc-6809-4914-8950-5501fee1c0fd"); |
|
810 |
UUID dnaSampleUuid = UUID.fromString("7efd1d66-ac7f-4202-acdf-a72cbb9c3a21"); |
|
811 |
// if this test fails be sure to check if there are left-over elements |
|
812 |
// in the DB |
|
813 |
// e.g. clear by adding "<AMPLIFICATIONRESULT/>" to the data set XML |
|
814 |
|
|
815 |
// //how the XML was generated |
|
816 |
// FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
817 |
// fieldUnit.setUuid(fieldUnitUuid); |
|
818 |
// //sub derivates (DerivedUnit, DnaSample) |
|
819 |
// DerivedUnit derivedUnit = |
|
820 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
821 |
// derivedUnit.setUuid(derivedUnitUuid); |
|
822 |
// DnaSample dnaSample = DnaSample.NewInstance(); |
|
823 |
// dnaSample.setUuid(dnaSampleUuid); |
|
824 |
// |
|
825 |
// //derivation events |
|
826 |
// DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, |
|
827 |
// DerivationEventType.ACCESSIONING()); |
|
828 |
// DerivationEvent.NewSimpleInstance(derivedUnit, dnaSample, |
|
829 |
// DerivationEventType.DNA_EXTRACTION()); |
|
830 |
// |
|
831 |
// occurrenceService.save(fieldUnit); |
|
832 |
// occurrenceService.save(derivedUnit); |
|
833 |
// occurrenceService.save(dnaSample); |
|
834 |
// |
|
835 |
// commitAndStartNewTransaction(null); |
|
836 |
// |
|
837 |
// setComplete(); |
|
838 |
// endTransaction(); |
|
839 |
// |
|
840 |
// try { |
|
841 |
// writeDbUnitDataSetFile(new String[] { |
|
842 |
// "SpecimenOrObservationBase", |
|
843 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
844 |
// "DerivationEvent", |
|
845 |
// "Sequence", |
|
846 |
// "SingleRead", |
|
847 |
// "SingleReadAlignment", |
|
848 |
// "Amplification", |
|
849 |
// "AmplificationResult", |
|
850 |
// "DescriptionElementBase", |
|
851 |
// "DescriptionBase", |
|
852 |
// "TaxonBase", |
|
853 |
// "TypeDesignationBase", |
|
854 |
// "TaxonNameBase", |
|
855 |
// "TaxonNameBase_TypeDesignationBase", |
|
856 |
// "HomotypicalGroup" |
|
857 |
// }, "testIsDeletableWithChildren"); |
|
858 |
// } catch (FileNotFoundException e) { |
|
859 |
// e.printStackTrace(); |
|
860 |
// } |
|
861 |
FieldUnit fieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid); |
|
862 |
// sub derivates (DerivedUnit, DnaSample) |
|
863 |
DerivedUnit derivedUnit = (DerivedUnit) occurrenceService.load(derivedUnitUuid); |
|
864 |
DnaSample dnaSample = (DnaSample) occurrenceService.load(dnaSampleUuid); |
|
865 |
|
|
866 |
// derivation events |
|
867 |
DerivationEvent fieldUnitToDerivedUnitEvent = fieldUnit.getDerivationEvents().iterator().next(); |
|
868 |
DerivationEvent derivedUnitToDnaSampleEvent = derivedUnit.getDerivationEvents().iterator().next(); |
|
869 |
|
|
870 |
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator(); |
|
871 |
|
|
872 |
DeleteResult deleteResult = null; |
|
873 |
// check deletion of DnaSample |
|
874 |
deleteResult = occurrenceService.isDeletable(dnaSample, config); |
|
875 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
876 |
|
|
877 |
// check deletion of Specimen |
|
878 |
deleteResult = occurrenceService.isDeletable(derivedUnit, config); |
|
879 |
assertFalse(deleteResult.toString(), deleteResult.isOk()); |
|
880 |
assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(derivedUnitToDnaSampleEvent)); |
|
881 |
|
|
882 |
// check deletion of fieldUnit |
|
883 |
deleteResult = occurrenceService.isDeletable(fieldUnit, config); |
|
884 |
assertFalse(deleteResult.toString(), deleteResult.isOk()); |
|
885 |
assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(fieldUnitToDerivedUnitEvent)); |
|
886 |
|
|
887 |
// check deletion of Specimen |
|
888 |
config.setDeleteChildren(true); |
|
889 |
deleteResult = occurrenceService.isDeletable(derivedUnit, config); |
|
890 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
891 |
assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(derivedUnitToDnaSampleEvent)); |
|
892 |
|
|
893 |
// check deletion of fieldUnit |
|
894 |
config.setDeleteFromDescription(true); |
|
895 |
deleteResult = occurrenceService.isDeletable(fieldUnit, config); |
|
896 |
assertTrue(deleteResult.toString(), deleteResult.isOk()); |
|
897 |
|
|
898 |
} |
|
899 |
|
|
900 |
@Test |
|
901 |
@DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testListAssociatedTaxaAndListByAssociatedTaxon.xml") |
|
902 |
public void testListAssociatedTaxaAndListByAssociatedTaxon(){ |
|
903 |
UUID associatedSpecimenUuid = UUID.fromString("6478a387-bc77-4f1b-bfab-671ad786a27e"); |
|
904 |
UUID unassociatedSpecimenUuid = UUID.fromString("820e1af6-9bff-4244-97d3-81fd9a49c91c"); |
|
905 |
UUID typeSpecimenUuid = UUID.fromString("b6f31b9f-f9e2-4bc7-883e-35bd6a9978b4"); |
|
906 |
UUID taxonUuid = UUID.fromString("5613698d-840b-4034-b9b1-1302938e183b"); |
|
907 |
// DerivedUnit typeSpecimen = DerivedUnit.NewInstance(SpecimenOrObservationType.TissueSample); |
|
908 |
// DerivedUnit associatedSpecimen = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
909 |
// DerivedUnit unassociatedSpecimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
910 |
// typeSpecimen.setUuid(typeSpecimenUuid); |
|
911 |
// associatedSpecimen.setUuid(associatedSpecimenUuid); |
|
912 |
// unassociatedSpecimen.setUuid(unassociatedSpecimenUuid); |
|
913 |
// |
|
914 |
// occurrenceService.save(typeSpecimen); |
|
915 |
// occurrenceService.save(associatedSpecimen); |
|
916 |
// occurrenceService.save(unassociatedSpecimen); |
|
917 |
// |
|
918 |
// BotanicalName name = BotanicalName.PARSED_NAME("Campanula patula"); |
|
919 |
// SpecimenTypeDesignation typeDesignation = SpecimenTypeDesignation.NewInstance(); |
|
920 |
// typeDesignation.setTypeSpecimen(typeSpecimen); |
|
921 |
// name.addTypeDesignation(typeDesignation, false); |
|
922 |
// |
|
923 |
// Taxon taxon = Taxon.NewInstance(name, null); |
|
924 |
// taxon.setUuid(taxonUuid); |
|
925 |
// TaxonDescription taxonDescription = TaxonDescription.NewInstance(); |
|
926 |
//// taxonDescription.setUuid(taxonDescriptionUuid); |
|
927 |
// |
|
928 |
// taxonDescription.addElement(IndividualsAssociation.NewInstance(associatedSpecimen)); |
|
929 |
// taxon.addDescription(taxonDescription); |
|
930 |
// |
|
931 |
// taxonService.saveOrUpdate(taxon); |
|
932 |
// |
|
933 |
// commitAndStartNewTransaction(null); |
|
934 |
// |
|
935 |
// setComplete(); |
|
936 |
// endTransaction(); |
|
937 |
// |
|
938 |
// try { |
|
939 |
// writeDbUnitDataSetFile(new String[]{ |
|
940 |
// "SpecimenOrObservationBase", |
|
941 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
942 |
// "DerivationEvent", |
|
943 |
// "Sequence", |
|
944 |
// "Sequence_SingleRead", |
|
945 |
// "SingleRead", |
|
946 |
// "AmplificationResult", |
|
947 |
// "DescriptionElementBase", |
|
948 |
// "DescriptionBase", |
|
949 |
// "TaxonBase", |
|
950 |
// "TypeDesignationBase", |
|
951 |
// "TaxonNameBase", |
|
952 |
// "TaxonNameBase_TypeDesignationBase", |
|
953 |
// "TeamOrPersonBase", |
|
954 |
// "HomotypicalGroup"}, "testListAssociatedTaxaAndListByAssociatedTaxon"); |
|
955 |
// } catch (FileNotFoundException e) { |
|
956 |
// // TODO Auto-generated catch block |
|
957 |
// e.printStackTrace(); |
|
958 |
// } |
|
959 |
//check initial state |
|
960 |
SpecimenOrObservationBase typeSpecimen = occurrenceService.load(typeSpecimenUuid); |
|
961 |
SpecimenOrObservationBase associatedSpecimen = occurrenceService.load(associatedSpecimenUuid); |
|
962 |
SpecimenOrObservationBase unassociatedSpecimen = occurrenceService.load(unassociatedSpecimenUuid); |
|
963 |
Taxon taxon = (Taxon) taxonService.load(taxonUuid); |
|
964 |
|
|
965 |
assertNotNull(typeSpecimen); |
|
966 |
assertNotNull(associatedSpecimen); |
|
967 |
assertNotNull(unassociatedSpecimen); |
|
968 |
assertNotNull(taxon); |
|
969 |
|
|
970 |
//check association (IndividualsAssociations + TypeDesignations) specimen -> taxon (name) |
|
971 |
|
|
972 |
//unassociated specimen |
|
973 |
java.util.Collection<TaxonBase<?>> associatedTaxa = occurrenceService.listAssociatedTaxa(unassociatedSpecimen, null, null, null, null); |
|
974 |
assertNotNull(associatedTaxa); |
|
975 |
assertTrue(associatedTaxa.isEmpty()); |
|
976 |
|
|
977 |
//type specimen |
|
978 |
associatedTaxa = occurrenceService.listAssociatedTaxa(typeSpecimen, null, null, null, null); |
|
979 |
assertNotNull(associatedTaxa); |
|
980 |
assertEquals(1, associatedTaxa.size()); |
|
981 |
assertEquals(taxon, associatedTaxa.iterator().next()); |
|
982 |
|
|
983 |
//associated specimen |
|
984 |
associatedTaxa = occurrenceService.listAssociatedTaxa(associatedSpecimen, null, null, null, null); |
|
985 |
assertNotNull(associatedTaxa); |
|
986 |
assertEquals(1, associatedTaxa.size()); |
|
987 |
assertEquals(taxon, associatedTaxa.iterator().next()); |
|
988 |
|
|
989 |
|
|
990 |
//check association (IndividualsAssociations + TypeDesignations) taxon (name) -> specimen |
|
991 |
List<DerivedUnit> byAssociatedTaxon = occurrenceService.listByAssociatedTaxon(DerivedUnit.class, null, taxon, null, null, null, null, null); |
|
992 |
assertNotNull(byAssociatedTaxon); |
|
993 |
assertEquals(2, byAssociatedTaxon.size()); |
|
994 |
assertTrue(byAssociatedTaxon.contains(associatedSpecimen)); |
|
995 |
assertTrue(byAssociatedTaxon.contains(typeSpecimen)); |
|
996 |
assertTrue(!byAssociatedTaxon.contains(unassociatedSpecimen)); |
|
997 |
|
|
998 |
} |
|
999 |
|
|
1000 |
@Test |
|
1001 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testFindOcurrences.xml") |
|
1002 |
public void testFindOccurrences() { |
|
1003 |
UUID derivedUnit1Uuid = UUID.fromString("843bc8c9-c0fe-4735-bf40-82f1996dcefb"); |
|
1004 |
UUID derivedUnit2Uuid = UUID.fromString("40cd9cb1-7c74-4e7d-a1f8-8a1e0314e940"); |
|
1005 |
UUID dnaSampleUuid = UUID.fromString("364969a6-2457-4e2e-ae1e-29a6fcaa741a"); |
|
1006 |
UUID tissueUuid = UUID.fromString("b608613c-1b5a-4882-8b14-d643b6fc5998"); |
|
1007 |
|
|
1008 |
UUID taxonUuid = UUID.fromString("dfca7629-8a60-4d51-998d-371897f725e9"); |
|
1009 |
|
|
1010 |
// DerivedUnit derivedUnit = |
|
1011 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
1012 |
// derivedUnit.setTitleCache("testUnit1"); |
|
1013 |
// derivedUnit.setAccessionNumber("ACC1"); |
|
1014 |
// DerivedUnit derivedUnit2 = |
|
1015 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
1016 |
// derivedUnit2.setTitleCache("testUnit2"); |
|
1017 |
// derivedUnit2.setBarcode("ACC2"); |
|
1018 |
// DerivedUnit dnaSample = |
|
1019 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.DnaSample); |
|
1020 |
// dnaSample.setTitleCache("dna"); |
|
1021 |
// dnaSample.setCatalogNumber("ACC1"); |
|
1022 |
// DerivedUnit tissue = |
|
1023 |
// DerivedUnit.NewInstance(SpecimenOrObservationType.TissueSample); |
|
1024 |
// tissue.setTitleCache("tissue"); |
|
1025 |
// |
|
1026 |
// DerivationEvent.NewSimpleInstance(derivedUnit, dnaSample, |
|
1027 |
// DerivationEventType.DNA_EXTRACTION()); |
|
1028 |
// |
|
1029 |
// derivedUnit.setUuid(derivedUnit1Uuid); |
|
1030 |
// derivedUnit2.setUuid(derivedUnit2Uuid); |
|
1031 |
// dnaSample.setUuid(dnaSampleUuid); |
|
1032 |
// tissue.setUuid(tissueUuid); |
|
1033 |
// |
|
1034 |
// occurrenceService.save(derivedUnit); |
|
1035 |
// occurrenceService.save(derivedUnit2); |
|
1036 |
// occurrenceService.save(dnaSample); |
|
1037 |
// occurrenceService.save(tissue); |
|
1038 |
// |
|
1039 |
// Taxon taxon = |
|
1040 |
// Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual"), |
|
1041 |
// null); |
|
1042 |
// taxon.setUuid(taxonUuid); |
|
1043 |
// TaxonDescription taxonDescription = TaxonDescription.NewInstance(); |
|
1044 |
// taxonDescription.setUuid(UUID.fromString("272d4d28-662c-468e-94d8-16993fab91ba")); |
|
1045 |
// //add voucher |
|
1046 |
// taxonDescription.addElement(IndividualsAssociation.NewInstance(derivedUnit)); |
|
1047 |
// taxonDescription.addElement(IndividualsAssociation.NewInstance(tissue)); |
|
1048 |
// taxon.addDescription(taxonDescription); |
|
1049 |
// taxonService.saveOrUpdate(taxon); |
|
1050 |
// |
|
1051 |
// commitAndStartNewTransaction(null); |
|
1052 |
// |
|
1053 |
// setComplete(); |
|
1054 |
// endTransaction(); |
|
1055 |
// |
|
1056 |
// |
|
1057 |
// try { |
|
1058 |
// writeDbUnitDataSetFile(new String[] { |
|
1059 |
// "SpecimenOrObservationBase", |
|
1060 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
1061 |
// "DerivationEvent", |
|
1062 |
// "DescriptionElementBase", |
|
1063 |
// "DescriptionBase", |
|
1064 |
// "TaxonBase", |
|
1065 |
// "TypeDesignationBase", |
|
1066 |
// "TaxonNameBase", |
|
1067 |
// "TaxonNameBase_TypeDesignationBase", |
|
1068 |
// "HomotypicalGroup", |
|
1069 |
// "TeamOrPersonBase" |
|
1070 |
// }, "testFindOcurrences"); |
|
1071 |
// } catch (FileNotFoundException e) { |
|
1072 |
// e.printStackTrace(); |
|
1073 |
// } |
|
1074 |
|
|
1075 |
SpecimenOrObservationBase derivedUnit1 = occurrenceService.load(derivedUnit1Uuid); |
|
1076 |
SpecimenOrObservationBase derivedUnit2 = occurrenceService.load(derivedUnit2Uuid); |
|
1077 |
SpecimenOrObservationBase tissue = occurrenceService.load(tissueUuid); |
|
1078 |
SpecimenOrObservationBase dnaSample = occurrenceService.load(dnaSampleUuid); |
|
1079 |
Taxon taxon = (Taxon) taxonService.load(taxonUuid); |
|
1080 |
|
|
1081 |
assertNotNull(derivedUnit1); |
|
1082 |
assertNotNull(derivedUnit2); |
|
1083 |
assertNotNull(tissue); |
|
1084 |
assertNotNull(dnaSample); |
|
1085 |
assertNotNull(taxon); |
|
1086 |
|
|
1087 |
// wildcard search => all derivates |
|
1088 |
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator(); |
|
1089 |
config.setTitleSearchString("*"); |
|
1090 |
assertEquals(4, occurrenceService.countOccurrences(config)); |
|
1091 |
List<SpecimenOrObservationBase> allDerivates = occurrenceService.findByTitle(config).getRecords(); |
|
1092 |
assertEquals(4, allDerivates.size()); |
|
1093 |
assertTrue(allDerivates.contains(derivedUnit1)); |
|
1094 |
assertTrue(allDerivates.contains(derivedUnit2)); |
|
1095 |
assertTrue(allDerivates.contains(tissue)); |
|
1096 |
assertTrue(allDerivates.contains(dnaSample)); |
|
1097 |
|
|
1098 |
// queryString search => 2 derivates |
|
1099 |
config = new FindOccurrencesConfigurator(); |
|
1100 |
config.setTitleSearchString("test*"); |
|
1101 |
// config.setClazz(SpecimenOrObservationBase.class); |
|
1102 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1103 |
List<SpecimenOrObservationBase> queryStringDerivates = occurrenceService.findByTitle(config).getRecords(); |
|
1104 |
assertEquals(2, queryStringDerivates.size()); |
|
1105 |
assertTrue(queryStringDerivates.contains(derivedUnit1)); |
|
1106 |
assertTrue(queryStringDerivates.contains(derivedUnit2)); |
|
1107 |
|
|
1108 |
// class search => 4 results |
|
1109 |
config = new FindOccurrencesConfigurator(); |
|
1110 |
config.setClazz(SpecimenOrObservationBase.class); |
|
1111 |
assertEquals(4, occurrenceService.countOccurrences(config)); |
|
1112 |
List<SpecimenOrObservationBase> specimenOrObservationBases = occurrenceService.findByTitle(config).getRecords(); |
|
1113 |
assertEquals(4, specimenOrObservationBases.size()); |
|
1114 |
|
|
1115 |
// class search => 0 results |
|
1116 |
config = new FindOccurrencesConfigurator(); |
|
1117 |
config.setClazz(FieldUnit.class); |
|
1118 |
assertEquals(0, occurrenceService.countOccurrences(config)); |
|
1119 |
List<SpecimenOrObservationBase> fieldUnits = occurrenceService.findByTitle(config).getRecords(); |
|
1120 |
assertEquals(0, fieldUnits.size()); |
|
1121 |
|
|
1122 |
// class search => 4 results |
|
1123 |
config = new FindOccurrencesConfigurator(); |
|
1124 |
config.setClazz(DerivedUnit.class); |
|
1125 |
assertEquals(4, occurrenceService.countOccurrences(config)); |
|
1126 |
List<SpecimenOrObservationBase> derivedUnits = occurrenceService.findByTitle(config).getRecords(); |
|
1127 |
assertEquals(4, derivedUnits.size()); |
|
1128 |
assertTrue(derivedUnits.contains(derivedUnit1)); |
|
1129 |
assertTrue(derivedUnits.contains(derivedUnit2)); |
|
1130 |
assertTrue(derivedUnits.contains(tissue)); |
|
1131 |
assertTrue(derivedUnits.contains(dnaSample)); |
|
1132 |
|
|
1133 |
// significant identifier search |
|
1134 |
config = new FindOccurrencesConfigurator(); |
|
1135 |
config.setClazz(DerivedUnit.class); |
|
1136 |
config.setSignificantIdentifier("ACC1"); |
|
1137 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1138 |
List<SpecimenOrObservationBase> accessionedUnits = occurrenceService.findByTitle(config).getRecords(); |
|
1139 |
assertEquals(2, accessionedUnits.size()); |
|
1140 |
assertTrue(accessionedUnits.contains(derivedUnit1)); |
|
1141 |
assertFalse(accessionedUnits.contains(derivedUnit2)); |
|
1142 |
assertFalse(accessionedUnits.contains(tissue)); |
|
1143 |
assertTrue(accessionedUnits.contains(dnaSample)); |
|
1144 |
|
|
1145 |
config = new FindOccurrencesConfigurator(); |
|
1146 |
config.setClazz(DerivedUnit.class); |
|
1147 |
config.setSignificantIdentifier("ACC2"); |
|
1148 |
assertEquals(1, occurrenceService.countOccurrences(config)); |
|
1149 |
List<SpecimenOrObservationBase> barcodedUnits = occurrenceService.findByTitle(config).getRecords(); |
|
1150 |
assertEquals(1, barcodedUnits.size()); |
|
1151 |
assertFalse(barcodedUnits.contains(derivedUnit1)); |
|
1152 |
assertTrue(barcodedUnits.contains(derivedUnit2)); |
|
1153 |
assertFalse(barcodedUnits.contains(tissue)); |
|
1154 |
assertFalse(barcodedUnits.contains(dnaSample)); |
|
1155 |
|
|
1156 |
// recordBasis search => 1 Fossil |
|
1157 |
config = new FindOccurrencesConfigurator(); |
|
1158 |
config.setSpecimenType(SpecimenOrObservationType.Fossil); |
|
1159 |
assertEquals(1, occurrenceService.countOccurrences(config)); |
|
1160 |
List<SpecimenOrObservationBase> fossils = occurrenceService.findByTitle(config).getRecords(); |
|
1161 |
assertEquals(1, fossils.size()); |
|
1162 |
assertTrue(fossils.contains(derivedUnit1)); |
|
1163 |
|
|
1164 |
// taxon determination search => 2 associated specimens |
|
1165 |
config = new FindOccurrencesConfigurator(); |
|
1166 |
config.setClazz(DerivedUnit.class); |
|
1167 |
config.setAssociatedTaxonUuid(taxon.getUuid()); |
|
1168 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1169 |
List<SpecimenOrObservationBase> associatedSpecimens = occurrenceService.findByTitle(config).getRecords(); |
|
1170 |
assertEquals(2, associatedSpecimens.size()); |
|
1171 |
assertTrue(associatedSpecimens.contains(derivedUnit1)); |
|
1172 |
assertTrue(associatedSpecimens.contains(tissue)); |
|
1173 |
|
|
1174 |
// taxon determination search (indirectly associated) => 3 associated |
|
1175 |
// specimens |
|
1176 |
config = new FindOccurrencesConfigurator(); |
|
1177 |
config.setClazz(DerivedUnit.class); |
|
1178 |
config.setAssociatedTaxonUuid(taxon.getUuid()); |
|
1179 |
config.setRetrieveIndirectlyAssociatedSpecimens(true); |
|
1180 |
assertEquals(3, occurrenceService.countOccurrences(config)); |
|
1181 |
List<SpecimenOrObservationBase> indirectlyAssociatedSpecimens = occurrenceService.findByTitle(config) |
|
1182 |
.getRecords(); |
|
1183 |
assertEquals(3, indirectlyAssociatedSpecimens.size()); |
|
1184 |
assertTrue(indirectlyAssociatedSpecimens.contains(derivedUnit1)); |
|
1185 |
assertTrue(indirectlyAssociatedSpecimens.contains(dnaSample)); |
|
1186 |
assertTrue(indirectlyAssociatedSpecimens.contains(tissue)); |
|
1187 |
|
|
1188 |
// taxon association search |
|
1189 |
config = new FindOccurrencesConfigurator(); |
|
1190 |
config.setClazz(SpecimenOrObservationBase.class); |
|
1191 |
config.setAssociatedTaxonUuid(taxon.getUuid()); |
|
1192 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1193 |
List<SpecimenOrObservationBase> specimensOrObservations = occurrenceService.findByTitle(config).getRecords(); |
|
1194 |
assertEquals(2, specimensOrObservations.size()); |
|
1195 |
assertTrue(specimensOrObservations.contains(tissue)); |
|
1196 |
assertTrue(specimensOrObservations.contains(derivedUnit1)); |
|
1197 |
|
|
1198 |
//test assignment status |
|
1199 |
//all specimen |
|
1200 |
config = new FindOccurrencesConfigurator(); |
|
1201 |
config.setAssignmentStatus(AssignmentStatus.ALL_SPECIMENS); |
|
1202 |
assertEquals(4, occurrenceService.countOccurrences(config)); |
|
1203 |
List<SpecimenOrObservationBase> allSpecimens = occurrenceService.findByTitle(config).getRecords(); |
|
1204 |
assertEquals(4, allSpecimens.size()); |
|
1205 |
assertTrue(allSpecimens.contains(derivedUnit1)); |
|
1206 |
assertTrue(allSpecimens.contains(derivedUnit2)); |
|
1207 |
assertTrue(allSpecimens.contains(tissue)); |
|
1208 |
assertTrue(allSpecimens.contains(dnaSample)); |
|
1209 |
|
|
1210 |
//assigned specimen |
|
1211 |
config = new FindOccurrencesConfigurator(); |
|
1212 |
config.setAssignmentStatus(AssignmentStatus.ASSIGNED_SPECIMENS); |
|
1213 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1214 |
List<SpecimenOrObservationBase> assignedSpecimens = occurrenceService.findByTitle(config).getRecords(); |
|
1215 |
assertEquals(2, assignedSpecimens.size()); |
|
1216 |
assertTrue(assignedSpecimens.contains(derivedUnit1)); |
|
1217 |
assertTrue(assignedSpecimens.contains(tissue)); |
|
1218 |
|
|
1219 |
//unassigned specimen |
|
1220 |
config = new FindOccurrencesConfigurator(); |
|
1221 |
config.setAssignmentStatus(AssignmentStatus.UNASSIGNED_SPECIMENS); |
|
1222 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1223 |
List<SpecimenOrObservationBase> unAssignedSpecimens = occurrenceService.findByTitle(config).getRecords(); |
|
1224 |
assertEquals(2, unAssignedSpecimens.size()); |
|
1225 |
assertTrue(unAssignedSpecimens.contains(derivedUnit2)); |
|
1226 |
assertTrue(unAssignedSpecimens.contains(dnaSample)); |
|
1227 |
|
|
1228 |
//ignore assignment status because taxon uuid is set |
|
1229 |
config = new FindOccurrencesConfigurator(); |
|
1230 |
config.setAssociatedTaxonUuid(taxon.getUuid()); |
|
1231 |
config.setAssignmentStatus(AssignmentStatus.UNASSIGNED_SPECIMENS); |
|
1232 |
assertEquals(2, occurrenceService.countOccurrences(config)); |
|
1233 |
List<SpecimenOrObservationBase> ignoreAssignmentStatusSpecimens = occurrenceService.findByTitle(config).getRecords(); |
|
1234 |
assertEquals(2, ignoreAssignmentStatusSpecimens.size()); |
|
1235 |
assertTrue(ignoreAssignmentStatusSpecimens.contains(derivedUnit1)); |
|
1236 |
assertTrue(ignoreAssignmentStatusSpecimens.contains(tissue)); |
|
1237 |
|
|
1238 |
|
|
1239 |
} |
|
1240 |
|
|
1241 |
/** |
|
1242 |
* This will test the retrieval of specimens that are in any way associated |
|
1243 |
* with a taxon resp. taxon name via type designation, determination event |
|
1244 |
* or individuals associations. It will also consider synonym relationships. |
|
1245 |
*/ |
|
1246 |
@Test |
|
1247 |
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testAllKindsOfSpecimenAssociations.xml") |
|
1248 |
public void testAllKindsOfSpecimenAssociations() { |
|
1249 |
|
|
1250 |
/** |
|
1251 |
* Structure is as follows: |
|
1252 |
* |
|
1253 |
* Taxon ----IndividualsAssociation---> DnaSample |
|
1254 |
* Taxon ----TypeDesignation---> Fossil |
|
1255 |
* Taxon ----Determination ---> PreservedSpecimenA |
|
1256 |
* |
|
1257 |
* Taxon ---> Taxon Name ----Determination ---> PreservedSpecimenB |
|
1258 |
* |
|
1259 |
* Taxon ---> Synonym ---> SynonymName ----Determination---> PreservedSpecimenC |
|
1260 |
* |
|
1261 |
* Orphan Name (not associated with any taxon) ----Determination ---> PreservedSpecimenD |
|
1262 |
*/ |
|
1263 |
|
|
1264 |
//UUIDS |
|
1265 |
UUID derivedUnitDeterminationTaxonUuid = UUID.fromString("941b8b22-1925-4b91-8ff8-97114499bb22"); |
|
1266 |
UUID derivedUnitDeterminationNameUuid = UUID.fromString("0cdc7a57-6f55-45c8-b3e5-523748c381e7"); |
|
1267 |
|
|
1268 |
UUID derivedUnitDeterminationSynonymUuid = UUID.fromString("8eb94a7d-c802-49a7-bc10-c26de20a52c2"); |
|
1269 |
UUID derivedUnitDeterminationSynonymNameUuid = UUID.fromString("d940a940-8caf-4a52-b1d8-ba4aad7ddae2"); |
|
1270 |
|
|
1271 |
UUID derivedUnitDeterminationOrphanNameUuid = UUID.fromString("587b7297-7d59-4f59-8ef3-c7a559cadeca"); |
|
1272 |
|
|
1273 |
UUID tissueUuidNoAssociationUuid = UUID.fromString("93e94260-5107-4b2c-9ce4-da9e1a4e7cb9"); |
|
1274 |
UUID dnaSampleUuidIndividualsAssociationUuid = UUID.fromString("1fb53903-c9b9-4078-8297-5b86aec7fe21"); |
|
1275 |
UUID fossilTypeDesignationUuid = UUID.fromString("42ec8dcf-a923-4256-bbd5-b0d10f4de5e2"); |
|
1276 |
|
|
1277 |
UUID taxonUuid = UUID.fromString("07cc47a5-1a63-46a1-8366-0d59d2b90d5b"); |
|
1278 |
UUID synoymUuid = UUID.fromString("c16bcd9b-7d18-4fb5-af60-f9ef14c1d3a9"); |
|
1279 |
|
|
1280 |
UUID taxonNameUuid = UUID.fromString("e59b95c0-9ad6-48be-af62-a982ba72b917"); |
|
1281 |
UUID synonymNameUuid = UUID.fromString("39f04b2a-b8bd-46e8-9102-ab665c64ec8e"); |
|
1282 |
UUID orphanNameUuid = UUID.fromString("d8e56365-3ad9-4b0e-88bf-acaaab223a9b"); |
|
1283 |
|
|
1284 |
//load cdm entities |
|
1285 |
DerivedUnit derivedUnitDeterminationTaxon = (DerivedUnit) occurrenceService.load(derivedUnitDeterminationTaxonUuid); |
|
1286 |
DerivedUnit derivedUnitDeterminationName = (DerivedUnit) occurrenceService.load(derivedUnitDeterminationNameUuid); |
|
1287 |
DerivedUnit derivedUnitDeterminationSynonym = (DerivedUnit) occurrenceService.load(derivedUnitDeterminationSynonymUuid); |
|
1288 |
DerivedUnit derivedUnitDeterminationSynonymName = (DerivedUnit) occurrenceService.load(derivedUnitDeterminationSynonymNameUuid); |
|
1289 |
DerivedUnit derivedUnitDeterminationOrphanName = (DerivedUnit) occurrenceService.load(derivedUnitDeterminationOrphanNameUuid); |
|
1290 |
DerivedUnit tissueUuidNoAssociation = (DerivedUnit) occurrenceService.load(tissueUuidNoAssociationUuid); |
|
1291 |
DnaSample dnaSampleUuidIndividualsAssociation = (DnaSample) occurrenceService.load(dnaSampleUuidIndividualsAssociationUuid); |
|
1292 |
DerivedUnit fossilTypeDesignation = (DerivedUnit) occurrenceService.load(fossilTypeDesignationUuid); |
|
1293 |
Taxon taxon = (Taxon) taxonService.load(taxonUuid); |
|
1294 |
Synonym synonym = (Synonym) taxonService.load(synoymUuid); |
|
1295 |
TaxonNameBase taxonName = nameService.load(taxonNameUuid); |
|
1296 |
TaxonNameBase synonymName = nameService.load(synonymNameUuid); |
|
1297 |
TaxonNameBase orphanName = nameService.load(orphanNameUuid); |
|
1298 |
|
|
1299 |
//check initial state |
|
1300 |
assertNotNull(derivedUnitDeterminationTaxon); |
|
1301 |
assertNotNull(derivedUnitDeterminationName); |
|
1302 |
assertNotNull(derivedUnitDeterminationSynonym); |
|
1303 |
assertNotNull(derivedUnitDeterminationSynonymName); |
|
1304 |
assertNotNull(derivedUnitDeterminationOrphanName); |
|
1305 |
assertNotNull(tissueUuidNoAssociation); |
|
1306 |
assertNotNull(dnaSampleUuidIndividualsAssociation); |
|
1307 |
assertNotNull(fossilTypeDesignation); |
|
1308 |
assertNotNull(taxon); |
|
1309 |
assertNotNull(synonym); |
|
1310 |
assertNotNull(taxonName); |
|
1311 |
assertNotNull(synonymName); |
|
1312 |
assertNotNull(orphanName); |
|
1313 |
|
|
1314 |
/* |
|
1315 |
* search for taxon |
|
1316 |
* should retrieve all specimens associated via |
|
1317 |
* - type designations (fossil) |
|
1318 |
* - individuals associations (dnaSample) |
|
1319 |
* - determinations on |
|
1320 |
* - taxon (specimenA) |
|
1321 |
* - taxon name (specimenA, specimenB) |
|
1322 |
* - synonym names (specimenC) |
|
1323 |
*/ |
|
1324 |
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator(); |
|
1325 |
config.setAssociatedTaxonUuid(taxonUuid); |
|
1326 |
List<SpecimenOrObservationBase> specimens = occurrenceService.findByTitle(config).getRecords(); |
|
1327 |
assertTrue(specimens.contains(derivedUnitDeterminationName)); |
|
1328 |
assertTrue(specimens.contains(derivedUnitDeterminationTaxon)); |
|
1329 |
assertTrue(specimens.contains(derivedUnitDeterminationSynonymName)); |
|
1330 |
assertTrue(specimens.contains(dnaSampleUuidIndividualsAssociation)); |
|
1331 |
assertTrue(specimens.contains(fossilTypeDesignation)); |
|
1332 |
assertTrue(!specimens.contains(tissueUuidNoAssociation)); |
|
1333 |
assertTrue(!specimens.contains(derivedUnitDeterminationOrphanName)); |
|
1334 |
assertEquals("Wrong number of associated specimens", 5, specimens.size()); |
|
1335 |
|
|
1336 |
/* |
|
1337 |
* search for taxon name |
|
1338 |
* should retrieve all specimens associated via |
|
1339 |
* - determinations on |
|
1340 |
* - taxon name (specimenA, specimenB) |
|
1341 |
*/ |
|
1342 |
config = new FindOccurrencesConfigurator(); |
|
1343 |
config.setAssociatedTaxonNameUuid(taxonNameUuid); |
|
1344 |
specimens = occurrenceService.findByTitle(config).getRecords(); |
|
1345 |
assertTrue(specimens.contains(derivedUnitDeterminationName)); |
|
1346 |
assertTrue(specimens.contains(derivedUnitDeterminationTaxon)); |
|
1347 |
assertTrue(!specimens.contains(derivedUnitDeterminationSynonymName)); |
|
1348 |
assertTrue(!specimens.contains(dnaSampleUuidIndividualsAssociation)); |
|
1349 |
assertTrue(!specimens.contains(fossilTypeDesignation)); |
|
1350 |
assertTrue(!specimens.contains(tissueUuidNoAssociation)); |
|
1351 |
assertTrue(!specimens.contains(derivedUnitDeterminationOrphanName)); |
|
1352 |
assertEquals("Wrong number of associated specimens", 2, specimens.size()); |
|
1353 |
|
|
1354 |
/* |
|
1355 |
* search for synonym name |
|
1356 |
* should retrieve all specimens associated via |
|
1357 |
* - determinations on |
|
1358 |
* - synonym names (specimenC) |
|
1359 |
*/ |
|
1360 |
config = new FindOccurrencesConfigurator(); |
|
1361 |
config.setAssociatedTaxonNameUuid(synonymNameUuid); |
|
1362 |
specimens = occurrenceService.findByTitle(config).getRecords(); |
|
1363 |
assertTrue(!specimens.contains(derivedUnitDeterminationName)); |
|
1364 |
assertTrue(!specimens.contains(derivedUnitDeterminationTaxon)); |
|
1365 |
assertTrue(specimens.contains(derivedUnitDeterminationSynonymName)); |
|
1366 |
assertTrue(!specimens.contains(dnaSampleUuidIndividualsAssociation)); |
|
1367 |
assertTrue(!specimens.contains(fossilTypeDesignation)); |
|
1368 |
assertTrue(!specimens.contains(tissueUuidNoAssociation)); |
|
1369 |
assertTrue(!specimens.contains(derivedUnitDeterminationOrphanName)); |
|
1370 |
assertEquals("Wrong number of associated specimens", 1, specimens.size()); |
|
1371 |
|
|
1372 |
/* |
|
1373 |
* search for orphan name |
|
1374 |
* should retrieve all specimens associated via |
|
1375 |
* - determinations on |
|
1376 |
* - taxon name (specimenD) |
|
1377 |
*/ |
|
1378 |
config = new FindOccurrencesConfigurator(); |
|
1379 |
config.setAssociatedTaxonNameUuid(orphanNameUuid); |
|
1380 |
specimens = occurrenceService.findByTitle(config).getRecords(); |
|
1381 |
assertTrue(!specimens.contains(derivedUnitDeterminationName)); |
|
1382 |
assertTrue(!specimens.contains(derivedUnitDeterminationTaxon)); |
|
1383 |
assertTrue(!specimens.contains(derivedUnitDeterminationSynonymName)); |
|
1384 |
assertTrue(!specimens.contains(dnaSampleUuidIndividualsAssociation)); |
|
1385 |
assertTrue(!specimens.contains(fossilTypeDesignation)); |
|
1386 |
assertTrue(!specimens.contains(tissueUuidNoAssociation)); |
|
1387 |
assertTrue(specimens.contains(derivedUnitDeterminationOrphanName)); |
|
1388 |
assertEquals("Wrong number of associated specimens", 1, specimens.size()); |
|
1389 |
|
|
1390 |
// //DERIVATIVES |
|
1391 |
// //determination: taxon |
|
1392 |
// DerivedUnit derivedUnitDeterminationTaxon = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
1393 |
// derivedUnitDeterminationTaxon.setTitleCache("Derived Unit determined as taxon"); |
|
1394 |
// //determination: taxon name |
|
1395 |
// DerivedUnit derivedUnitDeterminationName = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
1396 |
// derivedUnitDeterminationName.setTitleCache("Derived Unit determined as name"); |
|
1397 |
// //determination: synonym |
|
1398 |
// DerivedUnit derivedUnitDeterminationSynonym = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
1399 |
// derivedUnitDeterminationSynonym.setTitleCache("Derived Unit determined as synonym"); |
|
1400 |
// //determination: synonym name |
|
1401 |
// DerivedUnit derivedUnitDeterminationSynonymName = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
1402 |
// derivedUnitDeterminationSynonymName.setTitleCache("Derived Unit determined as synonym name"); |
|
1403 |
// //determination: orphan name |
|
1404 |
// DerivedUnit derivedUnitDeterminationOrphanName = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
1405 |
// derivedUnitDeterminationOrphanName.setTitleCache("Derived Unit determined as orphan name"); |
|
1406 |
// //no association |
|
1407 |
// DerivedUnit tissueUuidNoAssociation = DerivedUnit.NewInstance(SpecimenOrObservationType.TissueSample); |
|
1408 |
// tissueUuidNoAssociation.setTitleCache("tissue sample no association"); |
|
1409 |
// //individuals association with taxon |
|
1410 |
// DerivedUnit dnaSampleUuidIndividualsAssociation = DerivedUnit.NewInstance(SpecimenOrObservationType.DnaSample); |
|
1411 |
// dnaSampleUuidIndividualsAssociation.setTitleCache("dna associated via IndividualsAssociation"); |
|
1412 |
// //type specimen of taxon |
|
1413 |
// DerivedUnit fossilTypeDesignation = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil); |
|
1414 |
// fossilTypeDesignation.setTitleCache("Fossil with type designation"); |
|
1415 |
// |
|
1416 |
// derivedUnitDeterminationTaxon.setUuid(derivedUnitDeterminationTaxonUuid); |
|
1417 |
// derivedUnitDeterminationName.setUuid(derivedUnitDeterminationNameUuid); |
|
1418 |
// derivedUnitDeterminationSynonym.setUuid(derivedUnitDeterminationSynonymUuid); |
|
1419 |
// derivedUnitDeterminationSynonymName.setUuid(derivedUnitDeterminationSynonymNameUuid); |
|
1420 |
// derivedUnitDeterminationOrphanName.setUuid(derivedUnitDeterminationOrphanNameUuid); |
|
1421 |
// tissueUuidNoAssociation.setUuid(tissueUuidNoAssociationUuid); |
|
1422 |
// dnaSampleUuidIndividualsAssociation.setUuid(dnaSampleUuidIndividualsAssociationUuid); |
|
1423 |
// fossilTypeDesignation.setUuid(fossilTypeDesignationUuid); |
|
1424 |
// |
|
1425 |
// occurrenceService.save(derivedUnitDeterminationTaxon); |
|
1426 |
// occurrenceService.save(derivedUnitDeterminationName); |
|
1427 |
// occurrenceService.save(derivedUnitDeterminationSynonym); |
|
1428 |
// occurrenceService.save(derivedUnitDeterminationSynonymName); |
|
1429 |
// occurrenceService.save(derivedUnitDeterminationOrphanName); |
|
1430 |
// occurrenceService.save(tissueUuidNoAssociation); |
|
1431 |
// occurrenceService.save(dnaSampleUuidIndividualsAssociation); |
|
1432 |
// occurrenceService.save(fossilTypeDesignation); |
|
1433 |
// |
|
1434 |
// //NAMES |
|
1435 |
// BotanicalName taxonName = BotanicalName.PARSED_NAME("Campanula patual"); |
|
1436 |
// BotanicalName synonymName = BotanicalName.PARSED_NAME("Syno nyma"); |
|
1437 |
// BotanicalName orphanName = BotanicalName.PARSED_NAME("Orphanus lonelia"); |
|
1438 |
// taxonName.setUuid(taxonNameUuid); |
|
1439 |
// synonymName.setUuid(synonymNameUuid); |
|
1440 |
// orphanName.setUuid(orphanNameUuid); |
|
1441 |
// |
|
1442 |
// //TAXON |
|
1443 |
// Taxon taxon = Taxon.NewInstance(taxonName, null); |
|
1444 |
// taxon.setUuid(taxonUuid); |
|
1445 |
// |
|
1446 |
// //SYNONYM |
|
1447 |
// Synonym synonym = Synonym.NewInstance(synonymName, null); |
|
1448 |
// synonym.setUuid(synoymUuid); |
|
1449 |
// taxon.addSynonym(synonym, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF()); |
|
1450 |
// |
|
1451 |
// //IndividualsAssociation |
|
1452 |
// TaxonDescription taxonDescription = TaxonDescription.NewInstance(); |
|
1453 |
// IndividualsAssociation association = IndividualsAssociation.NewInstance(dnaSampleUuidIndividualsAssociation); |
|
1454 |
// association.setFeature(Feature.SPECIMEN()); |
|
1455 |
// taxonDescription.addElement(association); |
|
1456 |
// taxon.addDescription(taxonDescription); |
|
1457 |
// |
|
1458 |
// //DETERMINATION EVENTS |
|
1459 |
// DeterminationEvent.NewInstance(taxon, derivedUnitDeterminationTaxon); |
|
1460 |
// DeterminationEvent.NewInstance(taxonName, derivedUnitDeterminationName); |
|
1461 |
//// DeterminationEvent.NewInstance(synonym, derivedUnitDeterminationSynonym);//TODO determinationa on synonym not possible? |
|
1462 |
// DeterminationEvent.NewInstance(synonymName, derivedUnitDeterminationSynonymName); |
|
1463 |
// DeterminationEvent.NewInstance(orphanName, derivedUnitDeterminationOrphanName); |
|
1464 |
// |
|
1465 |
// //type designation |
|
1466 |
// SpecimenTypeDesignation specimenTypeDesignation = SpecimenTypeDesignation.NewInstance(); |
|
1467 |
// specimenTypeDesignation.setTypeSpecimen(fossilTypeDesignation); |
|
1468 |
// taxonName.addTypeDesignation(specimenTypeDesignation, false); |
|
1469 |
// |
|
1470 |
// taxonService.saveOrUpdate(taxon); |
|
1471 |
// |
|
1472 |
// commitAndStartNewTransaction(null); |
|
1473 |
// |
|
1474 |
// setComplete(); |
|
1475 |
// endTransaction(); |
|
1476 |
// |
|
1477 |
// |
|
1478 |
// try { |
|
1479 |
// writeDbUnitDataSetFile(new String[] { |
|
1480 |
// "SpecimenOrObservationBase", |
|
1481 |
// "SpecimenOrObservationBase_DerivationEvent", |
|
1482 |
// "DerivationEvent", |
|
1483 |
// "DescriptionElementBase", |
|
1484 |
// "DescriptionBase", |
|
1485 |
// "TaxonBase", |
|
1486 |
// "TypeDesignationBase", |
|
1487 |
// "TaxonNameBase", |
|
1488 |
// "TaxonNameBase_TypeDesignationBase", |
|
1489 |
// "HomotypicalGroup", |
|
1490 |
// "TeamOrPersonBase", |
Also available in: Unified diff
Remove bidirectionality for supplemental data #5743