Skip to content
Snippets Groups Projects
Commit 547bafba authored by Stian Fjæran Mogen's avatar Stian Fjæran Mogen
Browse files

Merge branch 'feat/pdf' into 'dev'

Implemented pdf generation on button click

See merge request !76
parents d3db828a 8de5910c
No related branches found
No related tags found
2 merge requests!104Weekly merge to Master,!76Implemented pdf generation on button click
package NTNU.IDATT1002.controllers; package NTNU.IDATT1002.controllers;
import NTNU.IDATT1002.App; import NTNU.IDATT1002.App;
import NTNU.IDATT1002.models.ImageAlbum;
import NTNU.IDATT1002.service.ImageAlbumService;
import NTNU.IDATT1002.utils.PdfDocument;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
...@@ -41,6 +44,7 @@ public class ViewAlbum { ...@@ -41,6 +44,7 @@ public class ViewAlbum {
public Button tbar_searchBtn; public Button tbar_searchBtn;
public Button tbar_albums; public Button tbar_albums;
/** /**
* Method that changes scene to Main page * Method that changes scene to Main page
* @param mouseEvent * @param mouseEvent
...@@ -136,6 +140,12 @@ public class ViewAlbum { ...@@ -136,6 +140,12 @@ public class ViewAlbum {
} }
public void createPdf(ActionEvent actionEvent) { public void createPdf(ActionEvent actionEvent) {
//write method that generates and downloads a PDF version of the album ImageAlbumService imageAlbumService = new ImageAlbumService();
Long currentAlbumId = App.ex.getChosenAlbumId();
ImageAlbum imageAlbum = imageAlbumService.getImageAlbumById(currentAlbumId)
.orElseThrow(IllegalArgumentException::new);
PdfDocument document = new PdfDocument(imageAlbum, "./Album.pdf");
document.createPdfDocument();
} }
} }
...@@ -43,6 +43,10 @@ public class ImageAlbumService { ...@@ -43,6 +43,10 @@ public class ImageAlbumService {
this.tagRepository = new TagRepository(entityManager); this.tagRepository = new TagRepository(entityManager);
} }
public Optional<ImageAlbum> getImageAlbumById(Long imageAlbumId) {
return imageAlbumRepository.findById(imageAlbumId);
}
/** /**
* Retrieves all image albums. * Retrieves all image albums.
* *
......
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