Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
bc8df484
by Tony CHEMIT at 2017-06-09T12:25:05+02:00
-
7eb5fb2d
by Tony CHEMIT at 2017-06-09T12:58:43+02:00
-
e2d2ebcd
by Tony CHEMIT at 2017-06-09T13:05:16+02:00
-
268d6af6
by Tony CHEMIT at 2017-06-09T13:17:09+02:00
8 changed files:
- application-swing/src/main/java/fr/ird/observe/application/swing/ui/actions/storage/SaveCurrentRemoteConfigurationUIAction.java
- persistence/src/main/java/fr/ird/observe/persistence/migration/DataSourceMigrationForVersion_6_0.java
- services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/ng/ReferentialSynchronizeSqlsRequestBuilder.java
- services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/sql/InsertSqlStatementGenerator.java
- services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/sql/InsertSqlWithCascadeStatementGenerator.java
- services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/sql/UpdateSqlStatementGenerator.java
- services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/sql/UpdateSqlWithCascadeStatementGenerator.java
- topia-extension/src/main/java/org/nuiton/topia/persistence/metadata/TopiaMetadataEntity.java
Changes:
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.application.swing.ui.actions.storage; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.application.swing.ObserveSwingApplicationContext;
|
|
| 25 | 26 |
import fr.ird.observe.application.swing.ui.ObserveKeyStrokes;
|
| 26 | 27 |
import fr.ird.observe.application.swing.ui.ObserveMainUI;
|
| 27 | 28 |
import fr.ird.observe.application.swing.ui.UIHelper;
|
| ... | ... | @@ -121,7 +122,7 @@ public class SaveCurrentRemoteConfigurationUIAction extends AbstractUIAction { |
| 121 | 122 |
configuration.setLogin(model.getRemoteLogin());
|
| 122 | 123 |
configuration.setPassword(new String(model.getRemotePassword()));
|
| 123 | 124 |
configuration.setUseSsl(model.isUseSsl());
|
| 124 |
- getMainUI().getConfig().addRemoteDataSourceConfiguration(configuration);
|
|
| 125 |
+ ObserveSwingApplicationContext.get().getConfig().addRemoteDataSourceConfiguration(configuration);
|
|
| 125 | 126 |
configUI.getHandler().addRemoteConfiguration(configuration);
|
| 126 | 127 |
}
|
| 127 | 128 |
}
|
| ... | ... | @@ -118,6 +118,7 @@ public class DataSourceMigrationForVersion_6_0 extends AbstractObserveMigrationC |
| 118 | 118 |
.put("LC", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499469115#0.42996318358928")
|
| 119 | 119 |
.put("LT", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499466532#0.844473292818293")
|
| 120 | 120 |
.put("", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499466532#0.844473292818293")
|
| 121 |
+ .put(" ", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499466532#0.844473292818293")
|
|
| 121 | 122 |
.put("FL", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499465700#0.0902433863375336")
|
| 122 | 123 |
.put("CFL", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499465999#0.707568018231541")
|
| 123 | 124 |
.put("PAL", "fr.ird.observe.entities.referentiel.SizeMeasureType#1433499466255#0.444246932631359")
|
| ... | ... | @@ -145,7 +146,7 @@ public class DataSourceMigrationForVersion_6_0 extends AbstractObserveMigrationC |
| 145 | 146 |
@Override
|
| 146 | 147 |
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
| 147 | 148 |
// Attention à ce moment là ce référentiel est encore dans le schema longline
|
| 148 |
- return connection.prepareStatement("SELECT code, topiaid FROM observe_longline.sizemeasuretype ");
|
|
| 149 |
+ return connection.prepareStatement("SELECT code, topiaid FROM observe_longline.sizemeasuretype WHERE code IS NOT NULL");
|
|
| 149 | 150 |
}
|
| 150 | 151 |
|
| 151 | 152 |
@Override
|
| ... | ... | @@ -142,7 +142,7 @@ public class ReferentialSynchronizeSqlsRequestBuilder { |
| 142 | 142 |
Class<E> entityType = binderEngine.getReferentialEntityType(type);
|
| 143 | 143 |
TopiaMetadataEntity metadata = metadataModel.getEntity(referentialName);
|
| 144 | 144 |
List<E> insertEntities = loadEntities(entityType, tasks);
|
| 145 |
- if (metadata.withShell()) {
|
|
| 145 |
+ if (metadata.withEntities()) {
|
|
| 146 | 146 |
|
| 147 | 147 |
InsertSqlWithCascadeStatementGenerator<R> insertGenerator = new InsertSqlWithCascadeStatementGenerator<R>(metadata, type, request.getIdsOnlyExistingOnThisSide()) {
|
| 148 | 148 |
|
| ... | ... | @@ -189,7 +189,7 @@ public class ReferentialSynchronizeSqlsRequestBuilder { |
| 189 | 189 |
Class<E> entityType = binderEngine.getReferentialEntityType(type);
|
| 190 | 190 |
List<E> updateEntities = loadEntities(entityType, tasks);
|
| 191 | 191 |
|
| 192 |
- if (metadata.withShell()) {
|
|
| 192 |
+ if (metadata.withEntities()) {
|
|
| 193 | 193 |
|
| 194 | 194 |
UpdateSqlWithCascadeStatementGenerator<R> updateGenerator = new UpdateSqlWithCascadeStatementGenerator<R>(metadata, type, request.getIdsOnlyExistingOnThisSide()) {
|
| 195 | 195 |
@Override
|
| ... | ... | @@ -101,6 +101,8 @@ public class InsertSqlStatementGenerator<R extends ReferentialDto> { |
| 101 | 101 |
|
| 102 | 102 |
public ImmutableList<String> generateSql(R referentialDto) {
|
| 103 | 103 |
|
| 104 |
+ ImmutableList.Builder<String> result = ImmutableList.builder();
|
|
| 105 |
+ |
|
| 104 | 106 |
List<String> parameters = new LinkedList<>();
|
| 105 | 107 |
|
| 106 | 108 |
addStringParameter(referentialDto.getId(), parameters);
|
| ... | ... | @@ -156,15 +158,15 @@ public class InsertSqlStatementGenerator<R extends ReferentialDto> { |
| 156 | 158 |
continue;
|
| 157 | 159 |
}
|
| 158 | 160 |
if (parameterValue instanceof ReferentialDto) {
|
| 159 |
- addReferentialDtoParameter((ReferentialDto) parameterValue, parameters);
|
|
| 161 |
+ addReferentialDtoParameter((ReferentialDto) parameterValue, parameters, result);
|
|
| 160 | 162 |
continue;
|
| 161 | 163 |
}
|
| 162 | 164 |
if (parameterValue instanceof ReferentialReference) {
|
| 163 |
- addReferentialReferenceParameter((ReferentialReference) parameterValue, parameters);
|
|
| 165 |
+ addReferentialReferenceParameter((ReferentialReference) parameterValue, parameters,result);
|
|
| 164 | 166 |
}
|
| 165 | 167 |
}
|
| 166 | 168 |
|
| 167 |
- ImmutableList.Builder<String> result = ImmutableList.builder();
|
|
| 169 |
+ |
|
| 168 | 170 |
|
| 169 | 171 |
result.add(String.format(INSERT_STATEMENT,
|
| 170 | 172 |
schemaName,
|
| ... | ... | @@ -278,11 +280,11 @@ public class InsertSqlStatementGenerator<R extends ReferentialDto> { |
| 278 | 280 |
parameters.add("" + parameter);
|
| 279 | 281 |
}
|
| 280 | 282 |
|
| 281 |
- protected void addReferentialReferenceParameter(ReferentialReference<?> parameter, List<String> parameters) {
|
|
| 283 |
+ protected void addReferentialReferenceParameter(ReferentialReference<?> parameter, List<String> parameters, ImmutableList.Builder<String> result) {
|
|
| 282 | 284 |
addStringParameter(parameter.getId(), parameters);
|
| 283 | 285 |
}
|
| 284 | 286 |
|
| 285 |
- protected void addReferentialDtoParameter(ReferentialDto parameter, List<String> parameters) {
|
|
| 287 |
+ protected void addReferentialDtoParameter(ReferentialDto parameter, List<String> parameters, ImmutableList.Builder<String> result) {
|
|
| 286 | 288 |
addStringParameter(parameter.getId(), parameters);
|
| 287 | 289 |
}
|
| 288 | 290 |
|
| ... | ... | @@ -26,15 +26,14 @@ import com.google.common.collect.ImmutableList; |
| 26 | 26 |
import com.google.common.collect.Multimap;
|
| 27 | 27 |
import fr.ird.observe.services.dto.reference.ReferentialReference;
|
| 28 | 28 |
import fr.ird.observe.services.dto.referential.ReferentialDto;
|
| 29 |
+import java.util.List;
|
|
| 29 | 30 |
import org.apache.commons.logging.Log;
|
| 30 | 31 |
import org.apache.commons.logging.LogFactory;
|
| 31 | 32 |
import org.nuiton.topia.persistence.metadata.TopiaMetadataEntity;
|
| 32 | 33 |
|
| 33 |
-import java.util.List;
|
|
| 34 |
- |
|
| 35 | 34 |
/**
|
| 36 | 35 |
* Pour générer une requète sql d'ajout à partir d'un référentiel donné et aussi tous les inserts manquants
|
| 37 |
- *
|
|
| 36 |
+ * <p>
|
|
| 38 | 37 |
* Created on 29/06/16.
|
| 39 | 38 |
*
|
| 40 | 39 |
* @author Tony Chemit - dev@tchemit.fr
|
| ... | ... | @@ -57,19 +56,19 @@ public abstract class InsertSqlWithCascadeStatementGenerator<R extends Referenti |
| 57 | 56 |
@Override
|
| 58 | 57 |
protected <D extends ReferentialDto> void addMnAssociation(String nmAssociationTableName, String nmAssociationDbColumnName, String referentialDtoId, Class<? extends ReferentialDto> associationType, String associationId, ImmutableList.Builder<String> builder) {
|
| 59 | 58 |
super.addMnAssociation(nmAssociationTableName, nmAssociationDbColumnName, referentialDtoId, associationType, associationId, builder);
|
| 60 |
- addMissingReferentialIfNecessary(associationType, associationId);
|
|
| 59 |
+ addMissingReferentialIfNecessary(associationType, associationId, builder);
|
|
| 61 | 60 |
}
|
| 62 | 61 |
|
| 63 | 62 |
@Override
|
| 64 |
- protected void addReferentialReferenceParameter(ReferentialReference<?> parameter, List<String> parameters) {
|
|
| 65 |
- super.addReferentialReferenceParameter(parameter, parameters);
|
|
| 66 |
- addMissingReferentialIfNecessary(parameter.getType(), parameter.getId());
|
|
| 63 |
+ protected void addReferentialReferenceParameter(ReferentialReference<?> parameter, List<String> parameters, ImmutableList.Builder<String> result) {
|
|
| 64 |
+ super.addReferentialReferenceParameter(parameter, parameters, result);
|
|
| 65 |
+ addMissingReferentialIfNecessary(parameter.getType(), parameter.getId(), result);
|
|
| 67 | 66 |
}
|
| 68 | 67 |
|
| 69 | 68 |
@Override
|
| 70 |
- protected void addReferentialDtoParameter(ReferentialDto parameter, List<String> parameters) {
|
|
| 71 |
- super.addReferentialDtoParameter(parameter, parameters);
|
|
| 72 |
- addMissingReferentialIfNecessary(parameter.getClass(), parameter.getId());
|
|
| 69 |
+ protected void addReferentialDtoParameter(ReferentialDto parameter, List<String> parameters, ImmutableList.Builder<String> result) {
|
|
| 70 |
+ super.addReferentialDtoParameter(parameter, parameters, result);
|
|
| 71 |
+ addMissingReferentialIfNecessary(parameter.getClass(), parameter.getId(), result);
|
|
| 73 | 72 |
}
|
| 74 | 73 |
};
|
| 75 | 74 |
}
|
| ... | ... | @@ -82,20 +81,19 @@ public abstract class InsertSqlWithCascadeStatementGenerator<R extends Referenti |
| 82 | 81 |
|
| 83 | 82 |
}
|
| 84 | 83 |
|
| 85 |
- private <D extends ReferentialDto> ImmutableList<String> addMissingReferentialIfNecessary(Class<D> associationType, String associationId) {
|
|
| 84 |
+ private <D extends ReferentialDto> void addMissingReferentialIfNecessary(Class<D> associationType, String associationId, ImmutableList.Builder<String> builder) {
|
|
| 86 | 85 |
|
| 87 | 86 |
if (idsOnlyExistingOnThisSide.containsEntry(associationType, associationId)) {
|
| 88 | 87 |
|
| 89 | 88 |
// il faut insérer aussi ce référentiel
|
| 90 | 89 |
ImmutableList<String> sql = insertMissingReferential(associationType, associationId);
|
| 91 | 90 |
|
| 91 |
+ builder.addAll(sql);
|
|
| 92 |
+ |
|
| 92 | 93 |
// ce référentiel est désormais présent dans les deux sources
|
| 93 | 94 |
idsOnlyExistingOnThisSide.remove(associationType, associationId);
|
| 94 | 95 |
|
| 95 |
- return sql;
|
|
| 96 |
- |
|
| 97 | 96 |
}
|
| 98 |
- return null;
|
|
| 99 | 97 |
}
|
| 100 | 98 |
|
| 101 | 99 |
}
|
| ... | ... | @@ -23,16 +23,8 @@ package fr.ird.observe.services.topia.service.actions.synchro.referential.sql; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableList;
|
| 26 |
-import fr.ird.observe.services.dto.referential.ReferentialDto;
|
|
| 27 | 26 |
import fr.ird.observe.services.dto.reference.ReferentialReference;
|
| 28 |
-import org.apache.commons.collections4.CollectionUtils;
|
|
| 29 |
-import org.apache.commons.logging.Log;
|
|
| 30 |
-import org.apache.commons.logging.LogFactory;
|
|
| 31 |
-import org.nuiton.topia.persistence.TopiaEntity;
|
|
| 32 |
-import org.nuiton.topia.persistence.metadata.TopiaMetadataEntity;
|
|
| 33 |
-import org.nuiton.util.beans.Binder;
|
|
| 34 |
-import org.nuiton.util.beans.BinderFactory;
|
|
| 35 |
- |
|
| 27 |
+import fr.ird.observe.services.dto.referential.ReferentialDto;
|
|
| 36 | 28 |
import java.sql.Timestamp;
|
| 37 | 29 |
import java.util.Collection;
|
| 38 | 30 |
import java.util.Date;
|
| ... | ... | @@ -40,10 +32,17 @@ import java.util.LinkedHashSet; |
| 40 | 32 |
import java.util.Map;
|
| 41 | 33 |
import java.util.Set;
|
| 42 | 34 |
import java.util.TreeMap;
|
| 35 |
+import org.apache.commons.collections4.CollectionUtils;
|
|
| 36 |
+import org.apache.commons.logging.Log;
|
|
| 37 |
+import org.apache.commons.logging.LogFactory;
|
|
| 38 |
+import org.nuiton.topia.persistence.TopiaEntity;
|
|
| 39 |
+import org.nuiton.topia.persistence.metadata.TopiaMetadataEntity;
|
|
| 40 |
+import org.nuiton.util.beans.Binder;
|
|
| 41 |
+import org.nuiton.util.beans.BinderFactory;
|
|
| 43 | 42 |
|
| 44 | 43 |
/**
|
| 45 | 44 |
* Pour générer une requète sql de mise à jour à partir d'un référentiel donné.
|
| 46 |
- *
|
|
| 45 |
+ * <p>
|
|
| 47 | 46 |
* Created on 29/06/16.
|
| 48 | 47 |
*
|
| 49 | 48 |
* @author Tony Chemit - dev@tchemit.fr
|
| ... | ... | @@ -152,6 +151,8 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 152 | 151 |
|
| 153 | 152 |
}
|
| 154 | 153 |
|
| 154 |
+ ImmutableList.Builder<String> result = ImmutableList.builder();
|
|
| 155 |
+ |
|
| 155 | 156 |
if (manyToOneAssociationNames.length > 0) {
|
| 156 | 157 |
|
| 157 | 158 |
Map<String, Object> manyToOneAssociations = binder.obtainProperties(referentialDto, true, manyToOneAssociationNames);
|
| ... | ... | @@ -166,18 +167,17 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 166 | 167 |
continue;
|
| 167 | 168 |
}
|
| 168 | 169 |
if (manyToOneAssociationValue instanceof ReferentialDto) {
|
| 169 |
- addReferentialDtoParameter(columnName, (ReferentialDto) manyToOneAssociationValue, parameters);
|
|
| 170 |
+ addReferentialDtoParameter(columnName, (ReferentialDto) manyToOneAssociationValue, parameters, result);
|
|
| 170 | 171 |
continue;
|
| 171 | 172 |
}
|
| 172 | 173 |
if (manyToOneAssociationValue instanceof ReferentialReference) {
|
| 173 |
- addReferentialReferenceParameter(columnName, (ReferentialReference) manyToOneAssociationValue, parameters);
|
|
| 174 |
+ addReferentialReferenceParameter(columnName, (ReferentialReference) manyToOneAssociationValue, parameters, result);
|
|
| 174 | 175 |
}
|
| 175 | 176 |
|
| 176 | 177 |
}
|
| 177 | 178 |
|
| 178 | 179 |
}
|
| 179 | 180 |
|
| 180 |
- ImmutableList.Builder<String> result = ImmutableList.builder();
|
|
| 181 | 181 |
|
| 182 | 182 |
String sql = String.format(UPDATE_STATEMENT,
|
| 183 | 183 |
schemaName,
|
| ... | ... | @@ -190,17 +190,14 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 190 | 190 |
}
|
| 191 | 191 |
|
| 192 | 192 |
for (ManyToManyAssociationStruct manyToManyAssociation : manyToManyAssociations) {
|
| 193 |
- String manyToManyAssociationSql = generateManyToManyAssociationSql(referentialDto, manyToManyAssociation);
|
|
| 194 |
- result.add(manyToManyAssociationSql);
|
|
| 193 |
+ generateManyToManyAssociationSql(referentialDto, manyToManyAssociation, result);
|
|
| 195 | 194 |
}
|
| 196 | 195 |
|
| 197 | 196 |
return result.build();
|
| 198 | 197 |
|
| 199 | 198 |
}
|
| 200 | 199 |
|
| 201 |
- private String generateManyToManyAssociationSql(R referentialDto, ManyToManyAssociationStruct manyToManyAssociation) {
|
|
| 202 |
- |
|
| 203 |
- StringBuilder builder = new StringBuilder();
|
|
| 200 |
+ private void generateManyToManyAssociationSql(R referentialDto, ManyToManyAssociationStruct manyToManyAssociation, ImmutableList.Builder<String> result) {
|
|
| 204 | 201 |
|
| 205 | 202 |
String referentialDtoId = referentialDto.getId();
|
| 206 | 203 |
String manyToManyAssociationTableName = manyToManyAssociation.tableName;
|
| ... | ... | @@ -211,7 +208,7 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 211 | 208 |
manyToManyAssociationTableName,
|
| 212 | 209 |
tableName,
|
| 213 | 210 |
referentialDtoId);
|
| 214 |
- builder.append(deleteSql);
|
|
| 211 |
+ result.add(deleteSql);
|
|
| 215 | 212 |
if (log.isDebugEnabled()) {
|
| 216 | 213 |
log.debug("sql: " + deleteSql);
|
| 217 | 214 |
}
|
| ... | ... | @@ -231,13 +228,11 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 231 | 228 |
referentialDtoId,
|
| 232 | 229 |
manyToManyAssociationValue.getType(),
|
| 233 | 230 |
manyToManyAssociationValue.getId(),
|
| 234 |
- builder
|
|
| 231 |
+ result
|
|
| 235 | 232 |
);
|
| 236 | 233 |
}
|
| 237 | 234 |
}
|
| 238 | 235 |
|
| 239 |
- return builder.toString();
|
|
| 240 |
- |
|
| 241 | 236 |
}
|
| 242 | 237 |
|
| 243 | 238 |
protected <D extends ReferentialDto> void addMnAssociation(String nmAssociationTableName,
|
| ... | ... | @@ -245,7 +240,7 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 245 | 240 |
String referentialDtoId,
|
| 246 | 241 |
Class<D> associationType,
|
| 247 | 242 |
String associationId,
|
| 248 |
- StringBuilder builder) {
|
|
| 243 |
+ ImmutableList.Builder<String> builder) {
|
|
| 249 | 244 |
|
| 250 | 245 |
String sql = String.format(MANY_TO_MANY_ASSOCIATION_INSERT_STATEMENT,
|
| 251 | 246 |
schemaName,
|
| ... | ... | @@ -257,7 +252,7 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 257 | 252 |
if (log.isDebugEnabled()) {
|
| 258 | 253 |
log.debug("sql: " + sql);
|
| 259 | 254 |
}
|
| 260 |
- builder.append(sql);
|
|
| 255 |
+ builder.add(sql);
|
|
| 261 | 256 |
|
| 262 | 257 |
}
|
| 263 | 258 |
|
| ... | ... | @@ -299,11 +294,11 @@ public class UpdateSqlStatementGenerator<R extends ReferentialDto> { |
| 299 | 294 |
addParameter0(columnName, "" + parameter, parameters);
|
| 300 | 295 |
}
|
| 301 | 296 |
|
| 302 |
- protected void addReferentialReferenceParameter(String columnName, ReferentialReference parameter, StringBuilder parameters) {
|
|
| 297 |
+ protected void addReferentialReferenceParameter(String columnName, ReferentialReference parameter, StringBuilder parameters, ImmutableList.Builder<String> result) {
|
|
| 303 | 298 |
addStringParameter(columnName, parameter.getId(), parameters);
|
| 304 | 299 |
}
|
| 305 | 300 |
|
| 306 |
- protected void addReferentialDtoParameter(String columnName, ReferentialDto parameter, StringBuilder parameters) {
|
|
| 301 |
+ protected void addReferentialDtoParameter(String columnName, ReferentialDto parameter, StringBuilder parameters, ImmutableList.Builder<String> result) {
|
|
| 307 | 302 |
addStringParameter(columnName, parameter.getId(), parameters);
|
| 308 | 303 |
}
|
| 309 | 304 |
|
| ... | ... | @@ -32,7 +32,7 @@ import org.nuiton.topia.persistence.metadata.TopiaMetadataEntity; |
| 32 | 32 |
|
| 33 | 33 |
/**
|
| 34 | 34 |
* Pour générer une requète sql d'ajout à partir d'un référentiel donné et aussi tous les inserts manquants.
|
| 35 |
- *
|
|
| 35 |
+ * <p>
|
|
| 36 | 36 |
* Created on 29/06/16.
|
| 37 | 37 |
*
|
| 38 | 38 |
* @author Tony Chemit - dev@tchemit.fr
|
| ... | ... | @@ -53,21 +53,21 @@ public abstract class UpdateSqlWithCascadeStatementGenerator<R extends Referenti |
| 53 | 53 |
this.delegateGenerator = new UpdateSqlStatementGenerator<R>(metadataEntity, dtoType) {
|
| 54 | 54 |
|
| 55 | 55 |
@Override
|
| 56 |
- protected <D extends ReferentialDto> void addMnAssociation(String nmAssociationTableName, String nmAssociationDbColumnName, String referentialDtoId, Class<D> associationType, String associationId, StringBuilder builder) {
|
|
| 57 |
- super.addMnAssociation(nmAssociationTableName, nmAssociationDbColumnName, referentialDtoId, associationType, associationId, builder);
|
|
| 58 |
- addMissingReferentialIfNecessary(associationType, associationId);
|
|
| 56 |
+ protected <D extends ReferentialDto> void addMnAssociation(String nmAssociationTableName, String nmAssociationDbColumnName, String referentialDtoId, Class<D> associationType, String associationId, ImmutableList.Builder<String> result) {
|
|
| 57 |
+ super.addMnAssociation(nmAssociationTableName, nmAssociationDbColumnName, referentialDtoId, associationType, associationId, result);
|
|
| 58 |
+ addMissingReferentialIfNecessary(associationType, associationId, result);
|
|
| 59 | 59 |
}
|
| 60 | 60 |
|
| 61 | 61 |
@Override
|
| 62 |
- protected void addReferentialReferenceParameter(String columnName, ReferentialReference parameter, StringBuilder parameters) {
|
|
| 63 |
- super.addReferentialReferenceParameter(columnName, parameter, parameters);
|
|
| 64 |
- addMissingReferentialIfNecessary(parameter.getType(), parameter.getId());
|
|
| 62 |
+ protected void addReferentialReferenceParameter(String columnName, ReferentialReference parameter, StringBuilder parameters, ImmutableList.Builder<String> result) {
|
|
| 63 |
+ super.addReferentialReferenceParameter(columnName, parameter, parameters, result);
|
|
| 64 |
+ addMissingReferentialIfNecessary(parameter.getType(), parameter.getId(), result);
|
|
| 65 | 65 |
}
|
| 66 | 66 |
|
| 67 | 67 |
@Override
|
| 68 |
- protected void addReferentialDtoParameter(String columnName, ReferentialDto parameter, StringBuilder parameters) {
|
|
| 69 |
- super.addReferentialDtoParameter(columnName, parameter, parameters);
|
|
| 70 |
- addMissingReferentialIfNecessary(parameter.getClass(), parameter.getId());
|
|
| 68 |
+ protected void addReferentialDtoParameter(String columnName, ReferentialDto parameter, StringBuilder parameters, ImmutableList.Builder<String> result) {
|
|
| 69 |
+ super.addReferentialDtoParameter(columnName, parameter, parameters, result);
|
|
| 70 |
+ addMissingReferentialIfNecessary(parameter.getClass(), parameter.getId(), result);
|
|
| 71 | 71 |
}
|
| 72 | 72 |
};
|
| 73 | 73 |
}
|
| ... | ... | @@ -80,20 +80,17 @@ public abstract class UpdateSqlWithCascadeStatementGenerator<R extends Referenti |
| 80 | 80 |
|
| 81 | 81 |
}
|
| 82 | 82 |
|
| 83 |
- private <D extends ReferentialDto> ImmutableList<String> addMissingReferentialIfNecessary(Class<D> associationType, String associationId) {
|
|
| 83 |
+ private <D extends ReferentialDto> void addMissingReferentialIfNecessary(Class<D> associationType, String associationId, ImmutableList.Builder<String> result) {
|
|
| 84 | 84 |
|
| 85 | 85 |
if (idsOnlyExistingOnThisSide.containsEntry(associationType, associationId)) {
|
| 86 | 86 |
|
| 87 | 87 |
// il faut insérer aussi ce référentiel
|
| 88 | 88 |
ImmutableList<String> sqls = insertMissingReferential(associationType, associationId);
|
| 89 |
- |
|
| 89 |
+ result.addAll(sqls);
|
|
| 90 | 90 |
// ce référentiel est désormais présent dans les deux sources
|
| 91 | 91 |
idsOnlyExistingOnThisSide.remove(associationType, associationId);
|
| 92 | 92 |
|
| 93 |
- return sqls;
|
|
| 94 |
- |
|
| 95 | 93 |
}
|
| 96 |
- return null;
|
|
| 97 | 94 |
}
|
| 98 | 95 |
|
| 99 | 96 |
}
|
| ... | ... | @@ -347,4 +347,7 @@ public class TopiaMetadataEntity { |
| 347 | 347 |
}
|
| 348 | 348 |
}
|
| 349 | 349 |
|
| 350 |
+ public boolean withEntities() {
|
|
| 351 |
+ return withShell() || !manyToOneAssociations.isEmpty();
|
|
| 352 |
+ }
|
|
| 350 | 353 |
}
|