From: David ‘Bombe’ Roden Date: Sat, 28 Jul 2012 10:10:31 +0000 (+0200) Subject: Add method to remove a derivative from the database. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=213e80871a5f574d7ee048a87fb1974fe4716d5c;p=demoscenemusic.git Add method to remove a derivative from the database. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index ad01bfe..31e5def 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -515,6 +515,23 @@ public class DataManager { } /** + * Removes the given track derivative and all its properties from the + * database. + * + * @param trackDerivative + * The track derivative to remove + * @throws DatabaseException + * if a database error occurs + */ + public void removeTrackDerivative(TrackDerivative trackDerivative) throws DatabaseException { + Query query = new Query(Type.DELETE, "TRACK_DERIVATIVES"); + query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_DERIVATIVES.ID", new StringParameter(trackDerivative.getId())))); + database.update(query); + /* remove the properties. */ + saveProperties(new Properties(), "TRACK_DERIVATIVE_PROPERTIES", "TRACK_DERIVATIVE", trackDerivative.getId()); + } + + /** * Returns all groups the artist with the given ID belongs to. * * @param artistId