Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
93ccd880
by Tony Chemit at 2024-01-22T13:02:31+01:00
-
9532f5f5
by Tony Chemit at 2024-01-22T13:02:31+01:00
-
7d086c2e
by Tony Chemit at 2024-01-22T13:02:31+01:00
-
b7d9286a
by Tony Chemit at 2024-01-22T13:02:31+01:00
-
bfd20961
by Tony Chemit at 2024-01-22T13:02:31+01:00
10 changed files:
- CHANGELOG.md
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/AdminTabUIHandler.java
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/pairing/ActivityPairingUIHandler.java
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/pairing/actions/Prepare.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/FloatingObjectUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/FloatingObjectUI.jaxx
- core/persistence/java/src/main/resources/META-INF/persistence/Observe/TopiaEntitySqlDeletePlanModel.json
- toolkit/api-services/src/main/java/fr/ird/observe/services/service/data/MoveRequest.java
- toolkit/persistence/src/main/java/org/nuiton/topia/persistence/support/QuerySupport.java
- toolkit/templates/src/main/java/org/nuiton/topia/templates/sql/plan/SqlHelper.java
Changes:
| 1 | 1 | # ObServe changelog
|
| 2 | 2 | |
| 3 | 3 | * Author [Tony Chemit](mailto:dev@tchemit.fr)
|
| 4 | - * Last generated at 2023-11-14 16:47.
|
|
| 4 | + * Last generated at 2024-01-22 12:54.
|
|
| 5 | + |
|
| 6 | +## Version [9.2.2](https://gitlab.com/ultreiaio/ird-observe/-/milestones/273)
|
|
| 7 | + |
|
| 8 | +**Closed at 2024-01-22.**
|
|
| 9 | + |
|
| 10 | +### Download
|
|
| 11 | +* [Client (observe-9.2.2-client.zip)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.2.2/observe-9.2.2-client.zip)
|
|
| 12 | +* [Serveur (observe-9.2.2.war)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.2.2/observe-9.2.2.war)
|
|
| 13 | +* [Serveur (observe-9.2.2-server.zip)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.2.2/observe-9.2.2-server.zip)
|
|
| 14 | + |
|
| 15 | +### Issues
|
|
| 16 | + * [[Type::Anomalie 2825]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2825) **Sur l'écran de définition Non déclenchement du bouton Enregistrer** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 17 | + * [[Type::Anomalie 2832]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2832) **Impossibilité de déplacer une activité PS observation sur une autre route en mode serveur** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 5 | 18 | |
| 6 | 19 | ## Version [9.2.1](https://gitlab.com/ultreiaio/ird-observe/-/milestones/272)
|
| 7 | 20 | |
| 21 | +**Closed at 2023-11-14.**
|
|
| 22 | + |
|
| 8 | 23 | ### Download
|
| 9 | 24 | * [Client (observe-9.2.1-client.zip)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.2.1/observe-9.2.1-client.zip)
|
| 10 | 25 | * [Serveur (observe-9.2.1.war)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.2.1/observe-9.2.1.war)
|
| 11 | 26 | * [Serveur (observe-9.2.1-server.zip)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.2.1/observe-9.2.1-server.zip)
|
| 12 | 27 | |
| 13 | -**Closed at 2023-11-14.**
|
|
| 14 | - |
|
| 15 | - |
|
| 16 | 28 | ### Issues
|
| 17 | 29 | * [[Type::Anomalie 2798]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2798) **Souci de décalage de lignes sur le rapport Vérification des plans de cuve** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| 18 | 30 | * [[Type::Anomalie 2800]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2800) **Erreur de migration sur bases AZTI locales** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
| ... | ... | @@ -193,7 +193,7 @@ public class AdminTabUIHandler<U extends AdminTabUI> implements WithClientUICont |
| 193 | 193 | |
| 194 | 194 | protected void onComingFromNextStepAdjust() {
|
| 195 | 195 | AdminUIModel model = ui.getModel();
|
| 196 | - if (model.containsOperation(AdminStep.VALIDATE) ||
|
|
| 196 | + if (model.containsOperation(AdminStep.VALIDATE) || model.containsOperation(AdminStep.ACTIVITY_PAIRING) ||
|
|
| 197 | 197 | (model.containsOperation(AdminStep.CONSOLIDATE) && !model.containsOperation(AdminStep.EXPORT_DATA))) {
|
| 198 | 198 | if (model.getStepState(AdminStep.CONSOLIDATE) == WizardState.SUCCESSED) {
|
| 199 | 199 | // set back to pending consolidate step
|
| ... | ... | @@ -203,6 +203,9 @@ public class AdminTabUIHandler<U extends AdminTabUI> implements WithClientUICont |
| 203 | 203 | model.setStepState(AdminStep.VALIDATE, WizardState.PENDING);
|
| 204 | 204 | // reset report model
|
| 205 | 205 | model.getValidateModel().reset();
|
| 206 | + } else if (model.getStepState(AdminStep.ACTIVITY_PAIRING) == WizardState.NEED_FIX || model.getStepState(AdminStep.ACTIVITY_PAIRING) == WizardState.SUCCESSED) {
|
|
| 207 | + // set back to pending activity pairing step
|
|
| 208 | + model.setStepState(AdminStep.ACTIVITY_PAIRING, WizardState.PENDING);
|
|
| 206 | 209 | }
|
| 207 | 210 | }
|
| 208 | 211 | }
|
| ... | ... | @@ -37,5 +37,6 @@ public class ActivityPairingUIHandler extends AdminTabUIHandler<ActivityPairingU |
| 37 | 37 | super.afterInit(ui);
|
| 38 | 38 | setAutoStart(ui.getPrepare());
|
| 39 | 39 | hideFixedPanelLabel(ui);
|
| 40 | + ui.getDescriptionContainer().remove(ui.getDescriptionPane());
|
|
| 40 | 41 | }
|
| 41 | 42 | } |
| ... | ... | @@ -87,7 +87,6 @@ public class Prepare extends ActivityPairingUIActionSupport { |
| 87 | 87 | }
|
| 88 | 88 | break;
|
| 89 | 89 | }
|
| 90 | - ui.getModel().setWasDone(true);
|
|
| 91 | 90 | stepModel.recomputeSelectedValues();
|
| 92 | 91 | return WizardState.NEED_FIX;
|
| 93 | 92 | }
|
| ... | ... | @@ -67,6 +67,7 @@ |
| 67 | 67 | <field name="transmittingBuoyOwnership" component="transmittingBuoyOwnership1"/>
|
| 68 | 68 | <field name="code" component="code1"/>
|
| 69 | 69 | <field name="country" component="country1"/>
|
| 70 | + <field name="vessel" component="vessel1"/>
|
|
| 70 | 71 | <field name='longitude' component='coordinate1'/>
|
| 71 | 72 | <field name='latitude' component='coordinate1'/>
|
| 72 | 73 | <field name='quadrant' component='coordinate1'/>
|
| ... | ... | @@ -80,6 +81,7 @@ |
| 80 | 81 | <field name="transmittingBuoyOwnership" component="transmittingBuoyOwnership2"/>
|
| 81 | 82 | <field name="code" component="code2"/>
|
| 82 | 83 | <field name="country" component="country2"/>
|
| 84 | + <field name="vessel" component="vessel2"/>
|
|
| 83 | 85 | <field name='comment' component='comment2'/>
|
| 84 | 86 | </BeanValidator>
|
| 85 | 87 |
| ... | ... | @@ -68,6 +68,7 @@ |
| 68 | 68 | <field name="transmittingBuoyOwnership" component="transmittingBuoyOwnership1"/>
|
| 69 | 69 | <field name="code" component="code1"/>
|
| 70 | 70 | <field name="country" component="country1"/>
|
| 71 | + <field name="vessel" component="vessel1"/>
|
|
| 71 | 72 | <field name='longitude' component='coordinate1'/>
|
| 72 | 73 | <field name='latitude' component='coordinate1'/>
|
| 73 | 74 | <field name='quadrant' component='coordinate1'/>
|
| ... | ... | @@ -81,6 +82,7 @@ |
| 81 | 82 | <field name="transmittingBuoyOwnership" component="transmittingBuoyOwnership2"/>
|
| 82 | 83 | <field name="code" component="code2"/>
|
| 83 | 84 | <field name="country" component="country2"/>
|
| 85 | + <field name="vessel" component="vessel2"/>
|
|
| 84 | 86 | <field name='comment' component='comment2'/>
|
| 85 | 87 | </BeanValidator>
|
| 86 | 88 | |
| ... | ... | @@ -229,7 +231,7 @@ |
| 229 | 231 | <JLabel id='vessel1Label'/>
|
| 230 | 232 | </cell>
|
| 231 | 233 | <cell anchor='east' weightx="1" fill="both">
|
| 232 | - <FilterableComboBox id='vessel1' genericType='VesselReference'/>
|
|
| 234 | + <FilterableComboBox id='vessel1' genericType='VesselReference' beanScope="transmittingBuoy1"/>
|
|
| 233 | 235 | </cell>
|
| 234 | 236 | </row>
|
| 235 | 237 | <row>
|
| ... | ... | @@ -120,23 +120,23 @@ |
| 120 | 120 | "ll_observation.set→DELETE FROM ll_observation.set WHERE set.activity %s;",
|
| 121 | 121 | "ll_observation.sensorUsed→DELETE FROM ll_observation.sensorUsed WHERE sensorUsed.activity %s;",
|
| 122 | 122 | "ll_observation.encounter→DELETE FROM ll_observation.encounter WHERE encounter.activity %s;",
|
| 123 | - "ll_logbook.activity→UPDATE ll_logbook.activity activity SET activity.relatedObservedActivity = NULL WHERE activity.relatedObservedActivity %s",
|
|
| 123 | + "ll_logbook.activity→UPDATE ll_logbook.activity SET relatedObservedActivity = NULL WHERE activity.relatedObservedActivity %s",
|
|
| 124 | 124 | "ll_observation.activity→DELETE FROM ll_observation.activity WHERE activity.topiaId %s;"
|
| 125 | 125 | ],
|
| 126 | 126 | "fr.ird.observe.entities.data.ll.observation.BaitsComposition": [
|
| 127 | 127 | "ll_observation.baitsComposition→DELETE FROM ll_observation.baitsComposition WHERE baitsComposition.topiaId %s;"
|
| 128 | 128 | ],
|
| 129 | 129 | "fr.ird.observe.entities.data.ll.observation.Basket": [
|
| 130 | - "ll_observation.catch→UPDATE ll_observation.catch catch SET catch.branchline = NULL WHERE catch.branchline IN ( SELECT branchline.topiaId FROM ll_observation.branchline branchline WHERE branchline.basket %s )",
|
|
| 131 | - "ll_observation.tdr→UPDATE ll_observation.tdr tdr SET tdr.branchline = NULL WHERE tdr.branchline IN ( SELECT branchline.topiaId FROM ll_observation.branchline branchline WHERE branchline.basket %s )",
|
|
| 130 | + "ll_observation.catch→UPDATE ll_observation.catch SET branchline = NULL WHERE catch.branchline IN ( SELECT branchline.topiaId FROM ll_observation.branchline branchline WHERE branchline.basket %s )",
|
|
| 131 | + "ll_observation.tdr→UPDATE ll_observation.tdr SET branchline = NULL WHERE tdr.branchline IN ( SELECT branchline.topiaId FROM ll_observation.branchline branchline WHERE branchline.basket %s )",
|
|
| 132 | 132 | "ll_observation.branchline→DELETE FROM ll_observation.branchline WHERE branchline.basket %s;",
|
| 133 | - "ll_observation.catch→UPDATE ll_observation.catch catch SET catch.basket = NULL WHERE catch.basket %s",
|
|
| 134 | - "ll_observation.tdr→UPDATE ll_observation.tdr tdr SET tdr.basket = NULL WHERE tdr.basket %s",
|
|
| 133 | + "ll_observation.catch→UPDATE ll_observation.catch SET basket = NULL WHERE catch.basket %s",
|
|
| 134 | + "ll_observation.tdr→UPDATE ll_observation.tdr SET basket = NULL WHERE tdr.basket %s",
|
|
| 135 | 135 | "ll_observation.basket→DELETE FROM ll_observation.basket WHERE basket.topiaId %s;"
|
| 136 | 136 | ],
|
| 137 | 137 | "fr.ird.observe.entities.data.ll.observation.Branchline": [
|
| 138 | - "ll_observation.catch→UPDATE ll_observation.catch catch SET catch.branchline = NULL WHERE catch.branchline %s",
|
|
| 139 | - "ll_observation.tdr→UPDATE ll_observation.tdr tdr SET tdr.branchline = NULL WHERE tdr.branchline %s",
|
|
| 138 | + "ll_observation.catch→UPDATE ll_observation.catch SET branchline = NULL WHERE catch.branchline %s",
|
|
| 139 | + "ll_observation.tdr→UPDATE ll_observation.tdr SET branchline = NULL WHERE tdr.branchline %s",
|
|
| 140 | 140 | "ll_observation.branchline→DELETE FROM ll_observation.branchline WHERE branchline.topiaId %s;"
|
| 141 | 141 | ],
|
| 142 | 142 | "fr.ird.observe.entities.data.ll.observation.BranchlinesComposition": [
|
| ... | ... | @@ -158,14 +158,14 @@ |
| 158 | 158 | "ll_observation.hooksComposition→DELETE FROM ll_observation.hooksComposition WHERE hooksComposition.topiaId %s;"
|
| 159 | 159 | ],
|
| 160 | 160 | "fr.ird.observe.entities.data.ll.observation.Section": [
|
| 161 | - "ll_observation.catch→UPDATE ll_observation.catch catch SET catch.branchline = NULL WHERE catch.branchline IN ( SELECT catch.branchline FROM ll_observation.branchline branchline INNER JOIN ll_observation.catch catch_ ON catch_.branchline = branchline.topiaId INNER JOIN ll_observation.basket basket ON basket.topiaId = branchline.basket WHERE basket.section %s )",
|
|
| 162 | - "ll_observation.tdr→UPDATE ll_observation.tdr tdr SET tdr.branchline = NULL WHERE tdr.branchline IN ( SELECT tdr.branchline FROM ll_observation.branchline branchline INNER JOIN ll_observation.tdr tdr_ ON tdr_.branchline = branchline.topiaId INNER JOIN ll_observation.basket basket ON basket.topiaId = branchline.basket WHERE basket.section %s )",
|
|
| 161 | + "ll_observation.catch→UPDATE ll_observation.catch SET branchline = NULL WHERE catch.branchline IN ( SELECT catch.branchline FROM ll_observation.branchline branchline INNER JOIN ll_observation.catch catch_ ON catch_.branchline = branchline.topiaId INNER JOIN ll_observation.basket basket ON basket.topiaId = branchline.basket WHERE basket.section %s )",
|
|
| 162 | + "ll_observation.tdr→UPDATE ll_observation.tdr SET branchline = NULL WHERE tdr.branchline IN ( SELECT tdr.branchline FROM ll_observation.branchline branchline INNER JOIN ll_observation.tdr tdr_ ON tdr_.branchline = branchline.topiaId INNER JOIN ll_observation.basket basket ON basket.topiaId = branchline.basket WHERE basket.section %s )",
|
|
| 163 | 163 | "ll_observation.branchline→DELETE FROM ll_observation.branchline WHERE branchline.topiaId IN (SELECT branchline.topiaId FROM ll_observation.branchline branchline INNER JOIN ll_observation.basket basket ON basket.topiaId = branchline.basket WHERE basket.section %s);",
|
| 164 | - "ll_observation.catch→UPDATE ll_observation.catch catch SET catch.basket = NULL WHERE catch.basket IN ( SELECT basket.topiaId FROM ll_observation.basket basket WHERE basket.section %s )",
|
|
| 165 | - "ll_observation.tdr→UPDATE ll_observation.tdr tdr SET tdr.basket = NULL WHERE tdr.basket IN ( SELECT basket.topiaId FROM ll_observation.basket basket WHERE basket.section %s )",
|
|
| 164 | + "ll_observation.catch→UPDATE ll_observation.catch SET basket = NULL WHERE catch.basket IN ( SELECT basket.topiaId FROM ll_observation.basket basket WHERE basket.section %s )",
|
|
| 165 | + "ll_observation.tdr→UPDATE ll_observation.tdr SET basket = NULL WHERE tdr.basket IN ( SELECT basket.topiaId FROM ll_observation.basket basket WHERE basket.section %s )",
|
|
| 166 | 166 | "ll_observation.basket→DELETE FROM ll_observation.basket WHERE basket.section %s;",
|
| 167 | - "ll_observation.catch→UPDATE ll_observation.catch catch SET catch.section = NULL WHERE catch.section %s",
|
|
| 168 | - "ll_observation.tdr→UPDATE ll_observation.tdr tdr SET tdr.section = NULL WHERE tdr.section %s",
|
|
| 167 | + "ll_observation.catch→UPDATE ll_observation.catch SET section = NULL WHERE catch.section %s",
|
|
| 168 | + "ll_observation.tdr→UPDATE ll_observation.tdr SET section = NULL WHERE tdr.section %s",
|
|
| 169 | 169 | "ll_observation.section→DELETE FROM ll_observation.section WHERE section.topiaId %s;"
|
| 170 | 170 | ],
|
| 171 | 171 | "fr.ird.observe.entities.data.ll.observation.SensorUsed": [
|
| ... | ... | @@ -268,7 +268,7 @@ |
| 268 | 268 | ],
|
| 269 | 269 | "fr.ird.observe.entities.data.ps.localmarket.Survey": [
|
| 270 | 270 | "ps_localmarket.surveyPart→DELETE FROM ps_localmarket.surveyPart WHERE surveyPart.survey %s;",
|
| 271 | - "ps_localmarket.batch→UPDATE ps_localmarket.batch batch SET batch.survey = NULL WHERE batch.survey %s",
|
|
| 271 | + "ps_localmarket.batch→UPDATE ps_localmarket.batch SET survey = NULL WHERE batch.survey %s",
|
|
| 272 | 272 | "ps_localmarket.survey→DELETE FROM ps_localmarket.survey WHERE survey.topiaId %s;"
|
| 273 | 273 | ],
|
| 274 | 274 | "fr.ird.observe.entities.data.ps.localmarket.SurveyPart": [
|
| ... | ... | @@ -353,7 +353,7 @@ |
| 353 | 353 | "ps_observation.floatingObject→DELETE FROM ps_observation.floatingObject WHERE floatingObject.activity %s;",
|
| 354 | 354 | "ps_observation.catch→DELETE FROM ps_observation.catch WHERE catch.topiaId IN (SELECT catch.topiaId FROM ps_observation.catch catch INNER JOIN ps_observation.set set ON set.topiaId = catch.set WHERE set.activity %s);",
|
| 355 | 355 | "ps_observation.set→DELETE FROM ps_observation.set WHERE set.activity %s;",
|
| 356 | - "ps_logbook.activity→UPDATE ps_logbook.activity activity SET activity.relatedObservedActivity = NULL WHERE activity.relatedObservedActivity %s",
|
|
| 356 | + "ps_logbook.activity→UPDATE ps_logbook.activity SET relatedObservedActivity = NULL WHERE activity.relatedObservedActivity %s",
|
|
| 357 | 357 | "ps_observation.activity→DELETE FROM ps_observation.activity WHERE activity.topiaId %s;"
|
| 358 | 358 | ],
|
| 359 | 359 | "fr.ird.observe.entities.data.ps.observation.Catch": [
|
| ... | ... | @@ -391,7 +391,7 @@ |
| 391 | 391 | "ps_observation.floatingObject→DELETE FROM ps_observation.floatingObject WHERE floatingObject.topiaId IN (SELECT floatingObject.topiaId FROM ps_observation.floatingObject floatingObject INNER JOIN ps_observation.activity activity ON activity.topiaId = floatingObject.activity WHERE activity.route %s);",
|
| 392 | 392 | "ps_observation.catch→DELETE FROM ps_observation.catch WHERE catch.topiaId IN (SELECT catch.topiaId FROM ps_observation.catch catch INNER JOIN ps_observation.set set ON set.topiaId = catch.set INNER JOIN ps_observation.activity activity ON activity.topiaId = set.activity WHERE activity.route %s);",
|
| 393 | 393 | "ps_observation.set→DELETE FROM ps_observation.set WHERE set.topiaId IN (SELECT set.topiaId FROM ps_observation.set set INNER JOIN ps_observation.activity activity ON activity.topiaId = set.activity WHERE activity.route %s);",
|
| 394 | - "ps_logbook.activity→UPDATE ps_logbook.activity activity SET activity.relatedObservedActivity = NULL WHERE activity.relatedObservedActivity IN ( SELECT activity.topiaId FROM ps_observation.activity activity WHERE activity.route %s )",
|
|
| 394 | + "ps_logbook.activity→UPDATE ps_logbook.activity SET relatedObservedActivity = NULL WHERE activity.relatedObservedActivity IN ( SELECT activity.topiaId FROM ps_observation.activity activity WHERE activity.route %s )",
|
|
| 395 | 395 | "ps_observation.activity→DELETE FROM ps_observation.activity WHERE activity.route %s;",
|
| 396 | 396 | "ps_observation.route→DELETE FROM ps_observation.route WHERE route.topiaId %s;"
|
| 397 | 397 | ],
|
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.services.service.data; |
| 25 | 25 | import fr.ird.observe.dto.BusinessDto;
|
| 26 | 26 | import fr.ird.observe.dto.ToolkitIdDtoBean;
|
| 27 | 27 | import fr.ird.observe.dto.data.RootOpenableDto;
|
| 28 | +import io.ultreia.java4all.util.json.JsonAware;
|
|
| 28 | 29 | |
| 29 | 30 | import java.util.Set;
|
| 30 | 31 | import java.util.StringJoiner;
|
| ... | ... | @@ -35,7 +36,7 @@ import java.util.StringJoiner; |
| 35 | 36 | * @author Tony Chemit - dev@tchemit.fr
|
| 36 | 37 | * @since 8.0.1
|
| 37 | 38 | */
|
| 38 | -public class MoveRequest {
|
|
| 39 | +public class MoveRequest implements JsonAware {
|
|
| 39 | 40 | |
| 40 | 41 | /**
|
| 41 | 42 | * Id of parent data to move.
|
| ... | ... | @@ -23,6 +23,7 @@ package org.nuiton.topia.persistence.support; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.datasource.SqlHelper;
|
| 26 | +import fr.ird.observe.dto.ToolkitId;
|
|
| 26 | 27 | import fr.ird.observe.entities.Entity;
|
| 27 | 28 | import fr.ird.observe.spi.context.DataDtoEntityContext;
|
| 28 | 29 | import org.hibernate.query.NativeQuery;
|
| ... | ... | @@ -31,14 +32,18 @@ import org.hibernate.query.QueryParameter; |
| 31 | 32 | |
| 32 | 33 | import javax.persistence.Parameter;
|
| 33 | 34 | import java.sql.Timestamp;
|
| 35 | +import java.util.Collection;
|
|
| 34 | 36 | import java.util.Collections;
|
| 35 | 37 | import java.util.Comparator;
|
| 36 | 38 | import java.util.LinkedList;
|
| 37 | 39 | import java.util.List;
|
| 38 | 40 | import java.util.Map;
|
| 41 | +import java.util.Objects;
|
|
| 39 | 42 | import java.util.function.BiConsumer;
|
| 43 | +import java.util.function.BiFunction;
|
|
| 40 | 44 | import java.util.function.Function;
|
| 41 | 45 | import java.util.stream.Collectors;
|
| 46 | +import java.util.stream.Stream;
|
|
| 42 | 47 | |
| 43 | 48 | |
| 44 | 49 | /**
|
| ... | ... | @@ -119,4 +124,36 @@ public interface QuerySupport { |
| 119 | 124 | default int execute(NativeQuery<?> sqlQuery) {
|
| 120 | 125 | return sqlQuery.executeUpdate();
|
| 121 | 126 | }
|
| 127 | + |
|
| 128 | + class MapBuilder<K extends ToolkitId, V> {
|
|
| 129 | + |
|
| 130 | + private final Map<K, List<V>> result;
|
|
| 131 | + |
|
| 132 | + private final Map<String, K> keysById;
|
|
| 133 | + private final BiFunction<K, Object[], V> valueCreator;
|
|
| 134 | + |
|
| 135 | + private K currentKey;
|
|
| 136 | + private List<V> currentList;
|
|
| 137 | + |
|
| 138 | + public MapBuilder(Map<K, List<V>> result, Collection<K> keys, BiFunction<K, Object[], V> valueCreator) {
|
|
| 139 | + this.result = result;
|
|
| 140 | + this.keysById = keys.stream().collect(Collectors.toMap(ToolkitId::getId, Function.identity()));
|
|
| 141 | + this.valueCreator = valueCreator;
|
|
| 142 | + keysById.values().forEach(r -> result.put(r, new LinkedList<>()));
|
|
| 143 | + }
|
|
| 144 | + |
|
| 145 | + public void addRow(Object[] row) {
|
|
| 146 | + String keyId = (String) row[0];
|
|
| 147 | + if (currentKey == null || !Objects.equals(currentKey.getId(), keyId)) {
|
|
| 148 | + currentKey = keysById.get(keyId);
|
|
| 149 | + currentList = result.get(currentKey);
|
|
| 150 | + }
|
|
| 151 | + currentList.add(valueCreator.apply(currentKey, row));
|
|
| 152 | + }
|
|
| 153 | + |
|
| 154 | + public Map<K, List<V>> build(Stream<Object[]> data) {
|
|
| 155 | + data.forEach(this::addRow);
|
|
| 156 | + return result;
|
|
| 157 | + }
|
|
| 158 | + }
|
|
| 122 | 159 | } |
| ... | ... | @@ -41,7 +41,7 @@ public class SqlHelper { |
| 41 | 41 | public static final String FROM_SQL = "%s WHERE %s";
|
| 42 | 42 | public static final String FROM_SQL_NO_WHERE = "%s";
|
| 43 | 43 | public static final String SQL_WHERE_CLAUSE_ALIAS = "%1$s.%2$s";
|
| 44 | - public static final String DELETE_REVERSE_ASSOCIATION_STATEMENT = "UPDATE %1$s.%2$s %2$s SET %2$s.%3$s = NULL WHERE %4$s";
|
|
| 44 | + public static final String DELETE_REVERSE_ASSOCIATION_STATEMENT = "UPDATE %1$s.%2$s SET %3$s = NULL WHERE %4$s";
|
|
| 45 | 45 | public static final String DELETE_FROM_SELECTOR_STATEMENT = "DELETE FROM %1$s.%2$s WHERE %2$s.%3$s IN (%4$s);";
|
| 46 | 46 | public static final String DELETE_FROM_SELECTOR_SIMPLIFIED_STATEMENT = "DELETE FROM %1$s.%2$s WHERE %3$s;";
|
| 47 | 47 |