Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
610449f6
by Tony Chemit at 2022-10-18T17:51:03+02:00
3 changed files:
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/composition/branchline/DeleteSelectedBranchline.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/composition/section/DeleteSelectedSection.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/observation/SetDetailCompositionSpi.java
Changes:
| ... | ... | @@ -61,7 +61,7 @@ public class DeleteSelectedBranchline extends SetDetailCompositionUIActionSuppor |
| 61 | 61 | if (!accept) {
|
| 62 | 62 | return;
|
| 63 | 63 | }
|
| 64 | - log.info(getLog(String.format("DeleteMultiple branchline: %s", selectedBranchline)));
|
|
| 64 | + log.info(getLog(String.format("Delete branchline: %s", selectedBranchline)));
|
|
| 65 | 65 | model.getStates().getBasketsTableModel().removeBranchline(selectedBranchline);
|
| 66 | 66 | }
|
| 67 | 67 | }
|
| ... | ... | @@ -53,7 +53,7 @@ public class DeleteSelectedSection extends SetDetailCompositionUIActionSupport { |
| 53 | 53 | SectionTableModel tableModel = model.getStates().getSectionsTableModel();
|
| 54 | 54 | SectionDto selectedSection = tableModel.getSelectedRow();
|
| 55 | 55 | if (selectedSection != null) {
|
| 56 | - if (!Objects.requireNonNull(selectedSection).canDelete()) {
|
|
| 56 | + if (!selectedSection.canDelete()) {
|
|
| 57 | 57 | // there is some references, can't delete
|
| 58 | 58 | displayWarning(t("observe.data.ll.observation.SetDetailComposition.section.cant.delete.title"), t("observe.data.ll.observation.SetDetailComposition.section.cant.delete.message"));
|
| 59 | 59 | return;
|
| ... | ... | @@ -62,7 +62,7 @@ public class DeleteSelectedSection extends SetDetailCompositionUIActionSupport { |
| 62 | 62 | if (!accept) {
|
| 63 | 63 | return;
|
| 64 | 64 | }
|
| 65 | - log.info(getLog(String.format("DeleteMultiple section: %s", selectedSection)));
|
|
| 65 | + log.info(getLog(String.format("Delete section: %s", selectedSection)));
|
|
| 66 | 66 | model.getStates().removeSection(selectedSection);
|
| 67 | 67 | }
|
| 68 | 68 | }
|
| ... | ... | @@ -22,6 +22,9 @@ package fr.ird.observe.entities.data.ll.observation; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.dto.data.ll.observation.BasketDto;
|
|
| 26 | +import fr.ird.observe.dto.data.ll.observation.BranchlineDto;
|
|
| 27 | +import fr.ird.observe.dto.data.ll.observation.SectionDto;
|
|
| 25 | 28 | import fr.ird.observe.dto.data.ll.observation.SetDetailCompositionDto;
|
| 26 | 29 | import fr.ird.observe.dto.form.Form;
|
| 27 | 30 | import fr.ird.observe.dto.result.SaveResultDto;
|
| ... | ... | @@ -44,21 +47,30 @@ public class SetDetailCompositionSpi extends GeneratedSetDetailCompositionSpi { |
| 44 | 47 | java.util.Set<String> sectionUsed = dao.getSectionUsed(entity.getTopiaId());
|
| 45 | 48 | java.util.Set<String> basketUsed = dao.getBasketUsed(entity.getTopiaId());
|
| 46 | 49 | java.util.Set<String> branchlineUsed = dao.getBranchlineUsed(entity.getTopiaId());
|
| 47 | - dto.getSection().forEach(section -> {
|
|
| 50 | + for (SectionDto section : dto.getSection()) {
|
|
| 48 | 51 | section.setParentId(dto.getId());
|
| 49 | 52 | String sectionId = section.getTopiaId();
|
| 50 | - section.setNotUsed(!sectionUsed.contains(sectionId));
|
|
| 51 | - section.getBasket().forEach(basket -> {
|
|
| 53 | + boolean sectionIsUsed = sectionUsed.contains(sectionId);
|
|
| 54 | + for (BasketDto basket : section.getBasket()) {
|
|
| 52 | 55 | basket.setParentId(sectionId);
|
| 53 | 56 | String basketId = basket.getTopiaId();
|
| 54 | - basket.setNotUsed(!basketUsed.contains(basketId));
|
|
| 55 | - basket.getBranchline().forEach(branchline -> {
|
|
| 57 | + boolean basketIsUsed = basketUsed.contains(basketId);
|
|
| 58 | + for (BranchlineDto branchline : basket.getBranchline()) {
|
|
| 56 | 59 | String branchlineId = branchline.getId();
|
| 57 | 60 | branchline.setParentId(basketId);
|
| 58 | - branchline.setNotUsed(!branchlineUsed.contains(branchlineId));
|
|
| 59 | - });
|
|
| 60 | - });
|
|
| 61 | - });
|
|
| 61 | + boolean branchlineIsUsed = branchlineUsed.contains(branchlineId);
|
|
| 62 | + branchline.setNotUsed(!branchlineIsUsed);
|
|
| 63 | + if (branchlineIsUsed) {
|
|
| 64 | + basketIsUsed = true;
|
|
| 65 | + }
|
|
| 66 | + }
|
|
| 67 | + if (basketIsUsed) {
|
|
| 68 | + sectionIsUsed = true;
|
|
| 69 | + }
|
|
| 70 | + basket.setNotUsed(!basketIsUsed);
|
|
| 71 | + }
|
|
| 72 | + section.setNotUsed(!sectionIsUsed);
|
|
| 73 | + }
|
|
| 62 | 74 | return form;
|
| 63 | 75 | }
|
| 64 | 76 |