From b40e0f563da6f1b4ae985aa6e9a679dd5ac63f55 Mon Sep 17 00:00:00 2001
From: Patric Plitzner
Date: Fri, 27 Mar 2015 10:40:23 +0000
Subject: [PATCH] - refactored DTO assembly for compressed specimen table in
the data portal - now data is assembled for each individual preserved
specimen and the for the parent field unit
---
.gitattributes | 5 +-
.../OccurrencePortalController.java | 5 +-
.../cdm/api/service/IOccurrenceService.java | 43 ++-
.../api/service/OccurrenceServiceImpl.java | 313 +++++++++++-------
.../cdm/api/service/dto/DerivateDTO.java | 116 +++++++
...HierarchyDTO.java => DerivateDataDTO.java} | 219 ++----------
.../cdm/api/service/dto/FieldUnitDTO.java | 133 ++++++++
.../api/service/dto/PreservedSpecimenDTO.java | 51 +++
8 files changed, 566 insertions(+), 319 deletions(-)
create mode 100644 cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java
rename cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/{DerivateHierarchyDTO.java => DerivateDataDTO.java} (50%)
create mode 100644 cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java
create mode 100644 cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java
diff --git a/.gitattributes b/.gitattributes
index cbb01c076a..8f76838f62 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2321,10 +2321,13 @@ cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/TaxonDeletionC
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/TaxonNodeDeletionConfigurator.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/TermDeletionConfigurator.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/TransmissionEngineDistribution.java -text
-cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateHierarchyDTO.java -text
+cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java -text
+cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDataDTO.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DistributionInfoDTO.java -text
+cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FindByIdentifierDTO.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/IncludedTaxaDTO.java -text
+cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/exception/DataChangeNoRollbackException.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/exception/HomotypicalGroupChangeException.java -text
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/exception/ReferencedObjectUndeletableException.java -text
diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrencePortalController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrencePortalController.java
index d5ca970b45..2c8d0d6206 100644
--- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrencePortalController.java
+++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrencePortalController.java
@@ -29,7 +29,8 @@ import org.springframework.web.servlet.ModelAndView;
import com.wordnik.swagger.annotations.Api;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
-import eu.etaxonomy.cdm.api.service.dto.DerivateHierarchyDTO;
+import eu.etaxonomy.cdm.api.service.dto.DerivateDTO;
+import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
@@ -118,7 +119,7 @@ public class OccurrencePortalController extends BaseController from, SpecimenOrObservationBase> to, DerivedUnit derivate);
/**
- * Assembles a {@link DerivateHierarchyDTO} for the given field unit uuid which is associated to the {@link Taxon}.
+ * Assembles a {@link FieldUnitDTO} for the given field unit uuid which is associated to the {@link Taxon}.
*
* For the meaning of "associated" see also {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
* @param fieldUnit
* @param associatedTaxonUuid
- * @return
+ * @return a DTO with all the assembled information
+ */
+ public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit, UUID associatedTaxonUuid);
+
+ /**
+ * Assembles a {@link PreservedSpecimenDTO} for the given derived unit.
+ * @param derivedUnit
+ * @return a DTO with all the assembled information
*/
- public DerivateHierarchyDTO assembleDerivateHierarchyDTO(FieldUnit fieldUnit, UUID associatedTaxonUuid);
+ public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit);
/**
* Returns a collection of {@link ICdmBase}s that are not persisted via cascading when saving the given specimen (mostly DefinedTerms).
@@ -389,4 +399,29 @@ public interface IOccurrenceService extends IIdentifiableEntityService> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase> specimen, Integer limit, Integer start, List orderHints, List propertyPaths);
+
+ /**
+ * Gets all description elements that are used for describing the character
+ * states of the given specimen
+ *
+ * @param specimen
+ * the specimen for which the character state description
+ * elements should be retrieved
+ * @return a collection of all character state description elements for this
+ * specimen
+ */
+ public Collection getCharacterDataForSpecimen(SpecimenOrObservationBase> specimen);
+
+ /**
+ * Gets all description elements that are used for describing the character
+ * states of the given specimen
+ *
+ * @param specimenUuid
+ * the specimen {@link UUID} for which the character state description
+ * elements should be retrieved
+ * @return a collection of all character state description elements for this
+ * specimen
+ */
+ public Collection getCharacterDataForSpecimen(UUID specimenUuid);
+
}
diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
index f7e46a240d..e4c16eb5f0 100644
--- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
+++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
@@ -16,6 +16,7 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -34,6 +35,7 @@ import org.hibernate.TransientObjectException;
import org.hibernate.search.spatial.impl.Rectangle;
import org.joda.time.Partial;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -43,9 +45,12 @@ import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
import eu.etaxonomy.cdm.api.service.UpdateResult.Status;
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
-import eu.etaxonomy.cdm.api.service.dto.DerivateHierarchyDTO;
-import eu.etaxonomy.cdm.api.service.dto.DerivateHierarchyDTO.ContigFile;
-import eu.etaxonomy.cdm.api.service.dto.DerivateHierarchyDTO.MolecularData;
+import eu.etaxonomy.cdm.api.service.dto.DerivateDTO;
+import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO;
+import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO.ContigFile;
+import eu.etaxonomy.cdm.api.service.dto.DerivateDataDTO.MolecularData;
+import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
+import eu.etaxonomy.cdm.api.service.dto.PreservedSpecimenDTO;
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
import eu.etaxonomy.cdm.api.service.pager.Pager;
@@ -68,9 +73,11 @@ import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
+import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
+import eu.etaxonomy.cdm.model.description.QuantitativeData;
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.location.Country;
@@ -85,7 +92,6 @@ import eu.etaxonomy.cdm.model.molecular.Sequence;
import eu.etaxonomy.cdm.model.molecular.SingleRead;
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
@@ -338,91 +344,180 @@ public class OccurrenceServiceImpl extends IdentifiableServiceBase typeSpecimenUUIDtoTypeDesignationStatus = new HashMap();
-
- //gather types for this taxon name
- TaxonNameBase,?> name = associatedTaxon.getName();
- Set> typeDesignations = name.getSpecimenTypeDesignations();
- for (Object object : typeDesignations) {
- if(object instanceof CdmBase && ((CdmBase)object).isInstanceOf(SpecimenTypeDesignation.class)){
- SpecimenTypeDesignation specimenTypeDesignation = HibernateProxyHelper.deproxy(object, SpecimenTypeDesignation.class);
- DerivedUnit typeSpecimen = specimenTypeDesignation.getTypeSpecimen();
- final TypeDesignationStatusBase typeStatus = specimenTypeDesignation.getTypeStatus();
- typeSpecimenUUIDtoTypeDesignationStatus.put(typeSpecimen.getUuid(), typeStatus);
- }
- }
+ FieldUnitDTO fieldUnitDTO = new FieldUnitDTO();
if(fieldUnit.getGatheringEvent()!=null){
GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
//Country
final NamedArea country = gatheringEvent.getCountry();
- dto.setCountry(country!=null?country.getDescription():"");
+ fieldUnitDTO.setCountry(country!=null?country.getDescription():"");
//Collection
final AgentBase collector = gatheringEvent.getCollector();
final String fieldNumber = fieldUnit.getFieldNumber();
- dto.setCollection(((collector!=null?collector:"") + " " + (fieldNumber!=null?fieldNumber:"")).trim());
+ fieldUnitDTO.setCollection(((collector!=null?collector:"") + " " + (fieldNumber!=null?fieldNumber:"")).trim());
//Date
final Partial gatheringDate = gatheringEvent.getGatheringDate();
- dto.setDate(gatheringDate!=null?gatheringDate.toString():"");
+ fieldUnitDTO.setDate(gatheringDate!=null?gatheringDate.toString():"");
}
//Taxon Name
- dto.setTaxonName(associatedTaxon.getName().getFullTitleCache());
+ fieldUnitDTO.setTaxonName(associatedTaxon.getName().getFullTitleCache());
- Collection derivedUnits = new ArrayList();
- getDerivedUnitsFor(fieldUnit, derivedUnits);
-
//Herbaria map
Map collectionToCountMap = new HashMap();
//List of accession numbers for citation
List preservedSpecimenAccessionNumbers = new ArrayList();
- //iterate over sub derivates
- for (DerivedUnit derivedUnit : derivedUnits) {
+ //assemble preserved specimen DTOs
+ Set derivationEvents = fieldUnit.getDerivationEvents();
+ for (DerivationEvent derivationEvent : derivationEvents) {
+ Set derivatives = derivationEvent.getDerivatives();
+ for (DerivedUnit derivedUnit : derivatives) {
+ if(derivedUnit.getRecordBasis().equals(SpecimenOrObservationType.PreservedSpecimen)){
+ PreservedSpecimenDTO preservedSpecimenDTO = assemblePreservedSpecimenDTO(derivedUnit, fieldUnitDTO);
+ fieldUnitDTO.addPreservedSpecimenDTO(preservedSpecimenDTO);
+ fieldUnitDTO.setHasCharacterData(preservedSpecimenDTO.isHasCharacterData());
+ fieldUnitDTO.setHasDetailImage(preservedSpecimenDTO.isHasDetailImage());
+ fieldUnitDTO.setHasDna(preservedSpecimenDTO.isHasDna());
+ fieldUnitDTO.setHasSpecimenScan(preservedSpecimenDTO.isHasSpecimenScan());
+ }
+ }
+ }
+ //assemble derivate data DTO
+ assembleDerivateDataDTO(fieldUnitDTO, fieldUnit);
+
+ final String separator = ", ";
+ //assemble citation
+ String citation = "";
+ citation += !fieldUnitDTO.getCountry().isEmpty()?fieldUnitDTO.getCountry()+separator:"";
+ if(fieldUnit.getGatheringEvent()!=null){
+ if(fieldUnit.getGatheringEvent().getLocality()!=null){
+ citation += fieldUnit.getGatheringEvent().getLocality().getText();
+ citation += separator;
+ }
+ if(fieldUnit.getGatheringEvent().getExactLocation()!=null
+ && fieldUnit.getGatheringEvent().getExactLocation().getLatitude()!=null
+ && fieldUnit.getGatheringEvent().getExactLocation().getLongitude()!=null){
+ citation += fieldUnit.getGatheringEvent().getExactLocation().getLatitude().toString();
+ citation += separator;
+ citation += fieldUnit.getGatheringEvent().getExactLocation().getLongitude().toString();
+ citation += separator;
+ }
+ }
+ citation += !fieldUnitDTO.getCollection().isEmpty()?fieldUnitDTO.getCollection():"";
+ if(!preservedSpecimenAccessionNumbers.isEmpty()){
+ citation += " (";
+ for(String accessionNumber:preservedSpecimenAccessionNumbers){
+ if(!accessionNumber.isEmpty()){
+ citation += accessionNumber+separator;
+ }
+ }
+ citation = removeTail(citation, separator);
+ citation += ")";
+ }
+ citation = removeTail(citation, separator);
+ fieldUnitDTO.setCitation(citation);
+
+ //assemble herbaria string
+ String herbariaString = "";
+ for(Entry e:collectionToCountMap.entrySet()){
+ eu.etaxonomy.cdm.model.occurrence.Collection collection = e.getKey();
+ if(collection.getCode()!=null){
+ herbariaString += collection.getCode();
+ }
+ if(e.getValue()>1){
+ herbariaString += "("+e.getValue()+")";
+ }
+ herbariaString += separator;
+ }
+ herbariaString = removeTail(herbariaString, separator);
+ fieldUnitDTO.setHerbarium(herbariaString);
+
+ return fieldUnitDTO;
+ }
+
+
+ @Override
+ public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit){
+ return assemblePreservedSpecimenDTO(derivedUnit, null);
+ }
+
+ public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit, FieldUnitDTO hierarchyDTO){
+ PreservedSpecimenDTO preservedSpecimenDTO = new PreservedSpecimenDTO();
+ preservedSpecimenDTO.setAccessionNumber(derivedUnit.getAccessionNumber());
+
+ //character state data
+ Collection characterDataForSpecimen = getCharacterDataForSpecimen(derivedUnit);
+ if(!characterDataForSpecimen.isEmpty()){
+ if(hierarchyDTO!=null){
+ hierarchyDTO.setHasCharacterData(true);
+ }
+ }
+ for (DescriptionElementBase descriptionElementBase : characterDataForSpecimen) {
+ String character = descriptionElementBase.getFeature().getLabel();
+ ArrayList languages = new ArrayList(Collections.singleton(Language.DEFAULT()));
+ if(descriptionElementBase instanceof QuantitativeData){
+ QuantitativeData quantitativeData = (QuantitativeData)descriptionElementBase;
+ DefaultQuantitativeDescriptionBuilder builder = new DefaultQuantitativeDescriptionBuilder();
+ String state = builder.build(quantitativeData, languages).getText(Language.DEFAULT());
+ preservedSpecimenDTO.addCharacterData(character, state);
+ }
+ else if(descriptionElementBase instanceof CategoricalData){
+ CategoricalData categoricalData = (CategoricalData)descriptionElementBase;
+ DefaultCategoricalDescriptionBuilder builder = new DefaultCategoricalDescriptionBuilder();
+ String state = builder.build(categoricalData, languages).getText(Language.DEFAULT());
+ preservedSpecimenDTO.addCharacterData(character, state);
+ }
+ }
+ //check if derived unit is a type
+ Collection specimenTypeDesignations = listTypeDesignations(derivedUnit, null, null, null, null);
+ for (SpecimenTypeDesignation specimenTypeDesignation : specimenTypeDesignations) {
+ if(hierarchyDTO!=null){
+ hierarchyDTO.setHasType(true);
+ }
+ preservedSpecimenDTO.addType(specimenTypeDesignation.getTypeStatus().getLabel());
+ }
+ //assemble sub derivates
+ preservedSpecimenDTO.setDerivateDataDTO(assembleDerivateDataDTO(preservedSpecimenDTO, derivedUnit));
+ return preservedSpecimenDTO;
+ }
+
+ /**
+ * @param derivedUnit
+ * @param derivateDataDTO
+ * @return
+ */
+ private DerivateDataDTO assembleDerivateDataDTO(DerivateDTO derivateDTO, SpecimenOrObservationBase> specimenOrObservation) {
+ DerivateDataDTO derivateDataDTO = new DerivateDataDTO();
+ Collection childDerivates = getDerivedUnitsFor(specimenOrObservation);
+ for (DerivedUnit childDerivate : childDerivates) {
//current accession number
- String currentAccessionNumber = derivedUnit.getAccessionNumber()!=null?derivedUnit.getAccessionNumber():"";
+ String currentAccessionNumber = childDerivate.getAccessionNumber()!=null?childDerivate.getAccessionNumber():"";
//current herbarium
String currentHerbarium = "";
- eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
+ eu.etaxonomy.cdm.model.occurrence.Collection collection = childDerivate.getCollection();
if(collection!=null){
currentHerbarium = collection.getCode()!=null?collection.getCode():"";
- //count herbaria
- Integer count = collectionToCountMap.get(collection);
- if(count==null){
- count = 1;
- }
- else{
- count++;
- }
- collectionToCountMap.put(collection, count);
- }
- //check if derived unit is a type
- if(typeSpecimenUUIDtoTypeDesignationStatus.keySet().contains(derivedUnit.getUuid())){
- dto.setHasType(true);
- TypeDesignationStatusBase typeDesignationStatus = typeSpecimenUUIDtoTypeDesignationStatus.get(derivedUnit.getUuid());
- String typeStatus = typeDesignationStatus.getLabel();
- dto.addTypes(typeStatus, currentAccessionNumber);
}
//assemble molecular data
//pattern: DNAMarker [contig1, primer1_1, primer1_2, ...][contig2, primer2_1, ...]...
- if(derivedUnit.isInstanceOf(DnaSample.class)){
- if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.TissueSample){
+ if(childDerivate.isInstanceOf(DnaSample.class)){
+ if(childDerivate.getRecordBasis()==SpecimenOrObservationType.TissueSample){
//TODO implement TissueSample assembly for web service
}
- if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.DnaSample){
+ if(childDerivate.getRecordBasis()==SpecimenOrObservationType.DnaSample){
- DnaSample dna = HibernateProxyHelper.deproxy(derivedUnit, DnaSample.class);
+ DnaSample dna = HibernateProxyHelper.deproxy(childDerivate, DnaSample.class);
if(!dna.getSequences().isEmpty()){
- dto.setHasDna(true);
+ derivateDTO.setHasDna(true);
}
for(Sequence sequence:dna.getSequences()){
URI boldUri = null;
@@ -432,7 +527,7 @@ public class OccurrenceServiceImpl extends IdentifiableServiceBase e:collectionToCountMap.entrySet()){
- eu.etaxonomy.cdm.model.occurrence.Collection collection = e.getKey();
- if(collection.getCode()!=null){
- herbariaString += collection.getCode();
- }
- if(e.getValue()>1){
- herbariaString += "("+e.getValue()+")";
- }
- herbariaString += separator;
- }
- herbariaString = removeTail(herbariaString, separator);
- dto.setHerbarium(herbariaString);
-
- return dto;
+ return derivateDataDTO;
}
@@ -562,13 +603,15 @@ public class OccurrenceServiceImpl extends IdentifiableServiceBase specimen, Collection derivedUnits){
+ private Collection getDerivedUnitsFor(SpecimenOrObservationBase> specimen){
+ Collection derivedUnits = new ArrayList();
for(DerivationEvent derivationEvent:specimen.getDerivationEvents()){
for(DerivedUnit derivative:derivationEvent.getDerivatives()){
derivedUnits.add(derivative);
- getDerivedUnitsFor(derivative, derivedUnits);
+ derivedUnits.addAll(getDerivedUnitsFor(derivative));
}
}
+ return derivedUnits;
}
@@ -1167,4 +1210,42 @@ public class OccurrenceServiceImpl extends IdentifiableServiceBase getCharacterDataForSpecimen(SpecimenOrObservationBase> specimen) {
+ Collection states = new ArrayList();
+ if(specimen!=null){
+ Set descriptions = specimen.getDescriptions();
+ for (DescriptionBase> descriptionBase : descriptions) {
+ if(descriptionBase.isInstanceOf(SpecimenDescription.class)){
+ SpecimenDescription specimenDescription = HibernateProxyHelper.deproxy(descriptionBase, SpecimenDescription.class);
+ Set elements = specimenDescription.getElements();
+ for (DescriptionElementBase descriptionElementBase : elements) {
+ if(descriptionElementBase.getFeature().isSupportsCategoricalData()
+ ||descriptionElementBase.getFeature().isSupportsQuantitativeData()){
+ states.add(descriptionElementBase);
+ }
+ }
+ }
+ }
+ }
+ return states;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#getStatesForSpecimen(java.util.UUID)
+ */
+ @Override
+ public Collection getCharacterDataForSpecimen(UUID specimenUuid) {
+ SpecimenOrObservationBase> specimen = load(specimenUuid);
+ if(specimen!=null){
+ return getCharacterDataForSpecimen(specimen);
+ }
+ else{
+ throw new DataRetrievalFailureException("Specimen with the given uuid not found in the data base");
+ }
+ }
+
}
diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java
new file mode 100644
index 0000000000..acd478d8df
--- /dev/null
+++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java
@@ -0,0 +1,116 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.api.service.dto;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.envers.tools.Pair;
+
+/**
+ * @author pplitzner
+ * @date Mar 27, 2015
+ *
+ */
+public abstract class DerivateDTO {
+
+ private boolean hasDna;
+ private boolean hasDetailImage;
+ private boolean hasCharacterData;
+ private List> characterData;
+ private DerivateDataDTO derivateDataDTO;
+ private boolean hasSpecimenScan;
+
+ /**
+ * @return the derivateDataDTO
+ */
+ public DerivateDataDTO getDerivateDataDTO() {
+ return derivateDataDTO;
+ }
+
+ /**
+ * @param derivateDataDTO the derivateDataDTO to set
+ */
+ public void setDerivateDataDTO(DerivateDataDTO derivateDataDTO) {
+ this.derivateDataDTO = derivateDataDTO;
+ }
+
+ /**
+ * @return the characterData
+ */
+ public List> getCharacterData() {
+ return characterData;
+ }
+
+ public void addCharacterData(String character, String state){
+ if(characterData==null){
+ characterData = new ArrayList>();
+ }
+ characterData.add(new Pair(character, state));
+ }
+
+ /**
+ * @return the hasDna
+ */
+ public boolean isHasDna() {
+ return hasDna;
+ }
+
+ /**
+ * @param hasDna the hasDna to set
+ */
+ public void setHasDna(boolean hasDna) {
+ this.hasDna = hasDna;
+ }
+
+ /**
+ * @return the hasDetailImage
+ */
+ public boolean isHasDetailImage() {
+ return hasDetailImage;
+ }
+
+ /**
+ * @param hasDetailImage the hasDetailImage to set
+ */
+ public void setHasDetailImage(boolean hasDetailImage) {
+ this.hasDetailImage = hasDetailImage;
+ }
+
+ /**
+ * @return the hasCharacterData
+ */
+ public boolean isHasCharacterData() {
+ return hasCharacterData;
+ }
+
+ /**
+ * @param hasCharacterData the hasCharacterData to set
+ */
+ public void setHasCharacterData(boolean hasCharacterData) {
+ this.hasCharacterData = hasCharacterData;
+ }
+
+ /**
+ * @return the hasSpecimenScan
+ */
+ public boolean isHasSpecimenScan() {
+ return hasSpecimenScan;
+ }
+
+ /**
+ * @param hasSpecimenScan the hasSpecimenScan to set
+ */
+ public void setHasSpecimenScan(boolean hasSpecimenScan) {
+ this.hasSpecimenScan = hasSpecimenScan;
+ }
+
+
+}
diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateHierarchyDTO.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDataDTO.java
similarity index 50%
rename from cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateHierarchyDTO.java
rename to cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDataDTO.java
index 37aca87820..f007c8be79 100644
--- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateHierarchyDTO.java
+++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDataDTO.java
@@ -1,37 +1,32 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
package eu.etaxonomy.cdm.api.service.dto;
import java.net.URI;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.hibernate.envers.tools.Pair;
-public class DerivateHierarchyDTO {
+/**
+ * @author pplitzner
+ * @date Mar 26, 2015
+ *
+ */
+public class DerivateDataDTO {
- //Filter Flags
- private boolean hasDna;
- private boolean hasDetailImage;
+ private List> specimenScans;
+ private List molecularDataList;
+ private List> detailImages;
- //Row Attributes
- private String country;
- private String collection;
- private String date;
- private String herbarium;
- private boolean hasType;
- private boolean hasSpecimenScan;
-
- //Detail pop-down
- private String taxonName;
- private String protologue;
- private String citation;
- private Map> types;
- private List> specimenScans;
- private List molecularDataList;
- private List> detailImages;
-
- /**
+ /**
* @return the molecularData
*/
public List getMolecularDataList() {
@@ -40,176 +35,13 @@ public class DerivateHierarchyDTO {
public MolecularData addProviderLink(URI uri, String linkText) {
if(this.molecularDataList==null){
- molecularDataList = new ArrayList();
+ molecularDataList = new ArrayList();
}
MolecularData molecularData = new MolecularData(new Link(uri, linkText));
this.molecularDataList.add(molecularData);
return molecularData;
}
- /**
- * @return the hasDna
- */
- public boolean isHasDna() {
- return hasDna;
- }
- /**
- * @param hasDna the hasDna to set
- */
- public void setHasDna(boolean hasDna) {
- this.hasDna = hasDna;
- }
- /**
- * @return the hasDetailImage
- */
- public boolean isHasDetailImage() {
- return hasDetailImage;
- }
- /**
- * @param hasDetailImage the hasDetailImage to set
- */
- public void setHasDetailImage(boolean hasDetailImage) {
- this.hasDetailImage = hasDetailImage;
- }
- /**
- * @return the country
- */
- public String getCountry() {
- return country;
- }
- /**
- * @param country the country to set
- */
- public void setCountry(String country) {
- this.country = country;
- }
- /**
- * @return the collection
- */
- public String getCollection() {
- return collection;
- }
- /**
- * @param collection the collection to set
- */
- public void setCollection(String collection) {
- this.collection = collection;
- }
- /**
- * @return the date
- */
- public String getDate() {
- return date;
- }
- /**
- * @param date the date to set
- */
- public void setDate(String date) {
- this.date = date;
- }
- /**
- * @return the herbarium
- */
- public String getHerbarium() {
- return herbarium;
- }
- /**
- * @param herbarium the herbarium to set
- */
- public void setHerbarium(String herbarium) {
- this.herbarium = herbarium;
- }
- /**
- * @return the hasType
- */
- public boolean isHasType() {
- return hasType;
- }
- /**
- * @param hasType the hasType to set
- */
- public void setHasType(boolean hasType) {
- this.hasType = hasType;
- }
- /**
- * @return the hasSpecimenScan
- */
- public boolean isHasSpecimenScan() {
- return hasSpecimenScan;
- }
- /**
- * @param hasSpecimenScan the hasSpecimenScan to set
- */
- public void setHasSpecimenScan(boolean hasSpecimenScan) {
- this.hasSpecimenScan = hasSpecimenScan;
- }
- /**
- * @return the taxonName
- */
- public String getTaxonName() {
- return taxonName;
- }
- /**
- * @param taxonName the taxonName to set
- */
- public void setTaxonName(String taxonName) {
- this.taxonName = taxonName;
- }
- /**
- * @return the protologue
- */
- public String getProtologue() {
- return protologue;
- }
- /**
- * @param protologue the protologue to set
- */
- public void setProtologue(String protologue) {
- this.protologue = protologue;
- }
- /**
- * @return the citation
- */
- public String getCitation() {
- return citation;
- }
- /**
- * @param citation the citation to set
- */
- public void setCitation(String citation) {
- this.citation = citation;
- }
-
- /**
- * @param types the types to set
- */
- public void setTypes(Map> types) {
- this.types = types;
- }
- /**
- * @return the types
- */
- public Map> getTypes() {
- return types;
- }
- public void addTypes(String typeStatus, String accessionNumber){
- if(types==null){
- types = new HashMap>();
- }
- List list = types.get(typeStatus);
- if(list==null){
- list = new ArrayList();
- }
- list.add(accessionNumber);
- types.put(typeStatus, list);
- }
-
- /**
- * @param specimenScans the specimenScans to set
- */
- public void setSpecimenScans(List> specimenScans) {
- this.specimenScans = specimenScans;
- }
/**
* @return the specimenScans
*/
@@ -230,12 +62,6 @@ public class DerivateHierarchyDTO {
public List> getDetailImages() {
return detailImages;
}
- /**
- * @param detailImages the detailImages to set
- */
- public void setDetailImages(List> detailImages) {
- this.detailImages = detailImages;
- }
public void addDetailImage(String uri, String motif){
if(detailImages==null){
@@ -255,7 +81,7 @@ public class DerivateHierarchyDTO {
public ContigFile addContigFile(URI uri, String linkText){
if(contigFiles==null){
- contigFiles = new ArrayList();
+ contigFiles = new ArrayList();
}
ContigFile contigFile = new ContigFile(new Link(uri, linkText));
contigFiles.add(contigFile);
@@ -282,7 +108,7 @@ public class DerivateHierarchyDTO {
public void addPrimerLink(URI uri, String linkText){
if(primerLinks==null){
- primerLinks = new ArrayList();
+ primerLinks = new ArrayList();
}
primerLinks.add(new Link(uri, linkText));
}
@@ -374,4 +200,5 @@ public class DerivateHierarchyDTO {
}
}
+
}
diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java
new file mode 100644
index 0000000000..557591e0f3
--- /dev/null
+++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java
@@ -0,0 +1,133 @@
+package eu.etaxonomy.cdm.api.service.dto;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class FieldUnitDTO extends DerivateDTO{
+
+ //Row Attributes
+ private String country;
+ private String collection;
+ private String date;
+ private String herbarium;
+ private boolean hasType;
+ //Detail pop-down
+ private String taxonName;
+ private String citation;
+ private String protologue;
+
+ private List preservedSpecimenDTOs;
+
+ /**
+ * @return the country
+ */
+ public String getCountry() {
+ return country;
+ }
+ /**
+ * @param country the country to set
+ */
+ public void setCountry(String country) {
+ this.country = country;
+ }
+ /**
+ * @return the collection
+ */
+ public String getCollection() {
+ return collection;
+ }
+ /**
+ * @param collection the collection to set
+ */
+ public void setCollection(String collection) {
+ this.collection = collection;
+ }
+ /**
+ * @return the date
+ */
+ public String getDate() {
+ return date;
+ }
+ /**
+ * @param date the date to set
+ */
+ public void setDate(String date) {
+ this.date = date;
+ }
+ /**
+ * @return the herbarium
+ */
+ public String getHerbarium() {
+ return herbarium;
+ }
+ /**
+ * @param herbarium the herbarium to set
+ */
+ public void setHerbarium(String herbarium) {
+ this.herbarium = herbarium;
+ }
+ /**
+ * @return the hasType
+ */
+ public boolean isHasType() {
+ return hasType;
+ }
+ /**
+ * @param hasType the hasType to set
+ */
+ public void setHasType(boolean hasType) {
+ this.hasType = hasType;
+ }
+ /**
+ * @return the taxonName
+ */
+ public String getTaxonName() {
+ return taxonName;
+ }
+ /**
+ * @param taxonName the taxonName to set
+ */
+ public void setTaxonName(String taxonName) {
+ this.taxonName = taxonName;
+ }
+ /**
+ * @return the protologue
+ */
+ public String getProtologue() {
+ return protologue;
+ }
+ /**
+ * @param protologue the protologue to set
+ */
+ public void setProtologue(String protologue) {
+ this.protologue = protologue;
+ }
+ /**
+ * @return the citation
+ */
+ public String getCitation() {
+ return citation;
+ }
+ /**
+ * @param citation the citation to set
+ */
+ public void setCitation(String citation) {
+ this.citation = citation;
+ }
+
+ /**
+ * @return the derivateDTOs
+ */
+ public List getPreservedSpecimenDTOs() {
+ return preservedSpecimenDTOs;
+ }
+
+ public void addPreservedSpecimenDTO(PreservedSpecimenDTO preservedSpecimenDTO){
+ if(preservedSpecimenDTOs==null){
+ preservedSpecimenDTOs = new ArrayList();
+ }
+ preservedSpecimenDTOs.add(preservedSpecimenDTO);
+ }
+
+}
diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java
new file mode 100644
index 0000000000..bfc538981a
--- /dev/null
+++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java
@@ -0,0 +1,51 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.api.service.dto;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author pplitzner
+ * @date Mar 26, 2015
+ *
+ */
+public class PreservedSpecimenDTO extends DerivateDTO{
+
+ private String accessionNumber;
+ private List types;
+
+ /**
+ * @return the accessionNumber
+ */
+ public String getAccessionNumber() {
+ return accessionNumber;
+ }
+ /**
+ * @param accessionNumber the accessionNumber to set
+ */
+ public void setAccessionNumber(String accessionNumber) {
+ this.accessionNumber = accessionNumber;
+ }
+ /**
+ * @return the types
+ */
+ public List getTypes() {
+ return types;
+ }
+ public void addType(String typeStatus){
+ if(types==null){
+ types = new ArrayList();
+ }
+ types.add(typeStatus);
+ }
+
+}
--
2.34.1