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()) {
|
if (!albumObj.isPresent()) {
|
||||||
Album album = new Album(metadata.album, metadata.artwork);
|
Album album = new Album(metadata.album, metadata.artwork);
|
||||||
albumObj = Optional.of(album);
|
albumObj = Optional.of(album);
|
||||||
session.save(album);
|
|
||||||
}
|
}
|
||||||
Optional<Artist> artistObj = getOneArtist(metadata.artist);
|
Optional<Artist> artistObj = getOneArtist(metadata.artist);
|
||||||
if (!artistObj.isPresent()) {
|
if (!artistObj.isPresent()) {
|
||||||
Artist artist = new Artist(metadata.artist);
|
Artist artist = new Artist(metadata.artist);
|
||||||
artistObj = Optional.of(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.save(new Song(metadata.trackNumber, metadata.title, artistObj.get(), albumObj.get(), metadata.genre, metadata.songFile));
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
@ -49,7 +49,7 @@ public class ExtractedMetadata {
|
|||||||
Image actualImage = ImageIO.read(imageFile.get().toFile());
|
Image actualImage = ImageIO.read(imageFile.get().toFile());
|
||||||
tmpArt = convertImageToBytes(actualImage);
|
tmpArt = convertImageToBytes(actualImage);
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (NullPointerException | IOException ignored) {}
|
||||||
}
|
}
|
||||||
artwork = tmpArt;
|
artwork = tmpArt;
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ public class Song implements Comparable<Song> {
|
|||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
private long id;
|
private long id;
|
||||||
@ManyToOne
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
private Artist artist;
|
private Artist artist;
|
||||||
@Column(name = "genre")
|
@Column(name = "genre")
|
||||||
private String genre;
|
private String genre;
|
||||||
@Column(name = "title")
|
@Column(name = "title")
|
||||||
private String title;
|
private String title;
|
||||||
@ManyToOne
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
private Album album;
|
private Album album;
|
||||||
@Column(name = "songFile")
|
@Column(name = "songFile")
|
||||||
private String songFile;
|
private String songFile;
|
||||||
|
Loading…
Reference in New Issue
Block a user