[DEV] udpate to the new JPA (not finished...)

This commit is contained in:
Edouard DUPIN 2023-10-15 23:39:25 +02:00
parent f04ea20c30
commit 1897fac53a
17 changed files with 701 additions and 765 deletions

View File

@ -22,7 +22,7 @@
<dependency>
<groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId>
<version>0.3.7</version>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -1,20 +1,27 @@
package org.kar.karusic.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Album;
import org.kar.karusic.model.Track;
import org.kar.archidata.annotation.security.RolesAllowed;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.List;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.security.RolesAllowed;
import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Album;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/album")
@Produces({ MediaType.APPLICATION_JSON })
public class AlbumResource {
@ -29,7 +36,7 @@ public class AlbumResource {
@GET
@RolesAllowed("USER")
public List<Album> get() throws Exception {
return SqlWrapper.gets(Album.class, false);
return SqlWrapper.gets(Album.class);
}
@POST
@ -52,7 +59,7 @@ public class AlbumResource {
@Path("{id}")
@RolesAllowed("ADMIN")
public Response delete(@PathParam("id") Long id) throws Exception {
SqlWrapper.setDelete(Album.class, id);
SqlWrapper.delete(Album.class, id);
return Response.ok().build();
}
@ -61,7 +68,7 @@ public class AlbumResource {
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Album addTrack(@PathParam("id") Long id, @PathParam("trackId") Long trackId) throws Exception {
SqlWrapper.removeLink(Album.class, id, "track", trackId);
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
return SqlWrapper.get(Album.class, id);
}
@ -69,7 +76,7 @@ public class AlbumResource {
@Path("{id}/rm_track/{trackId}")
@RolesAllowed("ADMIN")
public Album removeTrack(@PathParam("id") Long id, @PathParam("trackId") Long trackId) throws Exception {
SqlWrapper.removeLink(Album.class, id, "track", trackId);
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
return SqlWrapper.get(Album.class, id);
}
@ -77,11 +84,8 @@ public class AlbumResource {
@Path("{id}/add_cover")
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response uploadCover(@PathParam("id") Long id,
@FormDataParam("fileName") String fileName,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData
) {
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
}
@ -89,8 +93,7 @@ public class AlbumResource {
@Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN")
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
SqlWrapper.removeLink(Album.class, id, "cover", coverId);
AddOnManyToMany.removeLink(Album.class, id, "cover", coverId);
return Response.ok(SqlWrapper.get(Album.class, id)).build();
}
}

View File

@ -1,19 +1,27 @@
package org.kar.karusic.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.karusic.model.Artist;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import org.kar.archidata.annotation.security.RolesAllowed;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.List;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.security.RolesAllowed;
import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Artist;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/artist")
@Produces({ MediaType.APPLICATION_JSON })
public class ArtistResource {
@ -28,7 +36,7 @@ public class ArtistResource {
@GET
@RolesAllowed("USER")
public List<Artist> get() throws Exception {
return SqlWrapper.gets(Artist.class, false);
return SqlWrapper.gets(Artist.class);
}
@POST
@ -51,28 +59,24 @@ public class ArtistResource {
@Path("{id}")
@RolesAllowed("ADMIN")
public Response delete(@PathParam("id") Long id) throws Exception {
SqlWrapper.setDelete(Artist.class, id);
SqlWrapper.delete(Artist.class, id);
return Response.ok().build();
}
@POST
@Path("{id}/add_cover")
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response uploadCover(@PathParam("id") Long id,
@FormDataParam("fileName") String fileName,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData
) {
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
}
@GET
@Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN")
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
SqlWrapper.removeLink(Artist.class, id, "cover", coverId);
AddOnManyToMany.removeLink(Artist.class, id, "cover", coverId);
return Response.ok(SqlWrapper.get(Artist.class, id)).build();
}
}

View File

@ -1,20 +1,27 @@
package org.kar.karusic.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.karusic.model.Gender;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import org.kar.archidata.annotation.security.RolesAllowed;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.List;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.security.RolesAllowed;
import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Gender;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/gender")
@Produces({ MediaType.APPLICATION_JSON })
public class GenderResource {
@ -29,7 +36,7 @@ public class GenderResource {
@GET
@RolesAllowed("USER")
public List<Gender> get() throws Exception {
return SqlWrapper.gets(Gender.class, false);
return SqlWrapper.gets(Gender.class);
}
@POST
@ -52,28 +59,24 @@ public class GenderResource {
@Path("{id}")
@RolesAllowed("ADMIN")
public Response delete(@PathParam("id") Long id) throws Exception {
SqlWrapper.setDelete(Gender.class, id);
SqlWrapper.delete(Gender.class, id);
return Response.ok().build();
}
@POST
@Path("{id}/add_cover")
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response uploadCover(@PathParam("id") Long id,
@FormDataParam("fileName") String fileName,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData
) {
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
}
@GET
@Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN")
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
SqlWrapper.removeLink(Gender.class, id, "cover", coverId);
AddOnManyToMany.removeLink(Gender.class, id, "cover", coverId);
return Response.ok(SqlWrapper.get(Gender.class, id)).build();
}
}

View File

@ -1,19 +1,27 @@
package org.kar.karusic.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.karusic.model.Playlist;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import org.kar.archidata.annotation.security.RolesAllowed;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.List;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.security.RolesAllowed;
import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Playlist;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/playlist")
@Produces({ MediaType.APPLICATION_JSON })
public class PlaylistResource {
@ -28,7 +36,7 @@ public class PlaylistResource {
@GET
@RolesAllowed("USER")
public List<Playlist> get() throws Exception {
return SqlWrapper.gets(Playlist.class, false);
return SqlWrapper.gets(Playlist.class);
}
@POST
@ -51,7 +59,7 @@ public class PlaylistResource {
@Path("{id}")
@RolesAllowed("ADMIN")
public Response delete(@PathParam("id") Long id) throws Exception {
SqlWrapper.setDelete(Playlist.class, id);
SqlWrapper.delete(Playlist.class, id);
return Response.ok().build();
}
@ -60,39 +68,32 @@ public class PlaylistResource {
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Playlist addTrack(@PathParam("id") Long id, @PathParam("trackId") Long trackId) throws Exception {
SqlWrapper.removeLink(Playlist.class, id, "track", trackId);
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
return SqlWrapper.get(Playlist.class, id);
}
@GET
@Path("{id}/rm_track/{trackId}")
@RolesAllowed("ADMIN")
public Playlist removeTrack(@PathParam("id") Long id, @PathParam("trackId") Long trackId) throws Exception {
SqlWrapper.removeLink(Playlist.class, id, "track", trackId);
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
return SqlWrapper.get(Playlist.class, id);
}
@POST
@Path("{id}/add_cover")
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response uploadCover(@PathParam("id") Long id,
@FormDataParam("fileName") String fileName,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData
) {
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
}
@GET
@Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN")
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
SqlWrapper.removeLink(Playlist.class, id, "cover", coverId);
AddOnManyToMany.removeLink(Playlist.class, id, "cover", coverId);
return Response.ok(SqlWrapper.get(Playlist.class, id)).build();
}
}

View File

@ -1,26 +1,35 @@
package org.kar.karusic.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.karusic.model.Album;
import org.kar.karusic.model.Artist;
import org.kar.archidata.model.Data;
import org.kar.karusic.model.Gender;
import org.kar.karusic.model.Track;
import org.kar.archidata.SqlWrapper;
import org.kar.archidata.util.DataTools;
import org.kar.archidata.annotation.security.RolesAllowed;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.kar.archidata.annotation.security.RolesAllowed;
import org.kar.archidata.model.Data;
import org.kar.archidata.sqlWrapper.QuerryCondition;
import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.DataTools;
import org.kar.karusic.model.Album;
import org.kar.karusic.model.Artist;
import org.kar.karusic.model.Gender;
import org.kar.karusic.model.Track;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/track")
@Produces({ MediaType.APPLICATION_JSON })
public class TrackResource {
@ -35,7 +44,7 @@ public class TrackResource {
@GET
@RolesAllowed("USER")
public List<Track> get() throws Exception {
return SqlWrapper.gets(Track.class, false);
return SqlWrapper.gets(Track.class);
}
@POST
@ -58,7 +67,7 @@ public class TrackResource {
@Path("{id}")
@RolesAllowed("ADMIN")
public Response delete(@PathParam("id") Long id) throws Exception {
SqlWrapper.setDelete(Track.class, id);
SqlWrapper.delete(Track.class, id);
return Response.ok().build();
}
@ -67,57 +76,43 @@ public class TrackResource {
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Track addTrack(@PathParam("id") Long id, @PathParam("artistId") Long artistId) throws Exception {
SqlWrapper.removeLink(Track.class, id, "artist", artistId);
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
return SqlWrapper.get(Track.class, id);
}
@GET
@Path("{id}/rm_artist/{trackId}")
@RolesAllowed("ADMIN")
public Track removeTrack(@PathParam("id") Long id, @PathParam("artistId") Long artistId) throws Exception {
SqlWrapper.removeLink(Track.class, id, "artist", artistId);
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
return SqlWrapper.get(Track.class, id);
}
@POST
@Path("{id}/add_cover")
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response uploadCover(@PathParam("id") Long id,
@FormDataParam("fileName") String fileName,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData
) {
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
}
@GET
@Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN")
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
SqlWrapper.removeLink(Track.class, id, "cover", coverId);
AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
return Response.ok(SqlWrapper.get(Track.class, id)).build();
}
@POST
@Path("/upload/")
@RolesAllowed("ADMIN")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response uploadFile(@FormDataParam("fileName") String fileName,
@FormDataParam("gender") String gender,
@FormDataParam("artist") String artist,
public Response uploadFile(@FormDataParam("fileName") String fileName, @FormDataParam("gender") String gender, @FormDataParam("artist") String artist,
//@FormDataParam("seriesId") String seriesId, Not used ...
@FormDataParam("album") String album,
@FormDataParam("trackId") String trackId,
@FormDataParam("title") String title,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData
) {
@FormDataParam("album") String album, @FormDataParam("trackId") String trackId, @FormDataParam("title") String title, @FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
try {
// correct input string stream :
fileName = DataTools.multipartCorrection(fileName);
@ -177,7 +172,7 @@ public class TrackResource {
System.out.println("Find typeNode");
Gender genderElem = null;
if (gender != null) {
genderElem = SqlWrapper.getWith(Gender.class, "name", gender);
genderElem = SqlWrapper.getWhere(Gender.class, new QuerryCondition("name", "=", gender));
if (genderElem == null) {
genderElem = new Gender();
genderElem.name = gender;
@ -193,7 +188,7 @@ public class TrackResource {
Artist artistElem = null;
if (artist != null) {
artistElem = SqlWrapper.getWith(Artist.class, "name", artist);
artistElem = SqlWrapper.getWhere(Artist.class, new QuerryCondition("name", "=", artist));
if (artistElem == null) {
artistElem = new Artist();
artistElem.name = artist;
@ -204,7 +199,7 @@ public class TrackResource {
Album albumElem = null;
if (album != null) {
albumElem = SqlWrapper.getWith(Album.class, "name", album);
albumElem = SqlWrapper.getWhere(Album.class, new QuerryCondition("name", "=", album));
if (albumElem == null) {
albumElem = new Album();
albumElem.name = album;
@ -213,7 +208,6 @@ public class TrackResource {
}
System.out.println(" ==> " + album);
System.out.println("add media");
Track trackElem = new Track();
@ -238,12 +232,8 @@ public class TrackResource {
} catch (Exception ex) {
System.out.println("Catch an unexpected error ... " + ex.getMessage());
ex.printStackTrace();
return Response.status(417).
entity("Back-end error : " + ex.getMessage()).
type("text/plain").
build();
return Response.status(417).entity("Back-end error : " + ex.getMessage()).type("text/plain").build();
}
}
}

View File

@ -1,20 +1,23 @@
package org.kar.karusic.api;
import org.kar.archidata.SqlWrapper;
import java.util.List;
import org.kar.archidata.annotation.security.RolesAllowed;
import org.kar.archidata.filter.GenericContext;
import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.karusic.model.UserKarusic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.kar.archidata.annotation.security.RolesAllowed;
import jakarta.ws.rs.*;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.SecurityContext;
import java.util.List;
@Path("/users")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ -25,6 +28,7 @@ public class UserResource {
public class UserOut {
public long id;
public String login;
public UserOut(long id, String login) {
super();
this.id = id;
@ -33,8 +37,7 @@ public class UserResource {
}
public UserResource() {
}
public UserResource() {}
// curl http://localhost:9993/api/users
@GET
@ -42,7 +45,7 @@ public class UserResource {
public List<UserKarusic> getUsers() {
System.out.println("getUsers");
try {
return SqlWrapper.gets(UserKarusic.class, false);
return SqlWrapper.gets(UserKarusic.class);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -69,7 +72,6 @@ public class UserResource {
return null;
}
@GET
@Path("me")
@RolesAllowed("USER")
@ -80,35 +82,3 @@ public class UserResource {
return new UserOut(gc.userByToken.id, gc.userByToken.name);
}
}

View File

@ -1,4 +1,5 @@
package org.kar.karusic.model;
/*
CREATE TABLE `node` (
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
@ -14,11 +15,12 @@ CREATE TABLE `node` (
import java.sql.Date;
import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.SQLTableName;
import com.fasterxml.jackson.annotation.JsonInclude;
@SQLTableName ("album")
import jakarta.persistence.Table;
@Table(name = "album")
@SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Album extends NodeSmall {

View File

@ -12,30 +12,29 @@ CREATE TABLE `node` (
) AUTO_INCREMENT=10;
*/
import java.sql.Date;
import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.SQLLimitSize;
import org.kar.archidata.annotation.SQLTableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.sql.Date;
import jakarta.persistence.Column;
import jakarta.persistence.Table;
@SQLTableName ("artist")
@Table(name = "artist")
@SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Artist extends NodeSmall {
@SQLLimitSize(256)
@Column(length = 256)
public String firstName = null;
@SQLLimitSize(256)
@Column(length = 256)
public String surname = null;
public Date birth = null;
public Date death = null;
@Override
public String toString() {
return "Artist [id=" + id + ", name=" + name + ", description=" + description + ", covers=" + covers +
", firstName=" + firstName + ", surname=" + surname + ", birth=" + birth + ", death=" + death + "]";
return "Artist [id=" + id + ", name=" + name + ", description=" + description + ", covers=" + covers + ", firstName=" + firstName + ", surname=" + surname + ", birth=" + birth + ", death="
+ death + "]";
}
}

View File

@ -13,11 +13,12 @@ CREATE TABLE `node` (
*/
import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.SQLTableName;
import com.fasterxml.jackson.annotation.JsonInclude;
@SQLTableName ("gender")
import jakarta.persistence.Table;
@Table(name = "gender")
@SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Gender extends NodeSmall {

View File

@ -14,17 +14,20 @@ CREATE TABLE `node` (
import java.util.List;
import org.kar.archidata.annotation.SQLLimitSize;
import org.kar.archidata.annotation.SQLTableLinkGeneric;
import org.kar.archidata.model.Data;
import org.kar.archidata.model.GenericTable;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToMany;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NodeSmall extends GenericTable {
@SQLLimitSize(256)
@Column(length = 256)
public String name = null;
public String description = null;
@SQLTableLinkGeneric
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
public List<Long> covers = null;
}

View File

@ -15,15 +15,17 @@ CREATE TABLE `node` (
import java.util.List;
import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.SQLTableLinkGeneric;
import org.kar.archidata.annotation.SQLTableName;
import com.fasterxml.jackson.annotation.JsonInclude;
@SQLTableName ("playlist")
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.Table;
@Table(name = "playlist")
@SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Playlist extends NodeSmall {
@SQLTableLinkGeneric
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Track.class)
public List<Long> tracks = null;
}

View File

@ -15,12 +15,14 @@ CREATE TABLE `node` (
import java.util.List;
import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.SQLTableLinkGeneric;
import org.kar.archidata.annotation.SQLTableName;
import com.fasterxml.jackson.annotation.JsonInclude;
@SQLTableName ("track")
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.Table;
@Table(name = "track")
@SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Track extends NodeSmall {
@ -28,12 +30,12 @@ public class Track extends NodeSmall {
public Long albumId = null;
public Long track = null;
public Long dataId = null;
@SQLTableLinkGeneric(SQLTableLinkGeneric.ModelLink.INTERNAL)
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Artist.class)
public List<Long> artists = null;
@Override
public String toString() {
return "Track [id=" + id + ", deleted=" + deleted + ", create_date=" + create_date + ", modify_date="
+ modify_date + ", name=" + name + ", description=" + description + ", covers=" + covers + ", genderId="
+ genderId + ", albumId=" + albumId + ", track=" + track + ", dataId=" + dataId + ", artists=" + artists + "]";
return "Track [id=" + id + ", deleted=" + deleted + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + ", name=" + name + ", description=" + description + ", covers=" + covers
+ ", genderId=" + genderId + ", albumId=" + albumId + ", track=" + track + ", dataId=" + dataId + ", artists=" + artists + "]";
}
}

View File

@ -1,12 +1,13 @@
package org.kar.karusic.model;
import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.SQLTableName;
import org.kar.archidata.model.User;
import com.fasterxml.jackson.annotation.JsonInclude;
@SQLTableName ("user")
import jakarta.persistence.Table;
@Table(name = "user")
@SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserKarusic extends User {

View File

@ -8,15 +8,12 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select
import { AppRoutingModule } from './app-routing.module';
import { AsyncActionStatusComponent, BurgerPropertyComponent, CheckboxComponent, EntryComponent, EntryNumberComponent, EntryValidatorComponent, ErrorComponent, ErrorMessageStateComponent, PasswordEntryComponent, PopInComponent, RenderFormComponent, RenderSettingsComponent, SpinerComponent, TopMenuComponent, UploadFileComponent } from 'common/component/';
import { ElementDataImageComponent } from './component/data-image/data-image';
import { ElementTypeComponent } from './component/element-type/element-type';
import { PopInCreateType } from './popin/create-type/create-type';
import { PopInDeleteConfirm, PopInUploadProgress } from 'common/popin';
import { AppComponent } from './app.component';
import {
@ -24,16 +21,13 @@ import {
TrackEditScene, AlbumEditScene, ArtistEditScene, ArtistsScene, ArtistAlbumScene
} from './scene';
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service';
import { BddService, CookiesService, HttpWrapperService, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service';
import { ErrorViewerScene, ForbiddenScene, HomeOutScene, NotFound404Scene, SsoScene } from 'common/scene';
import { UploadScene } from './scene/upload/upload';
import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ElementVideoComponent, ElementPlayerAudioComponent } from './component';
import { common_module_declarations, common_module_imports, common_module_providers, common_module_exports } from 'common/module';
@NgModule({
declarations: [
AppComponent,
TopMenuComponent,
UploadFileComponent,
ElementDataImageComponent,
ElementTypeComponent,
ElementSeriesComponent,
@ -41,28 +35,10 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent,
ElementSeasonComponent,
ElementVideoComponent,
ElementPlayerAudioComponent,
ErrorComponent,
PasswordEntryComponent,
EntryComponent,
EntryValidatorComponent,
SpinerComponent,
AsyncActionStatusComponent,
ErrorMessageStateComponent,
CheckboxComponent,
BurgerPropertyComponent,
RenderSettingsComponent,
RenderFormComponent,
EntryNumberComponent,
PopInComponent,
PopInCreateType,
PopInUploadProgress,
PopInDeleteConfirm,
HomeScene,
ErrorViewerScene,
HelpScene,
SsoScene,
GenderScene,
PlaylistScene,
ArtistAlbumScene,
@ -76,28 +52,16 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent,
AlbumEditScene,
ArtistEditScene,
UploadScene,
ForbiddenScene,
HomeOutScene,
NotFound404Scene,
...common_module_declarations,
],
imports: [
BrowserModule,
RouterModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
...common_module_imports,
],
providers: [
PopInService,
HttpWrapperService,
SessionService,
CookiesService,
StorageService,
UserService,
SSOService,
BddService,
PlayerService,
GenderService,
DataService,
@ -106,25 +70,16 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent,
AlbumService,
TrackService,
ArianeService,
OnlyUsersGuard,
OnlyAdminGuard,
OnlyUsersGuardHome,
OnlyUnregisteredGuardHome,
...common_module_providers,
],
exports: [
AppComponent,
TopMenuComponent,
UploadFileComponent,
ErrorComponent,
ElementTypeComponent,
ElementSeriesComponent,
ElementSeasonComponent,
ElementVideoComponent,
PopInCreateType,
PopInComponent,
PopInUploadProgress,
PopInDeleteConfirm,
...common_module_exports,
],
bootstrap: [
AppComponent

View File

@ -9,7 +9,7 @@ import { isMedia, Media } from 'app/model';
import { NodeData } from 'common/model';
import { HttpWrapperService, BddService } from 'common/service';
import { DataInterface, isArrayOf, TypeCheck } from 'common/utils';
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
@Injectable()
@ -88,7 +88,7 @@ export class TrackService extends GenericInterfaceModelDB {
formData.append('gender', gender ?? null);
formData.append('artist', artist ?? null);
formData.append('album', album ?? null);
if(trackId !== null) {
if (!isNullOrUndefined(trackId)) {
formData.append('trackId', trackId.toString());
} else {
formData.append('trackId', null);

@ -1 +1 @@
Subproject commit 9fc25b4feaeba509ff39f70b24d97be47f4b30e1
Subproject commit ea5a4f6b7537eb707916f4610bf79fbe86c6296f