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;
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();
}
......
......@@ -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());
}
}
/**
......
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