ref #10334 further handle include unpublished in webservices
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 18 Jan 2024 19:06:56 +0000 (20:06 +0100)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 18 Jan 2024 19:06:56 +0000 (20:06 +0100)
17 files changed:
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/distribution/DistributionImport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/SpecimenSythesysExcelImport.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrenceListController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonPortalController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/dto/OccurrenceCatalogueController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ext/ExternalGeoController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ext/KmlController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/iiif/ManifestController.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IOccurrenceService.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonService.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/IIdentifiableEntityServiceConfigurator.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java

index 411dc212ac714a0b727859a6ff1aec7de16d6420..0850134d3e56bed7b067b36ff84dc2405517afcf 100644 (file)
@@ -20,8 +20,6 @@ import org.apache.logging.log4j.Logger;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.TransactionStatus;
 
-import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorFactory;
-import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorImpl;
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.common.ExcelUtils;
 import eu.etaxonomy.cdm.common.URI;
@@ -37,7 +35,6 @@ import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.location.NamedArea;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.persistence.query.MatchMode;
 
 /**
  * @author a.babadshanjan
@@ -169,10 +166,6 @@ public class DistributionImport
     private void saveRecord(String taxonName, List<String> distributionList,
                String status, String literatureNumber, String literature) {
 
-       IdentifiableServiceConfiguratorImpl<TaxonName> config = IdentifiableServiceConfiguratorFactory.getConfigurator(TaxonName.class);
-       config.setTitleSearchString(taxonName);
-       config.setMatchMode(MatchMode.BEGINNING);
-
                try {
                // get the matching names from the DB
                //List<TaxonName> taxonNames = getNameService().findByTitle(config);
index fef0432b68d780d62c20990a635b983311f477f8..3f40641100728de72816f3f11efb6f0c7d08d1f7 100644 (file)
@@ -879,8 +879,9 @@ public class SpecimenSythesysExcelImport  extends CdmImportBase<SpecimenSynthesy
                 //DEBUG CHENOPODIUM VULVARIA
                 UUID uuid = UUID.fromString("85234ff5-8e40-4813-8f06-44ab960a905a");
                 Taxon taxon = (Taxon)getTaxonService().find(uuid);
-
-                specimenOrObs = getOccurrenceService().listByAssociatedTaxon(null, null, taxon, null, null, null, null, null);
+                boolean includeUnpublished = true; //for import we always include
+                specimenOrObs = getOccurrenceService().listByAssociatedTaxon(null, null,
+                        taxon, includeUnpublished, null, null, null, null, null);
             }
             Map<String,String> unit=null;
             MyHashMap<String,String> myunit;
index fca844254c2fe986502e85e6a9d5fac8d96d0b55..fded695fb9d955eb0cd05927af9c6518ac053711 100644 (file)
@@ -99,6 +99,7 @@ public class OccurrenceListController extends AbstractIdentifiableListController
                 HttpServletResponse response) throws IOException {
 
         logger.info("doListByAssociatedTaxon()" + requestPathAndQuery(request));
+        boolean includeUnpublished = NO_UNPUBLISHED;
 
         Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(relationshipUuids, relationshipInversUuids, termService);
 
@@ -109,7 +110,7 @@ public class OccurrenceListController extends AbstractIdentifiableListController
         List<OrderHint> orderHints = null;
 
         return service.pageByAssociatedTaxon(null, includeRelationships, associatedTaxon,
-                maxDepth, pagerParams.getPageSize(), pagerParams.getPageIndex(),
+                includeUnpublished, maxDepth, pagerParams.getPageSize(), pagerParams.getPageIndex(),
                 orderHints, getInitializationStrategy());
     }
 
index 74311250d0fab7dbdddbb0310ca3a3a8116aefdf..3c5186e96a0e23ccd850ea4f9ca9dd01447f5115 100644 (file)
@@ -337,11 +337,13 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
             HttpServletResponse response) throws IOException {
         logger.info("doListSpecimensOrObservations() - " + request.getRequestURI());
 
+        boolean includeUnpublished = NO_UNPUBLISHED;
         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);
+            List<SpecimenOrObservationBase<?>> specimensOrObservations = occurrenceService.listByAssociatedTaxon(
+                    null, null, (Taxon)tb, includeUnpublished, null, null, null, orderHints, null);
             return specimensOrObservations;
         } else {
             HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
@@ -359,8 +361,9 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
             HttpServletResponse response) throws IOException {
         logger.info("doGetAssociatedRootUnits() - " + request.getRequestURI());
 
+        boolean includeUnpublished = NO_UNPUBLISHED;
         TaxonBase<?> taxonBase = service.load(uuid);
-        taxonBase = checkExistsAndAccess(taxonBase, NO_UNPUBLISHED, response);
+        taxonBase = checkExistsAndAccess(taxonBase, includeUnpublished, response);
 
         List<OrderHint> orderHints = new ArrayList<>();
         orderHints.add(new OrderHint("titleCache", SortOrder.ASCENDING));
@@ -369,7 +372,8 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
             PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
             pagerParams.normalizeAndValidate(response);
 
-            return occurrenceService.pageRootUnitsByAssociatedTaxon(null, null, (Taxon) taxonBase, maxDepth, pagerParams.getPageSize(), pagerParams.getPageIndex(), orderHints, null);
+            return occurrenceService.pageRootUnitsByAssociatedTaxon(null, null, (Taxon) taxonBase,
+                    includeUnpublished, maxDepth, pagerParams.getPageSize(), pagerParams.getPageIndex(), orderHints, null);
         }else{
             // FIXME proper HTTP code response
             return null;
index beb3e403ee8b553bdf54700785b069a7d8d562c1..de772b6f59b797ab8722c4fd250bb15c9debc7c7 100644 (file)
@@ -815,7 +815,7 @@ public class TaxonPortalController extends TaxonController{
         Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(relationshipUuids, relationshipInversUuids, termService);
 
         List<Media> media = listMediaForTaxon(taxon, includeRelationships,
-                includeTaxonDescriptions, includeOccurrences, includeTaxonNameDescriptions, mediaInitStrategy);
+                includeTaxonDescriptions, includeOccurrences, includeOriginals, includeTaxonNameDescriptions, includeUnpublished, mediaInitStrategy);
 
         EntityMediaContext<Taxon> entityMediaContext = new EntityMediaContext<>(taxon, media);
 
@@ -850,10 +850,12 @@ public class TaxonPortalController extends TaxonController{
 
         Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(relationshipUuids, relationshipInversUuids, termService);
 
+        boolean includeOriginals = false; //or when unifying methods, do we want this as webservice parameter, too?
         List<Media> media = listMediaForTaxon(taxon, includeRelationships,
-                includeTaxonDescriptions, includeOccurrences, includeTaxonNameDescriptions, null);
-        media = addTaxonomicChildrenMedia(includeTaxonDescriptions, includeOccurrences, includeTaxonNameDescriptions, taxon,
-                includeRelationships, media);
+                includeTaxonDescriptions, includeOccurrences, includeOriginals, includeTaxonNameDescriptions, includeUnpublished, null);
+        media = addTaxonomicChildrenMedia(includeTaxonDescriptions, includeOccurrences, includeOriginals,
+                includeTaxonNameDescriptions, taxon,
+                includeRelationships, media, includeUnpublished);
 
         List<Media> mediafilteredForPreferredRepresentations = mediaToolbox.processAndFilterPreferredMediaRepresentations(type, mimeTypes, widthOrDuration, height, size,
                 media);
@@ -862,8 +864,8 @@ public class TaxonPortalController extends TaxonController{
     }
 
     public List<Media> addTaxonomicChildrenMedia(Boolean includeTaxonDescriptions, Boolean includeOccurrences,
-            Boolean includeTaxonNameDescriptions, Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
-            List<Media> media) {
+            boolean includeOriginals, Boolean includeTaxonNameDescriptions, Taxon taxon,
+            Set<TaxonRelationshipEdge> includeRelationships, List<Media> media, boolean includeUnpublished) {
 
         //TODO use treeindex
         //looking for all medias of direct children
@@ -883,7 +885,8 @@ public class TaxonPortalController extends TaxonController{
                 if(childTaxon != null) {
                     childTaxon = (Taxon)taxonService.load(childTaxon.getUuid(), NO_UNPUBLISHED, null);
                     media.addAll(listMediaForTaxon(childTaxon, includeRelationships,
-                            includeTaxonDescriptions, includeOccurrences, includeTaxonNameDescriptions, MediaPortalController.MEDIA_INIT_STRATEGY.getPropertyPaths()));
+                            includeTaxonDescriptions, includeOccurrences, includeOriginals,
+                            includeTaxonNameDescriptions, includeUnpublished, MediaPortalController.MEDIA_INIT_STRATEGY.getPropertyPaths()));
                 }
             }
         }
@@ -891,16 +894,12 @@ public class TaxonPortalController extends TaxonController{
     }
 
     private List<Media> listMediaForTaxon(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
-            Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeTaxonNameDescriptions, List<String> propertyPath) {
-
-        return listMediaForTaxon(taxon, includeRelationships, includeTaxonDescriptions, includeOccurrences, false, includeTaxonNameDescriptions, propertyPath);
-    }
-
-    private List<Media> listMediaForTaxon(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
-            Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeOriginals, Boolean includeTaxonNameDescriptions, List<String> propertyPath) {
+            Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeOriginals,
+            Boolean includeTaxonNameDescriptions, boolean includeUnpublished, List<String> propertyPath) {
 
         List<Media> media = service.listMedia(taxon, includeRelationships,
-                false, includeTaxonDescriptions, includeOccurrences, includeOriginals, includeTaxonNameDescriptions, propertyPath);
+                false, includeTaxonDescriptions, includeOccurrences, includeOriginals,
+                includeTaxonNameDescriptions, includeUnpublished, propertyPath);
 
         return media;
     }
index 1b20d78f89b1ebe3cc03b0358157b18df11b6d62..9383d4273c444d6329f4c936bc6a37007fb5cebe 100644 (file)
@@ -206,9 +206,9 @@ public class OccurrenceCatalogueController
             HttpServletRequest request, HttpServletResponse response) throws IOException {
 
         logger.info("doGetOccurrenceSearch() " +  requestPathAndQuery(request));
-
         ModelAndView mv = new ModelAndView();
 
+        boolean includeUnpublished = NO_UNPUBLISHED;
         Integer pS = null;
         Integer pN = null;
 
@@ -268,6 +268,7 @@ public class OccurrenceCatalogueController
             specimenOrObs= service.pageByAssociatedTaxon(DerivedUnit.class,
                     null,
                     taxon,
+                    includeUnpublished,
                     null,
                     pagerParams.getPageSize(),
                     pagerParams.getPageIndex(),
index 8e7b54ce5dc85b033d33b658d0869046002cc1f7..5569ed378c821b99da710ca6925ad77a63160996 100644 (file)
@@ -133,13 +133,13 @@ public class ExternalGeoController extends BaseController<TaxonBase, ITaxonServi
             HttpServletResponse response)
             throws IOException {
 
-
         logger.info("doGetOccurrenceMapUriParams() " + requestPathAndQuery(request));
+        boolean includeUnpublished = NO_UNPUBLISHED;
 
         Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors = null;
 
         List<SpecimenOrObservationBase> specimensOrObersvations = occurencesForTaxon(uuid, relationshipUuids,
-                               relationshipInversUuids, maxDepth, response);
+                               relationshipInversUuids, includeUnpublished, maxDepth, response);
 
         OccurrenceServiceRequestParameterDto dto = geoService.getOccurrenceServiceRequestParameters(specimensOrObersvations,
                 specimenOrObservationTypeColors );
@@ -148,8 +148,10 @@ public class ExternalGeoController extends BaseController<TaxonBase, ITaxonServi
     }
 
        private List<SpecimenOrObservationBase> occurencesForTaxon(UUID taxonUuid, UuidList relationshipUuids,
-                       UuidList relationshipInversUuids, Integer maxDepth, HttpServletResponse response) throws IOException {
-               Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(
+                       UuidList relationshipInversUuids, boolean includeUnpublished, Integer maxDepth,
+                       HttpServletResponse response) throws IOException {
+
+           Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(
                 relationshipUuids, relationshipInversUuids, termService);
 
         Taxon taxon = getCdmBaseInstance(Taxon.class, taxonUuid, response, (List<String>)null);
@@ -158,7 +160,7 @@ public class ExternalGeoController extends BaseController<TaxonBase, ITaxonServi
         orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));
 
         List<SpecimenOrObservationBase> specimensOrObersvations = occurrenceService.listByAssociatedTaxon(
-                null, includeRelationships, taxon, maxDepth, null, null, orderHints, null);
+                null, includeRelationships, taxon, includeUnpublished, maxDepth, null, null, orderHints, null);
                return specimensOrObersvations;
        }
 
index 443f4ea763d5322c9773b77a3f05ac9d9c5371d2..5bd9ac3fca25071ea808a93ad17cc7523e850358 100644 (file)
@@ -217,13 +217,12 @@ public class KmlController extends BaseController<TaxonBase, ITaxonService> {
             HttpServletResponse response)
             throws IOException {
 
-
         logger.info("doGetTaxonOccurrenceKml() " + requestPathAndQuery(request));
-
+        boolean includeUnpublished = NO_UNPUBLISHED;
         Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors = null;
 
         List<SpecimenOrObservationBase> specimensOrObersvations = occurencesForTaxon(uuid, relationshipUuids,
-                               relationshipInversUuids, maxDepth, response);
+                               relationshipInversUuids, includeUnpublished, maxDepth, response);
 
         Kml kml = geoservice.occurrencesToKML(specimensOrObersvations, specimenOrObservationTypeColors);
 
@@ -231,17 +230,18 @@ public class KmlController extends BaseController<TaxonBase, ITaxonService> {
     }
 
        private List<SpecimenOrObservationBase> occurencesForTaxon(UUID taxonUuid, UuidList relationshipUuids,
-                       UuidList relationshipInversUuids, Integer maxDepth, HttpServletResponse response) throws IOException {
-               Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(
-                relationshipUuids, relationshipInversUuids, termService);
+                       UuidList relationshipInversUuids, boolean includeUnpublished, Integer maxDepth,
+                       HttpServletResponse response) throws IOException {
 
+           Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(
+                relationshipUuids, relationshipInversUuids, termService);
         Taxon taxon = getCdmBaseInstance(Taxon.class, taxonUuid, response, (List<String>)null);
 
         List<OrderHint> orderHints = new ArrayList<>();
         orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));
 
         List<SpecimenOrObservationBase> specimensOrObersvations = occurrenceService.listByAssociatedTaxon(
-                null, includeRelationships, taxon, maxDepth, null, null, orderHints, null);
+                null, includeRelationships, taxon, includeUnpublished, maxDepth, null, null, orderHints, null);
                return specimensOrObersvations;
        }
 
index be03bd43bf22d916f3acb28187fff055040330a5..7f9872751d89c206ab769e4bcda5d931ae85ce0c 100644 (file)
@@ -108,6 +108,9 @@ public class ManifestController {
                 HttpServletRequest request, HttpServletResponse response) throws IOException {
 
             logger.info("doGetMedia() " + AbstractController.requestPathAndQuery(request));
+            boolean includeUnpublished = false;
+
+            boolean includeOriginals = false; //TODO added during refactoring, do we want to add it to the webservice parameters?
 
             EntityInitStrategy taxonInitStrategy = includeTaxonomicChildren? TaxonPortalController.TAXON_WITH_CHILDNODES_INIT_STRATEGY : TaxonPortalController.TAXON_INIT_STRATEGY;
             EntityMediaContext<Taxon> entityMediaContext = taxonPortalController.loadMediaForTaxonAndRelated(uuid,
@@ -119,7 +122,8 @@ public class ManifestController {
             if(includeTaxonomicChildren){
                 Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(relationshipUuids, relationshipInversUuids, termService);
                 entityMediaContext.setMedia(
-                        taxonPortalController.addTaxonomicChildrenMedia(includeTaxonDescriptions, includeOccurrences, includeTaxonNameDescriptions, entityMediaContext.getEntity(), includeRelationships, entityMediaContext.getMedia())
+                        taxonPortalController.addTaxonomicChildrenMedia(includeTaxonDescriptions, includeOccurrences, includeOriginals, includeTaxonNameDescriptions,
+                                entityMediaContext.getEntity(), includeRelationships, entityMediaContext.getMedia(), includeUnpublished)
                                 );
             }
             ManifestComposer manifestFactory = new ManifestComposer(HTTP_IIIF_CYBERTAXONOMY_ORG, mediaTools, mediaService, mediaInfoFactory);
index 9fc70bb3ada38fed9b0072324d899dab34b79a04..a9485a4b695f76a99d5e8c8eda871d7981d0fb8f 100644 (file)
@@ -546,7 +546,7 @@ public class DescriptiveDataSetService
         IdentifiableServiceConfiguratorImpl<PolytomousKey> serviceConfig = new IdentifiableServiceConfiguratorImpl<>();
         serviceConfig.setTitleSearchString(descriptiveDataSet.getTitleCache());
         List<PolytomousKey> list = polytomousKeyService.findByTitle(serviceConfig).getRecords();
-        if(list!=null){
+        if(list != null){
             list.forEach(polytomousKey->polytomousKeyService.delete(polytomousKey));
         }
         key.setTitleCache(descriptiveDataSet.getTitleCache(), true);
index 863d701efd3a9a493867123fbcbfb6a89fdf8656..c8714209b4f5ed01a03ba7534eaed02d351b0e29 100644 (file)
@@ -72,7 +72,7 @@ public interface IOccurrenceService
     /**
      * Returns a paged list of occurrences that have been determined to belong
      * to the taxon concept determinedAs, optionally restricted to objects
-     * belonging to a class that that extends SpecimenOrObservationBase. This
+     * belonging to a class that extends SpecimenOrObservationBase. This
      * will also consider specimens that are determined as a taxon concept
      * belonging to the synonymy of the given taxon concept.
      * <p>
@@ -256,7 +256,7 @@ public interface IOccurrenceService
      * @return
      */
     public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
+            Taxon associatedTaxon, boolean includeUnpublished, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * The method will search for specimen associated with the taxon nodes.<br>
@@ -293,7 +293,8 @@ public interface IOccurrenceService
      * @return a Pager
      */
     public <T extends SpecimenOrObservationBase> Pager<T> pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
+            Taxon associatedTaxon, boolean includeUnpublished, Integer maxDepth, Integer pageSize, Integer pageNumber,
+            List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * Retrieves all {@link FieldUnit}s for the {@link SpecimenOrObservationBase} with the given {@link UUID}.<br>
@@ -334,21 +335,6 @@ public interface IOccurrenceService
             String queryString, RectangleDTO boundingBox, List<Language> languages, boolean highlightFragments,
             Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
             throws IOException, LuceneParseException;
-    /**
-     * See {@link #listByAssociatedTaxon(Class, Set, String, Integer, Integer, Integer, List, List)}
-     *
-     * @param type
-     * @param includeRelationships
-     * @param associatedTaxon
-     * @param maxDepth
-     * @param pageSize
-     * @param pageNumber
-     * @param orderHints
-     * @param propertyPaths
-     * @return a Pager
-     */
-    public <T extends SpecimenOrObservationBase> Pager<T>  pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            String taxonUUID, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * Moves the given {@link Sequence} from one {@link DnaSample} to another
@@ -444,12 +430,7 @@ public interface IOccurrenceService
      * @param propertyPaths
      * @return a collection of associated taxa
      */
-    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen,
-            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
-    /**
-      * @see #listIndividualsAssociationTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)
-      */
-    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
+     public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
             Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
@@ -491,11 +472,6 @@ public interface IOccurrenceService
      * @param propertyPaths
      * @return a collection of all taxa where the given specimen is the type specimen
      */
-    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen,
-            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
-    /**
-     * @see #listTypeDesignationTaxa(DerivedUnit, Integer, Integer, List, List)a
-     */
     public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, boolean includeUnpublished,
             Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
 
@@ -508,6 +484,7 @@ public interface IOccurrenceService
      * @param propertyPaths
      * @return map of all designations with the given type specimens
      */
+    //TODO needed?
     public Map<DerivedUnit, Collection<SpecimenTypeDesignation>> listTypeDesignations(Collection<DerivedUnit> specimens, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
@@ -697,7 +674,6 @@ public interface IOccurrenceService
     List<SpecimenOrObservationBaseDTO> listRootUnitDTOsByAssociatedTaxon(Set<TaxonRelationshipEdge> includedRelationships,
             UUID associatedTaxonUuid, boolean includeUnpublished, List<String> propertyPaths);
 
-
     /**
      * Lists all root units which are
      * associated <b>directly or indirectly</b>with the <code>taxon</code> specified
@@ -732,16 +708,14 @@ public interface IOccurrenceService
      * @param propertyPaths
      * @return
      */
-    public <T extends SpecimenOrObservationBase> Collection<T> listRootUnitsByAssociatedTaxon(Class<T> type, Taxon associatedTaxon, List<OrderHint> orderHints, List<String> propertyPaths);
-
+    public <T extends SpecimenOrObservationBase> Collection<T> listRootUnitsByAssociatedTaxon(
+            Class<T> type, Taxon associatedTaxon, boolean includeUnpublished, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * See {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
      */
     public <T extends SpecimenOrObservationBase> Pager<T> pageRootUnitsByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
-
-
+            Taxon associatedTaxon, boolean includeUnpublished, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     public List<Point> findPointsForFieldUnitList(List<UUID> fieldUnitUuids);
 
index c53941de21d84cefa4b4b949f28f429493bd7122..2cb2bb8c106ec40917427c9eb0a082038b71ecd2 100644 (file)
@@ -728,50 +728,7 @@ public interface ITaxonService
     public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz,
             String queryString, Classification classification, TaxonNode subtree, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
 
-    /**
-     * Lists all Media found in an any TaxonDescription associated with this
-     * taxon.
-     *
-     * @param taxon
-     * @param includeRelationships
-     *            the given list of TaxonRelationshipEdges will be taken into
-     *            account when retrieving media associated with the given taxon.
-     *            Can be NULL.
-     * @param limitToGalleries
-     *            whether to take only TaxonDescription into account which are
-     *            marked as gallery
-     * @return
-     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
-     */
-    @Deprecated
-    public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
-
-    /**
-     * Lists all Media found in an any TaxonDescription, NameDescription,
-     * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
-     *
-     * @param taxon
-     * @param includeRelationships
-     *            the given list of TaxonRelationshipEdges will be taken into
-     *            account when retrieving media associated with the given taxon.
-     *            Can be NULL.
-     * @param limitToGalleries
-     *            whether to take only descriptions into account which are
-     *            marked as gallery, can be NULL
-     * @param includeTaxonDescriptions
-     *            whether to take TaxonDescriptions into account, can be NULL
-     * @param includeOccurrences
-     *          whether to take TaxonDescriptions into account, can be NULL
-     * @param includeTaxonNameDescriptions
-     *       whether to take TaxonNameDescriptions into account, can be NULL
-     * @param propertyPath
-     * @return
-     */
-    public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
-            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
-            Boolean includeTaxonNameDescriptions, List<String> propertyPath);
-
-    /**
+     /**
      * Lists all Media found in an any TaxonDescription, NameDescription,
      * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
      *
@@ -796,7 +753,7 @@ public interface ITaxonService
      */
     public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
             Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeOriginals,
-            Boolean includeTaxonNameDescriptions, List<String> propertyPath);
+            Boolean includeTaxonNameDescriptions, boolean includeUnpublished, List<String> propertyPath);
 
     public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
 
index a44ee19ffc7801d94a24051e2e8ab61a9337453e..534042dc15a331ff85704e0fe01887dcfb960b77 100644 (file)
@@ -213,6 +213,7 @@ public class OccurrenceServiceImpl
                 );
         return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, mediaDTOs);
     }
+
     @Override
     public Pager<Media> getMediaInHierarchy(SpecimenOrObservationBase<?> rootOccurence, boolean collectOriginalMedia, boolean collectDerivateMedia, Integer pageSize,
             Integer pageNumber, List<String> propertyPaths) {
@@ -256,17 +257,15 @@ public class OccurrenceServiceImpl
                 }
          }
 
-
          return new DefaultPagerImpl<>(pageNumber, Long.valueOf(media.size()), pageSize, media);
     }
 
-
     @Override
     public Pager<Media> getMediaInHierarchy(SpecimenOrObservationBase<?> rootOccurence, Integer pageSize,
             Integer pageNumber, List<String> propertyPaths) {
-       return getMediaInHierarchy(rootOccurence, false, true, pageSize,
-                pageNumber, propertyPaths);
 
+        return getMediaInHierarchy(rootOccurence, false, true, pageSize,
+                pageNumber, propertyPaths);
     }
 
     @Override
@@ -315,9 +314,9 @@ public class OccurrenceServiceImpl
 
     @Override
     public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
+            Taxon associatedTaxon, boolean includeUnpublished, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
 
-        return pageByAssociatedTaxon(type, includeRelationships, associatedTaxon, maxDepth, pageSize, pageNumber, orderHints, propertyPaths).getRecords();
+        return pageByAssociatedTaxon(type, includeRelationships, associatedTaxon, includeUnpublished, maxDepth, pageSize, pageNumber, orderHints, propertyPaths).getRecords();
     }
 
     @Override
@@ -327,13 +326,14 @@ public class OccurrenceServiceImpl
     }
 
     @Override
-    public <T extends SpecimenOrObservationBase> Collection<T> listRootUnitsByAssociatedTaxon(Class<T> type, Taxon associatedTaxon, List<OrderHint> orderHints, List<String> propertyPaths) {
-        return pageRootUnitsByAssociatedTaxon(type, null, associatedTaxon, null, null, null, null, propertyPaths).getRecords();
+    public <T extends SpecimenOrObservationBase> Collection<T> listRootUnitsByAssociatedTaxon(
+            Class<T> type, Taxon associatedTaxon, boolean includeUnpublished, List<OrderHint> orderHints, List<String> propertyPaths) {
+        return pageRootUnitsByAssociatedTaxon(type, null, associatedTaxon, includeUnpublished, null, null, null, null, propertyPaths).getRecords();
     }
 
     @Override
     public <T extends SpecimenOrObservationBase> Pager<T> pageRootUnitsByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
+            Taxon associatedTaxon, boolean includeUnpublished, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
             List<String> propertyPaths) {
 
         if (!getSession().contains(associatedTaxon)) {
@@ -342,7 +342,8 @@ public class OccurrenceServiceImpl
 
         // gather the IDs of all relevant root units
         Set<UUID> rootUnitUuids = new HashSet<>();
-        List<SpecimenOrObservationBase> records = listByAssociatedTaxon(null, includeRelationships, associatedTaxon, maxDepth, null, null, orderHints, propertyPaths);
+        List<SpecimenOrObservationBase> records = listByAssociatedTaxon(null, includeRelationships,
+                associatedTaxon, includeUnpublished, maxDepth, null, null, orderHints, propertyPaths);
         for (SpecimenOrObservationBase<?> specimen : records) {
             for (SpecimenOrObservationBase<?> rootUnit : findRootUnits(specimen.getUuid(), null)) {
                 if(type == null || type.isAssignableFrom(rootUnit.getClass())) {
@@ -437,37 +438,14 @@ public class OccurrenceServiceImpl
         return derivedUnits;
     }
 
-//    private Set<DerivateDTO> getDerivedUnitDTOsFor(DerivateDTO specimenDto, DerivedUnit specimen, HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen) {
-//        Set<DerivateDTO> derivedUnits = new HashSet<>();
-////        load
-//        for (DerivationEvent derivationEvent : specimen.getDerivationEvents()) {
-//            for (DerivedUnit derivative : derivationEvent.getDerivatives()) {
-//                if (!alreadyCollectedSpecimen.containsKey(specimenDto.getUuid())){
-//                    PreservedSpecimenDTO dto;
-//                    if (derivative instanceof DnaSample){
-//                        dto = DNASampleDTO.newInstance(derivative);
-//                    }else{
-//                        dto = PreservedSpecimenDTO.newInstance(derivative);
-//                    }
-//                    alreadyCollectedSpecimen.put(dto.getUuid(), dto);
-//                    dto.addAllDerivates(getDerivedUnitDTOsFor(dto, derivative, alreadyCollectedSpecimen));
-//                    derivedUnits.add(dto);
-//                }
-//            }
-//        }
-//        return derivedUnits;
-//    }
-
-
-    @SuppressWarnings("unchecked")
     @Override
     public <T extends SpecimenOrObservationBase> Pager<T> pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includedRelationships,
-            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
+            Taxon associatedTaxon, boolean includeUnpublished, Integer maxDepth, Integer pageSize, Integer pageNumber,
+            List<OrderHint> orderHints, List<String> propertyPaths) {
 
         Set<Taxon> taxa = new HashSet<>();
         Set<Integer> occurrenceIds = new HashSet<>();
         List<T> occurrences = new ArrayList<>();
-        boolean includeUnpublished = INCLUDE_UNPUBLISHED;
 
         // Integer limit = PagerUtils.limitFor(pageSize);
         // Integer start = PagerUtils.startFor(pageSize, pageNumber);
@@ -495,15 +473,6 @@ public class OccurrenceServiceImpl
 
     }
 
-    @Override
-    public <T extends SpecimenOrObservationBase> Pager<T> pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
-            String taxonUUID, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
-
-        UUID uuid = UUID.fromString(taxonUUID);
-        Taxon taxon = (Taxon) taxonService.load(uuid);
-        return pageByAssociatedTaxon(type, includeRelationships, taxon, maxDepth, pageSize, pageNumber, orderHints, propertyPaths);
-    }
-
     @Override
     @Transactional
     public List<SpecimenOrObservationBaseDTO> listRootUnitDTOsByAssociatedTaxon(Set<TaxonRelationshipEdge> includedRelationships,
@@ -1297,14 +1266,6 @@ public class OccurrenceServiceImpl
         return associatedTaxa;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, Integer limit, Integer start,
-            List<OrderHint> orderHints, List<String> propertyPaths) {
-        return listTypeDesignationTaxa(specimen, INCLUDE_UNPUBLISHED, limit, start, orderHints, propertyPaths);
-    }
     @Override
     public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, boolean includeUnpublished,
             Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
@@ -1323,15 +1284,6 @@ public class OccurrenceServiceImpl
         return associatedTaxa;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,
-            Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
-        return listIndividualsAssociationTaxa(specimen, INCLUDE_UNPUBLISHED, limit, start, orderHints, propertyPaths);
-    }
-
     @Override
     public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
             Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
index 58d41cd7816adc2a879255fafd283abea48a967d..b307423d5218e39da4be754586c866dc2292dbb7 100644 (file)
@@ -959,27 +959,11 @@ public class TaxonServiceImpl
         return dao.getUuidAndTitleCache(limit, pattern);
     }
 
-    @Override
-    public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath){
-        return listMedia(taxon, includeRelationships, limitToGalleries, true, false, false, propertyPath);
-    }
-
-    @Override
-    public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
-            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
-            Boolean includeTaxonNameDescriptions, List<String> propertyPath) {
-       return  listMedia(taxon, includeRelationships, limitToGalleries, includeTaxonDescriptions, includeOccurrences, false,
-                includeTaxonNameDescriptions, propertyPath);
-    }
-
     @Override
     public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
             Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
             Boolean includeOriginalOccurences, Boolean includeTaxonNameDescriptions,
-            List<String> propertyPath) {
-
-        //TODO let inherit
-        boolean includeUnpublished = INCLUDE_UNPUBLISHED;
+            boolean includeUnpublished, List<String> propertyPath) {
 
 //      LogUtils.setLevel(logger, Level.TRACE);
 //      LogUtils.setLevel("org.hibernate.SQL", Level.TRACE);
index a433d83ac924330fbc6e5cd657f5992625c175bd..05c45da3bcee286f7d5b72062e44475672d94f0c 100644 (file)
@@ -60,4 +60,6 @@ public interface IIdentifiableEntityServiceConfigurator<T extends IIdentifiableE
        public List<String> getPropertyPaths();\r
        public void setPropertyPaths(List<String> propertyPaths);\r
 \r
-}\r
+    public boolean isIncludeUnpublished();\r
+    public void setIncludeUnpublished(boolean includeUnpublished);\r
+}
\ No newline at end of file
index 031ef764eaa2422fab105536746e20be2467f8d8..6474c520589e13f5fa1c0ba9ed39c5b2c5b39990 100644 (file)
@@ -37,7 +37,6 @@ import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorFactor
 import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorImpl;
 import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
-import eu.etaxonomy.cdm.common.DoubleResult;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;
@@ -66,7 +65,6 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
 import eu.etaxonomy.cdm.persistence.dao.common.Restriction.Operator;
-import eu.etaxonomy.cdm.persistence.dto.TaxonNameParts;
 import eu.etaxonomy.cdm.persistence.query.MatchMode;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
@@ -1005,7 +1003,7 @@ public class NameServiceImplTest extends CdmTransactionalIntegrationTest {
     public void testFindByTitleTitle_using_Configurator(){
 
         String searchString = "*";
-        IdentifiableServiceConfiguratorImpl<TaxonName> searchConfigurator = new IdentifiableServiceConfiguratorImpl<TaxonName>();
+        IdentifiableServiceConfiguratorImpl<TaxonName> searchConfigurator = new IdentifiableServiceConfiguratorImpl<>();
 
         searchConfigurator = IdentifiableServiceConfiguratorFactory.getConfigurator(TaxonName.class);
         searchConfigurator.setTitleSearchString(searchString);
index 23f3a31027cf5bddb5d518c1cc227c95bc5a922c..01b05afd67ff82f01b82744879bb41f3f0761c73 100644 (file)
@@ -899,7 +899,8 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertEquals(taxon, associatedTaxa.iterator().next());
 
         //check association (IndividualsAssociations + TypeDesignations) taxon (name) -> specimen
-        List<DerivedUnit> byAssociatedTaxon = occurrenceService.listByAssociatedTaxon(DerivedUnit.class, null, taxon, null, null, null, null, null);
+        List<DerivedUnit> byAssociatedTaxon = occurrenceService.listByAssociatedTaxon(
+                DerivedUnit.class, null, taxon, includeUnpublished, null, null, null, null, null);
         assertNotNull(byAssociatedTaxon);
         assertEquals(2, byAssociatedTaxon.size());
         assertTrue(byAssociatedTaxon.contains(associatedSpecimen));