diff --git a/src/main/java/NTNU/IDATT1002/controllers/CreateAlbum.java b/src/main/java/NTNU/IDATT1002/controllers/CreateAlbum.java index faffbad2bcf360d149e3ca2e8ac548f20fed36ce..da365402904560d2a637d2501aaf69293e6cc4dd 100644 --- a/src/main/java/NTNU/IDATT1002/controllers/CreateAlbum.java +++ b/src/main/java/NTNU/IDATT1002/controllers/CreateAlbum.java @@ -24,7 +24,6 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; -import org.hibernate.boot.jaxb.internal.stax.HbmEventReader; import javax.persistence.EntityManager; import java.io.IOException; @@ -161,15 +160,16 @@ public class CreateAlbum implements Initializable { String title = album_title_field.getText(); String description = album_desc_field.getText(); String tags = album_tag_field.getText(); + + if (tags.isEmpty()){ tags = " "; } + List<Tag> tagsToAdd = TagService.getTagsFromString(tags); User user = ApplicationState.getCurrentUser(); - //temporary solution for the toString problem with album log creation + //temporary solution for the toString problem with album log creation, along with the if(tag) above if (description.isEmpty()) { - description = "No desripton"; - } if (tags.isEmpty()){ - tags = " "; - } + description = "No desripton added"; + } List<Node> imageContainers = new ArrayList<>(fileContainer.getChildren()); List<String> checkedImagesId = new ArrayList<>(); @@ -192,7 +192,7 @@ public class CreateAlbum implements Initializable { createdAlbum.ifPresent(album -> { App.ex.setChosenAlbumId(album.getId()); try { - App.setRoot("main"); + App.setRoot("view_album"); } catch (IOException e) { e.printStackTrace(); } @@ -202,7 +202,7 @@ public class CreateAlbum implements Initializable { createdAlbum.ifPresent(album -> { App.ex.setChosenAlbumId(album.getId()); try { - App.setRoot("main"); + App.setRoot("view_album"); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/NTNU/IDATT1002/service/TagService.java b/src/main/java/NTNU/IDATT1002/service/TagService.java index f073aa87bfa1e762ed1d6647b7fcb09d1c4828f7..75f041af63c177960b22bee2566823fa9f96fb20 100644 --- a/src/main/java/NTNU/IDATT1002/service/TagService.java +++ b/src/main/java/NTNU/IDATT1002/service/TagService.java @@ -55,13 +55,23 @@ public class TagService { * @return the list of tag objects */ public static List<Tag> getTagsFromString(String tagsAsString) { - String[] tags = tagsAsString - .trim() - .split("[, ?.@]+"); + if (tagsAsString.isBlank()) { + String[] tags = tagsAsString.split(" "); - return Stream.of(tags) + return Stream.of(tags) .map(Tag::new) .collect(Collectors.toList()); + + }else { + String[] tags = tagsAsString + .trim() + .split("[, ?.@]+"); + + return Stream.of(tags) + .map(Tag::new) + .collect(Collectors.toList()); + + } } /**