[DEV] ready for deply new model of data UUID

This commit is contained in:
Edouard DUPIN 2024-03-19 23:17:05 +01:00
parent f6f9fa199a
commit e05fe70f80
8 changed files with 62 additions and 49 deletions

View File

@ -20,7 +20,7 @@
<dependency>
<groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -18,7 +18,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WebLauncherLocal extends WebLauncher {
final Logger logger = LoggerFactory.getLogger(WebLauncherLocal.class);
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
private WebLauncherLocal() {}
@ -36,9 +36,9 @@ public class WebLauncherLocal extends WebLauncher {
Initialization.CLASSES_BASE, "../front/src/app/back-api/");
final WebLauncherLocal launcher = new WebLauncherLocal();
launcher.process();
launcher.logger.info("end-configure the server & wait finish process:");
launcher.LOGGER.info("end-configure the server & wait finish process:");
Thread.currentThread().join();
launcher.logger.info("STOP the REST server:");
launcher.LOGGER.info("STOP the REST server:");
}
@Override

View File

@ -1,6 +1,22 @@
package org.kar.karusic.migration;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.kar.archidata.api.DataResource;
import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.dataAccess.addOn.model.LinkTable;
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
import org.kar.archidata.dataAccess.options.OverrideTableName;
import org.kar.archidata.migration.MigrationSqlStep;
import org.kar.archidata.tools.UuidUtils;
import org.kar.karusic.migration.model.CoverConversion;
import org.kar.karusic.migration.model.MediaConversion;
import org.kar.karusic.migration.model.UUIDConversion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,15 +36,13 @@ public class Migration20240226 extends MigrationSqlStep {
@Override
public void generateStep() throws Exception {
/*
addAction("""
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
""");
addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
for (final UUIDConversion elem: datas) {
elem.uuid = UUID.randomUUID();
//elem.uuid = new UUID(elem.id * (long)Math.pow(2, 32), 0);
elem.uuid = UuidUtils.nextUUID();
}
for (final UUIDConversion elem: datas) {
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
@ -93,10 +107,20 @@ public class Migration20240226 extends MigrationSqlStep {
addAction("""
ALTER TABLE `track` DROP `dataId`;
""");
*/
addAction("""
ALTER TABLE `track` CHANGE `dataUUID` `dataId` binary(16) NOT NULL;
""");
// Move the files...
addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
for (final UUIDConversion data: datas) {
final String origin = DataResource.getFileDataOld(data.id);
final String destination = DataResource.getFileData(data.uuid);
LOGGER.info("move file = {}", origin);
LOGGER.info(" ==> {}", destination);
Files.move(Paths.get(origin), Paths.get(destination), StandardCopyOption.ATOMIC_MOVE);
}
});
addAction("""
ALTER TABLE `data` DROP `id`;
""");
@ -106,17 +130,6 @@ public class Migration20240226 extends MigrationSqlStep {
addAction("""
ALTER TABLE `data` ADD PRIMARY KEY `id` (`id`);
""");
/*
// Move the files...
addAction(() -> {
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
for (final UUIDConversion data: datas) {
final String origin = DataResource.getFileData(data.id);
final String destination = DataResource.getFileData(data.uuid);
}
});
*/
}
}

View File

@ -72,29 +72,6 @@ export namespace TrackResource {
data,
}, isTrack);
};
export function uploadTrack({ restConfig, data, }: {
restConfig: RESTConfig,
data: {
fileName: string,
file: File,
gender: string,
artist: string,
album: string,
trackId: Long,
title: string,
},
}): Promise<Track> {
return RESTRequestJson({
restModel: {
endPoint: "/track/upload/",
requestType: HTTPRequestModel.POST,
contentType: HTTPMimeType.MULTIPART,
accept: HTTPMimeType.JSON,
},
restConfig,
data,
}, isTrack);
};
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Track[]> {
@ -183,4 +160,27 @@ export namespace TrackResource {
params,
}, isTrack);
};
export function uploadTrack({ restConfig, data, }: {
restConfig: RESTConfig,
data: {
fileName: string,
file: File,
gender: string,
artist: string,
album: string,
trackId: Long,
title: string,
},
}): Promise<Track> {
return RESTRequestJson({
restModel: {
endPoint: "/track/upload/",
requestType: HTTPRequestModel.POST,
contentType: HTTPMimeType.MULTIPART,
accept: HTTPMimeType.JSON,
},
restConfig,
data,
}, isTrack);
};
}

View File

@ -54,7 +54,7 @@ export class ElementSeasonComponent implements OnInit {
this.description = this.element.description;
console.log(`covers: ${this.element.covers}`);
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
console.log(`covers >> : ${this.covers}`);
console.log(`covers ${this.element.covers} >> : ${this.covers}`);
let self = this;
if (!isNullOrUndefined(this.countSubTypeCallBack)) {
this.countSubTypeCallBack(this.element.id)

View File

@ -36,8 +36,6 @@ export class ArtistsScene implements OnInit {
let self = this;
this.countTrack = (id: number) => { return self.countTrackCallback(id); };
this.countAlbum = (id: number) => { return self.countAlbumCallback(id); };
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
this.artistService.getOrder()
.then((response: Artist[]) => {
self.artists = response;

View File

@ -84,7 +84,9 @@ export class GenericDataService<TYPE> {
key: 'id',
value: [undefined, null],
},
]);
],
["name", "id"],
);
resolve(data);
}).catch((response) => {
console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`);

View File

@ -5,7 +5,7 @@
*/
import { Injectable } from '@angular/core';
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
import { isArrayOf, isNullOrUndefined, isNumberFinite, isString } from 'common/utils';
import { SessionService } from 'common/service';
import { RESTConfig, RESTUrl } from 'app/back-api/rest-tools';
@ -65,7 +65,7 @@ export class DataService {
* @returns the url of the cover
*/
getListUrl(dataIds?: string[]): string[] | undefined {
if (!isArrayOf(dataIds, isNumberFinite) || dataIds.length === 0) {
if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
return undefined;
}
let covers: string[] = [];
@ -97,7 +97,7 @@ export class DataService {
* @returns the url of the cover
*/
getListThumbnailUrl(dataIds?: string[]): string[] | undefined {
if (!isArrayOf(dataIds, isNumberFinite) || dataIds.length === 0) {
if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
return undefined;
}
let covers: string[] = [];