diff --git a/back/pom.xml b/back/pom.xml index c843089..e92b4c3 100644 --- a/back/pom.xml +++ b/back/pom.xml @@ -20,7 +20,7 @@ kangaroo-and-rabbit archidata - 0.5.0 + 0.6.0 org.slf4j diff --git a/back/src/org/kar/karusic/api/TrackResource.java b/back/src/org/kar/karusic/api/TrackResource.java index f63c2a8..d96d39b 100644 --- a/back/src/org/kar/karusic/api/TrackResource.java +++ b/back/src/org/kar/karusic/api/TrackResource.java @@ -11,6 +11,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam; import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.QueryCondition; import org.kar.archidata.dataAccess.addOn.AddOnManyToMany; +import org.kar.archidata.dataAccess.options.Condition; import org.kar.archidata.model.Data; import org.kar.archidata.tools.DataTools; import org.kar.karusic.model.Album; @@ -33,27 +34,27 @@ import jakarta.ws.rs.core.Response; @Path("/track") @Produces({ MediaType.APPLICATION_JSON }) public class TrackResource { - + @GET @Path("{id}") @RolesAllowed("USER") public static Track getWithId(@PathParam("id") final Long id) throws Exception { return DataAccess.get(Track.class, id); } - + @GET @RolesAllowed("USER") public List get() throws Exception { return DataAccess.gets(Track.class); } - + @POST @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) public Track create(final String jsonRequest) throws Exception { return DataAccess.insertWithJson(Track.class, jsonRequest); } - + @PUT @Path("{id}") @RolesAllowed("ADMIN") @@ -62,7 +63,7 @@ public class TrackResource { DataAccess.updateWithJson(Track.class, id, jsonRequest); return DataAccess.get(Track.class, id); } - + @DELETE @Path("{id}") @RolesAllowed("ADMIN") @@ -70,7 +71,7 @@ public class TrackResource { DataAccess.delete(Track.class, id); return Response.ok().build(); } - + @POST @Path("{id}/add_artist/{artistId}") @RolesAllowed("ADMIN") @@ -79,7 +80,7 @@ public class TrackResource { AddOnManyToMany.removeLink(Track.class, id, "artist", artistId); return DataAccess.get(Track.class, id); } - + @GET @Path("{id}/rm_artist/{trackId}") @RolesAllowed("ADMIN") @@ -87,7 +88,7 @@ public class TrackResource { AddOnManyToMany.removeLink(Track.class, id, "artist", artistId); return DataAccess.get(Track.class, id); } - + @POST @Path("{id}/add_cover") @RolesAllowed("ADMIN") @@ -96,7 +97,7 @@ public class TrackResource { @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData); } - + @GET @Path("{id}/rm_cover/{coverId}") @RolesAllowed("ADMIN") @@ -104,7 +105,7 @@ public class TrackResource { AddOnManyToMany.removeLink(Track.class, id, "cover", coverId); return Response.ok(DataAccess.get(Track.class, id)).build(); } - + @POST @Path("/upload/") @RolesAllowed("ADMIN") @@ -121,7 +122,7 @@ public class TrackResource { album = DataTools.multipartCorrection(album); trackId = DataTools.multipartCorrection(trackId); title = DataTools.multipartCorrection(title); - + //public NodeSmall uploadFile(final FormDataMultiPart form) { System.out.println("Upload media file: " + fileMetaData); System.out.println(" - fileName: " + fileName); @@ -141,7 +142,7 @@ public class TrackResource { build(); } */ - + final long tmpUID = DataTools.getTmpDataId(); final String sha512 = DataTools.saveTemporaryFile(fileInputStream, tmpUID); Data data = DataTools.getWithSha512(sha512); @@ -172,7 +173,7 @@ public class TrackResource { System.out.println("Find typeNode"); Gender genderElem = null; if (gender != null) { - genderElem = DataAccess.getWhere(Gender.class, new QueryCondition("name", "=", gender)); + genderElem = DataAccess.getWhere(Gender.class, new Condition(new QueryCondition("name", "=", gender))); if (genderElem == null) { genderElem = new Gender(); genderElem.name = gender; @@ -185,10 +186,10 @@ public class TrackResource { // return Response.notModified("TypeId does not exist ...").build(); // } System.out.println(" ==> " + genderElem); - + Artist artistElem = null; if (artist != null) { - artistElem = DataAccess.getWhere(Artist.class, new QueryCondition("name", "=", artist)); + artistElem = DataAccess.getWhere(Artist.class, new Condition(new QueryCondition("name", "=", artist))); if (artistElem == null) { artistElem = new Artist(); artistElem.name = artist; @@ -196,10 +197,10 @@ public class TrackResource { } } System.out.println(" ==> " + artistElem); - + Album albumElem = null; if (album != null) { - albumElem = DataAccess.getWhere(Album.class, new QueryCondition("name", "=", album)); + albumElem = DataAccess.getWhere(Album.class, new Condition(new QueryCondition("name", "=", album))); if (albumElem == null) { albumElem = new Album(); albumElem.name = album; @@ -207,9 +208,9 @@ public class TrackResource { } } System.out.println(" ==> " + album); - + System.out.println("add media"); - + Track trackElem = new Track(); trackElem.name = title; trackElem.track = trackId != null ? Long.parseLong(trackId) : null; @@ -235,5 +236,5 @@ public class TrackResource { return Response.status(417).entity("Back-end error : " + ex.getMessage()).type("text/plain").build(); } } - + }