[IX] continue integration of mango
This commit is contained in:
parent
2c0fb99202
commit
a503aa95a9
@ -1,13 +1,13 @@
|
|||||||
package org.kar.karusic;
|
package org.kar.karusic;
|
||||||
|
|
||||||
import org.kar.archidata.db.DbInterfaceMorphia;
|
import org.kar.archidata.db.DbIoMorphia;
|
||||||
import org.kar.karusic.model.Album;
|
import org.kar.karusic.model.Album;
|
||||||
import org.kar.karusic.model.Artist;
|
import org.kar.karusic.model.Artist;
|
||||||
import org.kar.karusic.model.Gender;
|
import org.kar.karusic.model.Gender;
|
||||||
import org.kar.karusic.model.Playlist;
|
import org.kar.karusic.model.Playlist;
|
||||||
import org.kar.karusic.model.Track;
|
import org.kar.karusic.model.Track;
|
||||||
|
|
||||||
public class MorphiaService extends DbInterfaceMorphia {
|
public class MorphiaService extends DbIoMorphia {
|
||||||
|
|
||||||
public MorphiaService() {
|
public MorphiaService() {
|
||||||
super("mongodb://root:base_db_password@localhost:27017", "karusic", Album.class, Artist.class, Gender.class, Playlist.class, Track.class);
|
super("mongodb://root:base_db_password@localhost:27017", "karusic", Album.class, Artist.class, Gender.class, Playlist.class, Track.class);
|
||||||
|
@ -17,9 +17,11 @@ import org.kar.archidata.UpdateJwtPublicKey;
|
|||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.api.ProxyResource;
|
import org.kar.archidata.api.ProxyResource;
|
||||||
import org.kar.archidata.catcher.GenericCatcher;
|
import org.kar.archidata.catcher.GenericCatcher;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
|
import org.kar.archidata.filter.ArchiveHttpMethodFilter;
|
||||||
import org.kar.archidata.filter.CORSFilter;
|
import org.kar.archidata.filter.CORSFilter;
|
||||||
import org.kar.archidata.filter.OptionFilter;
|
import org.kar.archidata.filter.OptionFilter;
|
||||||
|
import org.kar.archidata.filter.RestoreHttpMethodFilter;
|
||||||
import org.kar.archidata.migration.MigrationEngine;
|
import org.kar.archidata.migration.MigrationEngine;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.karusic.api.AlbumResource;
|
import org.kar.karusic.api.AlbumResource;
|
||||||
@ -45,18 +47,18 @@ public class WebLauncher {
|
|||||||
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||||
protected UpdateJwtPublicKey keyUpdater = null;
|
protected UpdateJwtPublicKey keyUpdater = null;
|
||||||
protected HttpServer server = null;
|
protected HttpServer server = null;
|
||||||
|
|
||||||
private final DataAccess da;
|
private final DBAccess da;
|
||||||
|
|
||||||
public WebLauncher() {
|
public WebLauncher() {
|
||||||
ConfigBaseVariable.bdDatabase = "karusic";
|
ConfigBaseVariable.bdDatabase = "karusic";
|
||||||
this.da = DataAccess.createInterface();
|
this.da = DBAccess.createInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static URI getBaseURI() {
|
private static URI getBaseURI() {
|
||||||
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrateDB() throws Exception {
|
public void migrateDB() throws Exception {
|
||||||
WebLauncher.LOGGER.info("Create migration engine");
|
WebLauncher.LOGGER.info("Create migration engine");
|
||||||
final MigrationEngine migrationEngine = new MigrationEngine(this.da);
|
final MigrationEngine migrationEngine = new MigrationEngine(this.da);
|
||||||
@ -71,12 +73,12 @@ public class WebLauncher {
|
|||||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.getDbconfig());
|
migrationEngine.migrateWaitAdmin(GlobalConfiguration.getDbconfig());
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
WebLauncher.LOGGER.info("[START] application wake UP");
|
WebLauncher.LOGGER.info("[START] application wake UP");
|
||||||
final WebLauncher launcher = new WebLauncher();
|
final WebLauncher launcher = new WebLauncher();
|
||||||
launcher.migrateDB();
|
launcher.migrateDB();
|
||||||
|
|
||||||
launcher.process();
|
launcher.process();
|
||||||
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
||||||
Thread.currentThread().join();
|
Thread.currentThread().join();
|
||||||
@ -84,7 +86,7 @@ public class WebLauncher {
|
|||||||
launcher.stopOther();
|
launcher.stopOther();
|
||||||
WebLauncher.LOGGER.info("STOP the REST server:");
|
WebLauncher.LOGGER.info("STOP the REST server:");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void plop(final String aaa) {
|
public void plop(final String aaa) {
|
||||||
// List available Image Readers
|
// List available Image Readers
|
||||||
System.out.println("Available Image Readers:");
|
System.out.println("Available Image Readers:");
|
||||||
@ -95,7 +97,7 @@ public class WebLauncher {
|
|||||||
System.out.println("Reader CN: " + reader.getOriginatingProvider().getPluginClassName());
|
System.out.println("Reader CN: " + reader.getOriginatingProvider().getPluginClassName());
|
||||||
// ImageIO.deregisterServiceProvider(reader.getOriginatingProvider());
|
// ImageIO.deregisterServiceProvider(reader.getOriginatingProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
// List available Image Writers
|
// List available Image Writers
|
||||||
System.out.println("\nAvailable Image Writers:");
|
System.out.println("\nAvailable Image Writers:");
|
||||||
final Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(aaa);
|
final Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(aaa);
|
||||||
@ -105,9 +107,9 @@ public class WebLauncher {
|
|||||||
System.out.println("Writer CN: " + writer.getOriginatingProvider().getPluginClassName());
|
System.out.println("Writer CN: " + writer.getOriginatingProvider().getPluginClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process() throws InterruptedException {
|
public void process() throws InterruptedException {
|
||||||
|
|
||||||
ImageIO.scanForPlugins();
|
ImageIO.scanForPlugins();
|
||||||
plop("jpeg");
|
plop("jpeg");
|
||||||
plop("png");
|
plop("png");
|
||||||
@ -117,7 +119,7 @@ public class WebLauncher {
|
|||||||
// Configure resources
|
// Configure resources
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
final ResourceConfig rc = new ResourceConfig();
|
final ResourceConfig rc = new ResourceConfig();
|
||||||
|
|
||||||
// add multipart models ..
|
// add multipart models ..
|
||||||
rc.register(MultiPartFeature.class);
|
rc.register(MultiPartFeature.class);
|
||||||
// global authentication system
|
// global authentication system
|
||||||
@ -126,6 +128,9 @@ public class WebLauncher {
|
|||||||
rc.register(CORSFilter.class);
|
rc.register(CORSFilter.class);
|
||||||
// global authentication system
|
// global authentication system
|
||||||
rc.register(KarusicAuthenticationFilter.class);
|
rc.register(KarusicAuthenticationFilter.class);
|
||||||
|
// add dependency of restore and archive
|
||||||
|
rc.register(RestoreHttpMethodFilter.class);
|
||||||
|
rc.register(ArchiveHttpMethodFilter.class);
|
||||||
// register exception catcher
|
// register exception catcher
|
||||||
GenericCatcher.addAll(rc);
|
GenericCatcher.addAll(rc);
|
||||||
// add default resource:
|
// add default resource:
|
||||||
@ -137,15 +142,15 @@ public class WebLauncher {
|
|||||||
rc.register(TrackResource.class);
|
rc.register(TrackResource.class);
|
||||||
rc.register(DataResource.class);
|
rc.register(DataResource.class);
|
||||||
rc.register(ProxyResource.class);
|
rc.register(ProxyResource.class);
|
||||||
|
|
||||||
rc.register(HealthCheck.class);
|
rc.register(HealthCheck.class);
|
||||||
rc.register(Front.class);
|
rc.register(Front.class);
|
||||||
|
|
||||||
// add jackson to be discover when we are ins standalone server
|
// add jackson to be discover when we are ins standalone server
|
||||||
rc.register(JacksonFeature.class);
|
rc.register(JacksonFeature.class);
|
||||||
// enable this to show low level request
|
// enable this to show low level request
|
||||||
// rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
// rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||||
|
|
||||||
// System.out.println("Connect on the BDD:");
|
// System.out.println("Connect on the BDD:");
|
||||||
// System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
|
// System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
|
||||||
// System.out.println(" getDBPort: '" + ConfigVariable.getDBPort() + "'");
|
// System.out.println(" getDBPort: '" + ConfigVariable.getDBPort() + "'");
|
||||||
@ -163,13 +168,13 @@ public class WebLauncher {
|
|||||||
serverLink.shutdownNow();
|
serverLink.shutdownNow();
|
||||||
}
|
}
|
||||||
}, "shutdownHook"));
|
}, "shutdownHook"));
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
// start periodic update of the token ...
|
// start periodic update of the token ...
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
this.keyUpdater = new UpdateJwtPublicKey();
|
this.keyUpdater = new UpdateJwtPublicKey();
|
||||||
this.keyUpdater.start();
|
this.keyUpdater.start();
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
// run JERSEY
|
// run JERSEY
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
@ -181,14 +186,14 @@ public class WebLauncher {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (this.server != null) {
|
if (this.server != null) {
|
||||||
this.server.shutdownNow();
|
this.server.shutdownNow();
|
||||||
this.server = null;
|
this.server = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopOther() {
|
public void stopOther() {
|
||||||
this.keyUpdater.kill();
|
this.keyUpdater.kill();
|
||||||
try {
|
try {
|
||||||
|
@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
|||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.FormDataOptional;
|
import org.kar.archidata.annotation.FormDataOptional;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunction;
|
import org.kar.archidata.dataAccess.options.CheckFunction;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
@ -36,7 +36,7 @@ public class AlbumResource {
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class);
|
||||||
static final AlbumChecker CHECKER = new AlbumChecker();
|
static final AlbumChecker CHECKER = new AlbumChecker();
|
||||||
|
|
||||||
private final DataAccess da = DataAccess.createInterface();
|
private final DBAccess da = DBAccess.createInterface();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
|||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.FormDataOptional;
|
import org.kar.archidata.annotation.FormDataOptional;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunction;
|
import org.kar.archidata.dataAccess.options.CheckFunction;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
@ -34,7 +34,7 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
public class ArtistResource {
|
public class ArtistResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
||||||
static final ArtistChecker CHECKER = new ArtistChecker();
|
static final ArtistChecker CHECKER = new ArtistChecker();
|
||||||
private final DataAccess da = DataAccess.createInterface();
|
private final DBAccess da = DBAccess.createInterface();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@ -9,7 +9,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
|||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.FormDataOptional;
|
import org.kar.archidata.annotation.FormDataOptional;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunction;
|
import org.kar.archidata.dataAccess.options.CheckFunction;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
@ -34,7 +34,7 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
public class GenderResource {
|
public class GenderResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
||||||
static final GenderChecker CHECKER = new GenderChecker();
|
static final GenderChecker CHECKER = new GenderChecker();
|
||||||
private final DataAccess da = DataAccess.createInterface();
|
private final DBAccess da = DBAccess.createInterface();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
|||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunction;
|
import org.kar.archidata.dataAccess.options.CheckFunction;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
@ -32,7 +32,7 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
public class PlaylistResource {
|
public class PlaylistResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
||||||
static final TrackChecker CHECKER = new TrackChecker();
|
static final TrackChecker CHECKER = new TrackChecker();
|
||||||
private final DataAccess da = DataAccess.createInterface();
|
private final DBAccess da = DBAccess.createInterface();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@ -12,7 +12,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
|||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.FormDataOptional;
|
import org.kar.archidata.annotation.FormDataOptional;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.CheckFunction;
|
import org.kar.archidata.dataAccess.options.CheckFunction;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
@ -39,7 +39,7 @@ import jakarta.ws.rs.core.Response;
|
|||||||
public class TrackResource {
|
public class TrackResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class);
|
||||||
static final TrackChecker CHECKER = new TrackChecker();
|
static final TrackChecker CHECKER = new TrackChecker();
|
||||||
private final DataAccess da = DataAccess.createInterface();
|
private final DBAccess da = DBAccess.createInterface();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@ -3,7 +3,7 @@ package org.kar.karusic.api;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.filter.GenericContext;
|
import org.kar.archidata.filter.GenericContext;
|
||||||
import org.kar.karusic.api.UserResourceModel.PartRight;
|
import org.kar.karusic.api.UserResourceModel.PartRight;
|
||||||
import org.kar.karusic.api.UserResourceModel.UserMe;
|
import org.kar.karusic.api.UserResourceModel.UserMe;
|
||||||
@ -26,7 +26,7 @@ import jakarta.ws.rs.core.SecurityContext;
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class UserResource {
|
public class UserResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
||||||
private final DataAccess da = DataAccess.createInterface();
|
private final DBAccess da = DBAccess.createInterface();
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class UserOut {
|
public class UserOut {
|
||||||
|
@ -2,7 +2,7 @@ package org.kar.karusic.migration;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
@ -35,7 +35,7 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
addClass(elem);
|
addClass(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
addAction((final DataAccess da) -> {
|
addAction((final DBAccess da) -> {
|
||||||
final List<Gender> data = List.of(//
|
final List<Gender> data = List.of(//
|
||||||
new Gender(1L, "Variété française"), //
|
new Gender(1L, "Variété française"), //
|
||||||
new Gender(2L, "Pop"), //
|
new Gender(2L, "Pop"), //
|
||||||
@ -85,7 +85,7 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
""", "mysql");
|
""", "mysql");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dropAll(final DataAccess da) {
|
public static void dropAll(final DBAccess da) {
|
||||||
for (final Class<?> element : CLASSES_BASE) {
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
try {
|
try {
|
||||||
da.drop(element);
|
da.drop(element);
|
||||||
@ -96,7 +96,7 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cleanAll(final DataAccess da) {
|
public static void cleanAll(final DBAccess da) {
|
||||||
for (final Class<?> element : CLASSES_BASE) {
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
try {
|
try {
|
||||||
da.cleanAll(element);
|
da.cleanAll(element);
|
||||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DBAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.model.LinkTableLongLong;
|
import org.kar.archidata.dataAccess.addOn.model.LinkTableLongLong;
|
||||||
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
||||||
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
||||||
@ -40,12 +40,12 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
||||||
""");
|
""");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
for (final UUIDConversion elem : datas) {
|
for (final UUIDConversion elem : datas) {
|
||||||
elem.uuid = UuidUtils.nextUUID();
|
elem.uuid = UuidUtils.nextUUID();
|
||||||
}
|
}
|
||||||
for (final UUIDConversion elem : datas) {
|
for (final UUIDConversion elem : datas) {
|
||||||
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
DBAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addAction("""
|
addAction("""
|
||||||
@ -55,9 +55,9 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
for (final String tableName : tableToTransform) {
|
for (final String tableName : tableToTransform) {
|
||||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
final List<CoverConversion> medias = DBAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
||||||
final List<LinkTableLongLong> links = DataAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
|
final List<LinkTableLongLong> links = DBAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
|
||||||
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
||||||
for (final CoverConversion media : medias) {
|
for (final CoverConversion media : medias) {
|
||||||
final List<UUID> values = new ArrayList<>();
|
final List<UUID> values = new ArrayList<>();
|
||||||
@ -75,7 +75,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
if (values.size() != 0) {
|
if (values.size() != 0) {
|
||||||
media.covers = values;
|
media.covers = values;
|
||||||
LOGGER.info(" update: {} => {}", media.id, media.covers);
|
LOGGER.info(" update: {} => {}", media.id, media.covers);
|
||||||
DataAccess.update(media, media.id, List.of("covers"), new OverrideTableName(tableName));
|
DBAccess.update(media, media.id, List.of("covers"), new OverrideTableName(tableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -85,13 +85,13 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
|
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
|
||||||
""");
|
""");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
final List<MediaConversion> medias = DBAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
||||||
for (final MediaConversion media : medias) {
|
for (final MediaConversion media : medias) {
|
||||||
for (final UUIDConversion data : datas) {
|
for (final UUIDConversion data : datas) {
|
||||||
if (data.id.equals(media.dataId)) {
|
if (data.id.equals(media.dataId)) {
|
||||||
media.dataUUID = data.uuid;
|
media.dataUUID = data.uuid;
|
||||||
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
|
DBAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
""");
|
""");
|
||||||
// Move the files...
|
// Move the files...
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DBAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
for (final UUIDConversion data : datas) {
|
for (final UUIDConversion data : datas) {
|
||||||
final String origin = DataResource.getFileDataOld(data.id);
|
final String origin = DataResource.getFileDataOld(data.id);
|
||||||
final String destination = DataResource.getFileData(data.uuid);
|
final String destination = DataResource.getFileData(data.uuid);
|
||||||
|
@ -19,6 +19,7 @@ services:
|
|||||||
|
|
||||||
kar_mongodb_service:
|
kar_mongodb_service:
|
||||||
image: mongo:latest
|
image: mongo:latest
|
||||||
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
MONGO_INITDB_ROOT_USERNAME: root
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
MONGO_INITDB_ROOT_PASSWORD: base_db_password
|
MONGO_INITDB_ROOT_PASSWORD: base_db_password
|
||||||
|
Loading…
x
Reference in New Issue
Block a user