[FEAT] update with archidata mongo interface

This commit is contained in:
Edouard DUPIN 2024-10-12 10:46:02 +02:00
parent 1cf08390ec
commit 2c0fb99202
18 changed files with 202 additions and 246 deletions

View File

@ -1,34 +1,17 @@
package org.kar.karusic; package org.kar.karusic;
import org.kar.archidata.db.DbInterfaceMorphia;
import org.kar.karusic.model.Album; import org.kar.karusic.model.Album;
import org.kar.karusic.model.Artist; import org.kar.karusic.model.Artist;
import org.kar.karusic.model.Gender; import org.kar.karusic.model.Gender;
import org.kar.karusic.model.Playlist; import org.kar.karusic.model.Playlist;
import org.kar.karusic.model.Track; import org.kar.karusic.model.Track;
import com.mongodb.client.MongoClient; public class MorphiaService extends DbInterfaceMorphia {
import com.mongodb.client.MongoClients;
import dev.morphia.Datastore;
import dev.morphia.Morphia;
public class MorphiaService {
private final Datastore datastore;
public MorphiaService() { public MorphiaService() {
// Connect to MongoDB super("mongodb://root:base_db_password@localhost:27017", "karusic", Album.class, Artist.class, Gender.class, Playlist.class, Track.class);
final MongoClient mongoClient = MongoClients.create("mongodb://root:base_db_password@localhost:27017");
this.datastore = Morphia.createDatastore(mongoClient, "karusic");
// Map entities
this.datastore.getMapper().map(Album.class, Artist.class, Gender.class, Playlist.class, Track.class);
// Ensure indexes
this.datastore.ensureIndexes();
}
public Datastore getDatastore() {
return this.datastore;
} }
} }

View File

@ -17,6 +17,7 @@ import org.kar.archidata.UpdateJwtPublicKey;
import org.kar.archidata.api.DataResource; import org.kar.archidata.api.DataResource;
import org.kar.archidata.api.ProxyResource; import org.kar.archidata.api.ProxyResource;
import org.kar.archidata.catcher.GenericCatcher; import org.kar.archidata.catcher.GenericCatcher;
import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.filter.CORSFilter; import org.kar.archidata.filter.CORSFilter;
import org.kar.archidata.filter.OptionFilter; import org.kar.archidata.filter.OptionFilter;
import org.kar.archidata.migration.MigrationEngine; import org.kar.archidata.migration.MigrationEngine;
@ -45,8 +46,11 @@ public class WebLauncher {
protected UpdateJwtPublicKey keyUpdater = null; protected UpdateJwtPublicKey keyUpdater = null;
protected HttpServer server = null; protected HttpServer server = null;
private final DataAccess da;
public WebLauncher() { public WebLauncher() {
ConfigBaseVariable.bdDatabase = "karusic"; ConfigBaseVariable.bdDatabase = "karusic";
this.da = DataAccess.createInterface();
} }
private static URI getBaseURI() { private static URI getBaseURI() {
@ -55,7 +59,7 @@ public class WebLauncher {
public void migrateDB() throws Exception { public void migrateDB() throws Exception {
WebLauncher.LOGGER.info("Create migration engine"); WebLauncher.LOGGER.info("Create migration engine");
final MigrationEngine migrationEngine = new MigrationEngine(); final MigrationEngine migrationEngine = new MigrationEngine(this.da);
WebLauncher.LOGGER.info("Add initialization"); WebLauncher.LOGGER.info("Add initialization");
migrationEngine.setInit(new Initialization()); migrationEngine.setInit(new Initialization());
WebLauncher.LOGGER.info("Add migration since last version"); WebLauncher.LOGGER.info("Add migration since last version");
@ -64,7 +68,7 @@ public class WebLauncher {
migrationEngine.add(new Migration20240226()); migrationEngine.add(new Migration20240226());
migrationEngine.add(new Migration20240907()); migrationEngine.add(new Migration20240907());
WebLauncher.LOGGER.info("Migrate the DB [START]"); WebLauncher.LOGGER.info("Migrate the DB [START]");
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig); migrationEngine.migrateWaitAdmin(GlobalConfiguration.getDbconfig());
WebLauncher.LOGGER.info("Migrate the DB [STOP]"); WebLauncher.LOGGER.info("Migrate the DB [STOP]");
} }
@ -148,7 +152,7 @@ public class WebLauncher {
// System.out.println(" getDBLogin: '" + ConfigVariable.getDBLogin() + "'"); // System.out.println(" getDBLogin: '" + ConfigVariable.getDBLogin() + "'");
// System.out.println(" getDBPassword: '" + ConfigVariable.getDBPassword() + "'"); // System.out.println(" getDBPassword: '" + ConfigVariable.getDBPassword() + "'");
// System.out.println(" getDBName: '" + ConfigVariable.getDBName() + "'"); // System.out.println(" getDBName: '" + ConfigVariable.getDBName() + "'");
System.out.println(" ==> " + GlobalConfiguration.dbConfig); System.out.println(" ==> " + GlobalConfiguration.getDbconfig());
System.out.println("OAuth service " + getBaseURI()); System.out.println("OAuth service " + getBaseURI());
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc); this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
final HttpServer serverLink = this.server; final HttpServer serverLink = this.server;

View File

@ -11,17 +11,13 @@ import org.kar.archidata.annotation.FormDataOptional;
import org.kar.archidata.annotation.TypeScriptProgress; import org.kar.archidata.annotation.TypeScriptProgress;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
import org.kar.karusic.MorphiaService;
import org.kar.karusic.model.Album; import org.kar.karusic.model.Album;
import org.kar.karusic.model.Album.AlbumChecker; import org.kar.karusic.model.Album.AlbumChecker;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import dev.morphia.query.Query;
import dev.morphia.query.filters.Filters;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.security.RolesAllowed; import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
@ -39,133 +35,108 @@ import jakarta.ws.rs.core.MediaType;
public class AlbumResource { public class AlbumResource {
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class);
static final AlbumChecker CHECKER = new AlbumChecker(); static final AlbumChecker CHECKER = new AlbumChecker();
private final MorphiaService morphiaService = new MorphiaService(); private final DataAccess da = DataAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
@Operation(description = "Get a specific Album with his ID") @Operation(description = "Get a specific Album with his ID")
public Album get(@PathParam("id") final Long id) throws Exception { public Album get(@PathParam("id") final Long id) throws Exception {
//return DataAccess.get(Album.class, id); return this.da.get(Album.class, id);
return this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id)).first(); // return this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id)).first();
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
@Operation(description = "Get all the available Albums") @Operation(description = "Get all the available Albums")
public List<Album> gets() throws Exception { public List<Album> gets() throws Exception {
//return DataAccess.gets(Album.class); return this.da.gets(Album.class);
final Query<Album> query = this.morphiaService.getDatastore().find(Album.class); // final Query<Album> query = this.morphiaService.getDatastore().find(Album.class);
return query.stream().toList(); // return query.stream().toList();
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Operation(description = "Add an album (when all the data already exist)") @Operation(description = "Add an album (when all the data already exist)")
public Album post(final Album data) throws Exception { public Album post(final Album data) throws Exception {
// TODO: how to manage the checker ??? // TODO: how to manage the checker ???
final Album ret = this.morphiaService.getDatastore().save(data); // final Album ret = this.morphiaService.getDatastore().save(data);
return ret; // return ret;
/* /* final MongoCollection<Track> trackCollection = db.getCollection("TTRACLK", Track.class); final InsertOneResult res = trackCollection.insertOne(plop); LOGGER.warn("plpop {}", res); final
* ObjectId ploppppp = res.getInsertedId().asObjectId().getValue(); LOGGER.warn("plpop 2522 {}", res.getInsertedId().asObjectId().getValue()); final Track ret =
final MongoCollection<Track> trackCollection = db.getCollection("TTRACLK", Track.class); * trackCollection.find(Filters.eq("_id", res.getInsertedId().asObjectId().getValue())) .first(); System.out.println("Grade found:\t" + ret); */
return this.da.insert(data, new CheckFunction(CHECKER));
final InsertOneResult res = trackCollection.insertOne(plop);
LOGGER.warn("plpop {}", res);
final ObjectId ploppppp = res.getInsertedId().asObjectId().getValue();
LOGGER.warn("plpop 2522 {}", res.getInsertedId().asObjectId().getValue());
final Track ret = trackCollection.find(Filters.eq("_id", res.getInsertedId().asObjectId().getValue()))
.first();
System.out.println("Grade found:\t" + ret);
return DataAccess.insert(data, new CheckFunction(CHECKER));
*/
} }
@PATCH @PATCH
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Operation(description = "Update a specific album") @Operation(description = "Update a specific album")
public Album patch(@PathParam("id") final Long id, @AsyncType(Album.class) final String jsonRequest) public Album patch(@PathParam("id") final Long id, @AsyncType(Album.class) final String jsonRequest) throws Exception {
throws Exception { // final Query<Album> query = this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id));
// final Query<Album> query = this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id)); // final UpdateOperations<Album> ops = this.morphiaService.getDatastore().createUpdateOperations(Album.class)
// final UpdateOperations<Album> ops = this.morphiaService.getDatastore().createUpdateOperations(Album.class) // .set("name", master.getName());
// .set("name", master.getName()); // this.morphiaService.getDatastore().update(query, ops);
// this.morphiaService.getDatastore().update(query, ops); // return Response.ok(master).build();
// return Response.ok(master).build();
this.da.updateWithJson(Album.class, id, jsonRequest, new CheckFunction(CHECKER));
DataAccess.updateWithJson(Album.class, id, jsonRequest, new CheckFunction(CHECKER)); return this.da.get(Album.class, id);
return DataAccess.get(Album.class, id);
} }
// @PUT // @PUT
// @Path("{id}") // @Path("{id}")
// @RolesAllowed("ADMIN") // @RolesAllowed("ADMIN")
// @Consumes(MediaType.APPLICATION_JSON) // @Consumes(MediaType.APPLICATION_JSON)
// @Operation(description = "Update a specific album") // @Operation(description = "Update a specific album")
// public Album put(@PathParam("id") final Long id, final Album album) // public Album put(@PathParam("id") final Long id, final Album album)
// throws Exception { // throws Exception {
// final Query<Album> query = this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id)); // final Query<Album> query = this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id));
// final UpdateOperations<Album> ops = this.morphiaService.getDatastore().createUpdateOperations(Album.class) // final UpdateOperations<Album> ops = this.morphiaService.getDatastore().createUpdateOperations(Album.class)
// .set("name", album.getName()); // .set("name", album.getName());
// this.morphiaService.getDatastore().update(query, ops); // this.morphiaService.getDatastore().update(query, ops);
// return Response.ok(album).build(); // return Response.ok(album).build();
// } // }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Operation(description = "Remove a specific album") @Operation(description = "Remove a specific album")
public void remove(@PathParam("id") final Long id) throws Exception { public void remove(@PathParam("id") final Long id) throws Exception {
//DataAccess.delete(Album.class, id); this.da.delete(Album.class, id);
this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id)).delete(); // this.morphiaService.getDatastore().find(Album.class).filter(Filters.eq("id", id)).delete();
} }
@POST /* @POST
@Path("{id}/track/{trackId}") * @Path("{id}/track/{trackId}")
@RolesAllowed("ADMIN") * @RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA }) * @Consumes({ MediaType.MULTIPART_FORM_DATA })
@Operation(description = "Add a Track on a specific album") * @Operation(description = "Add a Track on a specific album") public Album addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
public Album addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception { * AddOnManyToMany.removeLink(this.dam, Album.class, id, "track", trackId); return this.dam.get(Album.class, id); } */
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
return DataAccess.get(Album.class, id);
}
@POST @POST
@Path("{id}/cover") @Path("{id}/cover")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA }) @Consumes({ MediaType.MULTIPART_FORM_DATA })
@Operation(description = "Add a cover on a specific album") @Operation(description = "Add a cover on a specific album")
@TypeScriptProgress @TypeScriptProgress
public Album uploadCover( public Album uploadCover(@PathParam("id") final Long id, @FormDataOptional @FormDataParam("uri") final String uri, @FormDataOptional @FormDataParam("file") final InputStream fileInputStream,
@PathParam("id") final Long id,
@FormDataOptional @FormDataParam("uri") final String uri,
@FormDataOptional @FormDataParam("file") final InputStream fileInputStream,
@FormDataOptional @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception { @FormDataOptional @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
if (uri != null) { if (uri != null) {
DataTools.uploadCoverFromUri(Album.class, id, uri); DataTools.uploadCoverFromUri(this.da, Album.class, id, uri);
} else { } else {
DataTools.uploadCover(Album.class, id, fileInputStream, fileMetaData); DataTools.uploadCover(this.da, Album.class, id, fileInputStream, fileMetaData);
} }
return DataAccess.get(Album.class, id); return this.da.get(Album.class, id);
} }
@DELETE @DELETE
@Path("{id}/cover/{coverId}") @Path("{id}/cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Operation(description = "Remove a cover on a specific album") @Operation(description = "Remove a cover on a specific album")
public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
throws Exception { AddOnDataJson.removeLink(this.da, Album.class, id, "covers", coverId);
AddOnDataJson.removeLink(Album.class, id, "covers", coverId); return this.da.get(Album.class, id);
return DataAccess.get(Album.class, id);
} }
} }

View File

@ -34,25 +34,26 @@ import jakarta.ws.rs.core.MediaType;
public class ArtistResource { public class ArtistResource {
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
static final ArtistChecker CHECKER = new ArtistChecker(); static final ArtistChecker CHECKER = new ArtistChecker();
private final DataAccess da = DataAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Artist get(@PathParam("id") final Long id) throws Exception { public Artist get(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Artist.class, id); return this.da.get(Artist.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Artist> gets() throws Exception { public List<Artist> gets() throws Exception {
return DataAccess.gets(Artist.class); return this.da.gets(Artist.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Artist post(final Artist data) throws Exception { public Artist post(final Artist data) throws Exception {
return DataAccess.insert(data, new CheckFunction(CHECKER)); return this.da.insert(data, new CheckFunction(CHECKER));
} }
@PATCH @PATCH
@ -60,15 +61,15 @@ public class ArtistResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Artist patch(@PathParam("id") final Long id, @AsyncType(Artist.class) final String jsonRequest) throws Exception { public Artist patch(@PathParam("id") final Long id, @AsyncType(Artist.class) final String jsonRequest) throws Exception {
DataAccess.updateWithJson(Artist.class, id, jsonRequest, new CheckFunction(CHECKER)); this.da.updateWithJson(Artist.class, id, jsonRequest, new CheckFunction(CHECKER));
return DataAccess.get(Artist.class, id); return this.da.get(Artist.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public void remove(@PathParam("id") final Long id) throws Exception { public void remove(@PathParam("id") final Long id) throws Exception {
DataAccess.delete(Artist.class, id); this.da.delete(Artist.class, id);
} }
@POST @POST
@ -79,11 +80,11 @@ public class ArtistResource {
public Artist uploadCover(@PathParam("id") final Long id, @FormDataOptional @FormDataParam("uri") final String uri, @FormDataOptional @FormDataParam("file") final InputStream fileInputStream, public Artist uploadCover(@PathParam("id") final Long id, @FormDataOptional @FormDataParam("uri") final String uri, @FormDataOptional @FormDataParam("file") final InputStream fileInputStream,
@FormDataOptional @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception { @FormDataOptional @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
if (uri != null) { if (uri != null) {
DataTools.uploadCoverFromUri(Artist.class, id, uri); DataTools.uploadCoverFromUri(this.da, Artist.class, id, uri);
} else { } else {
DataTools.uploadCover(Artist.class, id, fileInputStream, fileMetaData); DataTools.uploadCover(this.da, Artist.class, id, fileInputStream, fileMetaData);
} }
return DataAccess.get(Artist.class, id); return this.da.get(Artist.class, id);
} }
@DELETE @DELETE
@ -91,7 +92,7 @@ public class ArtistResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception { public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
LOGGER.error("klmlmkmlkmlklmklmk"); LOGGER.error("klmlmkmlkmlklmklmk");
AddOnDataJson.removeLink(Artist.class, id, "covers", coverId); AddOnDataJson.removeLink(this.da, Artist.class, id, "covers", coverId);
return DataAccess.get(Artist.class, id); return this.da.get(Artist.class, id);
} }
} }

View File

@ -34,25 +34,26 @@ import jakarta.ws.rs.core.MediaType;
public class GenderResource { public class GenderResource {
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
static final GenderChecker CHECKER = new GenderChecker(); static final GenderChecker CHECKER = new GenderChecker();
private final DataAccess da = DataAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Gender get(@PathParam("id") final Long id) throws Exception { public Gender get(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Gender.class, id); return this.da.get(Gender.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Gender> gets() throws Exception { public List<Gender> gets() throws Exception {
return DataAccess.gets(Gender.class); return this.da.gets(Gender.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Gender post(final Gender data) throws Exception { public Gender post(final Gender data) throws Exception {
return DataAccess.insert(data, new CheckFunction(CHECKER)); return this.da.insert(data, new CheckFunction(CHECKER));
} }
@PATCH @PATCH
@ -60,15 +61,15 @@ public class GenderResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Gender patch(@PathParam("id") final Long id, @AsyncType(Gender.class) final String jsonRequest) throws Exception { public Gender patch(@PathParam("id") final Long id, @AsyncType(Gender.class) final String jsonRequest) throws Exception {
DataAccess.updateWithJson(Gender.class, id, jsonRequest, new CheckFunction(CHECKER)); this.da.updateWithJson(Gender.class, id, jsonRequest, new CheckFunction(CHECKER));
return DataAccess.get(Gender.class, id); return this.da.get(Gender.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public void remove(@PathParam("id") final Long id) throws Exception { public void remove(@PathParam("id") final Long id) throws Exception {
DataAccess.delete(Gender.class, id); this.da.delete(Gender.class, id);
} }
@POST @POST
@ -79,18 +80,18 @@ public class GenderResource {
public Gender uploadCover(@PathParam("id") final Long id, @FormDataOptional @FormDataParam("uri") final String uri, @FormDataOptional @FormDataParam("file") final InputStream fileInputStream, public Gender uploadCover(@PathParam("id") final Long id, @FormDataOptional @FormDataParam("uri") final String uri, @FormDataOptional @FormDataParam("file") final InputStream fileInputStream,
@FormDataOptional @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception { @FormDataOptional @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
if (uri != null) { if (uri != null) {
DataTools.uploadCoverFromUri(Gender.class, id, uri); DataTools.uploadCoverFromUri(this.da, Gender.class, id, uri);
} else { } else {
DataTools.uploadCover(Gender.class, id, fileInputStream, fileMetaData); DataTools.uploadCover(this.da, Gender.class, id, fileInputStream, fileMetaData);
} }
return DataAccess.get(Gender.class, id); return this.da.get(Gender.class, id);
} }
@DELETE @DELETE
@Path("{id}/cover/{coverId}") @Path("{id}/cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception { public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
AddOnDataJson.removeLink(Gender.class, id, "covers", coverId); AddOnDataJson.removeLink(this.da, Gender.class, id, "covers", coverId);
return DataAccess.get(Gender.class, id); return this.da.get(Gender.class, id);
} }
} }

View File

@ -9,7 +9,6 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.AsyncType; import org.kar.archidata.annotation.AsyncType;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
import org.kar.karusic.model.Playlist; import org.kar.karusic.model.Playlist;
@ -33,25 +32,26 @@ import jakarta.ws.rs.core.MediaType;
public class PlaylistResource { public class PlaylistResource {
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
static final TrackChecker CHECKER = new TrackChecker(); static final TrackChecker CHECKER = new TrackChecker();
private final DataAccess da = DataAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Playlist get(@PathParam("id") final Long id) throws Exception { public Playlist get(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Playlist.class, id); return this.da.get(Playlist.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Playlist> gets() throws Exception { public List<Playlist> gets() throws Exception {
return DataAccess.gets(Playlist.class); return this.da.gets(Playlist.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Playlist post(final Playlist data) throws Exception { public Playlist post(final Playlist data) throws Exception {
return DataAccess.insert(data, new CheckFunction(CHECKER)); return this.da.insert(data, new CheckFunction(CHECKER));
} }
@PATCH @PATCH
@ -59,15 +59,15 @@ public class PlaylistResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Playlist patch(@PathParam("id") final Long id, @AsyncType(Playlist.class) final String jsonRequest) throws Exception { public Playlist patch(@PathParam("id") final Long id, @AsyncType(Playlist.class) final String jsonRequest) throws Exception {
DataAccess.updateWithJson(Playlist.class, id, jsonRequest, new CheckFunction(CHECKER)); this.da.updateWithJson(Playlist.class, id, jsonRequest, new CheckFunction(CHECKER));
return DataAccess.get(Playlist.class, id); return this.da.get(Playlist.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public void remove(@PathParam("id") final Long id) throws Exception { public void remove(@PathParam("id") final Long id) throws Exception {
DataAccess.delete(Playlist.class, id); this.da.delete(Playlist.class, id);
} }
@POST @POST
@ -75,16 +75,16 @@ public class PlaylistResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA }) @Consumes({ MediaType.MULTIPART_FORM_DATA })
public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception { public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId); AddOnDataJson.removeLink(this.da, Playlist.class, id, "track", trackId);
return DataAccess.get(Playlist.class, id); return this.da.get(Playlist.class, id);
} }
@DELETE @DELETE
@Path("{id}/track/{trackId}") @Path("{id}/track/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Playlist removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception { public Playlist removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId); AddOnDataJson.removeLink(this.da, Playlist.class, id, "track", trackId);
return DataAccess.get(Playlist.class, id); return this.da.get(Playlist.class, id);
} }
@POST @POST
@ -94,14 +94,14 @@ public class PlaylistResource {
@AsyncType(Playlist.class) @AsyncType(Playlist.class)
public void uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData) public void uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
throws Exception { throws Exception {
DataTools.uploadCover(Playlist.class, id, fileInputStream, fileMetaData); DataTools.uploadCover(this.da, Playlist.class, id, fileInputStream, fileMetaData);
} }
@DELETE @DELETE
@Path("{id}/cover/{coverId}") @Path("{id}/cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception { public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
AddOnDataJson.removeLink(Playlist.class, id, "covers", coverId); AddOnDataJson.removeLink(this.da, Playlist.class, id, "covers", coverId);
return DataAccess.get(Playlist.class, id); return this.da.get(Playlist.class, id);
} }
} }

View File

@ -14,7 +14,6 @@ import org.kar.archidata.annotation.FormDataOptional;
import org.kar.archidata.annotation.TypeScriptProgress; import org.kar.archidata.annotation.TypeScriptProgress;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
import org.kar.archidata.dataAccess.options.CheckFunction; import org.kar.archidata.dataAccess.options.CheckFunction;
import org.kar.archidata.model.Data; import org.kar.archidata.model.Data;
import org.kar.archidata.tools.DataTools; import org.kar.archidata.tools.DataTools;
@ -40,25 +39,26 @@ import jakarta.ws.rs.core.Response;
public class TrackResource { public class TrackResource {
private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class);
static final TrackChecker CHECKER = new TrackChecker(); static final TrackChecker CHECKER = new TrackChecker();
private final DataAccess da = DataAccess.createInterface();
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Track get(@PathParam("id") final Long id) throws Exception { public Track get(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Track.class, id); return this.da.get(Track.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Track> gets() throws Exception { public List<Track> gets() throws Exception {
return DataAccess.gets(Track.class); return this.da.gets(Track.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Track post(final Track data) throws Exception { public Track post(final Track data) throws Exception {
return DataAccess.insert(data, new CheckFunction(CHECKER)); return this.da.insert(data, new CheckFunction(CHECKER));
} }
@PATCH @PATCH
@ -66,15 +66,15 @@ public class TrackResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Track patch(@PathParam("id") final Long id, @AsyncType(Track.class) final String jsonRequest) throws Exception { public Track patch(@PathParam("id") final Long id, @AsyncType(Track.class) final String jsonRequest) throws Exception {
DataAccess.updateWithJson(Track.class, id, jsonRequest, new CheckFunction(CHECKER)); this.da.updateWithJson(Track.class, id, jsonRequest, new CheckFunction(CHECKER));
return DataAccess.get(Track.class, id); return this.da.get(Track.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public void remove(@PathParam("id") final Long id) throws Exception { public void remove(@PathParam("id") final Long id) throws Exception {
DataAccess.delete(Track.class, id); this.da.delete(Track.class, id);
} }
@POST @POST
@ -82,16 +82,16 @@ public class TrackResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA }) @Consumes({ MediaType.MULTIPART_FORM_DATA })
public Track addTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception { public Track addTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId); AddOnDataJson.removeLink(this.da, Track.class, id, "artist", artistId);
return DataAccess.get(Track.class, id); return this.da.get(Track.class, id);
} }
@DELETE @DELETE
@Path("{id}/artist/{trackId}") @Path("{id}/artist/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Track removeTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception { public Track removeTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId); AddOnDataJson.removeLink(this.da, Track.class, id, "artist", artistId);
return DataAccess.get(Track.class, id); return this.da.get(Track.class, id);
} }
@POST @POST
@ -102,19 +102,19 @@ public class TrackResource {
public Track uploadCover(@PathParam("id") final Long id, @FormDataParam("uri") final String uri, @FormDataParam("file") final InputStream fileInputStream, public Track uploadCover(@PathParam("id") final Long id, @FormDataParam("uri") final String uri, @FormDataParam("file") final InputStream fileInputStream,
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception { @FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
if (uri != null) { if (uri != null) {
DataTools.uploadCoverFromUri(Track.class, id, uri); DataTools.uploadCoverFromUri(this.da, Track.class, id, uri);
} else { } else {
DataTools.uploadCover(Track.class, id, fileInputStream, fileMetaData); DataTools.uploadCover(this.da, Track.class, id, fileInputStream, fileMetaData);
} }
return DataAccess.get(Track.class, id); return this.da.get(Track.class, id);
} }
@DELETE @DELETE
@Path("{id}/cover/{coverId}") @Path("{id}/cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception { public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
AddOnDataJson.removeLink(Track.class, id, "covers", coverId); AddOnDataJson.removeLink(this.da, Track.class, id, "covers", coverId);
return DataAccess.get(Track.class, id); return this.da.get(Track.class, id);
} }
@POST @POST
@ -153,12 +153,12 @@ public class TrackResource {
final long tmpUID = DataTools.getTmpDataId(); final long tmpUID = DataTools.getTmpDataId();
final String sha512 = DataTools.saveTemporaryFile(fileInputStream, tmpUID); final String sha512 = DataTools.saveTemporaryFile(fileInputStream, tmpUID);
Data data = DataTools.getWithSha512(sha512); Data data = DataTools.getWithSha512(this.da, sha512);
if (data == null) { if (data == null) {
LOGGER.info("Need to add the data in the BDD ... "); LOGGER.info("Need to add the data in the BDD ... ");
try { try {
data = DataTools.createNewData(tmpUID, fileMetaData.getFileName(), sha512); data = DataTools.createNewData(this.da, tmpUID, fileMetaData.getFileName(), sha512);
} catch (final IOException ex) { } catch (final IOException ex) {
DataTools.removeTemporaryFile(tmpUID); DataTools.removeTemporaryFile(tmpUID);
ex.printStackTrace(); ex.printStackTrace();
@ -170,7 +170,7 @@ public class TrackResource {
} }
} else if (data.deleted) { } else if (data.deleted) {
LOGGER.info("Data already exist but deleted"); LOGGER.info("Data already exist but deleted");
DataTools.undelete(data.uuid); DataTools.undelete(this.da, data.uuid);
data.deleted = false; data.deleted = false;
} else { } else {
LOGGER.info("Data already exist ... all good"); LOGGER.info("Data already exist ... all good");
@ -188,8 +188,8 @@ public class TrackResource {
trackElem.artists = new ArrayList<>(); trackElem.artists = new ArrayList<>();
trackElem.artists.add(artistId != null ? Long.parseLong(artistId) : null); trackElem.artists.add(artistId != null ? Long.parseLong(artistId) : null);
} }
trackElem = DataAccess.insert(trackElem, new CheckFunction(CHECKER)); trackElem = this.da.insert(trackElem, new CheckFunction(CHECKER));
/* Old mode of artist insertion (removed due to the slowlest request of getting value if (artistElem != null) { DataAccess.addLink(Track.class, trackElem.id, "artist", artistElem.id); } */ /* Old mode of artist insertion (removed due to the slowlest request of getting value if (artistElem != null) { this.dam.addLink(Track.class, trackElem.id, "artist", artistElem.id); } */
return Response.ok(trackElem).build(); return Response.ok(trackElem).build();
} catch (final Exception ex) { } catch (final Exception ex) {
LOGGER.info("Catch an unexpected error ... {}", ex.getMessage()); LOGGER.info("Catch an unexpected error ... {}", ex.getMessage());

View File

@ -26,6 +26,7 @@ import jakarta.ws.rs.core.SecurityContext;
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public class UserResource { public class UserResource {
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class); private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
private final DataAccess da = DataAccess.createInterface();
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class UserOut { public class UserOut {
@ -47,7 +48,7 @@ public class UserResource {
public List<UserKarusic> gets() { public List<UserKarusic> gets() {
LOGGER.info("getUsers"); LOGGER.info("getUsers");
try { try {
return DataAccess.gets(UserKarusic.class); return this.da.gets(UserKarusic.class);
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -66,7 +67,7 @@ public class UserResource {
LOGGER.info("== USER {} ", gc.userByToken.name); LOGGER.info("== USER {} ", gc.userByToken.name);
LOGGER.info("==================================================="); LOGGER.info("===================================================");
try { try {
return DataAccess.get(UserKarusic.class, userId); return this.da.get(UserKarusic.class, userId);
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -35,35 +35,35 @@ public class Initialization extends MigrationSqlStep {
addClass(elem); addClass(elem);
} }
addAction(""" addAction((final DataAccess da) -> {
INSERT INTO `gender` (`id`, `name`, `description`) VALUES final List<Gender> data = List.of(//
(1, 'Variété française', NULL), new Gender(1L, "Variété française"), //
(2, 'Pop', NULL), new Gender(2L, "Pop"), //
(3, 'inconnue', NULL), new Gender(3L, "inconnue"), //
(4, 'Disco', NULL), new Gender(4L, "Disco"), //
(5, 'Enfants', NULL), new Gender(5L, "Enfants"), //
(6, 'Portugaise', NULL), new Gender(6L, "Portugaise"), //
(7, 'Apprentissage', NULL), new Gender(7L, "Apprentissage"), //
(8, 'Blues', NULL), new Gender(8L, "Blues"), //
(9, 'Jazz', NULL), new Gender(9L, "Jazz"), //
(10, 'Chanson Noël', NULL), new Gender(10L, "Chanson Noël"), //
(11, 'DubStep', NULL), new Gender(11L, "DubStep"), //
(12, 'Rap français', NULL), new Gender(12L, "Rap français"), //
(13, 'Classique', NULL), new Gender(13L, "Classique"), //
(14, 'Rock', NULL), new Gender(14L, "Rock"), //
(15, 'Electro', NULL), new Gender(15L, "Electro"), //
(16, 'Celtique', NULL), new Gender(16L, "Celtique"), //
(17, 'Country', NULL), new Gender(17L, "Country"), //
(18, 'Variété Québéquoise', NULL), new Gender(18L, "Variété Québéquoise"), //
(19, 'Médiéval', NULL), new Gender(19L, "Médiéval"), //
(20, 'Variété Italienne', NULL), new Gender(20L, "Variété Italienne"), //
(21, 'Comédie Musicale', NULL), new Gender(21L, "Comédie Musicale"), //
(22, 'Vianney', NULL), new Gender(22L, "Vianney"), //
(23, 'Bande Original', NULL), new Gender(23L, "Bande Original"), //
(24, 'Bande Originale', NULL), new Gender(24L, "Bande Originale"), //
(25, 'Variété Belge', NULL), new Gender(25L, "Variété Belge"), //
(26, 'Gospel', NULL); new Gender(26L, "Gospel"));
"""); });
// set start increment element to permit to add after default elements // set start increment element to permit to add after default elements
addAction(""" addAction("""
ALTER TABLE `album` AUTO_INCREMENT = 1000; ALTER TABLE `album` AUTO_INCREMENT = 1000;
@ -85,10 +85,10 @@ public class Initialization extends MigrationSqlStep {
""", "mysql"); """, "mysql");
} }
public static void dropAll() { public static void dropAll(final DataAccess da) {
for (final Class<?> element : CLASSES_BASE) { for (final Class<?> element : CLASSES_BASE) {
try { try {
DataAccess.drop(element); da.drop(element);
} catch (final Exception ex) { } catch (final Exception ex) {
LOGGER.error("Fail to drop table !!!!!!"); LOGGER.error("Fail to drop table !!!!!!");
ex.printStackTrace(); ex.printStackTrace();
@ -96,10 +96,10 @@ public class Initialization extends MigrationSqlStep {
} }
} }
public static void cleanAll() { public static void cleanAll(final DataAccess da) {
for (final Class<?> element : CLASSES_BASE) { for (final Class<?> element : CLASSES_BASE) {
try { try {
DataAccess.cleanAll(element); da.cleanAll(element);
} catch (final Exception ex) { } catch (final Exception ex) {
LOGGER.error("Fail to clean table !!!!!!"); LOGGER.error("Fail to clean table !!!!!!");
ex.printStackTrace(); ex.printStackTrace();

View File

@ -12,11 +12,13 @@ import org.kar.archidata.model.GenericDataSoftDelete;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import dev.morphia.annotations.Entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity("Album")
@Table(name = "album") @Table(name = "album")
@DataIfNotExists @DataIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)

View File

@ -12,11 +12,13 @@ import org.kar.archidata.model.GenericDataSoftDelete;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import dev.morphia.annotations.Entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity("Artist")
@Table(name = "artist") @Table(name = "artist")
@DataIfNotExists @DataIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)

View File

@ -23,11 +23,13 @@ import org.kar.archidata.model.GenericDataSoftDelete;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import dev.morphia.annotations.Entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity("Gender")
@Table(name = "gender") @Table(name = "gender")
@DataIfNotExists @DataIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@ -47,4 +49,11 @@ public class Gender extends GenericDataSoftDelete {
@Nullable @Nullable
public List<UUID> covers = null; public List<UUID> covers = null;
public Gender() {}
public Gender(final Long id, final String name) {
this.id = id;
this.name = name;
}
} }

View File

@ -23,6 +23,7 @@ import org.kar.archidata.model.GenericDataSoftDelete;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import dev.morphia.annotations.Entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
@ -30,6 +31,7 @@ import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity("Playlist")
@Table(name = "playlist") @Table(name = "playlist")
@DataIfNotExists @DataIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)

View File

@ -23,11 +23,13 @@ import org.kar.archidata.model.GenericDataSoftDelete;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import dev.morphia.annotations.Entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity("Track")
@Table(name = "track") @Table(name = "track")
@DataIfNotExists @DataIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)

View File

@ -3,12 +3,14 @@
# Default logging detail level for all instances of SimpleLogger. # Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error"). # Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info". # If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=trace org.slf4j.simpleLogger.defaultLogLevel=INFO
# Logging detail level for a SimpleLogger instance named "xxxxx". # Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error"). # Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used. # If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx= #org.slf4j.simpleLogger.log.xxxxx=
org.slf4j.simpleLogger.log.org.kar.archidata=TRACE
org.slf4j.simpleLogger.log.org.kar.karusic=TRACE
# Set to true if you want the current date and time to be included in output messages. # Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup. # Default is false, and will output the number of milliseconds elapsed since startup.

View File

@ -7,7 +7,6 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.kar.archidata.db.DBEntry;
import org.kar.archidata.tools.ConfigBaseVariable; import org.kar.archidata.tools.ConfigBaseVariable;
import org.kar.archidata.tools.RESTApi; import org.kar.archidata.tools.RESTApi;
import org.kar.karusic.migration.Initialization; import org.kar.karusic.migration.Initialization;

View File

@ -27,19 +27,6 @@ services:
volumes: volumes:
- ./dataMongo:/data/db - ./dataMongo:/data/db
mongo_express_service:
image: mongo-express
restart: always
ports:
- 8081:8081
links:
- kar_mongodb_service:db
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: base_db_password
ME_CONFIG_MONGODB_URL: mongodb://root:base_db_password@db:27017/
ME_CONFIG_BASICAUTH: false
kar_adminer_service: kar_adminer_service:
image: adminer:latest image: adminer:latest
restart: always restart: always
@ -52,3 +39,17 @@ services:
ports: ports:
- 4079:8080 - 4079:8080
mem_limit: 50m mem_limit: 50m
mongo_express_service:
image: mongo-express
restart: always
ports:
- 4077:8081
links:
- kar_mongodb_service:db
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: base_db_password
ME_CONFIG_MONGODB_URL: mongodb://root:base_db_password@db:27017/
ME_CONFIG_BASICAUTH: false

View File

@ -192,30 +192,6 @@ export namespace AlbumResource {
params, params,
}, isAlbum); }, isAlbum);
}; };
/**
* Remove a Track on a specific album
*/
export function removeTrack({
restConfig,
params,
}: {
restConfig: RESTConfig,
params: {
trackId: Long,
id: Long,
},
}): Promise<Album> {
return RESTRequestJson({
restModel: {
endPoint: "/album/{id}/track/{trackId}",
requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON,
},
restConfig,
params,
}, isAlbum);
};
/** /**
* Add a cover on a specific album * Add a cover on a specific album
*/ */