Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 91500115 by tchemit at 2019-05-07T13:19:51Z add a way to deploy yo central - - - - - 737ad92d by tchemit at 2019-05-13T11:55:00Z update pom - - - - - 75e3bbcb by tchemit at 2019-05-13T12:25:53Z [SYNCHRO SIMPLE] Une requête DELETE échoue pour cause de violation de contrainte FK - Closes #1270 - - - - - 3 changed files: - observe/pom.xml - pom.xml - services-local/src/main/java/fr/ird/observe/services/local/service/actions/synchro/referential/sql/DeleteSqlStatementGenerator.java Changes: ===================================== observe/pom.xml ===================================== @@ -140,4 +140,20 @@ </plugins> </build> + + <profiles> + <profile> + <id>deploy-to-central</id> + <activation> + <property> + <name>deploy.to.central</name> + <value>true</value> + </property> + </activation> + <properties> + <!-- allow to deploy artifacts --> + <maven.deploy.skip>false</maven.deploy.skip> + </properties> + </profile> + </profiles> </project> ===================================== pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2019.8.15</version> + <version>2019.8.16</version> </parent> <groupId>fr.ird.observe</groupId> @@ -161,7 +161,7 @@ <!--can't use 1.4.197 (date has changed + blob also)--> <lib.version.h2>1.4.196</lib.version.h2> - <!--<lib.version.java4all.topia>1.2-SNAPSHOT</lib.version.java4all.topia>--> + <lib.version.java4all.topia>1.8</lib.version.java4all.topia> <!--<lib.version.java4all.eugene>3.0-alpha-22</lib.version.java4all.eugene>--> <!-- <lib.version.java4all.jaxx>3.0-alpha-50</lib.version.java4all.jaxx>--> <!--<lib.version.java4all.i18n>4.0-beta-3-SNAPSHOT</lib.version.java4all.i18n>--> ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/synchro/referential/sql/DeleteSqlStatementGenerator.java ===================================== @@ -23,6 +23,9 @@ package fr.ird.observe.services.local.service.actions.synchro.referential.sql; */ import com.google.common.collect.ImmutableList; +import fr.ird.observe.entities.ObserveEntityEnum; +import fr.ird.observe.entities.referential.ObserveReferentialEntity; +import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.metadata.TopiaMetadataAssociation; import org.nuiton.topia.persistence.metadata.TopiaMetadataEntity; import org.nuiton.topia.persistence.metadata.TopiaMetadataModel; @@ -42,11 +45,13 @@ import java.util.Set; public class DeleteSqlStatementGenerator { private final Set<TopiaMetadataAssociation> associations; + private final Set<TopiaMetadataAssociation> reverseAssociations; private final TopiaMetadataEntity metadataEntity; public DeleteSqlStatementGenerator(TopiaMetadataModel topiaMetadataModel, TopiaMetadataEntity metadataEntity) { this.metadataEntity = Objects.requireNonNull(metadataEntity); - this.associations = topiaMetadataModel.getReverseAssociations(metadataEntity); + this.associations = topiaMetadataModel.getAssociations(metadataEntity); + this.reverseAssociations = topiaMetadataModel.getReverseAssociations(metadataEntity); } public List<String> generateSql(String id) { @@ -54,9 +59,19 @@ public class DeleteSqlStatementGenerator { String sql = TopiaSqlStatements.generateDeleteStatement(metadataEntity, id); result.add(sql); for (TopiaMetadataAssociation association : associations) { - String sql2 = TopiaSqlStatements.generateAssociationDeleteStatement(association, id); + String sql2 = TopiaSqlStatements.generateManyToManyAssociationDeleteStatement(association, id); result.add(TopiaSqlStatements.boxAssociationStatement(sql2)); } + for (TopiaMetadataAssociation association : reverseAssociations) { + Class<? extends TopiaEntity> entityType = ObserveEntityEnum.valueOf(association.getOwner().getType()).getContract(); + if (ObserveReferentialEntity.class.isAssignableFrom(entityType)) { + // always delete referential associations + // this is the opposite of https://gitlab.com/ultreiaio/ird-observe/issues/1065 + // See https://gitlab.com/ultreiaio/ird-observe/issues/11270 + String sql2 = TopiaSqlStatements.generateAssociationDeleteStatement(association, id); + result.add(TopiaSqlStatements.boxAssociationStatement(sql2)); + } + } return result.build(); } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/4e6d2f2c573b229548ead0e272f... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/4e6d2f2c573b229548ead0e272f... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT