Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
df376a3f
by Tony Chemit at 2022-09-11T20:04:04+02:00
-
553ce875
by Tony Chemit at 2022-09-11T20:23:37+02:00
-
355d696b
by Tony Chemit at 2022-09-11T20:34:39+02:00
-
a9be2e1d
by Tony Chemit at 2022-09-11T22:35:16+02:00
-
e6cebd5e
by Tony Chemit at 2022-09-11T23:24:38+02:00
-
f2f53e78
by Tony Chemit at 2022-09-12T00:38:25+02:00
9 changed files:
- CHANGELOG.md
- core/persistence/java/src/main/resources/META-INF/persistence/Observe/TopiaEntitySqlReplicatePlanModel.json
- pom.xml
- toolkit/persistence/src/main/java/org/nuiton/topia/service/sql/TopiaEntitySqlModelResource.java
- toolkit/persistence/src/main/java/org/nuiton/topia/service/sql/internal/consumer/DeletePartialEntityConsumer.java
- toolkit/persistence/src/main/java/org/nuiton/topia/service/sql/internal/consumer/DuplicateEntityConsumer.java
- toolkit/persistence/src/main/java/org/nuiton/topia/service/sql/internal/consumer/ReplicateEntityWork.java
- toolkit/persistence/src/main/java/org/nuiton/topia/service/sql/internal/consumer/ReplicateEntityWorkContext.java
- toolkit/templates/src/main/java/org/nuiton/topia/templates/sql/plan/TopiaEntitySqlReplicatePlanBuilder.java
Changes:
| 1 | 1 | # ObServe changelog
|
| 2 | 2 | |
| 3 | 3 | * Author [Tony Chemit](mailto:dev@tchemit.fr)
|
| 4 | - * Last generated at 2022-09-02 19:20.
|
|
| 4 | + * Last generated at 2022-09-11 20:03.
|
|
| 5 | 5 | |
| 6 | 6 | ## Version [9.0.7](https://gitlab.com/ultreiaio/ird-observe/-/milestones/232)
|
| 7 | 7 | |
| ... | ... | @@ -15,15 +15,25 @@ |
| 15 | 15 | ### Issues
|
| 16 | 16 | * [[Type::Anomalie 2324]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2324) **Ouverture de base impossible selon configuration précédente de l'arbre** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 17 | 17 | * [[Type::Anomalie 2327]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2327) **Clé de libellé non traduite en anglais sur la page de synchrod e la synchro avancée** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 18 | + * [[Type::Anomalie 2331]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2331) **Erreur après une mise à jour simple de référentiel de la base locale** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 19 | + * [[Type::Anomalie 2340]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2340) **La taille de la fenêtre de configuration de l'arbre de navigation tronque les boutons du bas si on passe du module PS vers LL** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 20 | + * [[Type::Anomalie 2381]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2381) **Connection manager, bases distantes, champs non visibles sous Windows** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 21 | + * [[Type::Anomalie 2399]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2399) **Problème SSL - en attente - ne s'est pas reproduit** (Thanks to Pascal Cauquil) (Reported by Pascal Cauquil)
|
|
| 18 | 22 | * [[Type::Anomalie 2411]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2411) **HResponseErrorException / InvalidAuthenticationTokenException en 9.0.6 en quittant l'application** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 19 | 23 | * [[Type::Anomalie 2412]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2412) **Certains services sont encore en GET alors qu'ils devraient être en POST** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
| 24 | + * [[Type::Anomalie 2415]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2415) **Erreur lors du rechargement de la source si token expiré** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 20 | 25 | * [[Type::Anomalie 2416]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2416) **La boîte 'A propos' ne fontionne pas** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 21 | 26 | * [[Type::Anomalie 2419]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2419) **Erreur de migration de l'espèce AVDTH 8 de CAPT_ELEM vers ps_logbook.catch** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 22 | 27 | * [[Type::Anomalie 2420]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2420) **Statut de la doc de mapping des espèces AVDTH/ObServe** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 23 | 28 | * [[Type::Anomalie 2423]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2423) **Erreur calcul des données sur V9** (Thanks to Tony CHEMIT) (Reported by Philippe Sabarros)
|
| 24 | 29 | * [[Type::Anomalie 2427]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2427) **Erreur de type de mesure sur les échantillons AVDTH migrés** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 30 | + * [[Type::Anomalie 2428]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2428) **Problème lors d'un déplacement de toutes les données d'une marée Senne** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 31 | + * [[Type::Evolution 1248]](https://gitlab.com/ultreiaio/ird-observe/-/issues/1248) **Mise à jour du module cartographie avec les nouvelles données** (Thanks to Pascal Cauquil) (Reported by Tony CHEMIT)
|
|
| 25 | 32 | * [[Type::Evolution 1751]](https://gitlab.com/ultreiaio/ird-observe/-/issues/1751) **Mettre un sablier lors de l'ouverture si le nœud a beaucoup de données à charger.** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
| 33 | + * [[Type::Evolution 1866]](https://gitlab.com/ultreiaio/ird-observe/-/issues/1866) **Remplir les données depuis AVDTH** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 26 | 34 | * [[Type::Evolution 2104]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2104) **On pourrait avoir un service de génération de topiaid** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 35 | + * [[Type::Evolution 2223]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2223) **Ajouter une action nouvelle marée dans l'arbre de navigation** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 36 | + * [[Type::Evolution 2225]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2225) **Bien gérer le repositionnement dans l'arbre de navigation d'une marée suite à une sauvegarde si le critère a été modifié** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 27 | 37 | * [[Type::Evolution 2232]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2232) **Dans l'UI des profils de connexion, trimmer les espaces** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 28 | 38 | * [[Type::Evolution 2259]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2259) **Dans l'assistant rapport, ajouter un export CSV** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 29 | 39 | * [[Type::Evolution 2293]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2293) **Il serait intéressant de permettre l'absence de base déclarée par défaut** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| ... | ... | @@ -898,6 +898,7 @@ |
| 898 | 898 | "from": "WHERE sampleActivity.sample %s",
|
| 899 | 899 | "parentColumnName": "sample",
|
| 900 | 900 | "columnNames": "topiaId,topiaCreateDate,topiaVersion,lastUpdateDate,homeId,weightedWeight,activity,sample",
|
| 901 | + "columnsToDetach": "activity~ps_logbook.activity",
|
|
| 901 | 902 | "requiredTypes": "ps_logbook.activity"
|
| 902 | 903 | },
|
| 903 | 904 | {
|
| ... | ... | @@ -926,6 +927,7 @@ |
| 926 | 927 | "from": "WHERE sampleActivity.topiaId %s",
|
| 927 | 928 | "parentColumnName": "sample",
|
| 928 | 929 | "columnNames": "topiaId,topiaCreateDate,topiaVersion,lastUpdateDate,homeId,weightedWeight,activity,sample",
|
| 930 | + "columnsToDetach": "activity~ps_logbook.activity",
|
|
| 929 | 931 | "requiredTypes": "ps_logbook.activity",
|
| 930 | 932 | "entryPoint": true
|
| 931 | 933 | }
|
| ... | ... | @@ -969,6 +971,7 @@ |
| 969 | 971 | "from": "WHERE wellPlan.topiaId %s",
|
| 970 | 972 | "parentColumnName": "trip",
|
| 971 | 973 | "columnNames": "topiaId,topiaCreateDate,topiaVersion,trip_idx,lastUpdateDate,homeId,well,weight,activity,species,weightCategory,wellSamplingConformity,wellSamplingStatus,trip",
|
| 974 | + "columnsToDetach": "activity~ps_logbook.activity",
|
|
| 972 | 975 | "requiredTypes": "ps_logbook.activity",
|
| 973 | 976 | "entryPoint": true
|
| 974 | 977 | }
|
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | <parent>
|
| 24 | 24 | <groupId>io.ultreia.maven</groupId>
|
| 25 | 25 | <artifactId>pom</artifactId>
|
| 26 | - <version>2022.84</version>
|
|
| 26 | + <version>2022.85</version>
|
|
| 27 | 27 | </parent>
|
| 28 | 28 | <groupId>fr.ird.observe</groupId>
|
| 29 | 29 | <artifactId>ird-observe</artifactId>
|
| ... | ... | @@ -119,7 +119,7 @@ |
| 119 | 119 | <lib.version.h2>1.4.196</lib.version.h2>
|
| 120 | 120 | <!-- FIXME can't use 1.4.197 (date has changed + blob also)-->
|
| 121 | 121 | <!-- FIXME <lib.version.h2>2.1.210</lib.version.h2>-->
|
| 122 | - <lib.version.hibernate>5.6.10.Final</lib.version.hibernate>
|
|
| 122 | + <lib.version.hibernate>5.6.11.Final</lib.version.hibernate>
|
|
| 123 | 123 | <!-- FIXME <lib.version.hibernate>6.1.0.Final</lib.version.hibernate>-->
|
| 124 | 124 | <lib.version.jaxb-api>2.4.0-b180830.0359</lib.version.jaxb-api>
|
| 125 | 125 | <lib.version.jaxb-runtime>2.4.0-b180830.0438</lib.version.jaxb-runtime>
|
| ... | ... | @@ -86,10 +86,6 @@ public interface TopiaEntitySqlModelResource { |
| 86 | 86 | |
| 87 | 87 | TopiaEntitySqlBlobModel getBlobModel();
|
| 88 | 88 | |
| 89 | -// TopiaMetadataModel getMetaModel();
|
|
| 90 | - |
|
| 91 | -// TopiaMetadataModelPaths getMetaModelPaths();
|
|
| 92 | - |
|
| 93 | 89 | Set<ReplicatePartialRequestCallback> getReplicatePartialRequestCallbacks();
|
| 94 | 90 | |
| 95 | 91 | Set<ReplicateRequestCallback> getReplicateRequestCallbacks();
|
| ... | ... | @@ -42,10 +42,6 @@ import java.util.Set; |
| 42 | 42 | public class DeletePartialEntityConsumer implements SqlRequestConsumer<DeletePartialEntityRequest> {
|
| 43 | 43 | public static final String DELETE_REVERSE_ASSOCIATION_STATEMENT = "UPDATE %1$s _main SET _main.%2$s = NULL WHERE _main.%2$s %3$s;";
|
| 44 | 44 | |
| 45 | - //fr.ird.data.ps.logbook.Route#1616767950667#0.2733836567509864 30/03/2019
|
|
| 46 | - //fr.ird.data.ps.observation.Activity#1554021069610#0.2462353141793846
|
|
| 47 | - //fr.ird.data.ps.logbook.Activity#1616767975989#0.4873500558653976
|
|
| 48 | - |
|
| 49 | 45 | @Override
|
| 50 | 46 | public void consume(DeletePartialEntityRequest request, SqlRequestSetConsumerContext context) {
|
| 51 | 47 | TopiaEntitySqlDeletePlan deletePlan = request.getDeletePlan();
|
| ... | ... | @@ -57,12 +53,12 @@ public class DeletePartialEntityConsumer implements SqlRequestConsumer<DeletePar |
| 57 | 53 | SqlScriptWriter writer = context.getWriter();
|
| 58 | 54 | for (TopiaEntitySqlDeletePlanTask task : deletePlan) {
|
| 59 | 55 | if (task.accept(shell)) {
|
| 60 | - consume(context, writer, ids, task, detachTasksMapping == null ? null : detachTasksMapping.get(task.getGav()));
|
|
| 56 | + consume(writer, ids, task, detachTasksMapping == null ? null : detachTasksMapping.get(task.getGav()));
|
|
| 61 | 57 | }
|
| 62 | 58 | }
|
| 63 | 59 | }
|
| 64 | 60 | |
| 65 | - protected void consume(SqlRequestSetConsumerContext context, SqlScriptWriter writer, String ids, TopiaEntitySqlDeletePlanTask task, Map<String, Set<String>> detachTasks) {
|
|
| 61 | + protected void consume(SqlScriptWriter writer, String ids, TopiaEntitySqlDeletePlanTask task, Map<String, Set<String>> detachTasks) {
|
|
| 66 | 62 | String deleteSql = task.getDeleteSql();
|
| 67 | 63 | String realDeleteSql = task.applyIds(deleteSql, ids);
|
| 68 | 64 | if (detachTasks != null) {
|
| ... | ... | @@ -25,11 +25,9 @@ package org.nuiton.topia.service.sql.internal.consumer; |
| 25 | 25 | import org.nuiton.topia.service.sql.internal.SqlRequestConsumer;
|
| 26 | 26 | import org.nuiton.topia.service.sql.internal.SqlRequestSetConsumerContext;
|
| 27 | 27 | import org.nuiton.topia.service.sql.internal.request.DuplicateEntityRequest;
|
| 28 | -import org.nuiton.topia.service.sql.internal.request.ReplicateEntityRequest;
|
|
| 29 | 28 | import org.nuiton.topia.service.sql.model.TopiaEntitySqlSelectArgument;
|
| 30 | 29 | import org.nuiton.topia.service.sql.plan.replicate.TopiaEntitySqlReplicatePlan;
|
| 31 | 30 | import org.nuiton.topia.service.sql.plan.replicate.TopiaEntitySqlReplicatePlanTask;
|
| 32 | -import org.nuiton.topia.service.sql.request.ReplicateRequestCallback;
|
|
| 33 | 31 | |
| 34 | 32 | import java.util.Set;
|
| 35 | 33 |
| ... | ... | @@ -75,8 +75,7 @@ class ReplicateEntityWork implements SqlWork { |
| 75 | 75 | this.columnNames = task.getColumnNames();
|
| 76 | 76 | String selectClause = SqlRequestConsumer.getSelectClause(task.getTableName(), columnNames);
|
| 77 | 77 | this.sql = TopiaEntitySqlReplicatePlanTask.applyIds(task.getSelectSql(), selectClause, ids);
|
| 78 | - |
|
| 79 | - this.blobsBuilder = context().initBlobsBuilder(task.useBlob(), task.getSchemaAndTableName());
|
|
| 78 | + this.blobsBuilder = context.initBlobsBuilder(task.useBlob(), task.getSchemaAndTableName());
|
|
| 80 | 79 | this.blobColumns = blobsBuilder.keySet();
|
| 81 | 80 | this.insertStatementSql = SqlRequestConsumer.newInsertStatementSql(task.getInsertSql(), columnNames, blobColumns);
|
| 82 | 81 | this.columnsToReplace = task.getColumnsToReplace();
|
| ... | ... | @@ -95,11 +94,16 @@ class ReplicateEntityWork implements SqlWork { |
| 95 | 94 | this.parentColumnName = parentColumnName;
|
| 96 | 95 | this.entryPoint = task.isEntryPoint();
|
| 97 | 96 | Set<String> shell = context.getShell();
|
| 98 | - // need to detach only when not in shell
|
|
| 97 | + // need to detach only when not in shell, otherwise replace
|
|
| 99 | 98 | this.columnsToDetach = new LinkedHashSet<>();
|
| 100 | 99 | for (Map.Entry<String, String> entry : task.getColumnsToDetachSimple()) {
|
| 101 | - if (!shell.contains(entry.getValue())) {
|
|
| 102 | - columnsToDetach.add(entry.getKey());
|
|
| 100 | + String otherGav = entry.getValue();
|
|
| 101 | + String columnName = entry.getKey();
|
|
| 102 | + if (!shell.contains(otherGav)) {
|
|
| 103 | + columnsToDetach.add(columnName);
|
|
| 104 | + } else {
|
|
| 105 | + // do replace
|
|
| 106 | + columnsToReplace.add(columnName);
|
|
| 103 | 107 | }
|
| 104 | 108 | }
|
| 105 | 109 | this.recursiveProperty = task.getRecursiveColumnName().orElse(null);
|
| ... | ... | @@ -114,10 +118,10 @@ class ReplicateEntityWork implements SqlWork { |
| 114 | 118 | this.columnNames = task.getColumnNames();
|
| 115 | 119 | String selectClause = SqlRequestConsumer.getSelectClause(task.getTableName(), columnNames);
|
| 116 | 120 | this.sql = TopiaEntitySqlReplicatePlanTask.applyIds(partialTask.getCopyTask().getSelectSql(), selectClause, ids);
|
| 117 | - this.blobsBuilder = context().initBlobsBuilder(task.useBlob(), task.getSchemaAndTableName());
|
|
| 121 | + this.blobsBuilder = context.initBlobsBuilder(task.useBlob(), task.getSchemaAndTableName());
|
|
| 118 | 122 | this.blobColumns = blobsBuilder.keySet();
|
| 119 | 123 | this.insertStatementSql = SqlRequestConsumer.newInsertStatementSql(task.getInsertSql(), columnNames, blobColumns);
|
| 120 | - this.columnsToReplace = task.getColumnsToReplace();
|
|
| 124 | + this.columnsToReplace = new LinkedHashSet<>(task.getColumnsToReplace());
|
|
| 121 | 125 | List<String> parentColumnNames = task.getParentColumnName();
|
| 122 | 126 | String parentColumnName = null;
|
| 123 | 127 | if (parentColumnNames.size() == 1) {
|
| ... | ... | @@ -133,11 +137,16 @@ class ReplicateEntityWork implements SqlWork { |
| 133 | 137 | this.parentColumnName = parentColumnName;
|
| 134 | 138 | this.entryPoint = task.isEntryPoint();
|
| 135 | 139 | Set<String> shell = context.getShell();
|
| 136 | - // need to detach only when not in shell
|
|
| 140 | + // need to detach only when not in shell, otherwise replace
|
|
| 137 | 141 | this.columnsToDetach = new LinkedHashSet<>();
|
| 138 | 142 | for (Map.Entry<String, String> entry : task.getColumnsToDetachSimple()) {
|
| 139 | - if (!shell.contains(entry.getValue())) {
|
|
| 140 | - columnsToDetach.add(entry.getKey());
|
|
| 143 | + String otherGav = entry.getValue();
|
|
| 144 | + String columnName = entry.getKey();
|
|
| 145 | + if (!shell.contains(otherGav)) {
|
|
| 146 | + columnsToDetach.add(columnName);
|
|
| 147 | + } else {
|
|
| 148 | + // do replace
|
|
| 149 | + columnsToReplace.add(columnName);
|
|
| 141 | 150 | }
|
| 142 | 151 | }
|
| 143 | 152 | this.recursiveProperty = task.getRecursiveColumnName().orElse(null);
|
| ... | ... | @@ -168,7 +177,7 @@ class ReplicateEntityWork implements SqlWork { |
| 168 | 177 | public void execute(Connection connection) throws SQLException {
|
| 169 | 178 | long t0 = TimeLog.getTime();
|
| 170 | 179 | try (PreparedStatement statement = connection.prepareStatement(sql)) {
|
| 171 | - statement.setFetchSize(context.context().getReadFetchSize());
|
|
| 180 | + statement.setFetchSize(context.getReadFetchSize());
|
|
| 172 | 181 | try (ResultSet resultSet = statement.executeQuery()) {
|
| 173 | 182 | if (recursiveProperty == null) {
|
| 174 | 183 | simpleCopy(statement, resultSet);
|
| ... | ... | @@ -199,7 +208,7 @@ class ReplicateEntityWork implements SqlWork { |
| 199 | 208 | parents.put(key == null ? sentinel : key, topiaId);
|
| 200 | 209 | requestsByTopiaId.put(topiaId, sql);
|
| 201 | 210 | }
|
| 202 | - List<String> orderedTopiaIds = context().generateOrder(parents, sentinel);
|
|
| 211 | + List<String> orderedTopiaIds = context.generateOrder(parents, sentinel);
|
|
| 203 | 212 | if (orderedTopiaIds.size() != requestsByTopiaId.size()) {
|
| 204 | 213 | throw new IllegalStateException("Mismatch ids size!!!");
|
| 205 | 214 | }
|
| ... | ... | @@ -251,11 +260,6 @@ class ReplicateEntityWork implements SqlWork { |
| 251 | 260 | String stringValue = (String) columnValue;
|
| 252 | 261 | if (entryPoint && stringValue.equals(oldParentId)) {
|
| 253 | 262 | argumentsBuilder.append(", NULL");
|
| 254 | -// if (newParentId.toLowerCase().contains("." + columnName + "#")) {
|
|
| 255 | -// argumentsBuilder.append(", '").append(newParentId).append("'");
|
|
| 256 | -// } else {
|
|
| 257 | -// argumentsBuilder.append(", NULL");
|
|
| 258 | -// }
|
|
| 259 | 263 | continue;
|
| 260 | 264 | }
|
| 261 | 265 | argumentsBuilder.append(", '").append(stringValue.replaceAll("'", "''")).append("'");
|
| ... | ... | @@ -270,7 +274,7 @@ class ReplicateEntityWork implements SqlWork { |
| 270 | 274 | for (String columnName : blobColumns) {
|
| 271 | 275 | Object columnValue = resultSet.getObject(columnName);
|
| 272 | 276 | if (blobColumns.contains(columnName)) {
|
| 273 | - context().copyBlob(statement, rowTopiaId, columnValue, blobsBuilder.get(columnName));
|
|
| 277 | + context.copyBlob(statement, rowTopiaId, columnValue, blobsBuilder.get(columnName));
|
|
| 274 | 278 | }
|
| 275 | 279 | }
|
| 276 | 280 | String arguments = argumentsBuilder.substring(2);
|
| ... | ... | @@ -22,10 +22,15 @@ package org.nuiton.topia.service.sql.internal.consumer; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import com.google.common.collect.Multimap;
|
|
| 26 | +import io.ultreia.java4all.util.sql.BlobsContainer;
|
|
| 25 | 27 | import io.ultreia.java4all.util.sql.SqlScriptWriter;
|
| 26 | 28 | import org.nuiton.topia.persistence.TopiaIdFactoryForBulkSupport;
|
| 27 | 29 | import org.nuiton.topia.service.sql.internal.SqlRequestSetConsumerContext;
|
| 28 | 30 | |
| 31 | +import java.sql.PreparedStatement;
|
|
| 32 | +import java.sql.SQLException;
|
|
| 33 | +import java.util.List;
|
|
| 29 | 34 | import java.util.Map;
|
| 30 | 35 | import java.util.Objects;
|
| 31 | 36 | import java.util.Set;
|
| ... | ... | @@ -86,4 +91,20 @@ class ReplicateEntityWorkContext { |
| 86 | 91 | public void writeSql(String sql) {
|
| 87 | 92 | writer.writeSql(sql);
|
| 88 | 93 | }
|
| 94 | + |
|
| 95 | + public Map<String, BlobsContainer.Builder> initBlobsBuilder(boolean useBlob, String schemaAndTableName) {
|
|
| 96 | + return context.initBlobsBuilder(useBlob, schemaAndTableName);
|
|
| 97 | + }
|
|
| 98 | + |
|
| 99 | + public int getReadFetchSize() {
|
|
| 100 | + return context.getReadFetchSize();
|
|
| 101 | + }
|
|
| 102 | + |
|
| 103 | + public void copyBlob(PreparedStatement preparedStatement, String topiaId, Object columnValue, BlobsContainer.Builder blobsBuilder) throws SQLException {
|
|
| 104 | + context.copyBlob(preparedStatement, topiaId, columnValue, blobsBuilder);
|
|
| 105 | + }
|
|
| 106 | + |
|
| 107 | + public List<String> generateOrder(Multimap<String, String> parents, String sentinel) {
|
|
| 108 | + return context.generateOrder(parents, sentinel);
|
|
| 109 | + }
|
|
| 89 | 110 | } |
| ... | ... | @@ -136,25 +136,24 @@ public class TopiaEntitySqlReplicatePlanBuilder { |
| 136 | 136 | throw new IllegalArgumentException(String.format("Can't manage with this case: %s", parentColumnNames));
|
| 137 | 137 | }
|
| 138 | 138 | }
|
| 139 | +// Set<String> requiredTypes = new LinkedHashSet<>();
|
|
| 139 | 140 | Set<String> requiredTypes = new LinkedHashSet<>();
|
| 140 | - Set<String> realRequiredTypes = new LinkedHashSet<>();
|
|
| 141 | 141 | String literalName = metadataEntity.getType();
|
| 142 | 142 | if (mandatoryReverseCompositions.containsKey(literalName)) {
|
| 143 | 143 | for (TopiaMetadataComposition composition : mandatoryReverseCompositions.get(literalName)) {
|
| 144 | 144 | String type = composition.getTarget().getType();
|
| 145 | 145 | if (missingTypes.contains(type)) {
|
| 146 | - requiredTypes.add(type);
|
|
| 147 | - realRequiredTypes.add(composition.getTarget().getSchemaAndTableName());
|
|
| 146 | + requiredTypes.add(composition.getTarget().getSchemaAndTableName());
|
|
| 148 | 147 | }
|
| 149 | 148 | }
|
| 150 | 149 | }
|
| 151 | 150 | List<String> columNames = List.copyOf(table.getAuthorizedColumnNames());
|
| 152 | 151 | Set<String> columnsToDetach = new LinkedHashSet<>();
|
| 153 | 152 | for (Map.Entry<String, String> entry : metadataEntity.getManyToOneAssociations().entrySet()) {
|
| 154 | - addSpecialColumns(columnsToReplace, columnsToDetach, requiredTypes, entry);
|
|
| 153 | + addSpecialColumns(columnsToReplace, columnsToDetach, entry);
|
|
| 155 | 154 | }
|
| 156 | 155 | for (Map.Entry<String, String> entry : metadataEntity.getReversedAssociations().entrySet()) {
|
| 157 | - addSpecialColumns(columnsToReplace, columnsToDetach, requiredTypes, entry);
|
|
| 156 | + addSpecialColumns(columnsToReplace, columnsToDetach, entry);
|
|
| 158 | 157 | }
|
| 159 | 158 | // the parent column is always to replace
|
| 160 | 159 | parentColumnNames.forEach(columnsToReplace::remove);
|
| ... | ... | @@ -167,7 +166,7 @@ public class TopiaEntitySqlReplicatePlanBuilder { |
| 167 | 166 | columNames,
|
| 168 | 167 | columnsToReplace,
|
| 169 | 168 | columnsToDetach,
|
| 170 | - realRequiredTypes,
|
|
| 169 | + requiredTypes,
|
|
| 171 | 170 | useBlob,
|
| 172 | 171 | mainTable,
|
| 173 | 172 | recursiveColumnName));
|
| ... | ... | @@ -228,12 +227,12 @@ public class TopiaEntitySqlReplicatePlanBuilder { |
| 228 | 227 | null));
|
| 229 | 228 | }
|
| 230 | 229 | |
| 231 | - private void addSpecialColumns(Set<String> columnsToReplace, Set<String> columnsToDetach, Set<String> requiredTypes, Map.Entry<String, String> entry) {
|
|
| 230 | + private void addSpecialColumns(Set<String> columnsToReplace, Set<String> columnsToDetach, Map.Entry<String, String> entry) {
|
|
| 232 | 231 | String literalName = entry.getValue();
|
| 233 | 232 | if (literals.contains(literalName)) {
|
| 234 | 233 | // this one need to be replace
|
| 235 | 234 | columnsToReplace.add(entry.getKey());
|
| 236 | - } else if (!standaloneLiterals.contains(literalName) && !requiredTypes.contains(literalName)) {
|
|
| 235 | + } else if (!standaloneLiterals.contains(literalName)) {// && !requiredTypes.contains(literalName)) {
|
|
| 237 | 236 | // this one need to be detach
|
| 238 | 237 | int endIndex = literalName.lastIndexOf("_");
|
| 239 | 238 | String columnDefinition = entry.getKey() + "~" + literalName.substring(0, endIndex) + "." + Introspector.decapitalize(literalName.substring(endIndex + 1));
|