From cce4658fb5d490a3f54c8cd16436306ce12be041 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lars=20Brodin=20=C3=98stby?= <larsbost@stud.ntnu.no>
Date: Mon, 23 Mar 2020 11:10:16 +0100
Subject: [PATCH] single image upload

---
 .../IDATT1002/controllers/UploadedSingle.java     | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java b/src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java
index 2a609c0e..e44af6a8 100644
--- a/src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java
+++ b/src/main/java/NTNU/IDATT1002/controllers/UploadedSingle.java
@@ -126,7 +126,7 @@ public class UploadedSingle implements Initializable {
   }
 
   /**
-   * Method for uploading image to database with title, tags and description
+   * Method for uploading image to database with tags
    * Image itself is not stored but URL is
    *
    * @param actionEvent
@@ -135,11 +135,10 @@ public class UploadedSingle implements Initializable {
 
   public void uploadSingle(ActionEvent actionEvent) throws IOException {
 
-    String tagTekst = photo_tag.toString();
     List<File> list = App.ex.getUploadedFiles();
     list.stream().forEach(x -> {
       image = imageService.createImage(applicationState.getCurrentUser(), x).get();
-      List tags = chopChopStringiBoi(tagTekst);
+      List tags = tagStringSplit(photo_tag);
       tags.stream().forEach(y -> {
         imageService.addTagToImage(image, new Tag((Tag) y));
       });
@@ -148,8 +147,14 @@ public class UploadedSingle implements Initializable {
     App.setRoot("main");
   }
 
-  public List<String> chopChopStringiBoi(String tagTekst) {
-    List<String> tags =  Arrays.asList(tagTekst.split(" #"));
+  /***
+   * Method for splitting the tag textField into tags in a list
+   * @param photo_tag
+   * @return list of string
+   */
+  public List<String> tagStringSplit(TextField photo_tag) {
+    String tagTekst = photo_tag.toString();
+    List<String> tags = Arrays.asList(tagTekst.split(" #"));
     return tags;
   }
 }
-- 
GitLab