Revision 16ab6c1f
Added by Andreas Müller almost 13 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java | ||
---|---|---|
85 | 85 |
* @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances) |
86 | 86 |
* @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty) |
87 | 87 |
* @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) |
88 |
* @param markerType Restrict the results to those descriptions which are marked as true by one of the given marker types (can be null or empty) |
|
88 |
* @param markerTypes Restrict the results to those descriptions which are marked as true by one of the given marker types (can be null or empty)
|
|
89 | 89 |
* @param pageSize The maximum number of descriptions returned (can be null for all descriptions) |
90 | 90 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
91 | 91 |
* @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)} |
92 | 92 |
* @return a List of TaxonDescription instances |
93 | 93 |
*/ |
94 |
List<TaxonDescription> getTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerType, Integer pageSize, Integer pageNumber, List<String> propertyPaths); |
|
94 |
List<TaxonDescription> getTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
|
95 | 95 |
|
96 | 96 |
/** |
97 | 97 |
* Returns a count of TaxonDescription instances, optionally filtered by parameters passed to this method |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java | ||
---|---|---|
234 | 234 |
} |
235 | 235 |
criteria.createCriteria("markers").add(Restrictions.eq("flag", true)) |
236 | 236 |
.createAlias("markerType", "mt") |
237 |
.add(Restrictions.in("id", markerTypeIds)); |
|
237 |
.add(Restrictions.in("mt.id", markerTypeIds));
|
|
238 | 238 |
} |
239 | 239 |
} |
240 | 240 |
|
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
import eu.etaxonomy.cdm.model.common.Language; |
34 | 34 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
35 |
import eu.etaxonomy.cdm.model.common.Marker; |
|
36 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
35 | 37 |
import eu.etaxonomy.cdm.model.description.AbsenceTerm; |
36 | 38 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
37 | 39 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
38 | 40 |
import eu.etaxonomy.cdm.model.description.Distribution; |
39 | 41 |
import eu.etaxonomy.cdm.model.description.Feature; |
40 | 42 |
import eu.etaxonomy.cdm.model.description.PresenceTerm; |
43 |
import eu.etaxonomy.cdm.model.description.Scope; |
|
41 | 44 |
import eu.etaxonomy.cdm.model.description.Sex; |
42 | 45 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
43 | 46 |
import eu.etaxonomy.cdm.model.description.TextData; |
... | ... | |
358 | 361 |
|
359 | 362 |
} |
360 | 363 |
|
364 |
@Test |
|
365 |
public void testListTaxonDescriptionWithMarker(){ |
|
366 |
Taxon taxon = (Taxon)this.taxonDao.findByUuid(UUID.fromString("b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06")); |
|
367 |
Set<Scope> scopes = null; |
|
368 |
Set<NamedArea> geographicalScope = null; |
|
369 |
Integer pageSize = null; |
|
370 |
Integer pageNumber = null; |
|
371 |
List<String> propertyPaths = null; |
|
372 |
|
|
373 |
//complete |
|
374 |
MarkerType completeMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433")); //Marker "complete" |
|
375 |
Assert.assertNotNull("MarkerType for 'complete' should exist", completeMarkerType); |
|
376 |
Set<MarkerType> markerTypes = new HashSet<MarkerType>(); |
|
377 |
markerTypes.add(completeMarkerType); |
|
378 |
int n1 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes); |
|
379 |
Assert.assertEquals("There should be 1 description marked 'complete'", 1, n1); |
|
380 |
List<TaxonDescription> descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths); |
|
381 |
Assert.assertEquals("There should be 1 description marked 'complete'", 1, descriptions.size()); |
|
382 |
|
|
383 |
//doubtful |
|
384 |
MarkerType isDoubtfulMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e")); //Marker "doubtful" |
|
385 |
Assert.assertNotNull("MarkerType for 'doubtful' should exist", isDoubtfulMarkerType); |
|
386 |
markerTypes = new HashSet<MarkerType>(); //reset |
|
387 |
markerTypes.add(isDoubtfulMarkerType); |
|
388 |
int n2 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes); |
|
389 |
Assert.assertEquals("There should be no description marked 'doubtful'", 0, n2); |
|
390 |
descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths); |
|
391 |
Assert.assertEquals("There should be 0 description marked 'doubtful'", 0, descriptions.size()); |
|
392 |
|
|
393 |
//imported = false |
|
394 |
UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679"); |
|
395 |
MarkerType importedMarkerType = (MarkerType)this.definedTermDao.findByUuid(uuidImported); |
|
396 |
Assert.assertNotNull("MarkerType for 'imported' should exist", completeMarkerType); |
|
397 |
markerTypes = new HashSet<MarkerType>(); |
|
398 |
markerTypes.add(importedMarkerType); |
|
399 |
int n3 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes); |
|
400 |
Assert.assertEquals("There should be no description marked 'imported' as true", 0, n3); |
|
401 |
descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths); |
|
402 |
Assert.assertEquals("There should be no description marked 'imported' as true", 0, descriptions.size()); |
|
403 |
markerTypes = null; |
|
404 |
descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths); |
|
405 |
Assert.assertEquals("There should be 1 description", 1, descriptions.size()); |
|
406 |
TaxonDescription desc = descriptions.iterator().next(); |
|
407 |
|
|
408 |
Set<Marker> markers = desc.getMarkers(); |
|
409 |
boolean hasMarkerImportedAsFalse = false; |
|
410 |
for (Marker marker: markers){ |
|
411 |
if (marker.getMarkerType().getUuid().equals(uuidImported)){ |
|
412 |
if (marker.getFlag() == false){ |
|
413 |
hasMarkerImportedAsFalse = true; |
|
414 |
break; |
|
415 |
} |
|
416 |
} |
|
417 |
} |
|
418 |
Assert.assertTrue("The only description should have a negative marker on 'imported'", hasMarkerImportedAsFalse); |
|
419 |
|
|
420 |
} |
|
421 |
|
|
361 | 422 |
|
362 | 423 |
} |
cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.xml | ||
---|---|---|
33 | 33 |
<DESCRIPTIONBASE DTYPE="TaxonDescription" ID="31" CREATED="2008-12-10 09:56:07.0" UUID="fd6cdb64-142c-4df1-b366-c5e76f08a1fc" UPDATED="2008-12-10 09:56:07.253" TITLECACHE="Acherontia lachesis (Fabricius, 1798) sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" TAXON_ID="36" IMAGEGALLERY="false"/> |
34 | 34 |
<DESCRIPTIONBASE DTYPE="TaxonDescription" ID="32" CREATED="2008-12-10 09:56:07.0" UUID="6d647bbe-5d91-46be-87f5-1781d9d5842c" UPDATED="2008-12-10 09:56:07.253" TITLECACHE="Acherontia styx Westwood, 1847 sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" TAXON_ID="37" IMAGEGALLERY="false"/> |
35 | 35 |
<DESCRIPTIONBASE DTYPE="TaxonDescription" ID="33" CREATED="2008-12-10 09:56:07.0" UUID="620de7a8-8c83-42c9-add7-fdc55ebf943a" UPDATED="2008-12-10 09:56:07.253" TITLECACHE="Cryptocoryne x purpurea nothovar borneoensis N.Jacobsen, Bastm. & Yuji Sasaki sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" TAXON_ID="38" IMAGEGALLERY="false"/> |
36 |
<DESCRIPTIONBASE_MARKER DESCRIPTIONBASE_ID="31" MARKERS_ID="1"/> |
|
37 |
<DESCRIPTIONBASE_MARKER DESCRIPTIONBASE_ID="31" MARKERS_ID="2"/> |
|
38 |
<MARKER ID="1" UUID="a0b943f6-3737-4ba4-9d5c-72f3f1476996" FLAG="TRUE" MARKEDOBJ_TYPE="eu.etaxonomy.cdm.model.description.TaxonDescription" MARKEDOBJ_ID="31" MARKERTYPE_ID="890"/> |
|
39 |
<MARKER ID="2" UUID="e873c908-ec5b-4edf-8e80-11da5a9d26b3" FLAG="FALSE" MARKEDOBJ_TYPE="eu.etaxonomy.cdm.model.description.TaxonDescription" MARKEDOBJ_ID="31" MARKERTYPE_ID="892"/> |
|
36 | 40 |
<DESCRIPTIONELEMENTBASE DTYPE="Distribution" ID="1" INDESCRIPTION_ID="1" CREATED="2008-12-10 09:56:07.0" UUID="40458e70-a065-450f-b27d-adf61cc28a7f" UPDATED="2008-12-10 09:56:07.253" AREA_ID="1969" STATUS_ID="1994"/> |
37 | 41 |
<DESCRIPTIONELEMENTBASE DTYPE="Distribution" ID="2" INDESCRIPTION_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="d4099b8d-0644-4025-8a56-e7fc2d95004e" UPDATED="2008-12-10 09:56:07.253" AREA_ID="1969" STATUS_ID="1994"/> |
38 | 42 |
<DESCRIPTIONELEMENTBASE DTYPE="Distribution" ID="3" INDESCRIPTION_ID="3" CREATED="2008-12-10 09:56:07.0" UUID="317fafca-3722-4d8d-8c4f-701d4f5b911d" UPDATED="2008-12-10 09:56:07.253" AREA_ID="1969" STATUS_ID="1994"/> |
Also available in: Unified diff
implemented tests for marker scope on descriptions