X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fdemoscenemusic%2Fdata%2FDataManager.java;h=c0001c41050e86a333a847718b39434ad9679987;hb=b2ab3fd2aefa2815f8c55b5b0e8b8d2eb912a192;hp=649960334e95eb041c547a815ccbef683403a68c;hpb=278bcc6a8c05363a6d157076e0a018f004803746;p=demoscenemusic.git diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index 6499603..c0001c4 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -502,6 +502,36 @@ public class DataManager { } /** + * Saves the given track derivative. As a track derivative does not have any + * attributes of its own only its properties are saved. + * + * @param trackDerivative + * The track derivative to save + * @throws DatabaseException + * if a database error occurs + */ + public void saveTrackDerivate(TrackDerivative trackDerivative) throws DatabaseException { + saveProperties(trackDerivative.getProperties(), "TRACK_DERIVATIVE_PROPERTIES", "TRACK_DERIVATIVE", trackDerivative.getId()); + } + + /** + * 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().set("dirty", "true").removeAll(), "TRACK_DERIVATIVE_PROPERTIES", "TRACK_DERIVATIVE", trackDerivative.getId()); + } + + /** * Returns all groups the artist with the given ID belongs to. * * @param artistId