update annotations in webservice
authorn.hoffmann <n.hoffmann@localhost>
Fri, 10 Oct 2008 15:40:49 +0000 (15:40 +0000)
committern.hoffmann <n.hoffmann@localhost>
Fri, 10 Oct 2008 15:40:49 +0000 (15:40 +0000)
.gitattributes
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationElementSTO.java [new file with mode: 0644]
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationSTO.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationTO.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/AnnotationAssembler.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/service/RestController.java

index ddfae9cb9afa0f6d87c56d870cb5bf93efda568b..b3cfc6dff535c1f09f5f6a0fdd4d3ce0dde83e74 100644 (file)
@@ -577,6 +577,7 @@ cdmlib-remote/src/main/java/carbonfive/spring/web/pathparameter/ParameterizedPat
 cdmlib-remote/src/main/java/carbonfive/spring/web/pathparameter/ParameterizedPathMatcher.java -text
 cdmlib-remote/src/main/java/carbonfive/spring/web/pathparameter/ParameterizedPathMatcherException.java -text
 cdmlib-remote/src/main/java/carbonfive/spring/web/pathparameter/ParameterizedUrlHandlerMapping.java -text
+cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationElementSTO.java -text
 cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationSTO.java -text
 cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationTO.java -text
 cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AssociationFeatureSTO.java -text
diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationElementSTO.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/AnnotationElementSTO.java
new file mode 100644 (file)
index 0000000..04dea3c
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+* Copyright (C) 2007 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.remote.dto;
+
+import org.apache.log4j.Logger;
+
+import eu.etaxonomy.cdm.model.agent.Person;
+
+/**
+ * @author n.hoffmann
+ * @created 26.09.2008
+ * @version 1.0
+ */
+public class AnnotationElementSTO extends BaseTO {
+       private static Logger logger = Logger.getLogger(AnnotationElementSTO.class);
+       
+       private String text;
+       private Person commentator;
+
+       /**
+        * @return the text
+        */
+       public String getText() {
+               return text;
+       }
+
+       /**
+        * @param text the text to set
+        */
+       public void setText(String text) {
+               this.text = text;
+       }
+
+       /**
+        * @param commentator
+        */
+       public void setCommentator(Person commentator) {
+               this.commentator = commentator;
+       }
+       
+       /**
+        * @return
+        */
+       public Person getCommentator(){
+               return commentator;
+       }
+}
index 248b6f3da00175d9214dda81f3f276f894c00996..a0f1115d90b92561dbce801f92af4ac47575f462 100644 (file)
@@ -9,30 +9,38 @@
 
 package eu.etaxonomy.cdm.remote.dto;
 
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
 import org.apache.log4j.Logger;
 
 /**
- * @author nho
+ * @author n.hoffmann
  * @created 24.09.2008
  * @version 1.0
  */
 public class AnnotationSTO extends BaseTO {
        private static Logger logger = Logger.getLogger(AnnotationSTO.class);
        
-       
-       private String text;
+       private Set<AnnotationElementSTO> annotationElements = new HashSet<AnnotationElementSTO>();
 
        /**
-        * @return the text
+        * @return the annotationElements
         */
-       public String getText() {
-               return text;
+       public Set<AnnotationElementSTO> getAnnotationElements() {
+               return annotationElements;
        }
 
        /**
-        * @param text the text to set
+        * @param annotationElements the annotationElements to set
         */
-       public void setText(String text) {
-               this.text = text;
+       public void setAnnotationElements(Set<AnnotationElementSTO> annotationElements) {
+               this.annotationElements = annotationElements;
        }
+       
+       public void addAnnotationElement(AnnotationElementSTO annotationElementSTO){
+               this.annotationElements.add(annotationElementSTO);
+       }
+
 }
index 15677434e35c915bb5ad493c70873ca9231b1071..17ba433b541e58f738227988367008206499b984 100644 (file)
@@ -9,6 +9,8 @@
 
 package eu.etaxonomy.cdm.remote.dto;
 
+import java.util.UUID;
+
 import org.apache.log4j.Logger;
 
 /**
@@ -20,4 +22,5 @@ public class AnnotationTO extends AnnotationSTO {
        private static Logger logger = Logger.getLogger(AnnotationTO.class);
 
        
+       
 }
index 7a3daf8e3ab3f798d3d84b7e8dcadc25e04ac7ba..515c0efcc057d72b08e4c65603a2313a51cd0b37 100644 (file)
@@ -11,11 +11,15 @@ package eu.etaxonomy.cdm.remote.dto.assembler;
 
 import java.util.Enumeration;
 import java.util.Locale;
+import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
 import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.remote.dto.AnnotationElementSTO;
 import eu.etaxonomy.cdm.remote.dto.AnnotationSTO;
 import eu.etaxonomy.cdm.remote.dto.AnnotationTO;
 
@@ -25,7 +29,7 @@ import eu.etaxonomy.cdm.remote.dto.AnnotationTO;
  * @version 1.0
  */
 @Component
-public class AnnotationAssembler extends AssemblerBase<AnnotationSTO, AnnotationTO, Annotation> {
+public class AnnotationAssembler extends AssemblerBase<AnnotationSTO, AnnotationTO, AnnotatableEntity> {
        private static Logger logger = Logger.getLogger(AnnotationAssembler.class);
 
 
@@ -33,7 +37,7 @@ public class AnnotationAssembler extends AssemblerBase<AnnotationSTO, Annotation
         * @see eu.etaxonomy.cdm.remote.dto.assembler.AssemblerBase#getSTO(eu.etaxonomy.cdm.model.common.CdmBase, java.util.Enumeration)
         */
        @Override
-       public AnnotationSTO getSTO(Annotation cdmObj, Enumeration<Locale> locales) {
+       public AnnotationSTO getSTO(AnnotatableEntity cdmObj, Enumeration<Locale> locales) {
                // TODO Auto-generated method stub
                return null;
        }
@@ -42,12 +46,34 @@ public class AnnotationAssembler extends AssemblerBase<AnnotationSTO, Annotation
         * @see eu.etaxonomy.cdm.remote.dto.assembler.AssemblerBase#getTO(eu.etaxonomy.cdm.model.common.CdmBase, java.util.Enumeration)
         */
        @Override
-       public AnnotationTO getTO(Annotation annotation, Enumeration<Locale> locales) {
+       public AnnotationTO getTO(AnnotatableEntity entity, Enumeration<Locale> locales) {
                
                AnnotationTO to = new AnnotationTO();
                
-               to.setText(annotation.getText());
+               to.setUuid(entity.getUuid().toString());
+               //
+               
+               Set<Annotation> annotations = entity.getAnnotations();
+               
+               for (Annotation annotation : annotations){
+                       to.addAnnotationElement(getAnnotationElementSTO(annotation));           
+               }
                
                return to;
        }
+       
+       private AnnotationElementSTO getAnnotationElementSTO(Annotation annotation){
+               AnnotationElementSTO sto = new AnnotationElementSTO();
+               
+               sto.setText(annotation.getText());
+               
+               sto.setCreated(annotation.getCreated());
+               
+               Person commentator = annotation.getCommentator();
+               if(commentator != null){
+                       //sto.setCommentator(annotation.getCommentator());
+               }
+                       
+               return sto;
+       }
 }
index 28bfdae9fff00ac9ce7c5ec7697387d73979b39a..d9aaddee87a616fe1b6b495172fa12087a097369 100644 (file)
@@ -212,14 +212,14 @@ public class RestController extends AbstractController
                                String requestMethod = req.getMethod();
                                
                                if(requestMethod.equalsIgnoreCase("GET")){
-                                       List<AnnotationTO> annotations = service.getAnnotations(annotatableEntityUuid, locales);
-                                       mv.addObject(annotations);                                      
+                                       logger.info("Processing GET request");
+                                       AnnotationTO annotation = service.getAnnotation(annotatableEntityUuid, locales);
+                                       mv.addObject(annotation);                                       
                                }else if(requestMethod.equalsIgnoreCase("POST")){
                                        
                                        String annotationText = req.getParameter("annotation");
-                                       
                                        // TODO set locale
-                                       
+                                       logger.info("Processing POST request");
                                        
                                        Annotation annotation = Annotation.NewInstance(annotationText, null);