ref #10334 evaluate descriptionBase.publish in webservices
authorAndreas Müller <a.mueller@bgbm.org>
Wed, 17 Jan 2024 21:36:15 +0000 (22:36 +0100)
committerAndreas Müller <a.mueller@bgbm.org>
Wed, 17 Jan 2024 21:36:15 +0000 (22:36 +0100)
18 files changed:
cdmlib-api/src/main/java/eu/etaxonomy/cdm/api/dto/portal/config/DistributionInfoConfiguration.java
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/excel/stream/ExcelStreamImportTest.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/occurrence/OccurrenceDaoHibernateImpl.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/occurrence/IOccurrenceDao.java
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionElementListController.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IOccurrenceService.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/IdentifiableServiceConfiguratorImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/geo/DistributionServiceImpl.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImplTest.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java

index 7c1bb5bffe75203a4f9f2d6eb58caea2632ff95a..931817554d59ef311c669386c5ad03673a4b49df 100644 (file)
@@ -51,6 +51,8 @@ public class DistributionInfoConfiguration {
 
     private boolean useTreeDto = true;
 
+    private boolean includeUnpublished = false;
+
 //********************* GETTER / SETTER ***************************/
 
     public boolean isPreferSubareas() {
@@ -143,4 +145,11 @@ public class DistributionInfoConfiguration {
     public void setStatusTree(UUID statusTree) {
         this.statusTree = statusTree;
     }
+
+    public boolean isIncludeUnpublished() {
+        return includeUnpublished;
+    }
+    public void setIncludeUnpublished(boolean includeUnpublished) {
+        this.includeUnpublished = includeUnpublished;
+    }
 }
\ No newline at end of file
index ba00bb41cb94eac757474aa389f4836e918d8fb0..759ede817074fadae44055129d33b72f860732e7 100644 (file)
@@ -136,9 +136,9 @@ public class ExcelStreamImportTest extends CdmTransactionalIntegrationTest{
 
                Set<TaxonDescription> taxonSet = secondTaxon.getTaxon().getDescriptions();
                assertTrue("Description is not Empty", !taxonSet.isEmpty());
-               assertEquals("Number of Distributions should be 7", 7, descriptionService.listDescriptionElements(null, null, Distribution.class, null, null, null).size());
+               assertEquals("Number of Distributions should be 7", 7, descriptionService.listDescriptionElements(null, null, Distribution.class, false, null, null, null).size());
 //             assertEquals("Number of Vernecular Names should be 7", 6, descriptionService.listDescriptionElements(null, null, CommonTaxonName.class, null, null, null).size());
-               List<CommonTaxonName> list = descriptionService.listDescriptionElements(null, null, CommonTaxonName.class, null, null, null);
+               List<CommonTaxonName> list = descriptionService.listDescriptionElements(null, null, CommonTaxonName.class, false, null, null, null);
                for(DescriptionElementBase db : list){
                        System.out.println(db.toString());
                }
index ca43f42d7068e72715abf8162891768b6981295a..e96d95c0484e0aae169f936769665b72c09d171e 100644 (file)
@@ -267,22 +267,15 @@ public interface IDescriptionDao extends IIdentifiableDao<DescriptionBase> {
      * @return the list of matching DescriptionElementBase instances
      */
     <T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(UUID taxonUuid,
-            Set<Feature> features,
-            Class<T> type, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths);
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Return a list of ids of the specimens attached to a taxon via IndividualsAssociations
-     * @param taxonUuid
-     * @param features
-     * @param pageSize
-     * @param pageNumber
-     * @param propertyPaths
-     * @return
      */
     public List<Integer> getIndividualAssociationSpecimenIDs(UUID taxonUuid,
-            Set<Feature> features, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths);
+            Set<Feature> features, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * @param taxon
@@ -293,7 +286,7 @@ public interface IDescriptionDao extends IIdentifiableDao<DescriptionBase> {
      * @return the count of matching TaxonDescription instances
      */
     <T extends DescriptionElementBase> long countDescriptionElementForTaxon(UUID taxonUuid,
-            Set<Feature> features, Class<T> type);
+            Set<Feature> features, Class<T> type, boolean includeUnpublished);
 
     /**
      * Method to list all {@link NamedAreas} instances which are currently used
index 92c0c0705680768de54d6bb04e532c1668f40821..c9b2bfcafdc4b61b20053a6a1c468b91919ac524 100644 (file)
@@ -687,9 +687,10 @@ public class DescriptionDaoImpl
 
     @Override
     public List<Integer> getIndividualAssociationSpecimenIDs(UUID taxonUuid,
-            Set<Feature> features, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths){
-        Query<Integer> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, IndividualsAssociation.class, pageSize, pageNumber, "de.associatedSpecimenOrObservation.id");
+            Set<Feature> features, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths){
+        Query<Integer> query = prepareGetDescriptionElementForTaxon(taxonUuid, features,
+                IndividualsAssociation.class, includeUnpublished, pageSize, pageNumber, "de.associatedSpecimenOrObservation.id");
         List<Integer> results = query.list();
         return results;
     }
@@ -705,11 +706,12 @@ public class DescriptionDaoImpl
     @Override
     public <T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(
             UUID taxonUuid, Set<Feature> features,
-            Class<T> type, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths) {
+            Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
 
 //      LogUtils.setLevel("org.hibernate.SQL", Level.TRACE);
-        Query<T> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, pageSize, pageNumber, "de");
+        Query<T> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, includeUnpublished,
+                pageSize, pageNumber, "de");
 
         if (logger.isDebugEnabled()){logger.debug(" dao: get list ...");}
         List<T> results = query.list();
@@ -723,20 +725,21 @@ public class DescriptionDaoImpl
 
     @Override
     public <T extends DescriptionElementBase> long countDescriptionElementForTaxon(
-            UUID taxonUuid, Set<Feature> features, Class<T> type) {
+            UUID taxonUuid, Set<Feature> features, Class<T> type, boolean includeUnpublished) {
 
-        Query<Long> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, null, null, "count(de)");
+        Query<Long> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, includeUnpublished, null, null, "count(de)");
 
         return query.uniqueResult();
     }
 
     private <T extends DescriptionElementBase, R extends Object> Query<R> prepareGetDescriptionElementForTaxon(UUID taxonUuid,
-            Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, String selectString) {
+            Set<Feature> features, Class<T> type, boolean includeUnpublished, Integer pageSize, Integer pageNumber, String selectString) {
 
         String queryString = "SELECT " + selectString + " FROM DescriptionElementBase AS de" +
                 " LEFT JOIN de.inDescription AS d" +
                 " LEFT JOIN d.taxon AS t" +
-                " WHERE d.class = 'TaxonDescription' AND t.uuid = :taxon_uuid ";
+                " WHERE d.class = 'TaxonDescription' AND t.uuid = :taxon_uuid " +
+                (includeUnpublished? "" : " AND de.publish = :publish ");                ;
 
         if(type != null){
             queryString += " and de.class = :type";
@@ -751,6 +754,9 @@ public class DescriptionDaoImpl
         if(type != null){
             query.setParameter("type", type.getSimpleName());
         }
+        if (!includeUnpublished){
+            query.setParameter("publish", true);
+        }
         if(hasFeatureFilter){
             query.setParameterList("features", features) ;
         }
index fa3d4dbe7d218fbe26ffdb503f5db86dfb852f9e..e42df8da8b16e3bad7c78c77e0cb73d4053df7ad 100644 (file)
@@ -324,10 +324,11 @@ public class OccurrenceDaoHibernateImpl
     @Override
     public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> findOccurrencesUuidAndTitleCache(
             Class<T> clazz, String queryString, String significantIdentifier, SpecimenOrObservationType recordBasis,
-            Taxon associatedTaxon, TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
-            List<OrderHint> orderHints) {
+            Taxon associatedTaxon, TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,
+            Integer limit, Integer start, List<OrderHint> orderHints) {
+
         Criteria criteria = createFindOccurrenceCriteria(clazz, queryString, significantIdentifier, recordBasis,
-                associatedTaxon, associatedTaxonName, matchmode, limit, start, orderHints, null);
+                associatedTaxon, associatedTaxonName, matchmode, includeUnpublished, limit, start, orderHints, null);
         if(criteria!=null){
             ProjectionList projectionList = Projections.projectionList();
             projectionList.add(Projections.property("uuid"));
@@ -350,10 +351,11 @@ public class OccurrenceDaoHibernateImpl
     @Override
     public <T extends SpecimenOrObservationBase> List<T> findOccurrences(Class<T> clazz, String queryString,
             String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon, TaxonName associatedTaxonName,
-            MatchMode matchmode, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+            MatchMode matchmode, boolean includeUnpublished,
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
 
         Criteria criteria = createFindOccurrenceCriteria(clazz, queryString, significantIdentifier, recordBasis,
-                associatedTaxon, associatedTaxonName, matchmode, limit, start, orderHints, propertyPaths);
+                associatedTaxon, associatedTaxonName, matchmode, includeUnpublished, limit, start, orderHints, propertyPaths);
         if(criteria!=null){
             @SuppressWarnings("unchecked")
             List<T> results = criteria.list();
@@ -366,8 +368,9 @@ public class OccurrenceDaoHibernateImpl
 
     private <T extends SpecimenOrObservationBase> Criteria createFindOccurrenceCriteria(Class<T> clazz, String queryString,
             String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon,
-            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit,
-            Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+            TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+
         Criteria criteria = null;
 
         if(clazz == null) {
@@ -416,7 +419,8 @@ public class OccurrenceDaoHibernateImpl
         Set<UUID> associationUuids = new HashSet<>();
         //taxon associations
         if(associatedTaxon!=null){
-            List<UuidAndTitleCache<SpecimenOrObservationBase>> associatedTaxaList = listUuidAndTitleCacheByAssociatedTaxon(clazz, associatedTaxon, limit, start, orderHints);
+            List<UuidAndTitleCache<SpecimenOrObservationBase>> associatedTaxaList = listUuidAndTitleCacheByAssociatedTaxon(
+                    clazz, associatedTaxon, includeUnpublished, limit, start, orderHints);
             if(associatedTaxaList!=null){
                 for (UuidAndTitleCache<SpecimenOrObservationBase> uuidAndTitleCache : associatedTaxaList) {
                     associationUuids.add(uuidAndTitleCache.getUuid());
@@ -452,10 +456,10 @@ public class OccurrenceDaoHibernateImpl
     @Override
     public <T extends SpecimenOrObservationBase> long countOccurrences(Class<T> clazz, String queryString,
             String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon, TaxonName associatedTaxonName,
-            MatchMode matchmode, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+            MatchMode matchmode, boolean includeUnpublished, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
 
         Criteria criteria = createFindOccurrenceCriteria(clazz, queryString, significantIdentifier, recordBasis,
-                associatedTaxon, associatedTaxonName, matchmode, limit, start, orderHints, propertyPaths);
+                associatedTaxon, associatedTaxonName, matchmode, includeUnpublished, limit, start, orderHints, propertyPaths);
 
         if(criteria!=null){
             criteria.setProjection(Projections.rowCount());
@@ -667,9 +671,11 @@ public class OccurrenceDaoHibernateImpl
     }
 
     @Override
-    public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> clazz, Taxon associatedTaxon,
+    public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(
+            Class<T> clazz, Taxon associatedTaxon, boolean includeUnpublished,
             Integer limit, Integer start, List<OrderHint> orderHints){
-        Query<Object[]> query = createSpecimenQuery("sob.uuid, sob.id, sob.titleCache", clazz, associatedTaxon, limit, start, orderHints, Object[].class);
+
+        Query<Object[]> query = createSpecimenQuery("sob.uuid, sob.id, sob.titleCache", clazz, associatedTaxon, includeUnpublished, limit, start, orderHints, Object[].class);
         if(query==null){
             return Collections.emptyList();
         }
@@ -683,10 +689,11 @@ public class OccurrenceDaoHibernateImpl
 
     @Override
     public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> clazz,
-            Taxon associatedTaxon, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+            Taxon associatedTaxon, boolean includeUnpublished, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
 
         @SuppressWarnings("rawtypes")
-        Query<SpecimenOrObservationBase> query = createSpecimenQuery("sob", clazz, associatedTaxon, limit, start, orderHints, SpecimenOrObservationBase.class);
+        Query<SpecimenOrObservationBase> query = createSpecimenQuery(
+                "sob", clazz, associatedTaxon, includeUnpublished, limit, start, orderHints, SpecimenOrObservationBase.class);
         if(query==null){
             return Collections.emptyList();
         }
@@ -698,7 +705,7 @@ public class OccurrenceDaoHibernateImpl
     }
 
     private <T extends SpecimenOrObservationBase, R extends Object> Query<R> createSpecimenQuery(String select, Class<T> clazz,
-            Taxon associatedTaxon, Integer limit, Integer start, List<OrderHint> orderHints, Class<R> returnClass){
+            Taxon associatedTaxon, boolean includeUnpublished, Integer limit, Integer start, List<OrderHint> orderHints, Class<R> returnClass){
 
         Set<Integer> setOfAllIds = new HashSet<>();
 
@@ -746,7 +753,7 @@ public class OccurrenceDaoHibernateImpl
 
         // The IndividualsAssociation elements in a TaxonDescription contain DerivedUnits
         setOfAllIds.addAll(descriptionDao.getIndividualAssociationSpecimenIDs(
-                associatedTaxon.getUuid(), null, null, 0, null));
+                associatedTaxon.getUuid(), null, includeUnpublished, null, 0, null));
 
 
         // SpecimenTypeDesignations may be associated with the TaxonName.
index e00e52ac0d39dc866f5e1a93be38cc7529dfbb9e..6acc33bd105c958975a7f1d883bc0154147b04d3 100644 (file)
@@ -128,7 +128,8 @@ public interface IOccurrenceDao extends IIdentifiableDao<SpecimenOrObservationBa
      */\r
     public <T extends SpecimenOrObservationBase> List<T> findOccurrences(Class<T> clazz, String queryString,\r
             String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,\r
-            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,\r
+            TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,\r
+            Integer limit, Integer start,\r
             List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
     /**\r
@@ -149,8 +150,8 @@ public interface IOccurrenceDao extends IIdentifiableDao<SpecimenOrObservationBa
     public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> findOccurrencesUuidAndTitleCache(\r
             Class<T> clazz, String queryString,\r
             String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,\r
-            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,\r
-            List<OrderHint> orderHints);\r
+            TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,\r
+            Integer limit, Integer start, List<OrderHint> orderHints);\r
 \r
     /**\r
      * Returns the number of specimens that match the given parameters\r
@@ -185,7 +186,8 @@ public interface IOccurrenceDao extends IIdentifiableDao<SpecimenOrObservationBa
      */\r
     public <T extends SpecimenOrObservationBase> long countOccurrences(Class<T> clazz, String queryString,\r
             String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon,\r
-            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,\r
+            TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,\r
+            Integer limit, Integer start,\r
             List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
        /**\r
@@ -284,30 +286,16 @@ public interface IOccurrenceDao extends IIdentifiableDao<SpecimenOrObservationBa
         * <li>{@link SpecimenTypeDesignation}s may be associated with any {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>\r
         * <li>A {@link Taxon} or a {@link TaxonName} may be referenced by the {@link DeterminationEvent} of the {@link SpecimenOrObservationBase}</li>\r
         * </ul>\r
-        *\r
-        * @param <T>\r
-        * @param type\r
-        * @param associatedTaxon\r
-        * @param limit\r
-        * @param start\r
-        * @param orderHints\r
-        * @param propertyPaths\r
-        * @return\r
         */\r
        public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,\r
-                       Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+               boolean includeUnpublished, Integer limit, Integer start,\r
+               List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
        /**\r
         * @see IOccurrenceDao#listByAssociatedTaxon(Class, Taxon, Integer, Integer, List, List)\r
-        * @param type\r
-        * @param associatedTaxon\r
-        * @param limit\r
-        * @param start\r
-        * @param orderHints\r
-        * @param propertyPaths\r
-        * @return\r
         */\r
-       public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,\r
+       public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(\r
+               Class<T> type, Taxon associatedTaxon, boolean includeUnpublished,\r
                Integer limit, Integer start, List<OrderHint> orderHints);\r
 \r
     /**\r
index 4d6f39e4bc50ceae519b1c1b700fdba434e591ac..40718edd8cad209ab52d11a198a1dde389535b2d 100644 (file)
@@ -352,21 +352,21 @@ public class DescriptionDaoHibernateImplTest extends CdmTransactionalIntegration
 
         // 1.
         List<DescriptionElementBase> elements1 = descriptionDao.getDescriptionElementForTaxon(
-                taxonSphingidae.getUuid() , null, null, null, 0, null);
+                taxonSphingidae.getUuid(), null, null, false, null, 0, null);
 
         assertNotNull("getDescriptionElementForTaxon should return a List", elements1);
         assertEquals("getDescriptionElementForTaxon should return 1 elements",1,elements1.size());
 
         // 2.
         List<DescriptionElementBase> elements2 = descriptionDao.getDescriptionElementForTaxon(
-                taxonSphingidae.getUuid() , null, DescriptionElementBase.class, null, 0, null);
+                taxonSphingidae.getUuid(), null, DescriptionElementBase.class, false, null, 0, null);
 
         assertNotNull("getDescriptionElementForTaxon should return a List", elements2);
         assertTrue("getDescriptionElementForTaxon should be empty",elements2.isEmpty());
 
         // 3.
         List<Distribution> elements3 = descriptionDao.getDescriptionElementForTaxon(
-                taxonSphingidae.getUuid() , null, Distribution.class, null, 0, null);
+                taxonSphingidae.getUuid() , null, Distribution.class, false, null, 0, null);
 
         assertNotNull("getDescriptionElementForTaxon should return a List", elements3);
         assertEquals("getDescriptionElementForTaxon should return 1 elements",1,elements3.size());
@@ -621,13 +621,13 @@ public class DescriptionDaoHibernateImplTest extends CdmTransactionalIntegration
         Assert.assertEquals(3, list.size());
     }
 
-    
+
     @Test
     @DataSet
     public void testGetNodeOfIndividualAssociationForSpecimen() {
        List<SortableTaxonNodeQueryResult> list = descriptionDao.getNodeOfIndividualAssociationForSpecimen(UUID.fromString("4c3231a9-336e-4b21-acf2-129683627de4"), null);
        Assert.assertEquals(1, list.size());
-    
+
     }
     @Override
     public void createTestDataSet() throws FileNotFoundException {}
index 8619618157f65fff60f140f5b14584916b5713c7..2af571fd3076b8caefdd5c1e1f9f4ed344d07994 100644 (file)
@@ -10,6 +10,7 @@ package eu.etaxonomy.cdm.remote.controller;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import javax.servlet.http.HttpServletRequest;
@@ -116,6 +117,7 @@ public class DescriptionElementListController {
             HttpServletResponse response) throws IOException {
 
         logger.info("doPageDescriptionElementsByFeature : " + requestPathAndQuery(request));
+        boolean includeUnpublished = false;
 
         PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
         pagerParams.normalizeAndValidate(response);
@@ -125,7 +127,7 @@ public class DescriptionElementListController {
         }
 
         Pager<? extends DescriptionElementBase> pager = service.pageDescriptionElements(null, descriptionType, features.asSet(),
-                type, pagerParams.getPageSize(), pagerParams.getPageIndex(), getInitializationStrategy());
+                type, includeUnpublished, pagerParams.getPageSize(), pagerParams.getPageIndex(), getInitializationStrategy());
 
         return pager;
     }
@@ -147,6 +149,7 @@ public class DescriptionElementListController {
         PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
         pagerParams.normalizeAndValidate(response);
 
+        boolean includeUnpublished = false;
         Taxon taxon = null;
         if( taxon_uuid!= null){
             try {
@@ -155,9 +158,10 @@ public class DescriptionElementListController {
                 HttpStatusMessage.UUID_NOT_FOUND.send(response);
             }
         }
+        Set<Feature> featureSet = features != null ? features.asSet() : null;
         List<String> propertyPath = getInitializationStrategy();
-        Pager<T> pager = service.pageDescriptionElementsForTaxon(taxon, features != null ? features.asSet() : null, type, pageSize,
-                pageIndex, getInitializationStrategy());
+        Pager<T> pager = service.pageDescriptionElementsForTaxon(taxon, featureSet, type, includeUnpublished,
+                pageSize, pageIndex, propertyPath);
         return pager;
     }
 
index 1b6ef86544d705c41075ee899a2964897b872b2b..adeb4e3cc500e155bb8813b154aee0e34d565e87 100644 (file)
@@ -299,17 +299,19 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
         return pager;
     }
 
-
     @RequestMapping(value = "specimensOrObservationsCount", method = RequestMethod.GET)
     public StringResultDTO doCountSpecimensOrObservations(
             @PathVariable("uuid") UUID uuid,
             HttpServletRequest request,
             HttpServletResponse response) {
+
         logger.info("doListSpecimensOrObservations() - " + request.getRequestURI());
+        boolean includeUnpublished = NO_UNPUBLISHED;
 
         List<OrderHint> orderHints = new ArrayList<>();
         orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));
         FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
+        config.setIncludeUnpublished(includeUnpublished);
         config.setAssociatedTaxonUuid(uuid);
         long countSpecimen = occurrenceService.countOccurrences(config);
         return new StringResultDTO(String.valueOf(countSpecimen));
@@ -527,7 +529,8 @@ public class TaxonController extends AbstractIdentifiableController<TaxonBase, I
                     + classSimpleName);
             if (taxonDescriptions != null) {
                 for (TaxonDescription description : taxonDescriptions) {
-                    elements = descriptionService.listDescriptionElements(description, null, type, null, 0, initStrategy);
+                    elements = descriptionService.listDescriptionElements(
+                            description, null, type, includeUnpublished, null, 0, initStrategy);
                     allElements.addAll(elements);
                     count += elements.size();
                 }
index ae28c0630fb9ebc61d367b38f733651a04d233eb..399211c1b1baffdf936a941d3cb9fedbbf6ebc3b 100644 (file)
@@ -225,22 +225,27 @@ public class DescriptionServiceImpl
 
     @Override
     public <T extends DescriptionElementBase> Pager<T> pageDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
-            Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
 
-        List<T> results = listDescriptionElements(description, descriptionType, features, type, pageSize, pageNumber, propertyPaths);
+        List<T> results = listDescriptionElements(description, descriptionType, features, type, includeUnpublished,
+                pageSize, pageNumber, propertyPaths);
         return new DefaultPagerImpl<>(pageNumber, Integer.valueOf(results.size()).longValue(), pageSize, results);
     }
 
     @Override
     @Deprecated
     public <T extends DescriptionElementBase> Pager<T> getDescriptionElements(DescriptionBase description,
-            Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
-        return pageDescriptionElements(description, null, features, type, pageSize, pageNumber, propertyPaths);
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+        return pageDescriptionElements(description, null, features, type, includeUnpublished, pageSize, pageNumber, propertyPaths);
     }
 
     @Override
     public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description,
-            Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber,
+            Class<? extends DescriptionBase> descriptionType,
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber,
             List<String> propertyPaths) {
 
         long numberOfResults = dao.countDescriptionElements(description, descriptionType, features, type);
@@ -253,10 +258,13 @@ public class DescriptionServiceImpl
 
     @Override
     @Deprecated
-    public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description,
-            Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+    public <T extends DescriptionElementBase> List<T> listDescriptionElements(
+            DescriptionBase description,
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
 
-        return listDescriptionElements(description, null, features, type, pageSize, pageNumber, propertyPaths);
+        return listDescriptionElements(description, null, features, type, includeUnpublished,
+                pageSize, pageNumber, propertyPaths);
     }
 
     @Override
@@ -726,35 +734,41 @@ public class DescriptionServiceImpl
     @Deprecated
     public <T extends DescriptionElementBase> List<T> getDescriptionElementsForTaxon(
             Taxon taxon, Set<Feature> features,
-            Class<T> type, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths) {
-        return listDescriptionElementsForTaxon(taxon, features, type, pageSize, pageNumber, propertyPaths);
+            Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+
+        return listDescriptionElementsForTaxon(taxon, features, type, includeUnpublished,
+                pageSize, pageNumber, propertyPaths);
     }
 
     @Override
     public <T extends DescriptionElementBase> List<T> listDescriptionElementsForTaxon(
             Taxon taxon, Set<Feature> features,
-            Class<T> type, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths) {
-        return dao.getDescriptionElementForTaxon(taxon.getUuid(), features, type, pageSize, pageNumber, propertyPaths);
+            Class<T> type, boolean includePublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+
+        return dao.getDescriptionElementForTaxon(taxon.getUuid(), features, type, includePublished,
+                pageSize, pageNumber, propertyPaths);
     }
 
     @Override
     public <T extends DescriptionElementBase> Pager<T> pageDescriptionElementsForTaxon(
             Taxon taxon, Set<Feature> features,
-            Class<T> type, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths) {
+            Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+
         if (logger.isDebugEnabled()){logger.debug(" get count ...");}
-        Long count = dao.countDescriptionElementForTaxon(taxon.getUuid(), features, type);
+        Long count = dao.countDescriptionElementForTaxon(taxon.getUuid(), features, type, includeUnpublished);
         List<T> descriptionElements;
         if(AbstractPagerImpl.hasResultsInRange(count, pageNumber, pageSize)){ // no point checking again
             if (logger.isDebugEnabled()){logger.debug(" get list ...");}
-            descriptionElements = listDescriptionElementsForTaxon(taxon, features, type, pageSize, pageNumber, propertyPaths);
+            descriptionElements = listDescriptionElementsForTaxon(taxon, features, type, includeUnpublished,
+                    pageSize, pageNumber, propertyPaths);
         } else {
-            descriptionElements = new ArrayList<T>(0);
+            descriptionElements = new ArrayList<>(0);
         }
         if (logger.isDebugEnabled()){logger.debug(" service - DONE ...");}
-        return new DefaultPagerImpl<T>(pageNumber, count, pageSize, descriptionElements);
+        return new DefaultPagerImpl<>(pageNumber, count, pageSize, descriptionElements);
     }
 
     @Override
index 4c07fab228cd024cf9efa6312dc7a0d48c00b70c..19b7a36512fbcf00df7b3746413242f32907289c 100644 (file)
@@ -106,7 +106,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *             instead
      */
     @Deprecated
-    public <T extends DescriptionElementBase> Pager<T> getDescriptionElements(DescriptionBase description,Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> Pager<T> getDescriptionElements(
+            DescriptionBase description,Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
 
     /**
@@ -137,7 +139,10 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *
      * @return a Pager containing DescriptionElementBase instances
      */
-    public <T extends DescriptionElementBase> Pager<T> pageDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> Pager<T> pageDescriptionElements(
+            DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Returns description elements of type <TYPE>, belonging to a given
@@ -165,7 +170,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @deprecated use {@link #listDescriptionElements(DescriptionBase, Class, Set, Class, Integer, Integer, List)} instead
      */
     @Deprecated
-    public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description,Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> List<T> listDescriptionElements(
+            DescriptionBase description, Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Returns description elements of type <TYPE>, belonging to a given
@@ -178,7 +185,7 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *            Restrict the results to those description elements which are
      *            scoped by one of the Features passed (can be null or empty)
      * @param type
-     *            A filter DescriptionElements of a for specific class
+     *            A filter DescriptionElements of a specific class
      * @param pageSize
      *            The maximum number of description elements returned (can be
      *            null for all description elements)
@@ -191,7 +198,10 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *            {@link IBeanInitializer#initialize(Object, List)}
      * @return a List of DescriptionElementBase instances
      */
-    public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> List<T> listDescriptionElements(
+            DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
+            Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
 
     /**
@@ -360,7 +370,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @deprecated use {@link #listDescriptionElementsForTaxon(Taxon, Set, Class, Integer, Integer, List)} instead
      */
     @Deprecated
-    public <T extends DescriptionElementBase> List<T>  getDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> List<T>  getDescriptionElementsForTaxon(
+            Taxon taxon, Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Provides access to all DescriptionElements associated with the given Taxon
@@ -373,6 +385,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *            scoped by one of the Features passed (can be null or empty)
      * @param type
      *            A filter for DescriptionElements of a specific class
+     * @param includeUnpublished
+     *            If true factual data in a description not being published
+     *            is included.
      * @param pageSize
      *            The maximum number of description elements returned (can be
      *            null for all description elements)
@@ -386,7 +401,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @return a List containing all matching DescriptionElementBase instances
      *
      */
-    public <T extends DescriptionElementBase> List<T>  listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> List<T>  listDescriptionElementsForTaxon(
+            Taxon taxon, Set<Feature> features, Class<T> type, boolean includePublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Provides access to all DescriptionElements associated with the given Taxon
@@ -399,6 +416,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *            scoped by one of the Features passed (can be null or empty)
      * @param type
      *            A filter for DescriptionElements of a specific class
+     * @param includeUnpublished
+     *            If true factual data in a description not being published
+     *            is included.
      * @param pageSize
      *            The maximum number of description elements returned
      * @param pageNumber
@@ -411,7 +431,9 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @return a Pager for all matching DescriptionElementBase instances
      *
      */
-    public <T extends DescriptionElementBase> Pager<T>  pageDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public <T extends DescriptionElementBase> Pager<T>  pageDescriptionElementsForTaxon(
+            Taxon taxon, Set<Feature> features, Class<T> type, boolean includeUnpublished,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
       * Generate a string representation of the structured <code>description</code> supplied in natural language
index a423c8ba45ab690666a0938bca1bb09e121c5db6..ef0b0fc73e5fc4138a6bfbf2d594334a4ad4d9bc 100644 (file)
@@ -223,7 +223,7 @@ public interface IOccurrenceService
 
     public DerivedUnitFacade getDerivedUnitFacade(DerivedUnit derivedUnit, List<String> propertyPaths) throws DerivedUnitFacadeNotSupportedException;
 
-    public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, List<String> propertyPaths);
+    public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, boolean includeUnpublished, List<String> propertyPaths);
 
     /**
      * Lists all instances of {@link SpecimenOrObservationBase} which are
index 1f045c478dd031db3e974f70e1dd10ec9640ffb6..d7b8c41a2b6f8c2842292ba52dadc9bce7dc66b0 100644 (file)
@@ -316,12 +316,14 @@ public class OccurrenceServiceImpl
 
     @Override
     public List<DerivedUnitFacade> listDerivedUnitFacades(
-            DescriptionBase description, List<String> derivedUnitFacadeInitStrategy) {
+            DescriptionBase description, boolean includeUnpublished,
+            List<String> derivedUnitFacadeInitStrategy) {
 
         List<DerivedUnitFacade> derivedUnitFacadeList = new ArrayList<>();
         IndividualsAssociation tempIndividualsAssociation;
         SpecimenOrObservationBase tempSpecimenOrObservationBase;
-        List<IndividualsAssociation> elements = descriptionService.listDescriptionElements(description, null, IndividualsAssociation.class, null, 0, Arrays.asList(new String []{"associatedSpecimenOrObservation"}));
+        List<IndividualsAssociation> elements = descriptionService.listDescriptionElements(
+                description, null, IndividualsAssociation.class, includeUnpublished, null, 0, Arrays.asList(new String []{"associatedSpecimenOrObservation"}));
         for (IndividualsAssociation element : elements) {
             tempIndividualsAssociation = HibernateProxyHelper.deproxy(element, IndividualsAssociation.class);
             if (tempIndividualsAssociation.getAssociatedSpecimenOrObservation() != null) {
@@ -518,7 +520,8 @@ public class OccurrenceServiceImpl
         taxa.add(associatedTaxon);
 
         for (Taxon taxon : taxa) {
-            List<T> perTaxonOccurrences = dao.listByAssociatedTaxon(type, taxon, null, null, orderHints, propertyPaths);
+            List<T> perTaxonOccurrences = dao.listByAssociatedTaxon(type, taxon, includeUnpublished,
+                    null, null, orderHints, propertyPaths);
             for (SpecimenOrObservationBase<?> o : perTaxonOccurrences) {
                 occurrenceIds.add(o.getId());
             }
@@ -558,7 +561,8 @@ public class OccurrenceServiceImpl
         for (Taxon taxon : taxa) {
             // TODO there might be a good potential to speed up the whole processing by collecting all entities first
             // and to create the DTOs in a second step
-            Set<SpecimenOrObservationBase> perTaxonOccurrences = dao.listByAssociatedTaxon(null, taxon, null, null, null, propertyPaths)
+            Set<SpecimenOrObservationBase> perTaxonOccurrences = dao.listByAssociatedTaxon(
+                    null, taxon, includeUnpublished, null, null, null, propertyPaths)
                     .stream()
                     .map(u -> HibernateProxyHelper.deproxy(u, SpecimenOrObservationBase.class))
                     .collect(Collectors.toSet());
@@ -1438,6 +1442,7 @@ public class OccurrenceServiceImpl
 
     @Override
     public long countByTitle(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> config){
+
         if (config instanceof FindOccurrencesConfigurator) {
             FindOccurrencesConfigurator occurrenceConfig = (FindOccurrencesConfigurator) config;
             Taxon taxon = null;
@@ -1460,7 +1465,8 @@ public class OccurrenceServiceImpl
                 List<SpecimenOrObservationBase> occurrences = new ArrayList<>();
                 List<SpecimenOrObservationBase> sobs = dao.findOccurrences(occurrenceConfig.getClazz(),
                         occurrenceConfig.getTitleSearchStringSqlized(), occurrenceConfig.getSignificantIdentifier(),
-                        occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null,
+                        occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(),
+                        occurrenceConfig.isIncludeUnpublished(), null, null,
                         occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
                 occurrences.addAll(sobs);
                 occurrences = filterOccurencesByAssignmentAndHierarchy(occurrenceConfig, occurrences, taxon, taxonName);
@@ -1469,7 +1475,8 @@ public class OccurrenceServiceImpl
 
             return dao.countOccurrences(occurrenceConfig.getClazz(),
                     occurrenceConfig.getTitleSearchStringSqlized(), occurrenceConfig.getSignificantIdentifier(),
-                    occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null,
+                    occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(),
+                    occurrenceConfig.isIncludeUnpublished(), null, null,
                     occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
         }
         else{
@@ -1480,6 +1487,7 @@ public class OccurrenceServiceImpl
     @Override
     public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(
             FindOccurrencesConfigurator config){
+
         List<UuidAndTitleCache<SpecimenOrObservationBase>> occurrences = new ArrayList<>();
         Taxon taxon = null;
         if(config.getAssociatedTaxonUuid()!=null){
@@ -1494,14 +1502,16 @@ public class OccurrenceServiceImpl
         }
         occurrences.addAll(dao.findOccurrencesUuidAndTitleCache(config.getClazz(),
                 config.getTitleSearchString(), config.getSignificantIdentifier(),
-                config.getSpecimenType(), taxon, taxonName, config.getMatchMode(), null, null,
-                config.getOrderHints()));
+                config.getSpecimenType(), taxon, taxonName, config.getMatchMode(),
+                config.isIncludeUnpublished(),
+                null, null, config.getOrderHints()));
         long count = Integer.valueOf(occurrences.size()).longValue();
         return new DefaultPagerImpl<>(config.getPageNumber(), count, config.getPageSize(), occurrences);
     }
 
     @Override
     public List<DerivedUnitDTO> findByTitleDerivedUnitDTO(FindOccurrencesConfigurator config) {
+
         Taxon taxon = null;
         if(config.getAssociatedTaxonUuid()!=null){
             TaxonBase<?> taxonBase = taxonService.load(config.getAssociatedTaxonUuid());
@@ -1516,7 +1526,8 @@ public class OccurrenceServiceImpl
         List<DerivedUnit> occurrences = new ArrayList<>();
         occurrences.addAll(dao.findOccurrences(DerivedUnit.class,
                 config.getTitleSearchString(), config.getSignificantIdentifier(),
-                config.getSpecimenType(), taxon, taxonName, config.getMatchMode(), null, null,
+                config.getSpecimenType(), taxon, taxonName, config.getMatchMode(),
+                config.isIncludeUnpublished(), null, null,
                 config.getOrderHints(), null));
 
         List<DerivedUnitDTO> dtos = new ArrayList<>();
@@ -1527,6 +1538,7 @@ public class OccurrenceServiceImpl
     @Override
     public <S extends SpecimenOrObservationBase> Pager<S> findByTitle(
             IIdentifiableEntityServiceConfigurator<S> config) {
+
         if (config instanceof FindOccurrencesConfigurator) {
             FindOccurrencesConfigurator occurrenceConfig = (FindOccurrencesConfigurator) config;
             List<SpecimenOrObservationBase> occurrences = new ArrayList<>();
@@ -1541,10 +1553,12 @@ public class OccurrenceServiceImpl
             if(occurrenceConfig.getAssociatedTaxonNameUuid()!=null){
                 taxonName = nameService.load(occurrenceConfig.getAssociatedTaxonNameUuid());
             }
-            List<? extends SpecimenOrObservationBase> foundOccurrences = dao.findOccurrences(occurrenceConfig.getClazz(),
+            List<? extends SpecimenOrObservationBase> foundOccurrences = dao.findOccurrences(
+                    occurrenceConfig.getClazz(),
                     occurrenceConfig.getTitleSearchString(), occurrenceConfig.getSignificantIdentifier(),
-                    occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null,
-                    occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
+                    occurrenceConfig.getSpecimenType(), taxon, taxonName,
+                    occurrenceConfig.getMatchMode(), occurrenceConfig.isIncludeUnpublished(),
+                    null, null, occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
             occurrences.addAll(foundOccurrences);
             occurrences = filterOccurencesByAssignmentAndHierarchy(occurrenceConfig, occurrences, taxon, taxonName);
 
index 9c40053f0fc9586b67fc372d54e09762708dda8c..58d41cd7816adc2a879255fafd283abea48a967d 100644 (file)
@@ -974,8 +974,9 @@ public class TaxonServiceImpl
 
     @Override
     public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
-            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeOriginalOccurences,
-            Boolean includeTaxonNameDescriptions, List<String> propertyPath) {
+            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
+            Boolean includeOriginalOccurences, Boolean includeTaxonNameDescriptions,
+            List<String> propertyPath) {
 
         //TODO let inherit
         boolean includeUnpublished = INCLUDE_UNPUBLISHED;
@@ -1033,7 +1034,8 @@ public class TaxonServiceImpl
             Set<SpecimenOrObservationBase> specimensOrObservations = new HashSet<>();
             // --- Specimens
             for (Taxon t : taxa) {
-                specimensOrObservations.addAll(occurrenceDao.listByAssociatedTaxon(null, t, null, null, null, null));
+                specimensOrObservations.addAll(occurrenceDao.listByAssociatedTaxon(
+                        null, t, includeUnpublished, null, null, null, null));
             }
             for (SpecimenOrObservationBase<?> occurrence : specimensOrObservations) {
 
index 7b57034b343e241dd8e296f570881757abf91f7f..88a688436849f987aadc16048a3b244f17f29a46 100644 (file)
@@ -26,7 +26,7 @@ import eu.etaxonomy.cdm.persistence.query.OrderHint;
 public class IdentifiableServiceConfiguratorImpl<T extends IIdentifiableEntity>\r
             implements IIdentifiableEntityServiceConfigurator<T>{\r
 \r
-    private static final long serialVersionUID = -8126736101861741087L;\r
+    private static final long serialVersionUID = -8136736101861741087L;\r
 \r
     private String titleSearchString;\r
        protected MatchMode matchMode;\r
@@ -37,6 +37,7 @@ public class IdentifiableServiceConfiguratorImpl<T extends IIdentifiableEntity>
        private List<Restriction<?>> restrictions;\r
        private List<String> propertyPaths;\r
        private List<OrderHint> orderHints;\r
+       private boolean includeUnpublished = false;\r
 \r
        @Override\r
        public Class<T> getClazz() {\r
@@ -145,9 +146,15 @@ public class IdentifiableServiceConfiguratorImpl<T extends IIdentifiableEntity>
        public List<String> getPropertyPaths() {\r
                return propertyPaths;\r
        }\r
-\r
        @Override\r
        public void setPropertyPaths(List<String> propertyPaths) {\r
                this.propertyPaths = propertyPaths;\r
        }\r
+\r
+    public boolean isIncludeUnpublished() {\r
+        return includeUnpublished;\r
+    }\r
+    public void setIncludeUnpublished(boolean includeUnpublished) {\r
+        this.includeUnpublished = includeUnpublished;\r
+    }\r
 }\r
index f01f6f895fa1ae023460de434e5c353a628beaa8..dc0a15bfac6b7f2cbd7e1addef83722e994957fa 100644 (file)
@@ -123,7 +123,8 @@ public class DistributionServiceImpl implements IDistributionService {
             initStrategy.add("markers.markerType");
         }
 
-        List<Distribution> distributions = dao.getDescriptionElementForTaxon(taxonUUID, features, Distribution.class, null, null, initStrategy);
+        List<Distribution> distributions = dao.getDescriptionElementForTaxon(
+                taxonUUID, features, Distribution.class, config.isIncludeUnpublished(), null, null, initStrategy);
 
         return composeDistributionInfoFor(config, distributions, neverUseFallbackAreaAsParent, presenceAbsenceTermColors, languages);
     }
index a76cadcd1035574b4a6a34edc560fa2e8d15e2af..19cab07efbc19b4da57c9340ddfa3b8045749a84 100644 (file)
@@ -80,7 +80,7 @@ public class DescriptionServiceImplTest extends CdmTransactionalIntegrationTest
             }
         }
         service.saveOrUpdate(descBase);
-        Pager<DescriptionElementBase> allElements = service.getDescriptionElements(null, null, null, null, null, null);
+        Pager<DescriptionElementBase> allElements = service.getDescriptionElements(null, null, null, false, null, null, null);
         Assert.assertEquals(1, allElements.getCount().intValue());
         DescriptionElementBase test = allElements.getRecords().get(0);
         if (test instanceof TextData){
index 0f4598c47ad95c2e14e15cf3088cc84ade36ef87..e7009d22d8a164d6ebf3b3792f66d64dda5f663e 100644 (file)
@@ -1007,6 +1007,7 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
 
         // wildcard search => all derivates
         FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
+        config.setIncludeUnpublished(false);
         config.setTitleSearchString("*");
         assertEquals(6, occurrenceService.countOccurrences(config));
         @SuppressWarnings("rawtypes")