commit 545f81158739623b6b83881b06e5616776171e47
Author: Katja Luther <k.luther@bgbm.org>
Date:   Tue Aug 14 10:21:37 2018 +0200

    smaller changes on specimenDTOs

diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java
index 7ad3bdc4ee..4a71425b1a 100644
--- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java
+++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java
@@ -30,7 +30,9 @@ import org.springframework.web.servlet.ModelAndView;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;
 import io.swagger.annotations.Api;
@@ -107,7 +109,13 @@ public class DerivedUnitFacadeController extends AbstractController<SpecimenOrOb
         ModelAndView mv = new ModelAndView();
         DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response,Arrays.asList(new String []{
                 "fieldObjectMedia", "fieldObjectMedia.title"}));
-        mv.addObject(duf.getFieldObjectMedia());
+        SpecimenOrObservationBase sob = service.load(occurrenceUuid, null);
+        FieldUnitDTO dto;
+        if (sob instanceof FieldUnit){
+            dto = FieldUnitDTO.newInstance((FieldUnit)sob);
+            mv.addObject(dto.getListOfMedia());
+        }
+
         return mv;
     }
 
diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
index b6679a68ab..146a8db98b 100644
--- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
+++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
@@ -242,8 +242,8 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
         return new StringResultDTO(String.valueOf(countSpecimen));
     }
 
-    @RequestMapping(value = "specimensOrObservations", method = RequestMethod.GET)
-    public ModelAndView doListSpecimensOrObservations(
+    @RequestMapping(value = "specimensOrObservationDTOs", method = RequestMethod.GET)
+    public ModelAndView doListSpecimensOrObservationDTOs(
             @PathVariable("uuid") UUID uuid,
             HttpServletRequest request,
             HttpServletResponse response) throws IOException {
@@ -256,6 +256,26 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
         return mv;
     }
 
+    @RequestMapping(value = "specimensOrObservations", method = RequestMethod.GET)
+    public ModelAndView doListSpecimensOrObservations(
+            @PathVariable("uuid") UUID uuid,
+            HttpServletRequest request,
+            HttpServletResponse response) throws IOException {
+        logger.info("doListSpecimensOrObservations() - " + request.getRequestURI());
+        ModelAndView mv = new ModelAndView();
+        TaxonBase<?> tb = service.load(uuid);
+        List<OrderHint> orderHints = new ArrayList<>();
+        orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));
+        if(tb instanceof Taxon){
+            List<SpecimenOrObservationBase<?>> specimensOrObservations = occurrenceService.listByAssociatedTaxon(null, null, (Taxon)tb, null, null, null, orderHints, null);
+            mv.addObject(specimensOrObservations);
+        } else {
+            HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
+            return null;
+        }
+        return mv;
+    }
+
     @RequestMapping(value = "associatedFieldUnits", method = RequestMethod.GET)
     public Pager<SpecimenOrObservationBase> doGetFieldUnits(
             @PathVariable("uuid") UUID uuid,
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
index 2e3a760091..32b6bc7b3e 100644
--- 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
@@ -43,7 +43,9 @@ public abstract class DerivateDTO extends TypedEntityReference{
     private TreeSet<Pair<String, String>> characterData;
     private DerivateDataDTO derivateDataDTO;
     protected String taxonName;
-    protected String titleCache;
+    protected String listLabel;
+
+
 
 
     protected String citation;
@@ -68,17 +70,21 @@ public abstract class DerivateDTO extends TypedEntityReference{
     private List<MediaDTO> listOfMedia = new ArrayList<>();
 
     public DerivateDTO(SpecimenOrObservationBase specimenOrObservation) {
-        super(specimenOrObservation.getClass(), specimenOrObservation.getUuid());
-
+        super(specimenOrObservation.getClass(), specimenOrObservation.getUuid(), specimenOrObservation.getTitleCache());
+        addMedia(specimenOrObservation);
     }
     public String getTitleCache() {
-        return titleCache;
+        return getLabel();
     }
 
-    public void setTitleCache(String titleCache) {
-        this.titleCache = titleCache;
+
+    public String getListLabel() {
+        return listLabel;
     }
 
+    public void setListLabel(String listLabel) {
+        this.listLabel = listLabel;
+    }
     public void setCollection(CollectionDTO collection) {
         this.collection = collection;
     }
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
index e1e76b2101..5666351642 100644
--- 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
@@ -39,8 +39,7 @@ public class FieldUnitDTO extends DerivateDTO{
 	    fieldUnitDto.kindOfUnit = fieldUnit.getKindOfUnit().getTitleCache();
 	    fieldUnitDto.gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
 	    fieldUnitDto.setRecordBase(fieldUnit.getRecordBasis().getMessage());
-	    fieldUnitDto.setTitleCache(fieldUnit.getTitleCache());
-
+	    fieldUnitDto.setListLabel(fieldUnit.getTitleCache());
 
 	    return fieldUnitDto;
 
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
index b29fbd433c..a788de4e19 100644
--- 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
@@ -38,6 +38,8 @@ public class PreservedSpecimenDTO extends DerivateDTO{
 
 
 
+
+
 //    public PreservedSpecimenDTO(DerivedUnit derivedUnit){
 //        super();
 //        this.setUuid(derivedUnit.getUuid());
@@ -78,13 +80,15 @@ public class PreservedSpecimenDTO extends DerivateDTO{
     public static PreservedSpecimenDTO newInstance(DerivedUnit derivedUnit, TaxonName name ){
         PreservedSpecimenDTO newInstance = new PreservedSpecimenDTO(derivedUnit);
 
-        newInstance.setTitleCache(derivedUnit.getTitleCache());
+//        newInstance.setTitleCache(derivedUnit.getTitleCache());
+
         newInstance.accessionNumber = derivedUnit.getAccessionNumber();
         newInstance.preferredStableUri = derivedUnit.getPreferredStableUri();
 
         newInstance.setCollectioDTo(new CollectionDTO(HibernateProxyHelper.deproxy(derivedUnit.getCollection())));
         newInstance.setBarcode(derivedUnit.getBarcode());
         newInstance.setCatalogNumber(derivedUnit.getCatalogNumber());
+        newInstance.listLabel = derivedUnit.getCatalogNumber();
         newInstance.setCollectorsNumber(derivedUnit.getCollectorsNumber());
         if (derivedUnit.getDerivedFrom() != null){
             newInstance.setDerivationEvent(new DerivationEventDTO(derivedUnit.getDerivedFrom() ));
