From: David ‘Bombe’ Roden Date: Thu, 26 Jul 2012 05:25:48 +0000 (+0200) Subject: Add method to create an artist. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a72d6f428117eb0c0623ba13c13e17761e932148;p=demoscenemusic.git Add method to create an artist. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index 60b8318..a6f5a54 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -24,6 +24,7 @@ import java.util.EnumMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.Callable; import net.pterodactylus.demoscenemusic.data.Track.Relationship; @@ -149,6 +150,24 @@ public class DataManager { } /** + * Creates a new artist with the given name. + * + * @param name + * The name of the artist + * @return The created artist + * @throws DatabaseException + * if a database error occurs + */ + public Artist createArtist(String name) throws DatabaseException { + Query query = new Query(Type.INSERT, "ARTISTS"); + String id = UUID.randomUUID().toString(); + query.addValueField(new ValueField("ID", new StringParameter(id))); + query.addValueField(new ValueField("NAME", new StringParameter(name))); + database.insert(query); + return getArtistById(id); + } + + /** * Returns all remix artists involved in the track with the given ID. * * @param trackId