* @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)\r
* @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)\r
* @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)\r
- * @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)\r
+ * @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)\r
* @param pageSize The maximum number of descriptions returned (can be null for all descriptions)\r
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
* @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}\r
* @return a List of TaxonDescription instances\r
*/\r
- List<TaxonDescription> getTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerType, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
+ List<TaxonDescription> getTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
\r
/**\r
* Returns a count of TaxonDescription instances, optionally filtered by parameters passed to this method\r
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.LanguageString;
+import eu.etaxonomy.cdm.model.common.Marker;
+import eu.etaxonomy.cdm.model.common.MarkerType;
import eu.etaxonomy.cdm.model.description.AbsenceTerm;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Distribution;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.PresenceTerm;
+import eu.etaxonomy.cdm.model.description.Scope;
import eu.etaxonomy.cdm.model.description.Sex;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.description.TextData;
}
+ @Test
+ public void testListTaxonDescriptionWithMarker(){
+ Taxon taxon = (Taxon)this.taxonDao.findByUuid(UUID.fromString("b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06"));
+ Set<Scope> scopes = null;
+ Set<NamedArea> geographicalScope = null;
+ Integer pageSize = null;
+ Integer pageNumber = null;
+ List<String> propertyPaths = null;
+
+ //complete
+ MarkerType completeMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433")); //Marker "complete"
+ Assert.assertNotNull("MarkerType for 'complete' should exist", completeMarkerType);
+ Set<MarkerType> markerTypes = new HashSet<MarkerType>();
+ markerTypes.add(completeMarkerType);
+ int n1 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
+ Assert.assertEquals("There should be 1 description marked 'complete'", 1, n1);
+ List<TaxonDescription> descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+ Assert.assertEquals("There should be 1 description marked 'complete'", 1, descriptions.size());
+
+ //doubtful
+ MarkerType isDoubtfulMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e")); //Marker "doubtful"
+ Assert.assertNotNull("MarkerType for 'doubtful' should exist", isDoubtfulMarkerType);
+ markerTypes = new HashSet<MarkerType>(); //reset
+ markerTypes.add(isDoubtfulMarkerType);
+ int n2 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
+ Assert.assertEquals("There should be no description marked 'doubtful'", 0, n2);
+ descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+ Assert.assertEquals("There should be 0 description marked 'doubtful'", 0, descriptions.size());
+
+ //imported = false
+ UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679");
+ MarkerType importedMarkerType = (MarkerType)this.definedTermDao.findByUuid(uuidImported);
+ Assert.assertNotNull("MarkerType for 'imported' should exist", completeMarkerType);
+ markerTypes = new HashSet<MarkerType>();
+ markerTypes.add(importedMarkerType);
+ int n3 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
+ Assert.assertEquals("There should be no description marked 'imported' as true", 0, n3);
+ descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+ Assert.assertEquals("There should be no description marked 'imported' as true", 0, descriptions.size());
+ markerTypes = null;
+ descriptions = this.descriptionDao.getTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+ Assert.assertEquals("There should be 1 description", 1, descriptions.size());
+ TaxonDescription desc = descriptions.iterator().next();
+
+ Set<Marker> markers = desc.getMarkers();
+ boolean hasMarkerImportedAsFalse = false;
+ for (Marker marker: markers){
+ if (marker.getMarkerType().getUuid().equals(uuidImported)){
+ if (marker.getFlag() == false){
+ hasMarkerImportedAsFalse = true;
+ break;
+ }
+ }
+ }
+ Assert.assertTrue("The only description should have a negative marker on 'imported'", hasMarkerImportedAsFalse);
+
+ }
+
}
<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"/>
<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"/>
<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"/>\r
+ <DESCRIPTIONBASE_MARKER DESCRIPTIONBASE_ID="31" MARKERS_ID="1"/>\r
+ <DESCRIPTIONBASE_MARKER DESCRIPTIONBASE_ID="31" MARKERS_ID="2"/>\r
+ <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"/>\r
+ <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"/>\r
<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"/>\r
<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"/>\r
<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"/>\r