Fixed album/artist cascading on song creation and null album art detection.
This commit is contained in:
parent
005e116505
commit
6344e9dbe9
@ -75,13 +75,11 @@ public class Gateway {
|
||||
if (!albumObj.isPresent()) {
|
||||
Album album = new Album(metadata.album, metadata.artwork);
|
||||
albumObj = Optional.of(album);
|
||||
session.save(album);
|
||||
}
|
||||
Optional<Artist> artistObj = getOneArtist(metadata.artist);
|
||||
if (!artistObj.isPresent()) {
|
||||
Artist artist = new Artist(metadata.artist);
|
||||
artistObj = Optional.of(artist);
|
||||
session.save(artist);
|
||||
}
|
||||
session.save(new Song(metadata.trackNumber, metadata.title, artistObj.get(), albumObj.get(), metadata.genre, metadata.songFile));
|
||||
session.getTransaction().commit();
|
||||
|
@ -49,7 +49,7 @@ public class ExtractedMetadata {
|
||||
Image actualImage = ImageIO.read(imageFile.get().toFile());
|
||||
tmpArt = convertImageToBytes(actualImage);
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
} catch (NullPointerException | IOException ignored) {}
|
||||
}
|
||||
artwork = tmpArt;
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ public class Song implements Comparable<Song> {
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
@ManyToOne
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
private Artist artist;
|
||||
@Column(name = "genre")
|
||||
private String genre;
|
||||
@Column(name = "title")
|
||||
private String title;
|
||||
@ManyToOne
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
private Album album;
|
||||
@Column(name = "songFile")
|
||||
private String songFile;
|
||||
|
Loading…
Reference in New Issue
Block a user