[DEV] update to the new model system

This commit is contained in:
Edouard DUPIN 2024-01-19 00:42:34 +01:00
parent 511c6d0bc7
commit 516a0bbfa0
12 changed files with 283 additions and 283 deletions

View File

@ -6,8 +6,8 @@
<properties> <properties>
<maven.compiler.version>3.1</maven.compiler.version> <maven.compiler.version>3.1</maven.compiler.version>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>
<maven.dependency.version>3.1.1</maven.dependency.version> <maven.dependency.version>3.1.1</maven.dependency.version>
</properties> </properties>
<repositories> <repositories>

View File

@ -6,9 +6,9 @@ import org.slf4j.LoggerFactory;
public class WebLauncherLocal extends WebLauncher { public class WebLauncherLocal extends WebLauncher {
final Logger logger = LoggerFactory.getLogger(WebLauncherLocal.class); final Logger logger = LoggerFactory.getLogger(WebLauncherLocal.class);
private WebLauncherLocal() {} private WebLauncherLocal() {}
public static void main(final String[] args) throws InterruptedException { public static void main(final String[] args) throws InterruptedException {
final WebLauncherLocal launcher = new WebLauncherLocal(); final WebLauncherLocal launcher = new WebLauncherLocal();
launcher.process(); launcher.process();
@ -16,14 +16,14 @@ public class WebLauncherLocal extends WebLauncher {
Thread.currentThread().join(); Thread.currentThread().join();
launcher.logger.info("STOP the REST server:"); launcher.logger.info("STOP the REST server:");
} }
@Override @Override
public void process() throws InterruptedException { public void process() throws InterruptedException {
if (true) { if (true) {
// for local test: // for local test:
ConfigBaseVariable.apiAdress = "http://0.0.0.0:19080/karusic/api/"; ConfigBaseVariable.apiAdress = "http://0.0.0.0:19080/karusic/api/";
//ConfigBaseVariable.ssoAdress = "https://atria-soft.org/karso/api/"; //ConfigBaseVariable.ssoAdress = "https://atria-soft.org/karso/api/";
ConfigBaseVariable.dbPort = "3307"; ConfigBaseVariable.dbPort = "3906";
} }
try { try {
super.migrateDB(); super.migrateDB();

View File

@ -14,8 +14,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE; import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
@ -25,28 +25,28 @@ import jakarta.ws.rs.core.Response;
@Path("/album") @Path("/album")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public class AlbumResource { public class AlbumResource {
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Album getWithId(@PathParam("id") final Long id) throws Exception { public static Album getWithId(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Album.class, id); return DataAccess.get(Album.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Album> get() throws Exception { public List<Album> get() throws Exception {
return DataAccess.gets(Album.class); return DataAccess.gets(Album.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Album post(final String jsonRequest) throws Exception { public Album post(final String jsonRequest) throws Exception {
return DataAccess.insertWithJson(Album.class, jsonRequest); return DataAccess.insertWithJson(Album.class, jsonRequest);
} }
@PUT @PATCH
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -54,7 +54,7 @@ public class AlbumResource {
DataAccess.updateWithJson(Album.class, id, jsonRequest); DataAccess.updateWithJson(Album.class, id, jsonRequest);
return DataAccess.get(Album.class, id); return DataAccess.get(Album.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -62,7 +62,7 @@ public class AlbumResource {
DataAccess.delete(Album.class, id); DataAccess.delete(Album.class, id);
return Response.ok().build(); return Response.ok().build();
} }
@POST @POST
@Path("{id}/add_track/{trackId}") @Path("{id}/add_track/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -71,7 +71,7 @@ public class AlbumResource {
AddOnManyToMany.removeLink(Album.class, id, "track", trackId); AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
return DataAccess.get(Album.class, id); return DataAccess.get(Album.class, id);
} }
@GET @GET
@Path("{id}/rm_track/{trackId}") @Path("{id}/rm_track/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -79,7 +79,7 @@ public class AlbumResource {
AddOnManyToMany.removeLink(Album.class, id, "track", trackId); AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
return DataAccess.get(Album.class, id); return DataAccess.get(Album.class, id);
} }
@POST @POST
@Path("{id}/add_cover") @Path("{id}/add_cover")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -88,7 +88,7 @@ public class AlbumResource {
@FormDataParam("file") final FormDataContentDisposition fileMetaData) { @FormDataParam("file") final FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData); return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
} }
@GET @GET
@Path("{id}/rm_cover/{coverId}") @Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")

View File

@ -14,8 +14,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE; import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
@ -25,28 +25,28 @@ import jakarta.ws.rs.core.Response;
@Path("/artist") @Path("/artist")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public class ArtistResource { public class ArtistResource {
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Artist getWithId(@PathParam("id") final Long id) throws Exception { public static Artist getWithId(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Artist.class, id); return DataAccess.get(Artist.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Artist> get() throws Exception { public List<Artist> get() throws Exception {
return DataAccess.gets(Artist.class); return DataAccess.gets(Artist.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Artist put(final String jsonRequest) throws Exception { public Artist put(final String jsonRequest) throws Exception {
return DataAccess.insertWithJson(Artist.class, jsonRequest); return DataAccess.insertWithJson(Artist.class, jsonRequest);
} }
@PUT @PATCH
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -54,7 +54,7 @@ public class ArtistResource {
DataAccess.updateWithJson(Artist.class, id, jsonRequest); DataAccess.updateWithJson(Artist.class, id, jsonRequest);
return DataAccess.get(Artist.class, id); return DataAccess.get(Artist.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -62,7 +62,7 @@ public class ArtistResource {
DataAccess.delete(Artist.class, id); DataAccess.delete(Artist.class, id);
return Response.ok().build(); return Response.ok().build();
} }
@POST @POST
@Path("{id}/add_cover") @Path("{id}/add_cover")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -71,7 +71,7 @@ public class ArtistResource {
@FormDataParam("file") final FormDataContentDisposition fileMetaData) { @FormDataParam("file") final FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData); return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
} }
@GET @GET
@Path("{id}/rm_cover/{coverId}") @Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")

View File

@ -14,8 +14,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE; import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
@ -25,28 +25,28 @@ import jakarta.ws.rs.core.Response;
@Path("/gender") @Path("/gender")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public class GenderResource { public class GenderResource {
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Gender getWithId(@PathParam("id") final Long id) throws Exception { public static Gender getWithId(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Gender.class, id); return DataAccess.get(Gender.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Gender> get() throws Exception { public List<Gender> get() throws Exception {
return DataAccess.gets(Gender.class); return DataAccess.gets(Gender.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Gender put(final String jsonRequest) throws Exception { public Gender put(final String jsonRequest) throws Exception {
return DataAccess.insertWithJson(Gender.class, jsonRequest); return DataAccess.insertWithJson(Gender.class, jsonRequest);
} }
@PUT @PATCH
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -54,7 +54,7 @@ public class GenderResource {
DataAccess.updateWithJson(Gender.class, id, jsonRequest); DataAccess.updateWithJson(Gender.class, id, jsonRequest);
return DataAccess.get(Gender.class, id); return DataAccess.get(Gender.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -62,7 +62,7 @@ public class GenderResource {
DataAccess.delete(Gender.class, id); DataAccess.delete(Gender.class, id);
return Response.ok().build(); return Response.ok().build();
} }
@POST @POST
@Path("{id}/add_cover") @Path("{id}/add_cover")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -71,7 +71,7 @@ public class GenderResource {
@FormDataParam("file") final FormDataContentDisposition fileMetaData) { @FormDataParam("file") final FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData); return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
} }
@GET @GET
@Path("{id}/rm_cover/{coverId}") @Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")

View File

@ -14,8 +14,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE; import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
@ -25,28 +25,28 @@ import jakarta.ws.rs.core.Response;
@Path("/playlist") @Path("/playlist")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public class PlaylistResource { public class PlaylistResource {
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Playlist getWithId(@PathParam("id") final Long id) throws Exception { public static Playlist getWithId(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Playlist.class, id); return DataAccess.get(Playlist.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Playlist> get() throws Exception { public List<Playlist> get() throws Exception {
return DataAccess.gets(Playlist.class); return DataAccess.gets(Playlist.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Playlist put(final String jsonRequest) throws Exception { public Playlist put(final String jsonRequest) throws Exception {
return DataAccess.insertWithJson(Playlist.class, jsonRequest); return DataAccess.insertWithJson(Playlist.class, jsonRequest);
} }
@PUT @PATCH
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -54,7 +54,7 @@ public class PlaylistResource {
DataAccess.updateWithJson(Playlist.class, id, jsonRequest); DataAccess.updateWithJson(Playlist.class, id, jsonRequest);
return DataAccess.get(Playlist.class, id); return DataAccess.get(Playlist.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -62,7 +62,7 @@ public class PlaylistResource {
DataAccess.delete(Playlist.class, id); DataAccess.delete(Playlist.class, id);
return Response.ok().build(); return Response.ok().build();
} }
@POST @POST
@Path("{id}/add_track/{trackId}") @Path("{id}/add_track/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -71,7 +71,7 @@ public class PlaylistResource {
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId); AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
return DataAccess.get(Playlist.class, id); return DataAccess.get(Playlist.class, id);
} }
@GET @GET
@Path("{id}/rm_track/{trackId}") @Path("{id}/rm_track/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -79,7 +79,7 @@ public class PlaylistResource {
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId); AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
return DataAccess.get(Playlist.class, id); return DataAccess.get(Playlist.class, id);
} }
@POST @POST
@Path("{id}/add_cover") @Path("{id}/add_cover")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -88,7 +88,7 @@ public class PlaylistResource {
@FormDataParam("file") final FormDataContentDisposition fileMetaData) { @FormDataParam("file") final FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData); return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
} }
@GET @GET
@Path("{id}/rm_cover/{coverId}") @Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")

View File

@ -23,8 +23,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes; import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE; import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST; import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
@ -34,28 +34,28 @@ import jakarta.ws.rs.core.Response;
@Path("/track") @Path("/track")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public class TrackResource { public class TrackResource {
@GET @GET
@Path("{id}") @Path("{id}")
@RolesAllowed("USER") @RolesAllowed("USER")
public static Track getWithId(@PathParam("id") final Long id) throws Exception { public static Track getWithId(@PathParam("id") final Long id) throws Exception {
return DataAccess.get(Track.class, id); return DataAccess.get(Track.class, id);
} }
@GET @GET
@RolesAllowed("USER") @RolesAllowed("USER")
public List<Track> get() throws Exception { public List<Track> get() throws Exception {
return DataAccess.gets(Track.class); return DataAccess.gets(Track.class);
} }
@POST @POST
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Track create(final String jsonRequest) throws Exception { public Track create(final String jsonRequest) throws Exception {
return DataAccess.insertWithJson(Track.class, jsonRequest); return DataAccess.insertWithJson(Track.class, jsonRequest);
} }
@PUT @PATCH
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -63,7 +63,7 @@ public class TrackResource {
DataAccess.updateWithJson(Track.class, id, jsonRequest); DataAccess.updateWithJson(Track.class, id, jsonRequest);
return DataAccess.get(Track.class, id); return DataAccess.get(Track.class, id);
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -71,7 +71,7 @@ public class TrackResource {
DataAccess.delete(Track.class, id); DataAccess.delete(Track.class, id);
return Response.ok().build(); return Response.ok().build();
} }
@POST @POST
@Path("{id}/add_artist/{artistId}") @Path("{id}/add_artist/{artistId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -80,7 +80,7 @@ public class TrackResource {
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId); AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
return DataAccess.get(Track.class, id); return DataAccess.get(Track.class, id);
} }
@GET @GET
@Path("{id}/rm_artist/{trackId}") @Path("{id}/rm_artist/{trackId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -88,7 +88,7 @@ public class TrackResource {
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId); AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
return DataAccess.get(Track.class, id); return DataAccess.get(Track.class, id);
} }
@POST @POST
@Path("{id}/add_cover") @Path("{id}/add_cover")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -97,7 +97,7 @@ public class TrackResource {
@FormDataParam("file") final FormDataContentDisposition fileMetaData) { @FormDataParam("file") final FormDataContentDisposition fileMetaData) {
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData); return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
} }
@GET @GET
@Path("{id}/rm_cover/{coverId}") @Path("{id}/rm_cover/{coverId}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -105,7 +105,7 @@ public class TrackResource {
AddOnManyToMany.removeLink(Track.class, id, "cover", coverId); AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
return Response.ok(DataAccess.get(Track.class, id)).build(); return Response.ok(DataAccess.get(Track.class, id)).build();
} }
@POST @POST
@Path("/upload/") @Path("/upload/")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@ -122,7 +122,7 @@ public class TrackResource {
album = DataTools.multipartCorrection(album); album = DataTools.multipartCorrection(album);
trackId = DataTools.multipartCorrection(trackId); trackId = DataTools.multipartCorrection(trackId);
title = DataTools.multipartCorrection(title); title = DataTools.multipartCorrection(title);
//public NodeSmall uploadFile(final FormDataMultiPart form) { //public NodeSmall uploadFile(final FormDataMultiPart form) {
System.out.println("Upload media file: " + fileMetaData); System.out.println("Upload media file: " + fileMetaData);
System.out.println(" - fileName: " + fileName); System.out.println(" - fileName: " + fileName);
@ -142,7 +142,7 @@ public class TrackResource {
build(); build();
} }
*/ */
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(sha512);
@ -186,7 +186,7 @@ public class TrackResource {
// return Response.notModified("TypeId does not exist ...").build(); // return Response.notModified("TypeId does not exist ...").build();
// } // }
System.out.println(" ==> " + genderElem); System.out.println(" ==> " + genderElem);
Artist artistElem = null; Artist artistElem = null;
if (artist != null) { if (artist != null) {
artistElem = DataAccess.getWhere(Artist.class, new Condition(new QueryCondition("name", "=", artist))); artistElem = DataAccess.getWhere(Artist.class, new Condition(new QueryCondition("name", "=", artist)));
@ -197,7 +197,7 @@ public class TrackResource {
} }
} }
System.out.println(" ==> " + artistElem); System.out.println(" ==> " + artistElem);
Album albumElem = null; Album albumElem = null;
if (album != null) { if (album != null) {
albumElem = DataAccess.getWhere(Album.class, new Condition(new QueryCondition("name", "=", album))); albumElem = DataAccess.getWhere(Album.class, new Condition(new QueryCondition("name", "=", album)));
@ -208,9 +208,9 @@ public class TrackResource {
} }
} }
System.out.println(" ==> " + album); System.out.println(" ==> " + album);
System.out.println("add media"); System.out.println("add media");
Track trackElem = new Track(); Track trackElem = new Track();
trackElem.name = title; trackElem.name = title;
trackElem.track = trackId != null ? Long.parseLong(trackId) : null; trackElem.track = trackId != null ? Long.parseLong(trackId) : null;
@ -236,5 +236,5 @@ public class TrackResource {
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

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AlbumService , ArianeService, DataService} from 'app/service'; import { AlbumService, ArianeService, DataService } from 'app/service';
import { NodeData } from 'common/model'; import { NodeData } from 'common/model';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
@ -20,18 +20,18 @@ export interface ElementList {
@Component({ @Component({
selector: 'app-album-edit', selector: 'app-album-edit',
templateUrl: './album-edit.html', templateUrl: './album-edit.html',
styleUrls: [ './album-edit.less' ] styleUrls: ['./album-edit.less']
}) })
export class AlbumEditScene implements OnInit { export class AlbumEditScene implements OnInit {
idAlbum: number = -1; idAlbum: number = -1;
itemIsRemoved:boolean = false; itemIsRemoved: boolean = false;
itemIsNotFound:boolean = false; itemIsNotFound: boolean = false;
itemIsLoading:boolean = true; itemIsLoading: boolean = true;
error:string = ''; error: string = '';
nameAlbum:string; nameAlbum: string;
description: string = ''; description: string = '';
coverFile: File; coverFile: File;
uploadFileValue: string = ''; uploadFileValue: string = '';
@ -48,11 +48,11 @@ export class AlbumEditScene implements OnInit {
private deleteCoverId: number = null; private deleteCoverId: number = null;
private deleteItemId: number = null; private deleteItemId: number = null;
deleteConfirmed() { deleteConfirmed() {
if(this.deleteCoverId !== null) { if (this.deleteCoverId !== null) {
this.removeCoverAfterConfirm(this.deleteCoverId); this.removeCoverAfterConfirm(this.deleteCoverId);
this.cleanConfirm(); this.cleanConfirm();
} }
if(this.deleteItemId !== null) { if (this.deleteItemId !== null) {
this.removeItemAfterConfirm(this.deleteItemId); this.removeItemAfterConfirm(this.deleteItemId);
this.cleanConfirm(); this.cleanConfirm();
} }
@ -66,9 +66,9 @@ export class AlbumEditScene implements OnInit {
constructor( constructor(
private albumService: AlbumService, private albumService: AlbumService,
private arianeService: ArianeService, private arianeService: ArianeService,
private popInService: PopInService, private popInService: PopInService,
private dataService: DataService) { private dataService: DataService) {
} }
@ -78,7 +78,7 @@ export class AlbumEditScene implements OnInit {
let self = this; let self = this;
this.albumService.get(this.idAlbum) this.albumService.get(this.idAlbum)
.then((response: NodeData) => { .then((response: NodeData) => {
console.log(`get response of album : ${ JSON.stringify(response, null, 2)}`); console.log(`get response of album : ${JSON.stringify(response, null, 2)}`);
self.nameAlbum = response.name; self.nameAlbum = response.name;
self.description = response.description; self.description = response.description;
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
@ -92,44 +92,44 @@ export class AlbumEditScene implements OnInit {
self.itemIsLoading = false; self.itemIsLoading = false;
}); });
this.albumService.getTrack(this.idAlbum) this.albumService.getTrack(this.idAlbum)
.then((response:any) => { .then((response: any) => {
self.trackCount = response.length; self.trackCount = response.length;
}).catch((response:any) => { }).catch((response: any) => {
self.trackCount = '---'; self.trackCount = '---';
}); });
} }
updateCoverList(covers: any) { updateCoverList(covers: any) {
this.coversDisplay = []; this.coversDisplay = [];
if(covers !== undefined && covers !== null) { if (covers !== undefined && covers !== null) {
for(let iii = 0; iii < covers.length; iii++) { for (let iii = 0; iii < covers.length; iii++) {
this.coversDisplay.push({ this.coversDisplay.push({
id:covers[iii], id: covers[iii],
url:this.dataService.getCoverThumbnailUrl(covers[iii]) url: this.dataService.getCoverThumbnailUrl(covers[iii])
}); });
} }
} else { } else {
this.coversDisplay = []; this.coversDisplay = [];
} }
} }
onName(value:any):void { onName(value: any): void {
this.nameAlbum = value; this.nameAlbum = value;
} }
onDescription(value:any):void { onDescription(value: any): void {
this.description = value; this.description = value;
} }
sendValues():void { sendValues(): void {
console.log('send new values....'); console.log('send new values....');
let data = { let data = {
name: this.nameAlbum, name: this.nameAlbum,
description: this.description description: this.description
}; };
if(this.description === undefined) { if (this.description === undefined) {
data.description = null; data.description = null;
} }
this.albumService.put(this.idAlbum, data); this.albumService.patch(this.idAlbum, data);
} }
// At the drag drop area // At the drag drop area
@ -148,15 +148,15 @@ export class AlbumEditScene implements OnInit {
// At the file input element // At the file input element
// (change)="selectFile($event)" // (change)="selectFile($event)"
onChangeCover(value:any):void { onChangeCover(value: any): void {
this.selectedFiles = value.files; this.selectedFiles = value.files;
this.coverFile = this.selectedFiles[0]; this.coverFile = this.selectedFiles[0];
console.log(`select file ${ this.coverFile.name}`); console.log(`select file ${this.coverFile.name}`);
this.uploadCover(this.coverFile); this.uploadCover(this.coverFile);
} }
uploadCover(file:File) { uploadCover(file: File) {
if(file === undefined) { if (file === undefined) {
console.log('No file selected!'); console.log('No file selected!');
return; return;
} }
@ -166,35 +166,35 @@ export class AlbumEditScene implements OnInit {
// display the upload pop-in // display the upload pop-in
this.popInService.open('popin-upload-progress'); this.popInService.open('popin-upload-progress');
this.albumService.uploadCover(file, this.idAlbum, (count, total) => { this.albumService.uploadCover(file, this.idAlbum, (count, total) => {
self.upload.mediaSendSize = count; self.upload.mediaSendSize = count;
self.upload.mediaSize = total; self.upload.mediaSize = total;
}) })
.then((response:any) => { .then((response: any) => {
self.upload.result = 'Cover added done'; self.upload.result = 'Cover added done';
// we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch((response:any) => { }).catch((response: any) => {
// self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log('Can not add the cover in the track...'); console.log('Can not add the cover in the track...');
}); });
} }
removeCover(id:number) { removeCover(id: number) {
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${ id}`; this.confirmDeleteComment = `Delete the cover ID: ${id}`;
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id); this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
this.deleteCoverId = id; this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm'); this.popInService.open('popin-delete-confirm');
} }
removeCoverAfterConfirm(id:number) { removeCoverAfterConfirm(id: number) {
console.log(`Request remove cover: ${ id}`); console.log(`Request remove cover: ${id}`);
let self = this; let self = this;
this.albumService.deleteCover(this.idAlbum, id) this.albumService.deleteCover(this.idAlbum, id)
.then((response:any) => { .then((response: any) => {
self.upload.result = 'Cover remove done'; self.upload.result = 'Cover remove done';
// we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch((response:any) => { }).catch((response: any) => {
// self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log('Can not remove the cover of the track...'); console.log('Can not remove the cover of the track...');
}); });
@ -203,11 +203,11 @@ export class AlbumEditScene implements OnInit {
removeItem() { removeItem() {
console.log('Request remove Media...'); console.log('Request remove Media...');
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = `Delete the Album: ${ this.idAlbum}`; this.confirmDeleteComment = `Delete the Album: ${this.idAlbum}`;
this.deleteItemId = this.idAlbum; this.deleteItemId = this.idAlbum;
this.popInService.open('popin-delete-confirm'); this.popInService.open('popin-delete-confirm');
} }
removeItemAfterConfirm(id:number) { removeItemAfterConfirm(id: number) {
let self = this; let self = this;
this.albumService.delete(id) this.albumService.delete(id)
.then((response3) => { .then((response3) => {

View File

@ -20,30 +20,30 @@ export class ElementList {
@Component({ @Component({
selector: 'app-artist-edit', selector: 'app-artist-edit',
templateUrl: './artist-edit.html', templateUrl: './artist-edit.html',
styleUrls: [ './artist-edit.less' ] styleUrls: ['./artist-edit.less']
}) })
export class ArtistEditScene implements OnInit { export class ArtistEditScene implements OnInit {
idArtist:number = -1; idArtist: number = -1;
itemIsRemoved:boolean = false; itemIsRemoved: boolean = false;
itemIsNotFound:boolean = false; itemIsNotFound: boolean = false;
itemIsLoading:boolean = true; itemIsLoading: boolean = true;
error:string = ''; error: string = '';
typeId:number = null; typeId: number = null;
name:string = ''; name: string = '';
description:string = ''; description: string = '';
coverFile:File; coverFile: File;
uploadFileValue:string = ''; uploadFileValue: string = '';
selectedFiles:FileList; selectedFiles: FileList;
albumsCount: string = null; albumsCount: string = null;
trackCount: string = null; trackCount: string = null;
coversDisplay:Array<any> = []; coversDisplay: Array<any> = [];
// section tha define the upload value to display in the pop-in of upload // section tha define the upload value to display in the pop-in of upload
public upload:UploadProgress = new UploadProgress(); public upload: UploadProgress = new UploadProgress();
listType: ElementList[] = [ listType: ElementList[] = [
@ -51,16 +51,16 @@ export class ArtistEditScene implements OnInit {
]; ];
// --------------- confirm section ------------------ // --------------- confirm section ------------------
public confirmDeleteComment:string = null; public confirmDeleteComment: string = null;
public confirmDeleteImageUrl:string = null; public confirmDeleteImageUrl: string = null;
private deleteCoverId:number = null; private deleteCoverId: number = null;
private deleteItemId:number = null; private deleteItemId: number = null;
deleteConfirmed() { deleteConfirmed() {
if(this.deleteCoverId !== null) { if (this.deleteCoverId !== null) {
this.removeCoverAfterConfirm(this.deleteCoverId); this.removeCoverAfterConfirm(this.deleteCoverId);
this.cleanConfirm(); this.cleanConfirm();
} }
if(this.deleteItemId !== null) { if (this.deleteItemId !== null) {
this.removeItemAfterConfirm(this.deleteItemId); this.removeItemAfterConfirm(this.deleteItemId);
this.cleanConfirm(); this.cleanConfirm();
} }
@ -74,25 +74,25 @@ export class ArtistEditScene implements OnInit {
constructor(private dataService: DataService, constructor(private dataService: DataService,
private typeService: GenderService, private typeService: GenderService,
private artistService: ArtistService, private artistService: ArtistService,
private arianeService: ArianeService, private arianeService: ArianeService,
private popInService: PopInService) { private popInService: PopInService) {
} }
ngOnInit() { ngOnInit() {
this.idArtist = this.arianeService.getArtistId(); this.idArtist = this.arianeService.getArtistId();
let self = this; let self = this;
this.listType = [ { value: null, label: '---' } ]; this.listType = [{ value: null, label: '---' }];
this.typeService.getData() this.typeService.getData()
.then((response2) => { .then((response2) => {
for(let iii = 0; iii < response2.length; iii++) { for (let iii = 0; iii < response2.length; iii++) {
self.listType.push({ value: response2[iii].id, label: response2[iii].name }); self.listType.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch((response2) => { }).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
}); });
this.artistService.get(this.idArtist) this.artistService.get(this.idArtist)
@ -112,7 +112,7 @@ export class ArtistEditScene implements OnInit {
self.itemIsNotFound = true; self.itemIsNotFound = true;
self.itemIsLoading = false; self.itemIsLoading = false;
}); });
console.log(`get parameter id: ${ this.idArtist}`); console.log(`get parameter id: ${this.idArtist}`);
this.artistService.getAlbum(this.idArtist) this.artistService.getAlbum(this.idArtist)
.then((response) => { .then((response) => {
self.albumsCount = "" + response.length; self.albumsCount = "" + response.length;
@ -129,11 +129,11 @@ export class ArtistEditScene implements OnInit {
updateCoverList(covers: any) { updateCoverList(covers: any) {
this.coversDisplay = []; this.coversDisplay = [];
if(covers !== undefined && covers !== null) { if (covers !== undefined && covers !== null) {
for(let iii = 0; iii < covers.length; iii++) { for (let iii = 0; iii < covers.length; iii++) {
this.coversDisplay.push({ this.coversDisplay.push({
id:covers[iii], id: covers[iii],
url:this.dataService.getCoverThumbnailUrl(covers[iii]) url: this.dataService.getCoverThumbnailUrl(covers[iii])
}); });
} }
} else { } else {
@ -141,33 +141,33 @@ export class ArtistEditScene implements OnInit {
} }
} }
onName(value:any):void { onName(value: any): void {
this.name = value; this.name = value;
} }
onDescription(value:any):void { onDescription(value: any): void {
this.description = value; this.description = value;
} }
onChangeType(value:any):void { onChangeType(value: any): void {
console.log(`Change requested of type ... ${ value}`); console.log(`Change requested of type ... ${value}`);
this.typeId = value; this.typeId = value;
if(this.typeId === undefined) { if (this.typeId === undefined) {
this.typeId = null; this.typeId = null;
} }
} }
sendValues():void { sendValues(): void {
console.log('send new values....'); console.log('send new values....');
let data = { let data = {
parentId: this.typeId, parentId: this.typeId,
name: this.name, name: this.name,
description: this.description description: this.description
}; };
if(this.description === undefined) { if (this.description === undefined) {
data.description = null; data.description = null;
} }
this.artistService.put(this.idArtist, data); this.artistService.patch(this.idArtist, data);
} }
// At the drag drop area // At the drag drop area
@ -186,15 +186,15 @@ export class ArtistEditScene implements OnInit {
// At the file input element // At the file input element
// (change)="selectFile($event)" // (change)="selectFile($event)"
onChangeCover(value:any):void { onChangeCover(value: any): void {
this.selectedFiles = value.files; this.selectedFiles = value.files;
this.coverFile = this.selectedFiles[0]; this.coverFile = this.selectedFiles[0];
console.log(`select file ${ this.coverFile.name}`); console.log(`select file ${this.coverFile.name}`);
this.uploadCover(this.coverFile); this.uploadCover(this.coverFile);
} }
uploadCover(file:File) { uploadCover(file: File) {
if(file === undefined) { if (file === undefined) {
console.log('No file selected!'); console.log('No file selected!');
return; return;
} }
@ -204,34 +204,34 @@ export class ArtistEditScene implements OnInit {
// display the upload pop-in // display the upload pop-in
this.popInService.open('popin-upload-progress'); this.popInService.open('popin-upload-progress');
this.artistService.uploadCover(file, this.idArtist, (count, total) => { this.artistService.uploadCover(file, this.idArtist, (count, total) => {
self.upload.mediaSendSize = count; self.upload.mediaSendSize = count;
self.upload.mediaSize = total; self.upload.mediaSize = total;
}) })
.then((response:any) => { .then((response: any) => {
self.upload.result = 'Cover added done'; self.upload.result = 'Cover added done';
// we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch((response:any) => { }).catch((response: any) => {
// self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log('Can not add the cover in the track...'); console.log('Can not add the cover in the track...');
}); });
} }
removeCover(id:number) { removeCover(id: number) {
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${ id}`; this.confirmDeleteComment = `Delete the cover ID: ${id}`;
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id); this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
this.deleteCoverId = id; this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm'); this.popInService.open('popin-delete-confirm');
} }
removeCoverAfterConfirm(id:number) { removeCoverAfterConfirm(id: number) {
console.log(`Request remove cover: ${ id}`); console.log(`Request remove cover: ${id}`);
let self = this; let self = this;
this.artistService.deleteCover(this.idArtist, id) this.artistService.deleteCover(this.idArtist, id)
.then((response:any) => { .then((response: any) => {
self.upload.result = 'Cover remove done'; self.upload.result = 'Cover remove done';
// we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch((response:any) => { }).catch((response: any) => {
// self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log('Can not remove the cover of the track...'); console.log('Can not remove the cover of the track...');
}); });
@ -239,11 +239,11 @@ export class ArtistEditScene implements OnInit {
removeItem() { removeItem() {
console.log('Request remove Media...'); console.log('Request remove Media...');
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = `Delete the Artist: ${ this.idArtist}`; this.confirmDeleteComment = `Delete the Artist: ${this.idArtist}`;
this.deleteItemId = this.idArtist; this.deleteItemId = this.idArtist;
this.popInService.open('popin-delete-confirm'); this.popInService.open('popin-delete-confirm');
} }
removeItemAfterConfirm(_id:number) { removeItemAfterConfirm(_id: number) {
let self = this; let self = this;
this.artistService.delete(_id) this.artistService.delete(_id)
.then((response3) => { .then((response3) => {

View File

@ -20,14 +20,14 @@ export interface ElementList {
class DataToSend { class DataToSend {
name:string = ''; name: string = '';
description:string = ''; description: string = '';
track?:number; track?: number;
artistId:number = null; artistId: number = null;
albumId:number = null; albumId: number = null;
dataId:number = -1; dataId: number = -1;
genderId:number = null; genderId: number = null;
generatedName:string = ''; generatedName: string = '';
clone() { clone() {
let tmp = new DataToSend(); let tmp = new DataToSend();
tmp.name = this.name; tmp.name = this.name;
@ -48,25 +48,25 @@ class DataToSend {
}) })
export class TrackEditScene implements OnInit { export class TrackEditScene implements OnInit {
idTrack:number = -1; idTrack: number = -1;
itemIsRemoved:boolean = false; itemIsRemoved: boolean = false;
itemIsNotFound:boolean = false; itemIsNotFound: boolean = false;
itemIsLoading:boolean = true; itemIsLoading: boolean = true;
error:string = ''; error: string = '';
data:DataToSend = new DataToSend(); data: DataToSend = new DataToSend();
dataOri:DataToSend = new DataToSend(); dataOri: DataToSend = new DataToSend();
needSend:boolean = false; needSend: boolean = false;
// section tha define the upload value to display in the pop-in of upload // section tha define the upload value to display in the pop-in of upload
upload:UploadProgress = new UploadProgress(); upload: UploadProgress = new UploadProgress();
// --------------- confirm section ------------------ // --------------- confirm section ------------------
public confirmDeleteComment:string = null; public confirmDeleteComment: string = null;
public confirmDeleteImageUrl:string = null; public confirmDeleteImageUrl: string = null;
private deleteCoverId:number = null; private deleteCoverId: number = null;
private deleteMediaId:number = null; private deleteMediaId: number = null;
// to create new album/artist/gender: // to create new album/artist/gender:
private albumInputNew: string; private albumInputNew: string;
@ -75,7 +75,7 @@ export class TrackEditScene implements OnInit {
deleteConfirmed() { deleteConfirmed() {
if(this.deleteMediaId !== null) { if (this.deleteMediaId !== null) {
this.removeItemAfterConfirm(this.deleteMediaId); this.removeItemAfterConfirm(this.deleteMediaId);
this.cleanConfirm(); this.cleanConfirm();
} }
@ -97,34 +97,34 @@ export class TrackEditScene implements OnInit {
{ value: undefined, label: '---' }, { value: undefined, label: '---' },
]; ];
constructor( constructor(
private genderService: GenderService, private genderService: GenderService,
private albumService: AlbumService, private albumService: AlbumService,
private artistService: ArtistService, private artistService: ArtistService,
private trackService: TrackService, private trackService: TrackService,
private arianeService: ArianeService, private arianeService: ArianeService,
private popInService: PopInService, private popInService: PopInService,
private dataService: DataService) { private dataService: DataService) {
} }
updateNeedSend(): boolean { updateNeedSend(): boolean {
this.needSend = false; this.needSend = false;
if(this.data.name !== this.dataOri.name) { if (this.data.name !== this.dataOri.name) {
this.needSend = true; this.needSend = true;
} }
if(this.data.description !== this.dataOri.description) { if (this.data.description !== this.dataOri.description) {
this.needSend = true; this.needSend = true;
} }
if(this.data.track !== this.dataOri.track) { if (this.data.track !== this.dataOri.track) {
this.needSend = true; this.needSend = true;
} }
if(this.data.genderId !== this.dataOri.genderId) { if (this.data.genderId !== this.dataOri.genderId) {
this.needSend = true; this.needSend = true;
} }
if(this.data.artistId !== this.dataOri.artistId) { if (this.data.artistId !== this.dataOri.artistId) {
this.needSend = true; this.needSend = true;
} }
if(this.data.albumId !== this.dataOri.albumId) { if (this.data.albumId !== this.dataOri.albumId) {
this.needSend = true; this.needSend = true;
} }
return this.needSend; return this.needSend;
@ -133,39 +133,39 @@ export class TrackEditScene implements OnInit {
ngOnInit() { ngOnInit() {
this.idTrack = this.arianeService.getTrackId(); this.idTrack = this.arianeService.getTrackId();
let self = this; let self = this;
this.listGender = [ { value: null, label: '---' } ]; this.listGender = [{ value: null, label: '---' }];
this.listArtist = [ { value: null, label: '---' } ]; this.listArtist = [{ value: null, label: '---' }];
this.listAlbum = [ { value: null, label: '---' } ]; this.listAlbum = [{ value: null, label: '---' }];
this.genderService.getOrder() this.genderService.getOrder()
.then((response2) => { .then((response2) => {
for(let iii = 0; iii < response2.length; iii++) { for (let iii = 0; iii < response2.length; iii++) {
self.listGender.push({ value: response2[iii].id, label: response2[iii].name }); self.listGender.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch((response2) => { }).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
}); });
// this.artistService.getOrder() // this.artistService.getOrder()
this.artistService.getOrder() this.artistService.getOrder()
.then((response3) => { .then((response3) => {
for(let iii = 0; iii < response3.length; iii++) { for (let iii = 0; iii < response3.length; iii++) {
self.listArtist.push({ value: response3[iii].id, label: response3[iii].name }); self.listArtist.push({ value: response3[iii].id, label: response3[iii].name });
console.log(`[${ self.data.dataId }] Get artist: ${ response3[iii].id }, label:${ response3[iii].name}`); console.log(`[${self.data.dataId}] Get artist: ${response3[iii].id}, label:${response3[iii].name}`);
} }
}).catch((response3) => { }).catch((response3) => {
console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`); console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
}); });
this.albumService.getOrder() this.albumService.getOrder()
.then((response3) => { .then((response3) => {
for(let iii = 0; iii < response3.length; iii++) { for (let iii = 0; iii < response3.length; iii++) {
self.listAlbum.push({ value: response3[iii].id, label: response3[iii].name }); self.listAlbum.push({ value: response3[iii].id, label: response3[iii].name });
console.log(`[${ self.data.dataId }] Get artist: ${ response3[iii].id }, label:${ response3[iii].name}`); console.log(`[${self.data.dataId}] Get artist: ${response3[iii].id}, label:${response3[iii].name}`);
} }
}).catch((response3) => { }).catch((response3) => {
console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`); console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
}); });
this.trackService.get(this.idTrack) this.trackService.get(this.idTrack)
.then((response: Media) => { .then((response: Media) => {
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`); console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
self.data.name = response.name; self.data.name = response.name;
self.data.description = response.description; self.data.description = response.description;
self.data.track = response.track; self.data.track = response.track;
@ -176,7 +176,7 @@ export class TrackEditScene implements OnInit {
self.onChangeArtist(response.artists[0]); self.onChangeArtist(response.artists[0]);
} }
self.data.albumId = response.albumId; self.data.albumId = response.albumId;
if(self.data.albumId === undefined) { if (self.data.albumId === undefined) {
self.data.albumId = null; self.data.albumId = null;
} }
self.dataOri = self.data.clone(); self.dataOri = self.data.clone();
@ -192,37 +192,37 @@ export class TrackEditScene implements OnInit {
}); });
} }
onChangeGender(value:any):void { onChangeGender(value: any): void {
console.log(`Change requested of gender ... ${value}`); console.log(`Change requested of gender ... ${value}`);
this.data.genderId = value; this.data.genderId = value;
if(this.data.genderId === undefined) { if (this.data.genderId === undefined) {
this.data.genderId = null; this.data.genderId = null;
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onChangeArtist(value:any):void { onChangeArtist(value: any): void {
this.data.artistId = value; this.data.artistId = value;
if(this.data.artistId === undefined) { if (this.data.artistId === undefined) {
this.data.artistId = null; this.data.artistId = null;
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onChangeAlbum(value:any):void { onChangeAlbum(value: any): void {
this.data.albumId = value; this.data.albumId = value;
if(this.data.albumId === undefined) { if (this.data.albumId === undefined) {
this.data.albumId = null; this.data.albumId = null;
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onName(value:any):void { onName(value: any): void {
this.data.name = value; this.data.name = value;
this.updateNeedSend(); this.updateNeedSend();
} }
onDescription(value:any):void { onDescription(value: any): void {
if(value.length === 0) { if (value.length === 0) {
this.data.description = null; this.data.description = null;
} else { } else {
this.data.description = value; this.data.description = value;
@ -230,8 +230,8 @@ export class TrackEditScene implements OnInit {
this.updateNeedSend(); this.updateNeedSend();
} }
onTrack(value:any):void { onTrack(value: any): void {
if(value.value.length > 4) { if (value.value.length > 4) {
value.value = this.data.track; value.value = this.data.track;
} else { } else {
this.data.track = parseInt(value.value, 10); this.data.track = parseInt(value.value, 10);
@ -239,38 +239,38 @@ export class TrackEditScene implements OnInit {
this.updateNeedSend(); this.updateNeedSend();
} }
sendValues():void { sendValues(): void {
console.log('send new values....'); console.log('send new values....');
let data:any = {}; let data: any = {};
if(this.data.name !== this.dataOri.name) { if (this.data.name !== this.dataOri.name) {
data.name = this.data.name; data.name = this.data.name;
} }
if(this.data.description !== this.dataOri.description) { if (this.data.description !== this.dataOri.description) {
if(this.data.description === undefined) { if (this.data.description === undefined) {
data.description = null; data.description = null;
} else { } else {
data.description = this.data.description; data.description = this.data.description;
} }
} }
if(this.data.track !== this.dataOri.track) { if (this.data.track !== this.dataOri.track) {
data.track = this.data.track; data.track = this.data.track;
} }
if(this.data.genderId !== this.dataOri.genderId) { if (this.data.genderId !== this.dataOri.genderId) {
if(this.data.genderId === undefined) { if (this.data.genderId === undefined) {
data.genderId = null; data.genderId = null;
} else { } else {
data.genderId = this.data.genderId; data.genderId = this.data.genderId;
} }
} }
if(this.data.artistId !== this.dataOri.artistId) { if (this.data.artistId !== this.dataOri.artistId) {
if(this.data.artistId === undefined) { if (this.data.artistId === undefined) {
data.artists = null; data.artists = null;
} else { } else {
data.artists = [ this.data.artistId ]; data.artists = [this.data.artistId];
} }
} }
if(this.data.albumId !== this.dataOri.albumId) { if (this.data.albumId !== this.dataOri.albumId) {
if(this.data.albumId === undefined) { if (this.data.albumId === undefined) {
data.albumId = null; data.albumId = null;
} else { } else {
data.albumId = this.data.albumId; data.albumId = this.data.albumId;
@ -278,23 +278,23 @@ export class TrackEditScene implements OnInit {
} }
let tmpp = this.data.clone(); let tmpp = this.data.clone();
let self = this; let self = this;
this.trackService.put(this.idTrack, data) this.trackService.patch(this.idTrack, data)
.then((response3) => { .then((response3) => {
self.dataOri = tmpp; self.dataOri = tmpp;
self.updateNeedSend(); self.updateNeedSend();
}).catch((response3) => { }).catch((response3) => {
console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`); console.log(`get response22 : ${JSON.stringify(response3, null, 2)}`);
self.updateNeedSend(); self.updateNeedSend();
}); });
} }
removeItem() { removeItem() {
console.log('Request remove Media...'); console.log('Request remove Media...');
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = `Delete the Media: ${ this.idTrack}`; this.confirmDeleteComment = `Delete the Media: ${this.idTrack}`;
this.deleteMediaId = this.idTrack; this.deleteMediaId = this.idTrack;
this.popInService.open('popin-delete-confirm'); this.popInService.open('popin-delete-confirm');
} }
removeItemAfterConfirm(id:number) { removeItemAfterConfirm(id: number) {
let self = this; let self = this;
this.trackService.delete(id) this.trackService.delete(id)
.then((response3) => { .then((response3) => {
@ -307,30 +307,30 @@ export class TrackEditScene implements OnInit {
} }
eventPopUpAlbum(event: string): void { eventPopUpAlbum(event: string): void {
console.log(`GET event: ${ event}`); console.log(`GET event: ${event}`);
this.popInService.close('popin-new-album'); this.popInService.close('popin-new-album');
if (event === "validate" && !isNullOrUndefined(this.albumInputNew)) { if (event === "validate" && !isNullOrUndefined(this.albumInputNew)) {
this.albumService.insert({ this.albumService.insert({
name:this.albumInputNew, name: this.albumInputNew,
}); });
} }
} }
eventPopUpArtist(event: string): void { eventPopUpArtist(event: string): void {
console.log(`GET event: ${ event}`); console.log(`GET event: ${event}`);
this.popInService.close('popin-new-artist'); this.popInService.close('popin-new-artist');
if (event === "validate" && !isNullOrUndefined(this.artistInputNew)) { if (event === "validate" && !isNullOrUndefined(this.artistInputNew)) {
this.artistService.insert({ this.artistService.insert({
name:this.artistInputNew, name: this.artistInputNew,
}); });
} }
} }
eventPopUpGender(event: string): void { eventPopUpGender(event: string): void {
console.log(`GET event: ${ event}`); console.log(`GET event: ${event}`);
this.popInService.close('popin-new-gender'); this.popInService.close('popin-new-gender');
if (event === "validate" && !isNullOrUndefined(this.genderInputNew)) { if (event === "validate" && !isNullOrUndefined(this.genderInputNew)) {
this.genderService.insert({ this.genderService.insert({
name:this.genderInputNew, name: this.genderInputNew,
}); });
} }
} }

View File

@ -5,7 +5,7 @@ import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/u
export class GenericInterfaceModelDB { export class GenericInterfaceModelDB {
constructor( constructor(
protected serviceName:string, protected serviceName: string,
protected http: HttpWrapperService, protected http: HttpWrapperService,
protected bdd: BddService) { protected bdd: BddService) {
// nothing to do ... // nothing to do ...
@ -18,7 +18,7 @@ export class GenericInterfaceModelDB {
self.bdd.get(self.serviceName) self.bdd.get(self.serviceName)
.then((response: DataInterface) => { .then((response: DataInterface) => {
let data = response.gets(); let data = response.gets();
if(isNullOrUndefined(data)) { if (isNullOrUndefined(data)) {
reject('Data does not exist in the local BDD'); reject('Data does not exist in the local BDD');
return; return;
} }
@ -30,13 +30,13 @@ export class GenericInterfaceModelDB {
}); });
} }
getLike(nameArtist:string):any { getLike(nameArtist: string): any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.get(self.serviceName) self.bdd.get(self.serviceName)
.then((response:DataInterface) => { .then((response: DataInterface) => {
let data = response.getNameLike(nameArtist); let data = response.getNameLike(nameArtist);
if(data === null || data === undefined || data.length === 0) { if (data === null || data === undefined || data.length === 0) {
reject('Data does not exist in the local BDD'); reject('Data does not exist in the local BDD');
return; return;
} }
@ -58,26 +58,26 @@ export class GenericInterfaceModelDB {
key: 'id', key: 'id',
value: [undefined, null], value: [undefined, null],
}, },
], ],
[ 'name', 'id' ]); ['name', 'id']);
//data = response.gets(); //data = response.gets();
if (isArrayOf(data, isNodeData)) { if (isArrayOf(data, isNodeData)) {
resolve(data); resolve(data);
} }
reject("The model is wrong ..."); reject("The model is wrong ...");
}).catch((response) => { }).catch((response) => {
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`); console.log(`[E] ${self.constructor.name}: can not retrive BDD values`);
reject(response); reject(response);
}); });
}); });
} }
get(id:number): Promise<NodeData> { get(id: number): Promise<NodeData> {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.get(self.serviceName) self.bdd.get(self.serviceName)
.then((response: DataInterface) => { .then((response: DataInterface) => {
let data = response.get(id); let data = response.get(id);
if(isNullOrUndefined(data)) { if (isNullOrUndefined(data)) {
reject('Data does not exist in the local BDD'); reject('Data does not exist in the local BDD');
return; return;
} }
@ -94,13 +94,13 @@ export class GenericInterfaceModelDB {
self.bdd.get(self.serviceName) self.bdd.get(self.serviceName)
.then((response: DataInterface) => { .then((response: DataInterface) => {
let data = response.getsWhere([ let data = response.getsWhere([
{ {
check: TypeCheck.EQUAL, check: TypeCheck.EQUAL,
key: 'id', key: 'id',
value: ids, value: ids,
}, },
], ],
[ 'name', 'id' ]); ['name', 'id']);
resolve(data); resolve(data);
return; return;
}).catch((response) => { }).catch((response) => {
@ -113,11 +113,11 @@ export class GenericInterfaceModelDB {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.get(self.serviceName) self.bdd.get(self.serviceName)
.then((response:DataInterface) => { .then((response: DataInterface) => {
let data = response.gets(); let data = response.gets();
resolve(data); resolve(data);
}).catch((response) => { }).catch((response) => {
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`); console.log(`[E] ${self.constructor.name}: can not retrive BDD values`);
reject(response); reject(response);
}); });
}); });
@ -126,25 +126,25 @@ export class GenericInterfaceModelDB {
insert(data: any): any { insert(data: any): any {
let ret = this.http.postSpecific([this.serviceName], data); let ret = this.http.postSpecific([this.serviceName], data);
return this.bdd.addAfterPost(this.serviceName, ret); return this.bdd.addAfterPost(this.serviceName, ret);
} }
put(id:number, data:any):any { patch(id: number, data: any): any {
let ret = this.http.putSpecific([this.serviceName, id], data); let ret = this.http.patchSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret); return this.bdd.setAfterPut(this.serviceName, id, ret);
} }
delete(id:number):any { delete(id: number): any {
let ret = this.http.deleteSpecific([this.serviceName, id]); let ret = this.http.deleteSpecific([this.serviceName, id]);
return this.bdd.delete(this.serviceName, id, ret); return this.bdd.delete(this.serviceName, id, ret);
} }
deleteCover(nodeId:number, coverId:number) { deleteCover(nodeId: number, coverId: number) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId]) self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
.then((response) => { .then((response) => {
let data = response; let data = response;
if(data === null || data === undefined) { if (data === null || data === undefined) {
reject('error retrive data from server'); reject('error retrive data from server');
return; return;
} }
@ -155,19 +155,19 @@ export class GenericInterfaceModelDB {
}); });
}); });
} }
uploadCover(file:File, uploadCover(file: File,
nodeId:number, nodeId: number,
progress:any = null) { progress: any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('fileName', file.name); formData.append('fileName', file.name);
formData.append('id', nodeId.toString()); formData.append('id', nodeId.toString());
formData.append('file', file); formData.append('file', file);
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.uploadMultipart(`${this.serviceName }/${nodeId}/add_cover/`, formData, progress) self.http.uploadMultipart(`${this.serviceName}/${nodeId}/add_cover/`, formData, progress)
.then((response) => { .then((response) => {
let data = response; let data = response;
if(data === null || data === undefined) { if (data === null || data === undefined) {
reject('error retrive data from server'); reject('error retrive data from server');
return; return;
} }

@ -1 +1 @@
Subproject commit ea5a4f6b7537eb707916f4610bf79fbe86c6296f Subproject commit c3489422f2df7f16465b4358e868664af9cda81c