[DEV] it works
This commit is contained in:
parent
14c10f4885
commit
cf221ec2bb
@ -176,7 +176,7 @@ public class TrackResource {
|
||||
System.out.println("Data already exist ... all good");
|
||||
System.out.flush();
|
||||
}
|
||||
// Fist step: retive all the Id of each parents:...
|
||||
// Fist step: retrieve all the Id of each parents:...
|
||||
System.out.println("Find typeNode");
|
||||
Gender genderElem = null;
|
||||
if (gender != null) {
|
||||
@ -221,15 +221,14 @@ public class TrackResource {
|
||||
|
||||
Track trackElem = new Track();
|
||||
trackElem.name = title;
|
||||
trackElem.track = trackId!=null?Long.parseLong(trackId):null;
|
||||
trackElem.albumId = albumElem!=null?albumElem.id:null;
|
||||
trackElem.genderId = genderElem!=null?genderElem.id:null;
|
||||
trackElem.dataId = data.id;
|
||||
trackElem = SqlWrapper.insert(trackElem);
|
||||
if (artistElem != null) {
|
||||
SqlWrapper.addLink(Track.class, trackElem.id, "artist", artistElem.id);
|
||||
}
|
||||
if (artistElem != null) {
|
||||
SqlWrapper.addLink(Album.class, albumElem.id , "track", trackElem.id);
|
||||
}
|
||||
return Response.ok(trackElem).build();
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Catch an unexpected error ... " + ex.getMessage());
|
||||
|
@ -12,8 +12,10 @@ CREATE TABLE `node` (
|
||||
) AUTO_INCREMENT=10;
|
||||
*/
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.karusic.annotation.SQLIfNotExists;
|
||||
import org.kar.karusic.annotation.SQLTableLinkGeneric;
|
||||
import org.kar.karusic.annotation.SQLTableName;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@ -22,6 +24,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@SQLTableName ("album")
|
||||
@SQLIfNotExists
|
||||
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
|
||||
public class Album extends Playlist {
|
||||
public class Album extends NodeSmall {
|
||||
public Date publication = null;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
|
||||
public class Track extends NodeSmall {
|
||||
public Long genderId = null;
|
||||
public Long albumId = null;
|
||||
public Long track = null;
|
||||
public Long dataId = null;
|
||||
@SQLTableLinkGeneric
|
||||
public List<Long> artists = null;
|
||||
@ -32,6 +34,6 @@ public class Track extends NodeSmall {
|
||||
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 + ", dataId=" + dataId + ", artists=" + artists + "]";
|
||||
+ genderId + ", albumId=" + albumId + ", track=" + track + ", dataId=" + dataId + ", artists=" + artists + "]";
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Media } from 'app/model';
|
||||
import { AlbumModel, isAlbumModel } from 'app/model/album';
|
||||
|
||||
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||
@ -27,7 +28,7 @@ export class ArtistAlbumScene implements OnInit {
|
||||
public albumCovers: string[] = undefined;
|
||||
|
||||
public tracksIds: number[] = undefined;
|
||||
public tracks: any[] = undefined;
|
||||
public tracks: Media[] = undefined;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -63,25 +64,22 @@ export class ArtistAlbumScene implements OnInit {
|
||||
self.albumName = response.name;
|
||||
self.albumDescription = response.description;
|
||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
||||
if (isAlbumModel(response)) {
|
||||
//console.log("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
|
||||
self.tracksIds = (response as AlbumModel).tracks;
|
||||
}
|
||||
//console.log("all the tracks: " + self.tracksIds);
|
||||
this.trackService.getAll(self.tracksIds)
|
||||
.then((response2: NodeData[]) => {
|
||||
self.tracks = response2;
|
||||
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
||||
}).catch((response) => {
|
||||
//console.log(`>>>>BBB plop`);
|
||||
self.tracks = undefined;
|
||||
});
|
||||
}).catch((response) => {
|
||||
self.albumDescription = undefined;
|
||||
self.albumName = '???';
|
||||
self.albumCovers = undefined;
|
||||
// no check just ==> an error occured on album
|
||||
});
|
||||
|
||||
//console.log("all the tracks: " + self.tracksIds);
|
||||
this.trackService.getWithAlbum(self.idAlbum)
|
||||
.then((response2: Media[]) => {
|
||||
self.tracks = response2;
|
||||
console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
||||
}).catch((response) => {
|
||||
//console.log(`>>>>BBB plop`);
|
||||
self.tracks = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
onSelectTrack(event: any, idSelected: number):void {
|
||||
|
@ -185,7 +185,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="request_raw_table" *ngIf="this.listFileInBdd !== undefined">
|
||||
<div class="request_raw_table" *ngIf="this.listFileInBdd">
|
||||
<table>
|
||||
<colgroup>
|
||||
<col style="width:10%">
|
||||
|
@ -11,6 +11,7 @@ import { GenderService, PlaylistService, ArtistService, TrackService, ArianeServ
|
||||
import { NodeData } from 'common/model';
|
||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||
import { PopInService } from 'common/service';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
export class ElementList {
|
||||
constructor(
|
||||
@ -51,13 +52,13 @@ export class UploadScene implements OnInit {
|
||||
parsedFailedElement: FileFailParsedElement[] = [];
|
||||
uploadFileValue: string = '';
|
||||
selectedFiles: FileList;
|
||||
genderId: number = null;
|
||||
artistId: number = null;
|
||||
saisonId: number = null;
|
||||
genderId: number = undefined;
|
||||
artistId: number = undefined;
|
||||
albumId: number = undefined;
|
||||
needSend: boolean = false;
|
||||
|
||||
// list of all files already registered in the bdd to compare with the curent list of files.
|
||||
listFileInBdd: any = null;
|
||||
listFileInBdd: any[] = undefined;
|
||||
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
public upload:UploadProgress = new UploadProgress();
|
||||
@ -65,13 +66,12 @@ export class UploadScene implements OnInit {
|
||||
listGender: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
listPlaylist: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
listArtist: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
listArtist2 = [ { id: null, description: '---' } ];
|
||||
listAlbum: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
|
||||
/*
|
||||
config = {
|
||||
@ -92,15 +92,11 @@ export class UploadScene implements OnInit {
|
||||
searchPlaceholder: 'Search', // label thats displayed in search input,
|
||||
searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
|
||||
};
|
||||
listAlbum: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
globalGender: string = '';
|
||||
globalArtist: string = '';
|
||||
globalGender: string = null;
|
||||
globalArtist: string = null;
|
||||
globalAlbum: string = null;
|
||||
constructor(private route: ActivatedRoute,
|
||||
private genderService: GenderService,
|
||||
private playlistService: PlaylistService,
|
||||
private artistService: ArtistService,
|
||||
private albumService: AlbumService,
|
||||
private trackService: TrackService,
|
||||
@ -116,12 +112,12 @@ export class UploadScene implements OnInit {
|
||||
}
|
||||
this.needSend = true;
|
||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||
if(this.parsedElement[iii].title === undefined || this.parsedElement[iii].title === null || this.parsedElement[iii].title === '') {
|
||||
if(isNullOrUndefined(this.parsedElement[iii].title) || this.parsedElement[iii].title === '') {
|
||||
this.needSend = false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if(this.genderId === undefined || this.genderId === null) {
|
||||
if(isNullOrUndefined(this.genderId)) {
|
||||
this.needSend = false;
|
||||
}
|
||||
*/
|
||||
@ -132,13 +128,12 @@ export class UploadScene implements OnInit {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
let self = this;
|
||||
this.listGender = [ { value: null, label: '---' } ];
|
||||
this.listPlaylist = [ { value: null, label: '---' } ];
|
||||
this.listArtist = [ { value: null, label: '---' } ];
|
||||
this.listAlbum = [ { value: null, label: '---' } ];
|
||||
this.playlistService.getData()
|
||||
this.artistService.getOrder()
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listPlaylist.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
self.listArtist.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
@ -155,36 +150,6 @@ export class UploadScene implements OnInit {
|
||||
console.log(' END INIT ');
|
||||
}
|
||||
|
||||
onChangeType(value: any): void {
|
||||
this.artistId = null;
|
||||
this.updateType(value);
|
||||
}
|
||||
|
||||
private updateType(value: any): void {
|
||||
console.log(`Change requested of type ... ${ value}`);
|
||||
if(this.genderId === value) {
|
||||
return;
|
||||
}
|
||||
this.genderId = value;
|
||||
// this.data.artist_id = null;
|
||||
// this.data.album_id = null;
|
||||
this.listArtist = [ { value: null, label: '---' } ];
|
||||
this.listAlbum = [ { value: null, label: '---' } ];
|
||||
let self = this;
|
||||
this.updateNeedSend();
|
||||
if(this.genderId !== null) {
|
||||
self.genderService.getSubArtist(this.genderId)
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listArtist.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onGender(value: any): void {
|
||||
this.globalGender = value;
|
||||
let self = this;
|
||||
@ -196,13 +161,13 @@ export class UploadScene implements OnInit {
|
||||
console.log(` - ${ JSON.stringify(response[iii])}`);
|
||||
}
|
||||
if(response.length === 0) {
|
||||
self.genderId = null;
|
||||
self.genderId = undefined;
|
||||
} else if(response.length === 1) {
|
||||
self.genderId = response[0].id;
|
||||
}
|
||||
}).catch((response) => {
|
||||
console.log('CAN NOT find element: ');
|
||||
self.genderId = null;
|
||||
self.genderId = undefined;
|
||||
});
|
||||
}
|
||||
this.updateNeedSend();
|
||||
@ -211,7 +176,7 @@ export class UploadScene implements OnInit {
|
||||
|
||||
onChangeGender(value: any): void {
|
||||
this.globalGender = value;
|
||||
if(!(value === undefined || value === null)) {
|
||||
if(!isNullOrUndefined(value)) {
|
||||
for(let iii = 0; iii < this.listGender.length; iii++) {
|
||||
if(this.listGender[iii].value === value) {
|
||||
this.globalGender = this.listGender[iii].label;
|
||||
@ -222,32 +187,50 @@ export class UploadScene implements OnInit {
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
private updateTheListOfAlbum() {
|
||||
this.listAlbum = [ { value: null, label: '---' } ];
|
||||
if (isNullOrUndefined(this.artistId)) {
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.artistService.getAlbum(this.artistId)
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listAlbum.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
}
|
||||
onArtist(value: any): void {
|
||||
this.globalArtist = value;
|
||||
let self = this;
|
||||
if(this.globalArtist !== '') {
|
||||
console.log(`update artist List Element: ${this.globalArtist}`);
|
||||
this.artistService.getLike(this.globalArtist)
|
||||
.then((response: any[]) => {
|
||||
console.log(`find element: ${ response.length}`);
|
||||
for(let iii = 0; iii < response.length; iii++) {
|
||||
console.log(` - ${ JSON.stringify(response[iii])}`);
|
||||
}
|
||||
console.log(` ==> find artist like ${this.globalArtist} : ${ JSON.stringify(response, null, 2)}`);
|
||||
if(response.length === 0) {
|
||||
self.artistId = null;
|
||||
self.artistId = undefined;
|
||||
} else if(response.length === 1) {
|
||||
self.artistId = response[0].id;
|
||||
self.updateTheListOfAlbum();
|
||||
}
|
||||
if (!isNullOrUndefined(this.globalAlbum)) {
|
||||
this.onAlbum(this.globalAlbum)
|
||||
} else {
|
||||
self.updateListOfTrackToCheck();
|
||||
}
|
||||
self.updateListOfTrackToCheck();
|
||||
}).catch((response) => {
|
||||
console.log('CAN NOT find element: ');
|
||||
self.artistId = null;
|
||||
console.log(` ==> CAN NOT find artist like ${this.globalArtist} : ${ response.length}`);
|
||||
self.artistId = undefined;
|
||||
});
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
onChangeArtist(value: any): void {
|
||||
this.artistId = value;
|
||||
if(!(value === undefined || value === null)) {
|
||||
if(!isNullOrUndefined(value)) {
|
||||
for(let iii = 0; iii < this.listArtist.length; iii++) {
|
||||
if(this.listArtist[iii].value === value) {
|
||||
this.globalArtist = this.listArtist[iii].label;
|
||||
@ -290,25 +273,24 @@ export class UploadScene implements OnInit {
|
||||
|
||||
clearData() {
|
||||
this.globalGender = null;
|
||||
this.globalArtist = '';
|
||||
this.globalArtist = null;
|
||||
this.globalAlbum = null;
|
||||
this.parsedElement = [];
|
||||
this.parsedFailedElement = [];
|
||||
this.listFileInBdd = null;
|
||||
this.listFileInBdd = undefined;
|
||||
|
||||
this.genderId = null;
|
||||
this.artistId = null;
|
||||
this.saisonId = null;
|
||||
this.genderId = undefined;
|
||||
this.artistId = undefined;
|
||||
this.albumId = undefined;
|
||||
//this.listGender = [ { value: null, label: '---' } ];
|
||||
this.listArtist = [ { value: null, label: '---' } ];
|
||||
this.listAlbum = [ { value: null, label: '---' } ];
|
||||
}
|
||||
|
||||
addFileWithMetaData(file: File) {
|
||||
// parsedElement: FileParsedElement[] = [];
|
||||
let artist: string = null;
|
||||
let album: string | null = null;
|
||||
let trackIdNumber: number | null = null;
|
||||
let artist: string = undefined;
|
||||
let album: string | null = undefined;
|
||||
let trackIdNumber: number | null = undefined;
|
||||
let title: string = '';
|
||||
|
||||
console.log(`select file ${ file.name}`);
|
||||
@ -337,10 +319,10 @@ export class UploadScene implements OnInit {
|
||||
title = tmpName;
|
||||
|
||||
if(isNaN(trackIdNumber)) {
|
||||
trackIdNumber = null;
|
||||
trackIdNumber = undefined;
|
||||
}
|
||||
// remove extention
|
||||
title = title.replace(new RegExp('\\.(mkv|MKV|Mkv|webm|WEBM|Webm|mp4)'), '');
|
||||
title = title.replace(new RegExp('\\.(webm|WEBM|Webm)'), '');
|
||||
let tmp = new FileParsedElement(file, artist, album, trackIdNumber, title);
|
||||
console.log(`==>${ JSON.stringify(tmp)}`);
|
||||
// add it in the list.
|
||||
@ -395,16 +377,14 @@ export class UploadScene implements OnInit {
|
||||
}
|
||||
console.log(`check : ${JSON.stringify(this.parsedElement[0])}`)
|
||||
this.globalArtist = this.parsedElement[0].artist ?? '';
|
||||
this.globalAlbum = this.parsedElement[0].album ?? null;
|
||||
this.globalAlbum = this.parsedElement[0].album ?? '';
|
||||
|
||||
this.updateNeedSend();
|
||||
this.artistId = null;
|
||||
this.saisonId = null;
|
||||
let self = this;
|
||||
this.artistId = undefined;
|
||||
this.albumId = undefined;
|
||||
this.onArtist(this.globalArtist);
|
||||
}
|
||||
|
||||
|
||||
sendFile(): void {
|
||||
console.log(`Send file requested ... ${ this.parsedElement.length}`);
|
||||
this.upload = new UploadProgress();
|
||||
@ -437,21 +417,21 @@ export class UploadScene implements OnInit {
|
||||
}
|
||||
*/
|
||||
// add artist
|
||||
if(self.globalArtist !== null) {
|
||||
if(!isNullOrUndefined(self.globalArtist)) {
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }:`;
|
||||
}
|
||||
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalArtist;
|
||||
}
|
||||
// add album
|
||||
if(self.globalAlbum !== null && self.globalAlbum !== undefined && self.globalAlbum.toString().length !== 0) {
|
||||
if(!isNullOrUndefined(self.globalAlbum) && self.globalAlbum.toString().length !== 0) {
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
|
||||
}
|
||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }s${ self.globalAlbum.toString()}`;
|
||||
}
|
||||
// add episode ID
|
||||
if(elemnent.trackId !== null && elemnent.trackId !== undefined && elemnent.trackId.toString().length !== 0) {
|
||||
if(!isNullOrUndefined(elemnent.trackId) && elemnent.trackId.toString().length !== 0) {
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
|
||||
}
|
||||
@ -502,7 +482,7 @@ export class UploadScene implements OnInit {
|
||||
}
|
||||
|
||||
checkConcordence():void {
|
||||
if(this.parsedElement === null) {
|
||||
if(isNullOrUndefined(this.parsedElement)) {
|
||||
return;
|
||||
}
|
||||
// ckear checker
|
||||
@ -510,7 +490,7 @@ export class UploadScene implements OnInit {
|
||||
this.parsedElement[iii].nameDetected = false;
|
||||
this.parsedElement[iii].episodeDetected = false;
|
||||
}
|
||||
if(this.listFileInBdd === null) {
|
||||
if(isNullOrUndefined(this.listFileInBdd)) {
|
||||
return;
|
||||
}
|
||||
for(let iii = 0; iii < this.listFileInBdd.length; iii++) {
|
||||
@ -533,55 +513,58 @@ export class UploadScene implements OnInit {
|
||||
|
||||
updateListOfTrackToCheck(): void {
|
||||
// No artist ID set ==> nothing to do.
|
||||
if(this.artistId === null) {
|
||||
this.listFileInBdd = null;
|
||||
if(isNullOrUndefined(this.artistId)) {
|
||||
this.listFileInBdd = undefined;
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// no album check only the artist files.
|
||||
if(this.globalAlbum === null) {
|
||||
if(isNullOrUndefined(this.globalAlbum)) {
|
||||
console.error(`NO ALBUM ==> check artist ID...`);
|
||||
self.artistService.getTrack(self.artistId)
|
||||
.then((response: any[]) => {
|
||||
self.listFileInBdd = response;
|
||||
// console.log("find track: " + response.length);
|
||||
console.error(`find track: ${JSON.stringify(response, null, 2)}`);
|
||||
// for (let iii = 0; iii<response.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response[iii]));
|
||||
// }
|
||||
self.checkConcordence();
|
||||
}).catch((response) => {
|
||||
self.listFileInBdd = null;
|
||||
self.listFileInBdd = undefined;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
self.saisonId = null;
|
||||
self.albumId = undefined;
|
||||
console.error(`ALBUM ==> check album values...`);
|
||||
// set 1 find the ID of the album:
|
||||
this.artistService.getAlbum(this.artistId)
|
||||
.then((response: any[]) => {
|
||||
// console.log("find album: " + response.length);
|
||||
console.log(`find album: ${JSON.stringify(response, null, 2)}`);
|
||||
for(let iii = 0; iii < response.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalAlbum));
|
||||
if(response[iii].name === `${self.globalAlbum}`) {
|
||||
self.saisonId = response[iii].id;
|
||||
self.albumId = response[iii].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(self.saisonId === null) {
|
||||
if(isNullOrUndefined(self.albumId)) {
|
||||
return;
|
||||
}
|
||||
self.albumService.getTrack(self.saisonId)
|
||||
self.albumService.getTrack(self.albumId)
|
||||
.then((response2: any[]) => {
|
||||
self.listFileInBdd = response2;
|
||||
console.log(`find album: ${JSON.stringify(response, null, 2)}`);
|
||||
// console.log("find track: " + response2.length);
|
||||
// for (let iii = 0; iii<response2.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response2[iii]));
|
||||
// }
|
||||
self.checkConcordence();
|
||||
}).catch((response3) => {
|
||||
self.listFileInBdd = null;
|
||||
self.listFileInBdd = undefined;
|
||||
});
|
||||
}).catch((response4) => {
|
||||
self.listFileInBdd = null;
|
||||
self.listFileInBdd = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,10 @@ export class AlbumService extends GenericInterfaceModelDB {
|
||||
|
||||
/**
|
||||
* Get all the track for a specific album
|
||||
* @param id - Id of the album.
|
||||
* @param idAlbum - Id of the album.
|
||||
* @returns a promise on the list of track elements
|
||||
*/
|
||||
getTrack(id:number): Promise<NodeData[]> {
|
||||
getTrack(idAlbum:number): Promise<NodeData[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
@ -34,10 +34,10 @@ export class AlbumService extends GenericInterfaceModelDB {
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'albumId',
|
||||
value: id,
|
||||
value: idAlbum,
|
||||
},
|
||||
],
|
||||
[ 'episode', 'name' ]);
|
||||
[ 'name' ]); // tODO : set the Id in the track ...
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
|
@ -24,10 +24,10 @@ export class ArtistService extends GenericInterfaceModelDB {
|
||||
|
||||
/**
|
||||
* Get all the track for a specific artist
|
||||
* @param id - Id of the artist.
|
||||
* @param idArtist - Id of the artist.
|
||||
* @returns a promise on the list of track elements
|
||||
*/
|
||||
getTrack(id:number): Promise<NodeData[]> {
|
||||
getTrack(idArtist:number): Promise<NodeData[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
@ -36,7 +36,7 @@ export class ArtistService extends GenericInterfaceModelDB {
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'artistId',
|
||||
value: id,
|
||||
value: idArtist,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'albumId',
|
||||
@ -77,37 +77,37 @@ export class ArtistService extends GenericInterfaceModelDB {
|
||||
|
||||
/**
|
||||
* Get all the album of a specific artist
|
||||
* @param id - ID of the artist
|
||||
* @param idArtist - ID of the artist
|
||||
* @returns the required List.
|
||||
*/
|
||||
getAlbum(id:number): Promise<NodeData[]> {
|
||||
getAlbum(idArtist:number): Promise<NodeData[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response:DataInterface) => {
|
||||
//console.log(" <<<========================================>>> " + id);
|
||||
console.log(" <<<========================================>>> " + idArtist);
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.CONTAINS, //< this is for array containing
|
||||
key: 'artists',
|
||||
value: id,
|
||||
value: idArtist,
|
||||
},
|
||||
], [ 'id' ]);
|
||||
//console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2));
|
||||
console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2));
|
||||
// extract a single time all value "id" in an array
|
||||
const listTrack = DataInterface.extractLimitOne(data, "id");
|
||||
//console.log("==> List Of ids: " + JSON.stringify(listTrack, null, 2));
|
||||
const listAlbumId = DataInterface.extractLimitOne(data, "albumId");
|
||||
console.log("==> List Of ids: " + JSON.stringify(listAlbumId, null, 2));
|
||||
self.bdd.get('album')
|
||||
.then((response:DataInterface) => {
|
||||
let dataAlbum = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.CONTAINS,
|
||||
key: 'tracks',
|
||||
value: listTrack,
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'id',
|
||||
value: listAlbumId,
|
||||
},
|
||||
], [ 'name', 'id' ]);
|
||||
], [ 'publication', 'name', 'id' ]);
|
||||
resolve(dataAlbum);
|
||||
//console.log("==> get all albums: " + JSON.stringify(dataAlbum, null, 2));
|
||||
console.log("==> get all albums: " + JSON.stringify(dataAlbum, null, 2));
|
||||
return;
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
|
@ -5,8 +5,10 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodeData } from 'common/model';
|
||||
|
||||
import { HttpWrapperService, BddService } from 'common/service';
|
||||
import { DataInterface, TypeCheck } from 'common/utils';
|
||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||
|
||||
@Injectable()
|
||||
@ -25,5 +27,25 @@ export class PlaylistService extends GenericInterfaceModelDB {
|
||||
// this.checkLocalBdd();
|
||||
}
|
||||
|
||||
getAll(ids: number[]): Promise<NodeData[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get(self.serviceName)
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'id',
|
||||
value: ids,
|
||||
},
|
||||
],
|
||||
[ 'name', 'id' ]);
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import { isMedia, Media } from 'app/model';
|
||||
import { NodeData } from 'common/model';
|
||||
|
||||
import { HttpWrapperService, BddService } from 'common/service';
|
||||
import { isArrayOf } from 'common/utils';
|
||||
import { DataInterface, isArrayOf, TypeCheck } from 'common/utils';
|
||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||
|
||||
@Injectable()
|
||||
@ -33,6 +33,30 @@ export class TrackService extends GenericInterfaceModelDB {
|
||||
});
|
||||
});
|
||||
}
|
||||
getWithAlbum(idAlbum: number): Promise<Media[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get(self.serviceName)
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'albumId',
|
||||
value: idAlbum,
|
||||
},
|
||||
],
|
||||
[ 'track', 'name', 'id' ]);
|
||||
if (isArrayOf(data, isMedia)) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
reject("model is wrong !!!");
|
||||
return;
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getData(): Promise<Media[]> {
|
||||
|
Loading…
Reference in New Issue
Block a user