From a72d6f428117eb0c0623ba13c13e17761e932148 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 26 Jul 2012 07:25:48 +0200 Subject: [PATCH] Add method to create an artist. --- .../demoscenemusic/data/DataManager.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 -- 2.7.4