From 62bd730cd38294909f778b3b273867931c7d5cad Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 28 Jul 2012 01:39:25 +0200 Subject: [PATCH] Automatically link new track to an artist. --- .../net/pterodactylus/demoscenemusic/page/admin/AddTrackPage.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackPage.java b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackPage.java index e0c8e7f..2234449 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackPage.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/AddTrackPage.java @@ -18,6 +18,7 @@ package net.pterodactylus.demoscenemusic.page.admin; import net.pterodactylus.demoscenemusic.core.Core; +import net.pterodactylus.demoscenemusic.data.Artist; import net.pterodactylus.demoscenemusic.data.Track; import net.pterodactylus.demoscenemusic.page.ServletRequest; import net.pterodactylus.util.database.DatabaseException; @@ -66,7 +67,14 @@ public class AddTrackPage extends AdminBasePage { return; } try { + String artistId = request.getServletRequest().getParameter("artist"); + Artist artist = getCore().getDataManager().getArtistById(artistId); + if (artist == null) { + templateContext.set("error", "no-artist-given"); + } Track track = getCore().getDataManager().createTrack(name); + track.getArtists().add(artist); + getCore().getDataManager().saveTrack(track); throw new RedirectException("admin.edit-track?id=" + track.getId()); } catch (DatabaseException de1) { throw new RuntimeException("Could not create track.", de1); -- 2.7.4