cleanup
authorAndreas Müller <a.mueller@bgbm.org>
Fri, 28 Apr 2023 19:21:37 +0000 (21:21 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Fri, 28 Apr 2023 19:21:37 +0000 (21:21 +0200)
15 files changed:
cdmlib-api/src/main/java/eu/etaxonomy/cdm/api/dto/portal/config/DistributionInfoConfiguration.java
cdmlib-api/src/main/java/eu/etaxonomy/cdm/api/dto/portal/config/DistributionOrder.java
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/SetMap.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/description/distribution/CondensedDistributionComposer.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/location/NamedAreaLevel.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/TermNode.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionListController.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/geo/DistributionServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/geo/DistributionServiceUtilities.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/geo/DistributionTree.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/DistributionTreeDtoLoader.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/geo/DistributionServiceImplTest.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/geo/DistributionServiceUtilitiesTest.java

index 1968d8323c98e21b75a3cdc50d4fd24680746b61..d88fa4549abd73957e0a91861db0784e8e3f6da2 100644 (file)
@@ -23,7 +23,7 @@ import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
  */
 public class DistributionInfoConfiguration {
 
-    private boolean subAreaPreference = false;
+    private boolean preferSubAreas = false;
 
     private boolean statusOrderPreference = false;
 
@@ -46,11 +46,11 @@ public class DistributionInfoConfiguration {
 
 //********************* GETTER / SETTER ***************************/
 
-    public boolean isSubAreaPreference() {
-        return subAreaPreference;
+    public boolean isPreferSubareas() {
+        return preferSubAreas;
     }
-    public void setSubAreaPreference(boolean subAreaPreference) {
-        this.subAreaPreference = subAreaPreference;
+    public void setPreferSubAreas(boolean preferSubAreas) {
+        this.preferSubAreas = preferSubAreas;
     }
 
     public boolean isStatusOrderPreference() {
index 55bf9bebd4413ce1afde2e1a58f488e69325883d..3c5315ed7aa519406db59db60a0479626e196991 100644 (file)
@@ -23,6 +23,7 @@ import eu.etaxonomy.cdm.model.location.NamedArea;
 
 /**
  * Enumeration that defines the ordering method for distribution trees.
+ * Either by {@link #LABEL} or {@link #AREA_ORDER}
  *
  * @author a.mueller
  * @since 04.04.2016
index b130fb4da02fb5660aa4e7c458070ba97b266869..7693c47d6b0024810f10b0f8740e103b8c5c7af0 100644 (file)
@@ -156,4 +156,8 @@ public class SetMap<K,V> implements Map<K, Set<V>>{
         return map.entrySet();
     }
 
+    @Override
+    public String toString() {
+        return map.toString();
+    }
 }
index 26f5ee656ae4b9011a01004f2cc2bb15d55ed500..d7cca72e019b21f70d73759f3da0e756f5da5560 100644 (file)
@@ -172,7 +172,7 @@ public class CondensedDistributionComposer {
         removeFallbackAreasWithChildDistributions(areaNodeMap, introducedAreaNodeMap, config);
 
         @SuppressWarnings("unchecked")
-        Map<NamedArea, AreaNode>[] result = new Map[]{areaNodeMap,introducedAreaNodeMap};
+        Map<NamedArea, AreaNode>[] result = new Map[]{areaNodeMap, introducedAreaNodeMap};
         return result;
     }
 
index 935b299e4a09f2d1c0ec1485d91bd29a0dc4cafc..eec30a92f9698e30702211a6a6e2865a3669ed81 100644 (file)
@@ -187,7 +187,7 @@ public class NamedAreaLevel extends DefinedTermBase<NamedAreaLevel> {
 
        @Override
        protected void setDefaultTerms(TermVocabulary<NamedAreaLevel> termVocabulary) {
-               termMap = new HashMap<UUID, NamedAreaLevel>();
+               termMap = new HashMap<>();
                for (NamedAreaLevel term : termVocabulary.getTerms()){
                        termMap.put(term.getUuid(), term);
                }
index ce8e9d75befe8f874cbb1c51c1c2006b48efb5a5..dd53561f04690f84618b15c08ec9586082d8c57c 100644 (file)
@@ -523,7 +523,7 @@ public class TermNode <T extends DefinedTermBase>
         */
        //TODO do we need to pass the terms parameter? Maybe a bit more performant
        // but more difficult to handle. We could use this internally but offer
-       //the method with return value as public
+       // the method with return value as public
        @Transient
        public Set<T> getDistinctTermsRecursive(Set<T> terms){
                T term = this.getTerm();
@@ -545,7 +545,7 @@ public class TermNode <T extends DefinedTermBase>
                result = parent.getPath() ;
            }
            if (getTerm()!= null){
-               String sep = StringUtils.isBlank(result)?"":"/";
+               String sep = StringUtils.isBlank(result)? "" : "/";
                result += sep+ getTerm().getLabel();
            }
            return result;
index 25d8465f067d4dee26e4ed3d7d81fe0b0d67dce5..1c5824a29b0555c0ccd7440deb1dce98a167dae6 100644 (file)
@@ -331,6 +331,9 @@ public interface ICdmEntityDao<T extends CdmBase> {
 
     public List<T> loadList(Collection<Integer> ids, List<OrderHint> orderHints, List<String> propertyPaths) throws DataAccessException;
 
+    /**
+     * Returns the CDM entity with the given UUID without initializing it further.
+     */
     public T findByUuid(UUID Uuid) throws DataAccessException;
 
     /**
index ed4193c51dcd7c42192a079abb8191ed0b478329..d1c155813d31b4aa1afab2226cf2e0d57c6fe6c7 100644 (file)
@@ -30,6 +30,7 @@ import org.hibernate.query.Query;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Repository;
 
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.common.LSID;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.description.CommonTaxonName;
@@ -730,7 +731,8 @@ public class DescriptionDaoImpl
         if(type != null){
             queryString += " and de.class = :type";
         }
-        if (features != null && features.size() > 0){
+        boolean hasFeatureFilter = !CdmUtils.isNullSafeEmpty(features);
+        if (hasFeatureFilter){
             queryString += " and de.feature in (:features) ";
         }
         Query<R> query = getSession().createQuery(queryString);
@@ -739,7 +741,7 @@ public class DescriptionDaoImpl
         if(type != null){
             query.setParameter("type", type.getSimpleName());
         }
-        if(features != null && features.size() > 0){
+        if(hasFeatureFilter){
             query.setParameterList("features", features) ;
         }
 
index 2ecbeb5aa2372de4b1c05ef1f12d623bc51c6263..86f199328e44f050e6f32eb1526af8461f024a36 100644 (file)
@@ -253,7 +253,7 @@ public class DescriptionListController
      * @param parts
      *            possible values: condensedStatus, tree, mapUriParams,
      *            elements,
-     * @param subAreaPreference
+     * @param preferSubAreas
      * @param statusOrderPreference
      * @param hideMarkedAreasList
      * @param omitLevels
@@ -272,10 +272,10 @@ public class DescriptionListController
     public ModelAndView doGetDistributionInfo(
             @PathVariable("uuid") UUID taxonUuid,
             @RequestParam("part") Set<InfoPart> partSet,
-            @RequestParam(value = "subAreaPreference", required = false) boolean subAreaPreference,
+            @RequestParam(value = "subAreaPreference", required = false) boolean preferSubAreas,
             @RequestParam(value = "statusOrderPreference", required = false) boolean statusOrderPreference,
-            @RequestParam(value = "features", required = false ) Set<UUID> featureUuids,
             @RequestParam(value = "hiddenAreaMarkerType", required = false) DefinedTermBaseList<MarkerType> hiddenAreaMarkerTypeList,
+            @RequestParam(value = "features", required = false ) Set<UUID> featureUuids,
             @RequestParam(value = "areaTree", required = false ) UUID areaTreeUuid,
             @RequestParam(value = "omitLevels", required = false) Set<NamedAreaLevel> omitLevels,
             @RequestParam(value = "statusColors", required = false) String statusColorsString,
@@ -309,7 +309,7 @@ public class DescriptionListController
 
                 DistributionInfoConfiguration config = new DistributionInfoConfiguration();
                 config.setInfoParts(parts);
-                config.setSubAreaPreference(subAreaPreference);
+                config.setPreferSubAreas(preferSubAreas);
                 config.setStatusOrderPreference(statusOrderPreference);
                 config.setHiddenAreaMarkerTypeList(hiddenAreaMarkerTypes);
                 config.setOmitLevels(omitLevels);
index 819fb272c5b811583566d3c93a76bbdd478f606a..ff5cf59348ffdc57f226978239a08633762ab4ca 100644 (file)
@@ -121,7 +121,7 @@ public class DistributionServiceImpl implements IDistributionService {
             List<Language> languages){
 
         EnumSet<DistributionInfoDto.InfoPart> parts = config.getInfoParts();
-        boolean subAreaPreference = config.isSubAreaPreference();
+        boolean subAreaPreference = config.isPreferSubareas();
         boolean statusOrderPreference = config.isStatusOrderPreference();
         Set<MarkerType> hiddenAreaMarkerTypes = config.getHiddenAreaMarkerTypeList();
         Set<NamedAreaLevel> omitLevels = config.getOmitLevels();
index a4231061decead16939d16ebd333f7d9b2b06be5..f938d2bde8ebf6238b1e20fb45183a09936886de 100644 (file)
@@ -644,16 +644,17 @@ public class DistributionServiceUtilities {
     /**
      * <b>NOTE: To avoid LayzyLoadingExceptions this method must be used in a transactional context.</b>
      *
-     * Filters the given set of {@link Distribution}s for publication purposes
+     * Filters the given set of {@link Distribution}s for publication purposes.
      * The following rules are respected during the filtering:
      * <ol>
      * <li><b>Marked area filter</b>: Skip distributions for areas having a {@code TRUE} {@link Marker}
      * with one of the specified {@link MarkerType}s. Existing sub-areas of a marked area must also be marked
      * with the same marker type, otherwise the marked area acts as a <b>fallback area</b> for the sub areas.
-     * An area is a <b>fallback area</b> if it is marked to be hidden and if it has at least one of
-     * sub area which is not marked to be hidden. The fallback area will be show if there is no {@link Distribution}
+     * An area is a <b>fallback area</b> if it is marked to be hidden and if it has at least one
+     * sub area which is not marked to be hidden. The fallback area will be shown if there is no {@link Distribution}
      * for any of the non hidden sub-areas. For more detailed discussion on fallback areas see
      * https://dev.e-taxonomy.eu/redmine/issues/4408</li>
+     *
      * <li><b>Prefer aggregated rule</b>: if this flag is set to <code>true</code> aggregated
      * distributions are preferred over non-aggregated elements.
      * (Aggregated description elements are identified by the description having type
@@ -661,6 +662,7 @@ public class DistributionServiceUtilities {
      * information exists for the same area for which aggregated data is available,
      * the aggregated data has to be given preference over other data.
      * see parameter <code>preferAggregated</code></li>
+     *
      * <li><b>Status order preference rule</b>: In case of multiple distribution
      * status ({@link PresenceAbsenceTermBase}) for the same area the status
      * with the highest order is preferred, see
index 7c3c60309e299df4c80140d4d4d0110b01329239..ceb0b3d5b570364b08f508b5ad351ad79751bd0f 100644 (file)
@@ -95,8 +95,8 @@ public class DistributionTree
     }
 
     /**
-     * This method will cause all parent areas to be loaded into the session cache to that
-     * all initialization of the NamedArea term instances in necessary. This improves the
+     * This method will cause all parent areas to be loaded into the session cache so that
+     * all initialization of the NamedArea term instances is ready. This improves the
      * performance of the tree building
      */
     private void loadAllParentAreas(Set<NamedArea> areas) {
index 8fad3b41ad445f46472d86c08bd640bd7a4876b1..9a15ad5dba90b4cc1b2ab2f350dc052d8c6c8940 100644 (file)
@@ -114,8 +114,8 @@ public class DistributionTreeDtoLoader {
   }
 
   /**
-   * This method will cause all parent areas to be loaded into the session cache to that
-   * all initialization of the NamedArea term instances in necessary. This improves the
+   * This method will cause all parent areas to be loaded into the session cache so that
+   * all initialization of the NamedArea term instances is ready. This improves the
    * performance of the tree building
    */
   private void loadAllParentAreas(Set<NamedAreaDto> areas) {
index c7329184a7f86a4076d54e1349e2554bfc9341bc..30c0c18c9c46445e4c0e1501d11f421f7856176e 100644 (file)
@@ -346,7 +346,6 @@ public class DistributionServiceImplTest extends CdmTransactionalIntegrationTest
         subTestWithEditMapService(result);
     }
 
-    @SuppressWarnings("deprecation")
 //    @Test
     @DataSet( value="EditGeoServiceTest.getDistributionServiceRequestParameterString.xml")
 //    @DataSets({
@@ -381,7 +380,7 @@ public class DistributionServiceImplTest extends CdmTransactionalIntegrationTest
 
         String distributions = distributionService.getDistributionServiceRequestParameterString(taxonDescriptions,
                 subAreaPreference, statusOrderPreference, hideMarkedAreas, presenceAbsenceTermColors, langs);
-        System.out.println(distributions);
+//        System.out.println(distributions);
         Assert.assertTrue("Distribution string should contain the non-persited distribution Germany", distributions.contains("DEU"));
         Assert.assertFalse("Distribution string should contain France as it has a non-distribution feature", distributions.contains("FRA"));
 //        CHE,POL
index 752ebff81bcd4edb97078eee61db31b563a76de0..ce5d6ea001e2255db45e233f4e2b1ec5e1b3aa1b 100644 (file)
@@ -60,14 +60,14 @@ public class DistributionServiceUtilitiesTest extends TermTestBase {
 
         /* 1.
          * Aggregated elements are preferred over entered or imported elements
-         * if the according flag ist set to true.
+         * if the according flag is set to true.
          * (Aggregated description elements are identified by belonging to descriptions
          * which have the type DescriptionType#AGGREGATED_DISTRIBUTION).
          * This means if a non-aggregated status information exist for the same
          * area for which aggregated data is available, the aggregated data has to be
          * given preference over other data.
          * Note by AM: be aware that according to #5050 the preference of aggregated
-         * distributions is not valid anymore (for the E+M usecase). However, the functionality
+         * distributions is not valid anymore (for the E+M use-case). However, the functionality
          * might be interesting for future use-cases.
          */
         TaxonDescription aggregatedDescription = TaxonDescription.NewInstance();