From ed3a00fc62cd7299655778eb2faa1b78dba12d5d Mon Sep 17 00:00:00 2001 From: Sven Carrillo Castillo Date: Tue, 12 Mar 2024 22:10:00 +0100 Subject: [PATCH 1/5] add h2 --- TODO.md | 11 ++++- .../map/rasterizer/LandMapRasterizer.java | 1 + .../map/rasterizer/SlopeMapRasterizer.java | 2 +- services/recom-backend/pom.xml | 43 ++++++++++++++++--- .../java/com/recom/entity/Configuration.java | 3 +- .../java/com/recom/entity/DBCachedItem.java | 3 +- .../main/java/com/recom/entity/Message.java | 5 ++- .../com/recom/entity/map/MapTopography.java | 3 +- .../ConfigurationMapToolsService.java | 9 +++- .../resources/application-local.properties | 9 ++-- 10 files changed, 73 insertions(+), 16 deletions(-) diff --git a/TODO.md b/TODO.md index d6858198..c9586e80 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,17 @@ # TODO LIST # 1 + * move mysql -> integrated h2 (/) + * execute sql on first start / db creation (add authentication) + * disable cache on authentification/ACCOUNT + * add authentication failed message to CLIENT!!!!!!!! + * maybe dbCached deserialization is broken?! + * make step size an int (minimum 1 meter); so no float and rounding will be used anymore in code > in client as well - * move mysql -> integrated h2 + + * add transparency of forest and structure merging + * add transparency of merging layers to configuration! + * * /api/v1/configuration/map-tools/resources/forest?mapName= tooks way too long; does it already make use of the resource_name, class_name and prefab_name tables? * cache forest and/or spatialForestMap > eclipseStore diff --git a/libs/commons/src/main/java/com/recom/commons/map/rasterizer/LandMapRasterizer.java b/libs/commons/src/main/java/com/recom/commons/map/rasterizer/LandMapRasterizer.java index fb9014b0..5c2ed061 100644 --- a/libs/commons/src/main/java/com/recom/commons/map/rasterizer/LandMapRasterizer.java +++ b/libs/commons/src/main/java/com/recom/commons/map/rasterizer/LandMapRasterizer.java @@ -25,6 +25,7 @@ public class LandMapRasterizer implements MapLayerRasterizer { private MapLayerRasterizerConfiguration mapLayerRasterizerConfiguration = MapLayerRasterizerConfiguration.builder() .rasterizerName(getClass().getSimpleName()) .layerOrder(LayerOrder.LAND_MAP) + .enabled(false) .build(); diff --git a/libs/commons/src/main/java/com/recom/commons/map/rasterizer/SlopeMapRasterizer.java b/libs/commons/src/main/java/com/recom/commons/map/rasterizer/SlopeMapRasterizer.java index 56be793c..951c3d9d 100644 --- a/libs/commons/src/main/java/com/recom/commons/map/rasterizer/SlopeMapRasterizer.java +++ b/libs/commons/src/main/java/com/recom/commons/map/rasterizer/SlopeMapRasterizer.java @@ -24,7 +24,7 @@ public class SlopeMapRasterizer implements MapLayerRasterizer { private MapLayerRasterizerConfiguration mapLayerRasterizerConfiguration = MapLayerRasterizerConfiguration.builder() .rasterizerName(getClass().getSimpleName()) .layerOrder(LayerOrder.SLOPE_MAP) - .visible(false) + .enabled(false) .build(); diff --git a/services/recom-backend/pom.xml b/services/recom-backend/pom.xml index 7079b0d4..cb4ffe58 100644 --- a/services/recom-backend/pom.xml +++ b/services/recom-backend/pom.xml @@ -101,11 +101,6 @@ org.springframework.boot spring-boot-starter-data-jpa - - org.mariadb.jdbc - mariadb-java-client - runtime - @@ -166,6 +161,44 @@ + + + h2-dev + + local + jdbc:h2:file:C:/Users/Sven/recomh2;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=8034;USER=username;PASSWORD=password + username + password + true + + + + com.h2database + h2 + runtime + + + + + mariadb-dev + + local + jdbc:mariadb://127.0.0.1:8033/recom_db + root + recomRootPwd + false + + + + org.mariadb.jdbc + mariadb-java-client + runtime + + + + + + diff --git a/services/recom-backend/src/main/java/com/recom/entity/Configuration.java b/services/recom-backend/src/main/java/com/recom/entity/Configuration.java index 2fda55bc..ff56fba9 100644 --- a/services/recom-backend/src/main/java/com/recom/entity/Configuration.java +++ b/services/recom-backend/src/main/java/com/recom/entity/Configuration.java @@ -45,7 +45,8 @@ public class Configuration implements Persistable, Serializable { private ConfigurationType type; @Lob - @Column(insertable = true, updatable = true, nullable = false, columnDefinition = "LONGTEXT") + // @Column(insertable = true, updatable = true, nullable = false, columnDefinition = "LONGTEXT") // MARIA DB + @Column(name = "conf_value", insertable = true, updatable = true, nullable = false) // H2 CHARACTER LARGE OBJECT private String value; @Nullable diff --git a/services/recom-backend/src/main/java/com/recom/entity/DBCachedItem.java b/services/recom-backend/src/main/java/com/recom/entity/DBCachedItem.java index 1ca3fea1..9f495ae2 100644 --- a/services/recom-backend/src/main/java/com/recom/entity/DBCachedItem.java +++ b/services/recom-backend/src/main/java/com/recom/entity/DBCachedItem.java @@ -36,7 +36,8 @@ public class DBCachedItem implements Persistable, Serializable { private String cacheName; @Lob - @Column(insertable = true, updatable = true, nullable = false, columnDefinition = "LONGBLOB") + // @Column(insertable = true, updatable = true, nullable = false, columnDefinition = "LONGBLOB") // MARIA DB + @Column(insertable = true, updatable = true, nullable = false) // H2 BINARY LARGE OBJECT private byte[] cachedValue; diff --git a/services/recom-backend/src/main/java/com/recom/entity/Message.java b/services/recom-backend/src/main/java/com/recom/entity/Message.java index 030449a9..54acd932 100644 --- a/services/recom-backend/src/main/java/com/recom/entity/Message.java +++ b/services/recom-backend/src/main/java/com/recom/entity/Message.java @@ -27,7 +27,7 @@ public class Message implements Persistable, Serializable { @Id -// @GeneratedValue(strategy = GenerationType.AUTO) + // @GeneratedValue(strategy = GenerationType.AUTO) @Column(insertable = true, updatable = false, nullable = false) private UUID uuid; @@ -39,7 +39,8 @@ public class Message implements Persistable, Serializable { private MessageType messageType; @Lob - @Column(insertable = true, updatable = true, nullable = true, columnDefinition = "LONGTEXT") + // @Column(insertable = true, updatable = true, nullable = true, columnDefinition = "LONGTEXT") // MARIA DB + @Column(insertable = true, updatable = true, nullable = true) // H2 CHARACTER LARGE OBJECT private String payload; @Column(insertable = true, updatable = false, nullable = true, columnDefinition = "DATETIME(6) DEFAULT NOW(6)") diff --git a/services/recom-backend/src/main/java/com/recom/entity/map/MapTopography.java b/services/recom-backend/src/main/java/com/recom/entity/map/MapTopography.java index 3a723c82..baf33b48 100644 --- a/services/recom-backend/src/main/java/com/recom/entity/map/MapTopography.java +++ b/services/recom-backend/src/main/java/com/recom/entity/map/MapTopography.java @@ -30,7 +30,8 @@ public class MapTopography implements Persistable, Serializable, MapRelate private GameMap gameMap; @Lob - @Column(insertable = true, updatable = true, nullable = false, columnDefinition = "LONGBLOB") + // @Column(insertable = true, updatable = true, nullable = false, columnDefinition = "LONGBLOB") + @Column(insertable = true, updatable = true, nullable = false) // H2 BINARY LARGE OBJECT private byte[] data; diff --git a/services/recom-backend/src/main/java/com/recom/service/configuration/ConfigurationMapToolsService.java b/services/recom-backend/src/main/java/com/recom/service/configuration/ConfigurationMapToolsService.java index c410ad1a..3143b478 100644 --- a/services/recom-backend/src/main/java/com/recom/service/configuration/ConfigurationMapToolsService.java +++ b/services/recom-backend/src/main/java/com/recom/service/configuration/ConfigurationMapToolsService.java @@ -77,16 +77,21 @@ private ConfigurationMapToolsService.AddResourcesTuple mergeWithExistingConfigur .toList(); final List matchedResourcesByPrefabs = mapStructurePersistenceLayer.findAllByPrefabIn(gameMap, matchedPrefabs).stream() .map(MapStructureEntity::getResourceName) + .filter(Objects::nonNull) .map(ResourceNameEntity::getName) + .filter(Objects::nonNull) .toList(); resourcesToAdd.addAll(matchedResourcesByPrefabs); final List matchedClasses = gameMapService.provideGameMapMetaData(gameMap).getUtilizedClasses().stream() .filter(utilizedPrefab -> utilizedPrefab.toLowerCase().matches(entityMatcher.toLowerCase())) .toList(); - final List matchedResourcesByClasses = mapStructurePersistenceLayer.findAllByClassIn(gameMap, matchedClasses).stream() + List allByClassIn = mapStructurePersistenceLayer.findAllByClassIn(gameMap, matchedClasses); + final List matchedResourcesByClasses = allByClassIn.stream() .map(MapStructureEntity::getResourceName) + .filter(Objects::nonNull) .map(ResourceNameEntity::getName) + .filter(Objects::nonNull) .toList(); resourcesToAdd.addAll(matchedResourcesByClasses); @@ -95,7 +100,9 @@ private ConfigurationMapToolsService.AddResourcesTuple mergeWithExistingConfigur .toList(); final List matchedResourcesByMapDescriptorTypes = mapStructurePersistenceLayer.findAllByMapDescriptorTypeIn(gameMap, matchedMapDescriptorTypes).stream() .map(MapStructureEntity::getResourceName) + .filter(Objects::nonNull) .map(ResourceNameEntity::getName) + .filter(Objects::nonNull) .toList(); resourcesToAdd.addAll(matchedResourcesByMapDescriptorTypes); }); diff --git a/services/recom-backend/src/main/resources/application-local.properties b/services/recom-backend/src/main/resources/application-local.properties index 6f920dc8..2f9bbb93 100644 --- a/services/recom-backend/src/main/resources/application-local.properties +++ b/services/recom-backend/src/main/resources/application-local.properties @@ -1,8 +1,11 @@ server.port=8080 -spring.datasource.url=jdbc:mariadb://127.0.0.1:8033/recom_db -spring.datasource.username=root -spring.datasource.password=recomRootPwd +spring.datasource.url=@env.spring.datasource.url@ +spring.datasource.username=@env.spring.datasource.username@ +spring.datasource.password=@env.spring.datasource.password@ + +spring.h2.console.enabled=@env.spring.h2.console.enabled@ + spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto=update From 94251f3f9354237ae2e516765ef9b4f660a9a91a Mon Sep 17 00:00:00 2001 From: Sven Carrillo Castillo Date: Tue, 12 Mar 2024 22:58:01 +0100 Subject: [PATCH 2/5] add h2; init sql --- services/recom-backend/pom.xml | 4 ++-- .../java/com/recom/security/PublicEndpointsProvider.java | 6 ++++++ .../src/main/resources/application-local.properties | 5 +++++ services/recom-backend/src/main/resources/data.sql | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 services/recom-backend/src/main/resources/data.sql diff --git a/services/recom-backend/pom.xml b/services/recom-backend/pom.xml index cb4ffe58..9bdbc5ea 100644 --- a/services/recom-backend/pom.xml +++ b/services/recom-backend/pom.xml @@ -166,10 +166,10 @@ h2-dev local - jdbc:h2:file:C:/Users/Sven/recomh2;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=8034;USER=username;PASSWORD=password + jdbc:h2:file:C:/Users/Sven/RECOMBackend/recomh2;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=8034;USER=username;PASSWORD=password username password - true + false diff --git a/services/recom-backend/src/main/java/com/recom/security/PublicEndpointsProvider.java b/services/recom-backend/src/main/java/com/recom/security/PublicEndpointsProvider.java index ebc65cce..6cd1d20e 100644 --- a/services/recom-backend/src/main/java/com/recom/security/PublicEndpointsProvider.java +++ b/services/recom-backend/src/main/java/com/recom/security/PublicEndpointsProvider.java @@ -42,6 +42,12 @@ private static List publicEndpoints() { @NonNull private static List swaggerEndpoints() { return List.of( +// AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/favicon.ico"), +// AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/h2-console"), +// AntPathRequestMatcher.antMatcher(HttpMethod.POST, "/h2-console"), +// AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/h2-console/**"), +// AntPathRequestMatcher.antMatcher(HttpMethod.POST, "/h2-console/**"), + AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/swagger-ui.html"), AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/swagger-ui/**"), AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/v3/api-docs/**"), diff --git a/services/recom-backend/src/main/resources/application-local.properties b/services/recom-backend/src/main/resources/application-local.properties index 2f9bbb93..dae501d3 100644 --- a/services/recom-backend/src/main/resources/application-local.properties +++ b/services/recom-backend/src/main/resources/application-local.properties @@ -4,6 +4,11 @@ spring.datasource.url=@env.spring.datasource.url@ spring.datasource.username=@env.spring.datasource.username@ spring.datasource.password=@env.spring.datasource.password@ +# executes data.sql AFTER hibernate DDL +spring.jpa.defer-datasource-initialization=true +# run data.sql on every startup (not only on first startup) +spring.sql.init.mode=always + spring.h2.console.enabled=@env.spring.h2.console.enabled@ diff --git a/services/recom-backend/src/main/resources/data.sql b/services/recom-backend/src/main/resources/data.sql new file mode 100644 index 00000000..3423cf2d --- /dev/null +++ b/services/recom-backend/src/main/resources/data.sql @@ -0,0 +1,3 @@ +MERGE INTO account (account_uuid, access_key) + KEY (account_uuid) + VALUES ('d7840e5e-7fd8-48ee-a3f8-86ff15aacd0d', '06c6db2a-e49e-4153-906a-14beb0e8fc29'); \ No newline at end of file From 4968c7fe4157edde14e7a018cb7c81f02868cc99 Mon Sep 17 00:00:00 2001 From: Sven Carrillo Castillo Date: Tue, 12 Mar 2024 23:12:55 +0100 Subject: [PATCH 3/5] add db vendor platform data.sql --- TODO.md | 9 +++++---- .../src/main/resources/application-local.properties | 4 ++-- .../src/main/resources/{data.sql => data-h2.sql} | 0 services/recom-backend/src/main/resources/data-maria.sql | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) rename services/recom-backend/src/main/resources/{data.sql => data-h2.sql} (100%) create mode 100644 services/recom-backend/src/main/resources/data-maria.sql diff --git a/TODO.md b/TODO.md index c9586e80..3a5b6708 100644 --- a/TODO.md +++ b/TODO.md @@ -2,17 +2,18 @@ # 1 * move mysql -> integrated h2 (/) - * execute sql on first start / db creation (add authentication) + * execute sql on first start / db creation (add authentication) (/) + * * disable cache on authentification/ACCOUNT * add authentication failed message to CLIENT!!!!!!!! * maybe dbCached deserialization is broken?! * make step size an int (minimum 1 meter); so no float and rounding will be used anymore in code > in client as well - * add transparency of forest and structure merging - * add transparency of merging layers to configuration! + * Merge Layer Transparency + * add transparency of forest and structure merging + * add transparency of merging layers to configuration! - * * /api/v1/configuration/map-tools/resources/forest?mapName= tooks way too long; does it already make use of the resource_name, class_name and prefab_name tables? * cache forest and/or spatialForestMap > eclipseStore diff --git a/services/recom-backend/src/main/resources/application-local.properties b/services/recom-backend/src/main/resources/application-local.properties index dae501d3..39c311f0 100644 --- a/services/recom-backend/src/main/resources/application-local.properties +++ b/services/recom-backend/src/main/resources/application-local.properties @@ -4,9 +4,9 @@ spring.datasource.url=@env.spring.datasource.url@ spring.datasource.username=@env.spring.datasource.username@ spring.datasource.password=@env.spring.datasource.password@ -# executes data.sql AFTER hibernate DDL +# executes data-h2.sql AFTER hibernate DDL spring.jpa.defer-datasource-initialization=true -# run data.sql on every startup (not only on first startup) +# run data-h2.sql on every startup (not only on first startup) spring.sql.init.mode=always spring.h2.console.enabled=@env.spring.h2.console.enabled@ diff --git a/services/recom-backend/src/main/resources/data.sql b/services/recom-backend/src/main/resources/data-h2.sql similarity index 100% rename from services/recom-backend/src/main/resources/data.sql rename to services/recom-backend/src/main/resources/data-h2.sql diff --git a/services/recom-backend/src/main/resources/data-maria.sql b/services/recom-backend/src/main/resources/data-maria.sql new file mode 100644 index 00000000..0d4ab4bc --- /dev/null +++ b/services/recom-backend/src/main/resources/data-maria.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO account (account_uuid, access_key) +VALUES ('d7840e5e-7fd8-48ee-a3f8-86ff15aacd0d', '06c6db2a-e49e-4153-906a-14beb0e8fc29'); \ No newline at end of file From 4849a7dae9d66f248d29b3b7ce36e74c59828556 Mon Sep 17 00:00:00 2001 From: Sven Carrillo Castillo Date: Tue, 12 Mar 2024 23:17:06 +0100 Subject: [PATCH 4/5] add h2 data.sql --- .../src/main/resources/application-local.properties | 4 ++-- services/recom-backend/src/main/resources/data-maria.sql | 2 -- .../src/main/resources/{data-h2.sql => data.sql} | 0 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 services/recom-backend/src/main/resources/data-maria.sql rename services/recom-backend/src/main/resources/{data-h2.sql => data.sql} (100%) diff --git a/services/recom-backend/src/main/resources/application-local.properties b/services/recom-backend/src/main/resources/application-local.properties index 39c311f0..dae501d3 100644 --- a/services/recom-backend/src/main/resources/application-local.properties +++ b/services/recom-backend/src/main/resources/application-local.properties @@ -4,9 +4,9 @@ spring.datasource.url=@env.spring.datasource.url@ spring.datasource.username=@env.spring.datasource.username@ spring.datasource.password=@env.spring.datasource.password@ -# executes data-h2.sql AFTER hibernate DDL +# executes data.sql AFTER hibernate DDL spring.jpa.defer-datasource-initialization=true -# run data-h2.sql on every startup (not only on first startup) +# run data.sql on every startup (not only on first startup) spring.sql.init.mode=always spring.h2.console.enabled=@env.spring.h2.console.enabled@ diff --git a/services/recom-backend/src/main/resources/data-maria.sql b/services/recom-backend/src/main/resources/data-maria.sql deleted file mode 100644 index 0d4ab4bc..00000000 --- a/services/recom-backend/src/main/resources/data-maria.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT IGNORE INTO account (account_uuid, access_key) -VALUES ('d7840e5e-7fd8-48ee-a3f8-86ff15aacd0d', '06c6db2a-e49e-4153-906a-14beb0e8fc29'); \ No newline at end of file diff --git a/services/recom-backend/src/main/resources/data-h2.sql b/services/recom-backend/src/main/resources/data.sql similarity index 100% rename from services/recom-backend/src/main/resources/data-h2.sql rename to services/recom-backend/src/main/resources/data.sql From e2a8c72ad442d2906bbcc0b7b6219c0eddab1451 Mon Sep 17 00:00:00 2001 From: Sven Carrillo Castillo Date: Wed, 13 Mar 2024 22:04:54 +0100 Subject: [PATCH 5/5] add h2 data.sql --- TODO.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 3a5b6708..7fc7baed 100644 --- a/TODO.md +++ b/TODO.md @@ -1,15 +1,22 @@ # TODO LIST # 1 - * move mysql -> integrated h2 (/) - * execute sql on first start / db creation (add authentication) (/) - * - * disable cache on authentification/ACCOUNT * add authentication failed message to CLIENT!!!!!!!! - * maybe dbCached deserialization is broken?! + * make stepSize Integer!!!!!!!! (client + server) + + * topography: + * map has to be stored in chunks + * if enough data are send, a chunk is stored in db + * client asks always for next chunk before it is created. + * chunk size 1000x1000 + + * dbcache forest and structure provider!!! + * call to load/prepare caches for specific map * make step size an int (minimum 1 meter); so no float and rounding will be used anymore in code > in client as well + + * dbBache layers (input configuration parameters) * Merge Layer Transparency * add transparency of forest and structure merging * add transparency of merging layers to configuration!