From 5e2a8c64a6a37974d04ced06178115e99f098703 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sven=20K=C3=A4stle?= <sven.kaestle@gmx.de>
Date: Sat, 23 Jun 2018 16:07:41 +0200
Subject: [PATCH] fix: New response for 'addAnnotation' method

---
 .../controller/AnnotationController.java         | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java
index 4e6bb8e9..27abdc4b 100644
--- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java
+++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java
@@ -21,27 +21,21 @@ public class AnnotationController implements IAnnotation {
             uuid = UUID.randomUUID().toString();
         }
 
-        // build the annotation
-        Annotation annotation = new Annotation(uuid,
-                ZonedDateTime.now().toEpochSecond(),
-                annotationPostRequest.getUserId(),
-                annotationPostRequest.getTargetId(),
-                annotationPostRequest.getBody(),
-                annotationPostRequest.getStartCharacter(),
-                annotationPostRequest.getEndCharacter());
-
         // establish connection
         MysqlConnect connection = new MysqlConnect();
         connection.connect();
 
         // build and execute request
         String request = "INSERT INTO annotations (`id`, `userId`, `targetId`, `body`, `startCharacter`, `endCharacter`) VALUES (?,?,?,?,?,?);";
-        connection.issueInsertOrDeleteStatement(request, annotation.getId(), annotation.getUserId(), annotation.getTargetId(), annotation.getBody(), annotation.getStartCharacter(), annotation.getEndCharacter());
+        connection.issueInsertOrDeleteStatement(request, uuid, annotationPostRequest.getUserId(), annotationPostRequest.getTargetId(), annotationPostRequest.getBody(), annotationPostRequest.getStartCharacter(), annotationPostRequest.getEndCharacter());
 
         // close connection
         connection.close();
 
-        return annotation;
+        // build response annotation
+        Annotation annotationResponse = getAnnotation(uuid);
+
+        return annotationResponse;
 
     }
 
-- 
GitLab