From: David ‘Bombe’ Roden Date: Mon, 30 Jul 2012 12:57:31 +0000 (+0200) Subject: Store party links when storing tracks. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=914852381662c9d29d504cf51efbd2073e32c265;p=demoscenemusic.git Store party links when storing tracks. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index ea040bd..f5b071f 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -457,6 +457,19 @@ public class DataManager { query.addValueField(new ValueField("TRACK_ARTISTS.DISPLAY_ORDER", new IntegerParameter(index + 1))); database.insert(query); } + + /* store party links. */ + Collection parties = track.getParties(); /* prefetch parties. */ + query = new Query(Type.DELETE, "PARTY_TRACKS"); + query.addWhereClause(new ValueFieldWhereClause(new ValueField("PARTY_TRACKS.TRACK", new StringParameter(track.getId())))); + database.update(query); + for (Party party : parties) { + query = new Query(Type.INSERT, "PARTY_TRACKS"); + query.addValueField(new ValueField("PARTY_TRACKS.TRACK", new StringParameter(track.getId()))); + query.addValueField(new ValueField("PARTY_TRACKS.PARTY", new StringParameter(party.getId()))); + database.insert(query); + } + /* store properties. */ saveProperties(track.getProperties(), "TRACK_PROPERTIES", "TRACK", track.getId()); }