import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;\r
import eu.etaxonomy.cdm.model.molecular.DnaSample;\r
import eu.etaxonomy.cdm.model.molecular.Sequence;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;\r
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;\r
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;\r
}\r
\r
private DerivateHierarchyDTO assembleDerivateHierarchyDTO(FieldUnit fieldUnit, Taxon associatedTaxon){\r
+ final String separator = ", ";\r
\r
DerivateHierarchyDTO dto = new DerivateHierarchyDTO();\r
- // TaxonNameBase name = associatedTaxon.getName();\r
- // name = HibernateProxyHelper.deproxy(name, TaxonNameBase.class);\r
- // dto.setType(!name.getTypeDesignations().isEmpty());\r
+ Map<UUID, SpecimenTypeDesignation> typeSpecimenUUIDtoTypeDesignation = new HashMap<UUID, SpecimenTypeDesignation>();\r
+\r
+ //types\r
+ TaxonNameBase<?,?> name = associatedTaxon.getName();\r
+ Set<?> typeDesignations = name.getSpecimenTypeDesignations();\r
+ for (Object object : typeDesignations) {\r
+ if(object instanceof SpecimenTypeDesignation){\r
+ SpecimenTypeDesignation specimenTypeDesignation = (SpecimenTypeDesignation)object;\r
+ DerivedUnit typeSpecimen = specimenTypeDesignation.getTypeSpecimen();\r
+ typeSpecimenUUIDtoTypeDesignation.put(typeSpecimen.getUuid(), specimenTypeDesignation);\r
+ }\r
+ }\r
\r
if(fieldUnit.getGatheringEvent()!=null){\r
GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();\r
getDerivedUnitsFor(fieldUnit, derivedUnits);\r
//Herbaria map\r
Map<eu.etaxonomy.cdm.model.occurrence.Collection, Integer> collectionToCountMap = new HashMap<eu.etaxonomy.cdm.model.occurrence.Collection, Integer>();\r
+ //Type map\r
+ Map<String, List<String>> typeStatusToAccessionNumber = new HashMap<String, List<String>>();\r
\r
//iterate over sub derivates\r
for (DerivedUnit derivedUnit : derivedUnits) {\r
+ //current accession number\r
+ String currentAccessionNumber = derivedUnit.getAccessionNumber()!=null?derivedUnit.getAccessionNumber():"";\r
+ //current herbarium\r
+ String currentHerbarium = "";\r
+ eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();\r
+ if(collection!=null){\r
+ currentHerbarium = collection.getCode()!=null?collection.getCode():"";\r
+ //count herbaria\r
+ Integer count = collectionToCountMap.get(collection);\r
+ if(count==null){\r
+ count = 1;\r
+ }\r
+ else{\r
+ count++;\r
+ }\r
+ collectionToCountMap.put(collection, count);\r
+ }\r
+ //check if derived unit is a type\r
+ if(typeSpecimenUUIDtoTypeDesignation.keySet().contains(derivedUnit.getUuid())){\r
+ dto.setHasType(true);\r
+ SpecimenTypeDesignation specimenTypeDesignation = typeSpecimenUUIDtoTypeDesignation.get(derivedUnit.getUuid());\r
+ SpecimenTypeDesignationStatus specimenTypeDesignationStatus = specimenTypeDesignation.getTypeStatus();\r
+ String typeStatus = specimenTypeDesignationStatus.getLabel(Language.DEFAULT());\r
+ dto.addTypes(typeStatus, currentAccessionNumber);\r
+ }\r
//assemble molecular data\r
if(derivedUnit instanceof DnaSample){//.getRecordBasis()==SpecimenOrObservationType.DnaSample){\r
dto.setHasDna(true);\r
\r
DnaSample dna = (DnaSample)derivedUnit;\r
if(dna.getBankNumber()!=null){\r
- dto.addMolecularData(dna.getBankNumber());\r
+ dto.addMolecularData(dna.getBankNumber(), "SampleDesignation?");//FIXME replace with actual getter\r
}\r
}\r
//assemble media data\r
if(media.getKindOfUnit().getUuid().equals(UUID.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03"))){\r
dto.setHasSpecimenScan(true);\r
if(mediaUriString!=null){\r
- dto.addSpecimenScan(mediaUriString);\r
+ dto.addSpecimenScan(mediaUriString, currentHerbarium+" "+currentAccessionNumber);\r
}\r
}\r
else if(media.getKindOfUnit().getUuid().equals(UUID.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34"))){\r
dto.setHasDetailImage(true);\r
if(mediaUriString!=null){\r
- dto.addDetailImage(mediaUriString);\r
+ String motif = "";\r
+ if(media.getMediaSpecimen()!=null && media.getMediaSpecimen().getTitle(Language.DEFAULT())!=null){\r
+ motif = media.getMediaSpecimen().getTitle(Language.DEFAULT()).getText();\r
+ }\r
+ dto.addDetailImage(mediaUriString, motif);\r
}\r
}\r
}\r
}\r
//assemble preserved specimen data\r
else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){\r
- eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();\r
- Integer count = collectionToCountMap.get(collection);\r
- if(count==null){\r
- count = 1;\r
- }\r
- else{\r
- count++;\r
- }\r
- collectionToCountMap.put(collection, count);\r
+\r
+ }\r
+ }\r
+\r
+ //assemble citation\r
+ String citation = "";\r
+ citation += dto.getCountry();\r
+ citation += separator;\r
+ if(fieldUnit.getGatheringEvent()!=null){\r
+ if(fieldUnit.getGatheringEvent().getLocality()!=null){\r
+ citation += fieldUnit.getGatheringEvent().getLocality().getText();\r
+ citation += separator;\r
+ }\r
+ if(fieldUnit.getGatheringEvent().getExactLocation()!=null\r
+ && fieldUnit.getGatheringEvent().getExactLocation().getLatitude()!=null\r
+ && fieldUnit.getGatheringEvent().getExactLocation().getLongitude()!=null){\r
+ citation += fieldUnit.getGatheringEvent().getExactLocation().getLatitude().toString();\r
+ citation += separator;\r
+ citation += fieldUnit.getGatheringEvent().getExactLocation().getLongitude().toString();\r
+ citation += separator;\r
}\r
}\r
+ if(citation.endsWith(separator)){\r
+ citation = citation.substring(0, citation.length()-separator.length());\r
+ }\r
+ dto.setCitation(citation);\r
+\r
//assemble herbaria string\r
String herbariaString = "";\r
- final String herbariaSeparator = ", ";\r
for(Entry<eu.etaxonomy.cdm.model.occurrence.Collection, Integer> e:collectionToCountMap.entrySet()){\r
eu.etaxonomy.cdm.model.occurrence.Collection collection = e.getKey();\r
- herbariaString += collection.getCode();\r
+ if(collection.getCode()!=null){\r
+ herbariaString += collection.getCode();\r
+ }\r
if(e.getValue()>1){\r
herbariaString += "("+e.getValue()+")";\r
}\r
- herbariaString += herbariaSeparator;\r
+ herbariaString += separator;\r
}\r
- if(herbariaString.endsWith(herbariaSeparator)){\r
- herbariaString = herbariaString.substring(0, herbariaString.length()-herbariaSeparator.length());\r
+ if(herbariaString.endsWith(separator)){\r
+ herbariaString = herbariaString.substring(0, herbariaString.length()-separator.length());\r
}\r
dto.setHerbarium(herbariaString);\r
return dto;\r