Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
91500115
by tchemit at 2019-05-07T13:19:51Z
-
737ad92d
by tchemit at 2019-05-13T11:55:00Z
-
75e3bbcb
by tchemit at 2019-05-13T12:25:53Z
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:
| ... | ... | @@ -140,4 +140,20 @@ |
| 140 | 140 |
|
| 141 | 141 |
</plugins>
|
| 142 | 142 |
</build>
|
| 143 |
+ |
|
| 144 |
+ <profiles>
|
|
| 145 |
+ <profile>
|
|
| 146 |
+ <id>deploy-to-central</id>
|
|
| 147 |
+ <activation>
|
|
| 148 |
+ <property>
|
|
| 149 |
+ <name>deploy.to.central</name>
|
|
| 150 |
+ <value>true</value>
|
|
| 151 |
+ </property>
|
|
| 152 |
+ </activation>
|
|
| 153 |
+ <properties>
|
|
| 154 |
+ <!-- allow to deploy artifacts -->
|
|
| 155 |
+ <maven.deploy.skip>false</maven.deploy.skip>
|
|
| 156 |
+ </properties>
|
|
| 157 |
+ </profile>
|
|
| 158 |
+ </profiles>
|
|
| 143 | 159 |
</project>
|
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 |
<parent>
|
| 27 | 27 |
<groupId>io.ultreia.maven</groupId>
|
| 28 | 28 |
<artifactId>pom</artifactId>
|
| 29 |
- <version>2019.8.15</version>
|
|
| 29 |
+ <version>2019.8.16</version>
|
|
| 30 | 30 |
</parent>
|
| 31 | 31 |
|
| 32 | 32 |
<groupId>fr.ird.observe</groupId>
|
| ... | ... | @@ -161,7 +161,7 @@ |
| 161 | 161 |
<!--can't use 1.4.197 (date has changed + blob also)-->
|
| 162 | 162 |
<lib.version.h2>1.4.196</lib.version.h2>
|
| 163 | 163 |
|
| 164 |
- <!--<lib.version.java4all.topia>1.2-SNAPSHOT</lib.version.java4all.topia>-->
|
|
| 164 |
+ <lib.version.java4all.topia>1.8</lib.version.java4all.topia>
|
|
| 165 | 165 |
<!--<lib.version.java4all.eugene>3.0-alpha-22</lib.version.java4all.eugene>-->
|
| 166 | 166 |
<!-- <lib.version.java4all.jaxx>3.0-alpha-50</lib.version.java4all.jaxx>-->
|
| 167 | 167 |
<!--<lib.version.java4all.i18n>4.0-beta-3-SNAPSHOT</lib.version.java4all.i18n>-->
|
| ... | ... | @@ -23,6 +23,9 @@ package fr.ird.observe.services.local.service.actions.synchro.referential.sql; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableList;
|
| 26 |
+import fr.ird.observe.entities.ObserveEntityEnum;
|
|
| 27 |
+import fr.ird.observe.entities.referential.ObserveReferentialEntity;
|
|
| 28 |
+import org.nuiton.topia.persistence.TopiaEntity;
|
|
| 26 | 29 |
import org.nuiton.topia.persistence.metadata.TopiaMetadataAssociation;
|
| 27 | 30 |
import org.nuiton.topia.persistence.metadata.TopiaMetadataEntity;
|
| 28 | 31 |
import org.nuiton.topia.persistence.metadata.TopiaMetadataModel;
|
| ... | ... | @@ -42,11 +45,13 @@ import java.util.Set; |
| 42 | 45 |
public class DeleteSqlStatementGenerator {
|
| 43 | 46 |
|
| 44 | 47 |
private final Set<TopiaMetadataAssociation> associations;
|
| 48 |
+ private final Set<TopiaMetadataAssociation> reverseAssociations;
|
|
| 45 | 49 |
private final TopiaMetadataEntity metadataEntity;
|
| 46 | 50 |
|
| 47 | 51 |
public DeleteSqlStatementGenerator(TopiaMetadataModel topiaMetadataModel, TopiaMetadataEntity metadataEntity) {
|
| 48 | 52 |
this.metadataEntity = Objects.requireNonNull(metadataEntity);
|
| 49 |
- this.associations = topiaMetadataModel.getReverseAssociations(metadataEntity);
|
|
| 53 |
+ this.associations = topiaMetadataModel.getAssociations(metadataEntity);
|
|
| 54 |
+ this.reverseAssociations = topiaMetadataModel.getReverseAssociations(metadataEntity);
|
|
| 50 | 55 |
}
|
| 51 | 56 |
|
| 52 | 57 |
public List<String> generateSql(String id) {
|
| ... | ... | @@ -54,9 +59,19 @@ public class DeleteSqlStatementGenerator { |
| 54 | 59 |
String sql = TopiaSqlStatements.generateDeleteStatement(metadataEntity, id);
|
| 55 | 60 |
result.add(sql);
|
| 56 | 61 |
for (TopiaMetadataAssociation association : associations) {
|
| 57 |
- String sql2 = TopiaSqlStatements.generateAssociationDeleteStatement(association, id);
|
|
| 62 |
+ String sql2 = TopiaSqlStatements.generateManyToManyAssociationDeleteStatement(association, id);
|
|
| 58 | 63 |
result.add(TopiaSqlStatements.boxAssociationStatement(sql2));
|
| 59 | 64 |
}
|
| 65 |
+ for (TopiaMetadataAssociation association : reverseAssociations) {
|
|
| 66 |
+ Class<? extends TopiaEntity> entityType = ObserveEntityEnum.valueOf(association.getOwner().getType()).getContract();
|
|
| 67 |
+ if (ObserveReferentialEntity.class.isAssignableFrom(entityType)) {
|
|
| 68 |
+ // always delete referential associations
|
|
| 69 |
+ // this is the opposite of https://gitlab.com/ultreiaio/ird-observe/issues/1065
|
|
| 70 |
+ // See https://gitlab.com/ultreiaio/ird-observe/issues/11270
|
|
| 71 |
+ String sql2 = TopiaSqlStatements.generateAssociationDeleteStatement(association, id);
|
|
| 72 |
+ result.add(TopiaSqlStatements.boxAssociationStatement(sql2));
|
|
| 73 |
+ }
|
|
| 74 |
+ }
|
|
| 60 | 75 |
return result.build();
|
| 61 | 76 |
}
|
| 62 | 77 |
|