Skip to content
Snippets Groups Projects
Commit 50cc4fc9 authored by Lars Brodin Østby's avatar Lars Brodin Østby
Browse files

Validate album name and toString fix for album

parent b9319a68
No related branches found
No related tags found
2 merge requests!165Weekly merge to Master,!132Need valdig title at album
...@@ -24,7 +24,6 @@ import javafx.scene.layout.GridPane; ...@@ -24,7 +24,6 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import org.hibernate.boot.jaxb.internal.stax.HbmEventReader;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import java.io.IOException; import java.io.IOException;
...@@ -161,15 +160,16 @@ public class CreateAlbum implements Initializable { ...@@ -161,15 +160,16 @@ public class CreateAlbum implements Initializable {
String title = album_title_field.getText(); String title = album_title_field.getText();
String description = album_desc_field.getText(); String description = album_desc_field.getText();
String tags = album_tag_field.getText(); String tags = album_tag_field.getText();
if (tags.isEmpty()){ tags = " "; }
List<Tag> tagsToAdd = TagService.getTagsFromString(tags); List<Tag> tagsToAdd = TagService.getTagsFromString(tags);
User user = ApplicationState.getCurrentUser(); 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()) { if (description.isEmpty()) {
description = "No desripton"; description = "No desripton added";
} if (tags.isEmpty()){ }
tags = " ";
}
List<Node> imageContainers = new ArrayList<>(fileContainer.getChildren()); List<Node> imageContainers = new ArrayList<>(fileContainer.getChildren());
List<String> checkedImagesId = new ArrayList<>(); List<String> checkedImagesId = new ArrayList<>();
...@@ -192,7 +192,7 @@ public class CreateAlbum implements Initializable { ...@@ -192,7 +192,7 @@ public class CreateAlbum implements Initializable {
createdAlbum.ifPresent(album -> { createdAlbum.ifPresent(album -> {
App.ex.setChosenAlbumId(album.getId()); App.ex.setChosenAlbumId(album.getId());
try { try {
App.setRoot("main"); App.setRoot("view_album");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -202,7 +202,7 @@ public class CreateAlbum implements Initializable { ...@@ -202,7 +202,7 @@ public class CreateAlbum implements Initializable {
createdAlbum.ifPresent(album -> { createdAlbum.ifPresent(album -> {
App.ex.setChosenAlbumId(album.getId()); App.ex.setChosenAlbumId(album.getId());
try { try {
App.setRoot("main"); App.setRoot("view_album");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -55,13 +55,23 @@ public class TagService { ...@@ -55,13 +55,23 @@ public class TagService {
* @return the list of tag objects * @return the list of tag objects
*/ */
public static List<Tag> getTagsFromString(String tagsAsString) { public static List<Tag> getTagsFromString(String tagsAsString) {
String[] tags = tagsAsString if (tagsAsString.isBlank()) {
.trim() String[] tags = tagsAsString.split(" ");
.split("[, ?.@]+");
return Stream.of(tags) return Stream.of(tags)
.map(Tag::new) .map(Tag::new)
.collect(Collectors.toList()); .collect(Collectors.toList());
}else {
String[] tags = tagsAsString
.trim()
.split("[, ?.@]+");
return Stream.of(tags)
.map(Tag::new)
.collect(Collectors.toList());
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment