Add method to remove a derivative from the database.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 28 Jul 2012 10:10:31 +0000 (12:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 28 Jul 2012 10:10:31 +0000 (12:10 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java

index ad01bfe..31e5def 100644 (file)
@@ -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