ref #9896 adding missing AnnotationDTO class
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Fri, 10 Dec 2021 15:50:59 +0000 (16:50 +0100)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Fri, 10 Dec 2021 15:50:59 +0000 (16:50 +0100)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/AnnotationDTO.java [new file with mode: 0644]

diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/AnnotationDTO.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/AnnotationDTO.java
new file mode 100644 (file)
index 0000000..f6330c8
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+* Copyright (C) 2021 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.api.service.dto;
+
+import java.util.UUID;
+
+import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.ref.TypedEntityReference;
+
+/**
+ * @author a.kohlbecker
+ * @since Dec 10, 2021
+ */
+public class AnnotationDTO extends TypedEntityReference<Annotation> {
+
+    private static final long serialVersionUID = 4865632821417238523L;
+
+    private UUID annotationTypeUuid = null;
+    private String text = null;
+
+    public static <T extends CdmBase> AnnotationDTO fromEntity(Annotation annotation) {
+        AnnotationDTO dto = new AnnotationDTO(Annotation.class, annotation.getUuid());
+        if(annotation.getAnnotationType() != null) {
+            dto.setAnnotationTypeUuid(annotation.getAnnotationType().getUuid());
+        }
+        dto.setText(annotation.getText());
+        return dto;
+    }
+
+    @SuppressWarnings("deprecation")
+    public AnnotationDTO(Class<Annotation> type, UUID uuid) {
+        super(type, uuid);
+        this.label = null;
+    }
+
+    public UUID getAnnotationTypeUuid() {
+        return annotationTypeUuid;
+    }
+
+    private void setAnnotationTypeUuid(UUID annotationTypeUuid) {
+        this.annotationTypeUuid = annotationTypeUuid;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    private void setText(String text) {
+        this.text = text;
+    }
+
+}