ref #9004, ref #6581 add isEmpty to OriginalSource and super classes
authorAndreas Müller <a.mueller@bgbm.org>
Fri, 12 Jun 2020 12:18:44 +0000 (14:18 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Fri, 12 Jun 2020 18:05:33 +0000 (20:05 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AnnotatableEntity.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/CdmBase.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableSource.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ReferencedEntityBase.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/VersionableEntity.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/DescriptionElementSource.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/OriginalSourceBase.java

index 45bbb64d42b6302d81c8e4d465a5b72f015c3a94..73fb72d0d28d66370afa070ed74d8b1fe1e99139 100644 (file)
@@ -172,8 +172,17 @@ public abstract class AnnotatableEntity
             new EntityCollectionSetterAdapter<AnnotatableEntity, Annotation>(AnnotatableEntity.class, Annotation.class, "annotations").setCollection(this, annotations);
     }
 
-//********************** CLONE *****************************************/
+// **************** EMPTY ************************/
 
+    @Override
+    protected boolean isEmpty(){
+       return super.isEmpty()
+            && this.annotations.isEmpty()
+            && this.markers.isEmpty()
+           ;
+    }
+
+//********************** CLONE *****************************************/
 
        @Override
        public Object clone() throws CloneNotSupportedException{
index d86c8ccef0ab925636b217ffe4e96381bfd6c5a3..f8d4ef4ad18391a9316027bd0cf0cde462418e77 100644 (file)
@@ -523,7 +523,11 @@ public abstract class CdmBase implements Serializable, ICdmBase, ISelfDescriptiv
         return StringUtils.isNotBlank(str);
     }
 
+// **************** EMPTY ************************/
 
+    protected boolean isEmpty(){
+       return true;
+    }
 
 //********************** CLONE *****************************************/
 
index 980e31d1a50da38da471a8aabbfd972ae7e3494e..9dbbc62182b34b0e58b973a83d175cce488d8aed 100644 (file)
@@ -110,7 +110,7 @@ public class IdentifiableSource
 // ****************** CONSTRUCTOR ********************************/
 
        //for hibernate only
-       private IdentifiableSource() {
+       protected IdentifiableSource() {
        }
 
        private IdentifiableSource(OriginalSourceType type) {
@@ -119,6 +119,11 @@ public class IdentifiableSource
 
 // ********************** GETTER /SETTER *****************************/
 
+       @Override
+    public boolean isEmpty(){
+           //nothing to do
+           return super.isEmpty();
+       }
 
 //*********************************** CLONE *********************************************************/
 
index 141d778739a3c537752c41bb6a4d4f4ef4f20428..f2fc2d251ea21f76059610d961e6042fb278d5b8 100644 (file)
@@ -107,6 +107,17 @@ public abstract class ReferencedEntityBase
                this.citation = citation;
        }
 
+// **************** EMPTY ************************/
+
+    @Override
+    protected boolean isEmpty(){
+       return super.isEmpty()
+            && this.getCitation() == null
+            && this.getCitationMicroReference() == null
+            && isBlank(this.getOriginalNameString())
+           ;
+    }
+
 //****************** CLONE ************************************************/
 
        @Override
index 931b955457f6b7f36f98a2e20aba8f530d657700..91361f0cf8a4230ee4c382a415373662e9eff6df 100644 (file)
@@ -117,6 +117,14 @@ public abstract class VersionableEntity
            return super.equals(obj);
        }
 
+// **************** EMPTY ************************/
+
+    protected boolean isEmpty(){
+       return super.isEmpty()
+               //nothing to do
+           ;
+    }
+
 //********************** CLONE *****************************************/
 
        /**
index 1e4cfcbf7290cf1553b83a497ee4431866e141b0..5da2318a451800fb76ca51ceb9c5dd7fdb4db3c6 100644 (file)
@@ -164,6 +164,14 @@ public class DescriptionElementSource extends OriginalSourceBase<DescriptionElem
                this.nameUsedInSource = nameUsedInSource;
        }
 
+// **************** EMPTY ************************/
+
+    @Override
+    public boolean isEmpty(){
+       return super.isEmpty()
+            && this.nameUsedInSource != null
+           ;
+    }
 
 //*********************************** CLONE *********************************************************/
 
index fbd3e1c51cd68d3b32db911d112a6916aaabd445..2cf63dccdba8657283c5ec9d89906c28602ca1df 100644 (file)
@@ -231,6 +231,18 @@ public abstract class OriginalSourceBase<T extends ISourceable>
                return result;
        }
 
+// **************** EMPTY ************************/
+
+       @Override
+    public boolean isEmpty(){
+          return super.isEmpty()
+               && isBlank(this.getIdInSource())
+               && isBlank(this.getIdNamespace())
+               && this.links.isEmpty()
+               && this.cdmSource != null
+               && this.type == null
+           ;
+       }
 
 //************************ toString ***************************************/
        @Override