Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe
Commits:
-
90eb070a
by Tony Chemit at 2023-01-05T13:39:00+01:00
-
29d23042
by Tony Chemit at 2023-01-05T13:39:00+01:00
-
37f45b04
by Tony Chemit at 2023-01-05T13:39:00+01:00
18 changed files:
- CHANGELOG.md
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUINavigationHandler.java
- core/services/i18n/src/main/i18n/translations/services_en_GB.properties
- core/services/i18n/src/main/i18n/translations/services_fr_FR.properties
- toolkit/api-report/src/main/java/fr/ird/observe/report/Report.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/ReportRepeatVariable.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/ReportVariable.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/ReportVariableSupport.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/definition/DefaultReportDefinitionsBuilder.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/definition/ReportDefinition.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/definition/ReportOperationDefinition.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/definition/ReportRepeatVariableDefinition.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/definition/ReportVariableDefinition.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/definition/ReportVariableSupportDefinition.java → toolkit/api-report/src/main/java/fr/ird/observe/report/definition/ReportVariableDefinitionSupport.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/json/ReportRepeatVariableAdapter.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/json/ReportVariableAdapter.java
- toolkit/api-report/src/main/java/fr/ird/observe/report/json/ReportVariableSupportAdapter.java
Changes:
| 1 | 1 | # ObServe changelog
|
| 2 | 2 | |
| 3 | 3 | * Author [Tony Chemit](mailto:dev@tchemit.fr)
|
| 4 | - * Last generated at 2022-12-12 19:31.
|
|
| 4 | + * Last generated at 2023-01-05 13:38.
|
|
| 5 | 5 | |
| 6 | -## Version [9.1.0-RC-1](https://gitlab.com/ultreiaio/ird-observe/-/milestones/243)
|
|
| 6 | +## Version [9.0.23](https://gitlab.com/ultreiaio/ird-observe/-/milestones/253)
|
|
| 7 | 7 | |
| 8 | -**Closed at 2022-11-25.**
|
|
| 8 | +**Closed at 2023-01-04.**
|
|
| 9 | 9 | |
| 10 | +### Download
|
|
| 11 | +* [Client (observe-9.0.23-client.zip)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.0.23/observe-9.0.23-client.zip)
|
|
| 12 | +* [Serveur (observe-9.0.23.war)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.0.23/observe-9.0.23.war)
|
|
| 13 | +* [Serveur (observe-9.0.23-server.zip)](https://repo1.maven.org/maven2/fr/ird/observe/observe/9.0.23/observe-9.0.23-server.zip)
|
|
| 10 | 14 | |
| 11 | 15 | ### Issues
|
| 12 | - * [[Type::Evolution 2218]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2218) **tms_version va-t-elle rester dans le schéma public ?** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 13 | - * [[Type::Evolution 2478]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2478) **Réusinage du plan de cuve** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 16 | + * [[Type::Anomalie 2579]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2579) **Impossible de créer une route en 9.0.22** (Thanks to Tony CHEMIT) (Reported by Pascal Cauquil)
|
|
| 17 | + * [[Type::Anomalie 2580]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2580) **Lors de la suppression gloable d'une capture utilisée sur le formulaire espèces sensibles, la demande de confirmation n'est pas proposée (mais elle l'est bien si l'espèce est utilisée dans un échantillon)** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 18 | + * [[Type::Anomalie 2581]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2581) **Imperfection de la validation sur une activité de pêche** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 19 | + * [[Type::Anomalie 2582]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2582) **Après création d'une activité, le nœud captures n'apparaît pas** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 20 | + * [[Type::Anomalie 2584]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2584) **Les activités ne sont pas disponibles lors de la création d'un échantillon (mais disponible en mode mis à jour)** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 21 | + * [[Type::Anomalie 2585]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2585) **Problème sur la sauvegarde d'un échantillon (si on lui associe des activités)** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 22 | + * [[Type::Anomalie 2587]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2587) **Si on quitte le formulaire marée modifié, aucune alerte n'est proposée pour enregistrer les modifications** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 23 | + * [[Type::Anomalie 2589]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2589) **Sur un formulaire tableau modifié, la demande confirmation est demandée deux fois si la première fois, on dit annuler** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 24 | + * [[Type::Anomalie 2591]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2591) **Mauvaise persistence des lots au niveau des sondages** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 25 | + * [[Type::Anomalie 2592]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2592) **Sur le formulaire lot, le champs commentaire n'est pas lié à un commentaire de la marée** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 26 | + * [[Type::Evolution 2577]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2577) **Améliorer les variables dans les rapports pour proposer les variables suivantes en filtrant sur la variable précédente** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 27 | + * [[Type::Evolution 2578]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2578) **Revoir la syntaxe des rapports** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 28 | + * [[Type::Evolution 2586]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2586) **Amélioration du texte d'information quand on ne peut pas encore remplir le marché local** (Thanks to Pascal Cauquil) (Reported by Tony CHEMIT)
|
|
| 29 | + * [[Type::Evolution 2590]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2590) **Ajout sur le formulaire d'une information sur la saisie possible ou non du marché local à partir du port d'arrivée sélectionné** (Thanks to Tony CHEMIT) (Reported by Tony CHEMIT)
|
|
| 30 | + * [[Type::Evolution 2595]](https://gitlab.com/ultreiaio/ird-observe/-/issues/2595) **Améliorations de libellés de l'arbre** (Thanks to Pascal Cauquil) (Reported by Pascal Cauquil)
|
|
| 14 | 31 | |
| 15 | 32 | ## Version [9.0.22](https://gitlab.com/ultreiaio/ird-observe/-/milestones/252)
|
| 16 | 33 |
| ... | ... | @@ -342,7 +342,7 @@ public class ReportModel extends AdminActionModel { |
| 342 | 342 | }
|
| 343 | 343 | |
| 344 | 344 | public ReportDefinition getSelectedReportDefinition() {
|
| 345 | - return selectedReport == null ? null : selectedReport.getDefinition();
|
|
| 345 | + return selectedReport == null ? null : selectedReport.definition();
|
|
| 346 | 346 | }
|
| 347 | 347 | |
| 348 | 348 | public void setSelectedReport(Report selectedReport) {
|
| ... | ... | @@ -64,7 +64,7 @@ public abstract class ContentTableUINavigationHandler<N extends ContentTableUINa |
| 64 | 64 | |
| 65 | 65 | @Override
|
| 66 | 66 | public String getText() {
|
| 67 | - String result = getNode().getScope().getI18nTranslation("type");
|
|
| 67 | + String result = getNode().getScope().getI18nTranslation("title");
|
|
| 68 | 68 | Long count = getNode().getInitializer().getCount();
|
| 69 | 69 | if (count != null) {
|
| 70 | 70 | result += String.format(" (%d)", count);
|
| ... | ... | @@ -862,13 +862,13 @@ observe.data.ll.observation.SetDetailComposition.section.delete.message=Confirm |
| 862 | 862 | observe.data.ll.observation.SetDetailComposition.sectionTemplate.delete=Confirm to delete current template.
|
| 863 | 863 | observe.data.ll.observation.SetDetailComposition.sections=Sections
|
| 864 | 864 | observe.data.ll.observation.SetDetailComposition.title.section.cant.use.firstTemplate=Can't use the first template while generating
|
| 865 | -observe.data.ll.observation.SetDetailComposition.type=Detailed compositions
|
|
| 865 | +observe.data.ll.observation.SetDetailComposition.type=Detailed composition
|
|
| 866 | 866 | observe.data.ll.observation.SetGlobalComposition.baitsCompositionTab=Baits
|
| 867 | 867 | observe.data.ll.observation.SetGlobalComposition.branchlinesCompositionTab=Branchlines
|
| 868 | 868 | observe.data.ll.observation.SetGlobalComposition.floatlinesCompositionTab=Floatlines
|
| 869 | 869 | observe.data.ll.observation.SetGlobalComposition.hooksCompositionTab=Hooks
|
| 870 | 870 | observe.data.ll.observation.SetGlobalComposition.mitigationTypeTab=Mitigation
|
| 871 | -observe.data.ll.observation.SetGlobalComposition.type=Global compositions
|
|
| 871 | +observe.data.ll.observation.SetGlobalComposition.type=Global composition
|
|
| 872 | 872 | observe.data.ll.observation.SetTdr.type=Fishing operation tdr
|
| 873 | 873 | observe.data.ll.observation.SizeMeasure.size=Size (cm)
|
| 874 | 874 | observe.data.ll.observation.SizeMeasure.size.short=Size (cm)
|
| ... | ... | @@ -994,7 +994,7 @@ observe.data.ps.localmarket.Batch.count.short=Count |
| 994 | 994 | observe.data.ps.localmarket.Batch.count.validation.required=Count or weight must be filled (but not both).
|
| 995 | 995 | observe.data.ps.localmarket.Batch.date=Date
|
| 996 | 996 | observe.data.ps.localmarket.Batch.title=Batches
|
| 997 | -observe.data.ps.localmarket.Batch.type=Batches
|
|
| 997 | +observe.data.ps.localmarket.Batch.type=Batch
|
|
| 998 | 998 | observe.data.ps.localmarket.Batch.validation.date.after.currentPsCommonTrip.endDate=Date (%2$s) must be after trip end date (%1$s).
|
| 999 | 999 | observe.data.ps.localmarket.Batch.validation.date.after.currentPsCommonTrip.startDate=Date (%2$s) must be after trip start date (%1$s).
|
| 1000 | 1000 | observe.data.ps.localmarket.Batch.validation.date.delay.too.long=Delay in days with trip end date is %d and can not be more than %s days.
|
| ... | ... | @@ -1308,7 +1308,7 @@ observe.data.ps.observation.ObjectObservedSpecies.type=Object observed species |
| 1308 | 1308 | observe.data.ps.observation.ObjectSchoolEstimate.action.create=Create a new estimate
|
| 1309 | 1309 | observe.data.ps.observation.ObjectSchoolEstimate.action.save=Insert this estimate
|
| 1310 | 1310 | observe.data.ps.observation.ObjectSchoolEstimate.action.save.tip=Insert this estimate
|
| 1311 | -observe.data.ps.observation.ObjectSchoolEstimate.title=School estimate
|
|
| 1311 | +observe.data.ps.observation.ObjectSchoolEstimate.title=Object School estimate
|
|
| 1312 | 1312 | observe.data.ps.observation.ObjectSchoolEstimate.totalWeight=Weight (in t)
|
| 1313 | 1313 | observe.data.ps.observation.ObjectSchoolEstimate.totalWeight.short=Total weight
|
| 1314 | 1314 | observe.data.ps.observation.ObjectSchoolEstimate.type=Object school estimate
|
| ... | ... | @@ -471,8 +471,8 @@ observe.data.GearUseFeatures.gear=Équipement |
| 471 | 471 | observe.data.GearUseFeatures.gear.short=Équipement
|
| 472 | 472 | observe.data.GearUseFeatures.number=Nombre
|
| 473 | 473 | observe.data.GearUseFeatures.number.short=Nombre
|
| 474 | -observe.data.GearUseFeatures.title=Équipement du bateau
|
|
| 475 | -observe.data.GearUseFeatures.type=Équipement du bateau
|
|
| 474 | +observe.data.GearUseFeatures.title=Équipements du navire
|
|
| 475 | +observe.data.GearUseFeatures.type=Équipement du navire
|
|
| 476 | 476 | observe.data.GearUseFeaturesMeasurement.type=Caractéristique d'un équipement
|
| 477 | 477 | observe.data.InlineData.action.add=Nouvelle entrée
|
| 478 | 478 | observe.data.InlineData.action.add.tip=Ajouter une nouvelle donnée de type «%s»
|
| ... | ... | @@ -714,7 +714,7 @@ observe.data.ll.logbook.SetGlobalComposition.branchlinesCompositionTab=Avançons |
| 714 | 714 | observe.data.ll.logbook.SetGlobalComposition.floatlinesCompositionTab=Orins
|
| 715 | 715 | observe.data.ll.logbook.SetGlobalComposition.hooksCompositionTab=Hameçons
|
| 716 | 716 | observe.data.ll.logbook.SetGlobalComposition.mitigationTypeTab=Atténuations
|
| 717 | -observe.data.ll.logbook.SetGlobalComposition.type=Compositions globales
|
|
| 717 | +observe.data.ll.logbook.SetGlobalComposition.type=Composition globale
|
|
| 718 | 718 | observe.data.ll.observation.Activity.action.create=Activité suivante
|
| 719 | 719 | observe.data.ll.observation.Activity.action.move=Changer de marée
|
| 720 | 720 | observe.data.ll.observation.Activity.action.move.choose.parent.message=À quelle marée voulez-vous associer les activités sélectionnées ?
|
| ... | ... | @@ -729,8 +729,8 @@ observe.data.ll.observation.Activity.sensorUsedStat=Nombre de capteurs utilisés |
| 729 | 729 | observe.data.ll.observation.Activity.setStat=Nombre d'opérations de pêche
|
| 730 | 730 | observe.data.ll.observation.Activity.title=Activité
|
| 731 | 731 | observe.data.ll.observation.Activity.type=Activité
|
| 732 | -observe.data.ll.observation.ActivityEncounter.type=Rencontre
|
|
| 733 | -observe.data.ll.observation.ActivitySensorUsed.type=Capteur
|
|
| 732 | +observe.data.ll.observation.ActivityEncounter.type=Rencontres
|
|
| 733 | +observe.data.ll.observation.ActivitySensorUsed.type=Capteurs utilisés
|
|
| 734 | 734 | observe.data.ll.observation.BaitsComposition.action.create=Nouvel appât
|
| 735 | 735 | observe.data.ll.observation.BaitsComposition.action.save=Insérer cet appât
|
| 736 | 736 | observe.data.ll.observation.BaitsComposition.action.save.tip=Insérer cet appât
|
| ... | ... | @@ -798,7 +798,7 @@ observe.data.ll.observation.SensorUsed.action.create=Nouveau capteur |
| 798 | 798 | observe.data.ll.observation.SensorUsed.action.save=Insérer ce capteur
|
| 799 | 799 | observe.data.ll.observation.SensorUsed.action.save.tip=Insérer ce capteur
|
| 800 | 800 | observe.data.ll.observation.SensorUsed.dataLocation.short=Hébergement
|
| 801 | -observe.data.ll.observation.SensorUsed.title=Capteurs
|
|
| 801 | +observe.data.ll.observation.SensorUsed.title=Capteurs utilisés
|
|
| 802 | 802 | observe.data.ll.observation.SensorUsed.type=Capteur utilisé
|
| 803 | 803 | observe.data.ll.observation.Set.action.add=Ajouter l'opération de pêche
|
| 804 | 804 | observe.data.ll.observation.Set.action.add.tip=Ajouter l'opération de pêche associée à cette activité
|
| ... | ... | @@ -862,13 +862,13 @@ observe.data.ll.observation.SetDetailComposition.section.delete.message=Confirme |
| 862 | 862 | observe.data.ll.observation.SetDetailComposition.sectionTemplate.delete=Confirmer la suppression du patron sélectionné.
|
| 863 | 863 | observe.data.ll.observation.SetDetailComposition.sections=Sections
|
| 864 | 864 | observe.data.ll.observation.SetDetailComposition.title.section.cant.use.firstTemplate=Impossible d'utiliser le premier modèle lors de la génération
|
| 865 | -observe.data.ll.observation.SetDetailComposition.type=Compositions détaillées
|
|
| 865 | +observe.data.ll.observation.SetDetailComposition.type=Composition détaillée
|
|
| 866 | 866 | observe.data.ll.observation.SetGlobalComposition.baitsCompositionTab=Appâts
|
| 867 | 867 | observe.data.ll.observation.SetGlobalComposition.branchlinesCompositionTab=Avançons
|
| 868 | 868 | observe.data.ll.observation.SetGlobalComposition.floatlinesCompositionTab=Orins
|
| 869 | 869 | observe.data.ll.observation.SetGlobalComposition.hooksCompositionTab=Hameçons
|
| 870 | 870 | observe.data.ll.observation.SetGlobalComposition.mitigationTypeTab=Atténuations
|
| 871 | -observe.data.ll.observation.SetGlobalComposition.type=Compositions globales
|
|
| 871 | +observe.data.ll.observation.SetGlobalComposition.type=Composition globale
|
|
| 872 | 872 | observe.data.ll.observation.SetTdr.type=Enregistreur de profondeur
|
| 873 | 873 | observe.data.ll.observation.SizeMeasure.size=Mesure (cm)
|
| 874 | 874 | observe.data.ll.observation.SizeMeasure.size.short=Mesure (cm)
|
| ... | ... | @@ -883,7 +883,7 @@ observe.data.ll.observation.Tdr.keyDataTab=Données clef |
| 883 | 883 | observe.data.ll.observation.Tdr.localisationTab=Localisation
|
| 884 | 884 | observe.data.ll.observation.Tdr.speciesTab=Espèces associées
|
| 885 | 885 | observe.data.ll.observation.Tdr.timestampTab=Horodatage
|
| 886 | -observe.data.ll.observation.Tdr.title=Enregistreur de profondeur
|
|
| 886 | +observe.data.ll.observation.Tdr.title=Enregistreurs de profondeur
|
|
| 887 | 887 | observe.data.ll.observation.Tdr.type=Enregistreur de profondeur
|
| 888 | 888 | observe.data.ll.observation.Tdr.validation.deploymentEnd.after.fishingEnd=L'horodatage de fin de déploiement (%2$s) doit être après le début de celui de fin de pêche (%1$s).
|
| 889 | 889 | observe.data.ll.observation.Tdr.validation.fishingEnd.after.fishingStart=L'horodatage de fin de pêche (%2$s) doit être après le début de celui de début de pêche (%1$s).
|
| ... | ... | @@ -1308,7 +1308,7 @@ observe.data.ps.observation.ObjectObservedSpecies.type=Faune observée |
| 1308 | 1308 | observe.data.ps.observation.ObjectSchoolEstimate.action.create=Nouvelle estimation
|
| 1309 | 1309 | observe.data.ps.observation.ObjectSchoolEstimate.action.save=Insérer cette estimation
|
| 1310 | 1310 | observe.data.ps.observation.ObjectSchoolEstimate.action.save.tip=Insérer la nouvelle estimation dans la table
|
| 1311 | -observe.data.ps.observation.ObjectSchoolEstimate.title=Estimation banc
|
|
| 1311 | +observe.data.ps.observation.ObjectSchoolEstimate.title=Estimation banc objet
|
|
| 1312 | 1312 | observe.data.ps.observation.ObjectSchoolEstimate.totalWeight=Poids (en t)
|
| 1313 | 1313 | observe.data.ps.observation.ObjectSchoolEstimate.totalWeight.short=Poids total
|
| 1314 | 1314 | observe.data.ps.observation.ObjectSchoolEstimate.type=Estimation banc objet
|
| ... | ... | @@ -59,11 +59,11 @@ public final class Report implements Serializable, JsonAware { |
| 59 | 59 | /**
|
| 60 | 60 | * Cache of variables of this report indexed by their name.
|
| 61 | 61 | */
|
| 62 | - private final transient Map<String, ReportVariable<?>> variableByName;
|
|
| 62 | + private transient Map<String, ReportVariable<?>> variableByName;
|
|
| 63 | 63 | /**
|
| 64 | 64 | * Cache of repeat variables of this report indexed by their name.
|
| 65 | 65 | */
|
| 66 | - private final transient Map<String, ReportRepeatVariable<?>> repeatVariableByName;
|
|
| 66 | + private transient Map<String, ReportRepeatVariable<?>> repeatVariableByName;
|
|
| 67 | 67 | |
| 68 | 68 | public Report(ReportDefinition definition) {
|
| 69 | 69 | this.definition = Objects.requireNonNull(definition);
|
| ... | ... | @@ -82,82 +82,90 @@ public final class Report implements Serializable, JsonAware { |
| 82 | 82 | ReportRepeatVariableDefinition<?> definitionRepeatVariable = definitionRepeatVariables[i];
|
| 83 | 83 | this.repeatVariables[i] = definitionRepeatVariable.toVariable();
|
| 84 | 84 | }
|
| 85 | - this.variableByName = Collections.unmodifiableMap(Arrays.stream(variables).collect(Collectors.toMap(ReportVariableSupport::getName, Function.identity())));
|
|
| 86 | - this.repeatVariableByName = Collections.unmodifiableMap(Arrays.stream(repeatVariables).collect(Collectors.toMap(ReportVariableSupport::getName, Function.identity())));
|
|
| 87 | 85 | }
|
| 88 | 86 | |
| 89 | - public ReportDefinition getDefinition() {
|
|
| 87 | + public ReportDefinition definition() {
|
|
| 90 | 88 | return definition;
|
| 91 | 89 | }
|
| 92 | 90 | |
| 91 | + public String getModelType() {
|
|
| 92 | + return definition().getModelType();
|
|
| 93 | + }
|
|
| 94 | + |
|
| 93 | 95 | public String getId() {
|
| 94 | - return getDefinition().getId();
|
|
| 96 | + return definition().getId();
|
|
| 95 | 97 | }
|
| 96 | 98 | |
| 97 | 99 | public String getName() {
|
| 98 | - return getDefinition().getName();
|
|
| 100 | + return definition().getName();
|
|
| 99 | 101 | }
|
| 100 | 102 | |
| 101 | 103 | public String getDescription() {
|
| 102 | - return getDefinition().getDescription();
|
|
| 104 | + return definition().getDescription();
|
|
| 103 | 105 | }
|
| 104 | 106 | |
| 105 | 107 | public int getRows() {
|
| 106 | - return getDefinition().getRows();
|
|
| 108 | + return definition().getRows();
|
|
| 107 | 109 | }
|
| 108 | 110 | |
| 109 | 111 | public int getColumns() {
|
| 110 | - return getDefinition().getColumns();
|
|
| 112 | + return definition().getColumns();
|
|
| 111 | 113 | }
|
| 112 | 114 | |
| 113 | 115 | public String[] getColumnHeaders() {
|
| 114 | - return getDefinition().getColumnHeaders();
|
|
| 116 | + return definition().getColumnHeaders();
|
|
| 115 | 117 | }
|
| 116 | 118 | |
| 117 | 119 | public String[] getRowHeaders() {
|
| 118 | - return getDefinition().getRowHeaders();
|
|
| 120 | + return definition().getRowHeaders();
|
|
| 119 | 121 | }
|
| 120 | 122 | |
| 121 | 123 | public ReportRequestDefinition[] getRequests() {
|
| 122 | - return getDefinition().getRequests();
|
|
| 124 | + return definition().getRequests();
|
|
| 123 | 125 | }
|
| 124 | 126 | |
| 125 | 127 | public ReportOperationDefinition[] getOperations() {
|
| 126 | - return getDefinition().getOperations();
|
|
| 128 | + return definition().getOperations();
|
|
| 127 | 129 | }
|
| 128 | 130 | |
| 129 | - public ReportVariable<?>[] getVariables() {
|
|
| 130 | - return variables;
|
|
| 131 | + public Map<String, Set<String>> getVariableDependencies() {
|
|
| 132 | + return definition().getVariableDependencies();
|
|
| 131 | 133 | }
|
| 132 | 134 | |
| 133 | - public Map<String, Set<String>> getVariableDependencies() {
|
|
| 134 | - return getDefinition().getVariableDependencies();
|
|
| 135 | + public ReportVariable<?>[] getVariables() {
|
|
| 136 | + return variables;
|
|
| 135 | 137 | }
|
| 136 | 138 | |
| 137 | 139 | public Map<String, ReportVariable<?>> getVariableByName() {
|
| 140 | + if (variableByName == null) {
|
|
| 141 | + this.variableByName = Collections.unmodifiableMap(Arrays.stream(variables).collect(Collectors.toMap(ReportVariable::getName, Function.identity())));
|
|
| 142 | + }
|
|
| 138 | 143 | return variableByName;
|
| 139 | 144 | }
|
| 140 | 145 | |
| 141 | 146 | public ReportVariable<?> getVariable(String variableName) {
|
| 142 | - return variableByName.get(variableName);
|
|
| 147 | + return getVariableByName().get(variableName);
|
|
| 143 | 148 | }
|
| 144 | 149 | |
| 145 | 150 | public ReportRepeatVariable<?>[] getRepeatVariables() {
|
| 146 | 151 | return repeatVariables;
|
| 147 | 152 | }
|
| 148 | 153 | |
| 149 | - public String getModelType() {
|
|
| 150 | - return getDefinition().getModelType();
|
|
| 151 | - }
|
|
| 152 | - |
|
| 153 | - @Override
|
|
| 154 | - public String toString() {
|
|
| 155 | - return getDefinition().toString();
|
|
| 154 | + public Map<String, ReportRepeatVariable<?>> getRepeatVariableByName() {
|
|
| 155 | + if (repeatVariableByName == null) {
|
|
| 156 | + this.repeatVariableByName = Collections.unmodifiableMap(Arrays.stream(repeatVariables).collect(Collectors.toMap(ReportRepeatVariable::getName, Function.identity())));
|
|
| 157 | + }
|
|
| 158 | + return repeatVariableByName;
|
|
| 156 | 159 | }
|
| 157 | 160 | |
| 158 | 161 | @SuppressWarnings("unchecked")
|
| 159 | 162 | public <V> ReportRepeatVariable<V> getRepeatVariable(String name) {
|
| 160 | - return (ReportRepeatVariable<V>) repeatVariableByName.get(name);
|
|
| 163 | + return (ReportRepeatVariable<V>) getRepeatVariableByName().get(name);
|
|
| 164 | + }
|
|
| 165 | + |
|
| 166 | + @Override
|
|
| 167 | + public String toString() {
|
|
| 168 | + return definition().toString();
|
|
| 161 | 169 | }
|
| 162 | 170 | |
| 163 | 171 | /**
|
| ... | ... | @@ -246,12 +254,13 @@ public final class Report implements Serializable, JsonAware { |
| 246 | 254 | * @param dependencyVariableName the dependency variable name that has changed
|
| 247 | 255 | */
|
| 248 | 256 | public void unloadVariablesIfNecessary(String dependencyVariableName) {
|
| 257 | + Map<String, Set<String>> variableDependencyNamesMap = getVariableDependencies();
|
|
| 249 | 258 | for (ReportVariable<?> variable : variables) {
|
| 250 | 259 | if (!variable.isValuesLoaded()) {
|
| 251 | 260 | // this variable is not loaded (so can not unload it)
|
| 252 | 261 | continue;
|
| 253 | 262 | }
|
| 254 | - Set<String> variableDependencyNames = getVariableDependencies().get(variable.getName());
|
|
| 263 | + Set<String> variableDependencyNames = variableDependencyNamesMap.get(variable.getName());
|
|
| 255 | 264 | if (variableDependencyNames == null) {
|
| 256 | 265 | // this variable has no dependency
|
| 257 | 266 | continue;
|
| ... | ... | @@ -262,4 +271,5 @@ public final class Report implements Serializable, JsonAware { |
| 262 | 271 | }
|
| 263 | 272 | }
|
| 264 | 273 | }
|
| 274 | + |
|
| 265 | 275 | } |
| ... | ... | @@ -44,22 +44,16 @@ import java.util.stream.Collectors; |
| 44 | 44 | * @author Tony Chemit - dev@tchemit.fr
|
| 45 | 45 | * @since 9.0.23
|
| 46 | 46 | */
|
| 47 | -public final class ReportRepeatVariable<V> extends ReportVariableSupport<V> {
|
|
| 47 | +public final class ReportRepeatVariable<V> extends ReportVariableSupport<V, ReportRepeatVariableDefinition<V>> {
|
|
| 48 | 48 | |
| 49 | 49 | private static final long serialVersionUID = 1L;
|
| 50 | - private final ReportRepeatVariableDefinition<V> definition;
|
|
| 51 | 50 | |
| 52 | 51 | public ReportRepeatVariable(ReportRepeatVariableDefinition<V> definition) {
|
| 53 | - this.definition = definition;
|
|
| 54 | - }
|
|
| 55 | - |
|
| 56 | - @Override
|
|
| 57 | - public ReportRepeatVariableDefinition<V> getDefinition() {
|
|
| 58 | - return definition;
|
|
| 52 | + super(definition);
|
|
| 59 | 53 | }
|
| 60 | 54 | |
| 61 | 55 | public boolean isAddNullValue() {
|
| 62 | - return getDefinition().isAddNullValue();
|
|
| 56 | + return definition().isAddNullValue();
|
|
| 63 | 57 | }
|
| 64 | 58 | |
| 65 | 59 | @Override
|
| ... | ... | @@ -72,7 +66,7 @@ public final class ReportRepeatVariable<V> extends ReportVariableSupport<V> { |
| 72 | 66 | |
| 73 | 67 | public List<String> computeIndexList() {
|
| 74 | 68 | //FIXME This is already done by setValues method? Why using a "null" instead of null value?
|
| 75 | - Set<V> tmp = new LinkedHashSet<>(values);
|
|
| 69 | + Set<V> tmp = new LinkedHashSet<>(getValues());
|
|
| 76 | 70 | boolean useNullValue = tmp.remove(null);
|
| 77 | 71 | List<String> result = tmp.stream().map(s -> s instanceof ToolkitId ? ((ToolkitId) s).getId() : String.valueOf(s)).collect(Collectors.toList());
|
| 78 | 72 | if (useNullValue || isAddNullValue()) {
|
| ... | ... | @@ -30,25 +30,19 @@ import fr.ird.observe.report.definition.ReportVariableDefinition; |
| 30 | 30 | * @author Tony Chemit - dev@tchemit.fr
|
| 31 | 31 | * @since 1.7
|
| 32 | 32 | */
|
| 33 | -public final class ReportVariable<V> extends ReportVariableSupport<V> {
|
|
| 33 | +public final class ReportVariable<V> extends ReportVariableSupport<V, ReportVariableDefinition<V>> {
|
|
| 34 | 34 | |
| 35 | 35 | public final static String PROPERTY_SELECTED_VALUE = "selectedValue";
|
| 36 | 36 | |
| 37 | 37 | private static final long serialVersionUID = 1L;
|
| 38 | 38 | |
| 39 | - private final ReportVariableDefinition<V> definition;
|
|
| 40 | 39 | /**
|
| 41 | 40 | * Selected value for this variable, that will be used to execute report.
|
| 42 | 41 | */
|
| 43 | 42 | private V selectedValue;
|
| 44 | 43 | |
| 45 | 44 | public ReportVariable(ReportVariableDefinition<V> definition) {
|
| 46 | - this.definition = definition;
|
|
| 47 | - }
|
|
| 48 | - |
|
| 49 | - @Override
|
|
| 50 | - public ReportVariableDefinition<V> getDefinition() {
|
|
| 51 | - return definition;
|
|
| 45 | + super(definition);
|
|
| 52 | 46 | }
|
| 53 | 47 | |
| 54 | 48 | public V getSelectedValue() {
|
| ... | ... | @@ -64,7 +58,7 @@ public final class ReportVariable<V> extends ReportVariableSupport<V> { |
| 64 | 58 | }
|
| 65 | 59 | |
| 66 | 60 | public boolean isValuesLoadedAndSelectedValueFilled() {
|
| 67 | - return isValuesLoaded() && getSelectedValue() != null;
|
|
| 61 | + return isValuesLoaded() && isSelectedValueFilled();
|
|
| 68 | 62 | }
|
| 69 | 63 | |
| 70 | 64 | @Override
|
| ... | ... | @@ -22,7 +22,7 @@ package fr.ird.observe.report; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | -import fr.ird.observe.report.definition.ReportVariableSupportDefinition;
|
|
| 25 | +import fr.ird.observe.report.definition.ReportVariableDefinitionSupport;
|
|
| 26 | 26 | import io.ultreia.java4all.util.json.JsonAware;
|
| 27 | 27 | |
| 28 | 28 | import java.io.Serializable;
|
| ... | ... | @@ -39,27 +39,38 @@ import java.util.Set; |
| 39 | 39 | * @see ReportRepeatVariable
|
| 40 | 40 | * @since 9.0.22
|
| 41 | 41 | */
|
| 42 | -public abstract class ReportVariableSupport<V> implements Serializable, JsonAware {
|
|
| 42 | +public abstract class ReportVariableSupport<V, D extends ReportVariableDefinitionSupport<V>> implements Serializable, JsonAware {
|
|
| 43 | 43 | |
| 44 | + public final static String PROPERTY_DEFINITION = "definition";
|
|
| 44 | 45 | public final static String PROPERTY_VALUES = "values";
|
| 45 | 46 | |
| 46 | 47 | /**
|
| 47 | - * Found values to this variable.
|
|
| 48 | + * Definition of this variable.
|
|
| 48 | 49 | */
|
| 49 | - protected Set<V> values;
|
|
| 50 | + private final D definition;
|
|
| 51 | + /**
|
|
| 52 | + * Values loaded for this variable.
|
|
| 53 | + */
|
|
| 54 | + private Set<V> values;
|
|
| 50 | 55 | |
| 51 | - public abstract ReportVariableSupportDefinition<V> getDefinition();
|
|
| 56 | + protected ReportVariableSupport(D definition) {
|
|
| 57 | + this.definition = definition;
|
|
| 58 | + }
|
|
| 59 | + |
|
| 60 | + public final D definition() {
|
|
| 61 | + return definition;
|
|
| 62 | + }
|
|
| 52 | 63 | |
| 53 | 64 | public final String getName() {
|
| 54 | - return getDefinition().getName();
|
|
| 65 | + return definition().getName();
|
|
| 55 | 66 | }
|
| 56 | 67 | |
| 57 | 68 | public final Class<V> getType() {
|
| 58 | - return getDefinition().getType();
|
|
| 69 | + return definition().getType();
|
|
| 59 | 70 | }
|
| 60 | 71 | |
| 61 | 72 | public final String getRequest() {
|
| 62 | - return getDefinition().getRequest();
|
|
| 73 | + return definition().getRequest();
|
|
| 63 | 74 | }
|
| 64 | 75 | |
| 65 | 76 | public final Set<V> getValues() {
|
| ... | ... | @@ -82,12 +93,12 @@ public abstract class ReportVariableSupport<V> implements Serializable, JsonAwar |
| 82 | 93 | public final boolean equals(Object o) {
|
| 83 | 94 | if (this == o) return true;
|
| 84 | 95 | if (o == null || !getClass().equals(o.getClass())) return false;
|
| 85 | - ReportVariableSupport<?> that = (ReportVariableSupport<?>) o;
|
|
| 86 | - return Objects.equals(getDefinition(), that.getDefinition());
|
|
| 96 | + ReportVariableSupport<?, ?> that = (ReportVariableSupport<?, ?>) o;
|
|
| 97 | + return Objects.equals(definition(), that.definition());
|
|
| 87 | 98 | }
|
| 88 | 99 | |
| 89 | 100 | @Override
|
| 90 | 101 | public final int hashCode() {
|
| 91 | - return Objects.hash(getDefinition());
|
|
| 102 | + return Objects.hash(definition());
|
|
| 92 | 103 | }
|
| 93 | 104 | } |
| ... | ... | @@ -139,7 +139,7 @@ public class DefaultReportDefinitionsBuilder implements ReportDefinitionsBuilder |
| 139 | 139 | String[] rowHeaders = loadHeaders(reportName, REPORT_ROWS, reportProperties);
|
| 140 | 140 | String[] columnHeaders = loadHeaders(reportName, REPORT_COLUMNS, reportProperties);
|
| 141 | 141 | List<ReportVariableDefinition<?>> variables = getVariables(reportName, reportProperties);
|
| 142 | - Set<String> variablesNames = variables.stream().map(ReportVariableSupportDefinition::getName).collect(Collectors.toSet());
|
|
| 142 | + Set<String> variablesNames = variables.stream().map(ReportVariableDefinition::getName).collect(Collectors.toSet());
|
|
| 143 | 143 | List<ReportRepeatVariableDefinition<?>> repeatVariables = getRepeatVariables(reportName, reportProperties, variablesNames);
|
| 144 | 144 | ReportRequestDefinition[] requests = getRequests(reportName, reportProperties);
|
| 145 | 145 | List<ReportOperationDefinition> operations = getOperations(reportName, reportProperties);
|
| ... | ... | @@ -94,7 +94,7 @@ public final class ReportDefinition implements Serializable, JsonAware { |
| 94 | 94 | /**
|
| 95 | 95 | * Cache of dependencies on variables (key is variable name, value is the required variable names to be able to populate the variable).
|
| 96 | 96 | */
|
| 97 | - private final transient Map<String, Set<String>> variableDependencies;
|
|
| 97 | + private transient Map<String, Set<String>> variableDependencies;
|
|
| 98 | 98 | |
| 99 | 99 | public ReportDefinition(String modelType,
|
| 100 | 100 | String id,
|
| ... | ... | @@ -116,8 +116,6 @@ public final class ReportDefinition implements Serializable, JsonAware { |
| 116 | 116 | this.operations = operations;
|
| 117 | 117 | this.variables = variables;
|
| 118 | 118 | this.repeatVariables = repeatVariables;
|
| 119 | - Map<String, ReportVariableDefinition<?>> variableByName = Collections.unmodifiableMap(Arrays.stream(variables).collect(Collectors.toMap(ReportVariableDefinition::getName, Function.identity())));
|
|
| 120 | - this.variableDependencies = computeVariableDependencies(variableByName);
|
|
| 121 | 119 | }
|
| 122 | 120 | |
| 123 | 121 | public String getModelType() {
|
| ... | ... | @@ -149,6 +147,9 @@ public final class ReportDefinition implements Serializable, JsonAware { |
| 149 | 147 | }
|
| 150 | 148 | |
| 151 | 149 | public Map<String, Set<String>> getVariableDependencies() {
|
| 150 | + if (variableDependencies == null) {
|
|
| 151 | + this.variableDependencies = computeVariableDependencies();
|
|
| 152 | + }
|
|
| 152 | 153 | return variableDependencies;
|
| 153 | 154 | }
|
| 154 | 155 | |
| ... | ... | @@ -181,8 +182,8 @@ public final class ReportDefinition implements Serializable, JsonAware { |
| 181 | 182 | return t(name);
|
| 182 | 183 | }
|
| 183 | 184 | |
| 184 | - static Map<String, Set<String>> computeVariableDependencies(Map<String, ReportVariableDefinition<?>> variableByNames) {
|
|
| 185 | - |
|
| 185 | + private Map<String, Set<String>> computeVariableDependencies() {
|
|
| 186 | + Map<String, ReportVariableDefinition<?>> variableByNames = Collections.unmodifiableMap(Arrays.stream(variables).collect(Collectors.toMap(ReportVariableDefinition::getName, Function.identity())));
|
|
| 186 | 187 | Set<String> variableNames = variableByNames.keySet();
|
| 187 | 188 | Map<String, Set<String>> variableDependencies = new TreeMap<>();
|
| 188 | 189 | for (Map.Entry<String, ReportVariableDefinition<?>> entry : variableByNames.entrySet()) {
|
| ... | ... | @@ -38,6 +38,9 @@ public final class ReportOperationDefinition implements JsonAware { |
| 38 | 38 | * Name of the operation, this is the fully qualified name of the ReportOperationConsumer.
|
| 39 | 39 | */
|
| 40 | 40 | private final String name;
|
| 41 | + /**
|
|
| 42 | + * Optional parameters of this operation.
|
|
| 43 | + */
|
|
| 41 | 44 | private final String parameters;
|
| 42 | 45 | |
| 43 | 46 | public static ReportOperationDefinition of(String name) {
|
| ... | ... | @@ -30,9 +30,7 @@ import fr.ird.observe.report.ReportRepeatVariable; |
| 30 | 30 | * @author Tony Chemit - dev@tchemit.fr
|
| 31 | 31 | * @since 9.0.23
|
| 32 | 32 | */
|
| 33 | -public final class ReportRepeatVariableDefinition<V> extends ReportVariableSupportDefinition<V> {
|
|
| 34 | - |
|
| 35 | - public final static String PROPERTY_ADD_NULL_VALUE = "addNullValue";
|
|
| 33 | +public final class ReportRepeatVariableDefinition<V> extends ReportVariableDefinitionSupport<V> {
|
|
| 36 | 34 | |
| 37 | 35 | private static final long serialVersionUID = 1L;
|
| 38 | 36 |
| ... | ... | @@ -33,7 +33,7 @@ import fr.ird.observe.report.ReportVariable; |
| 33 | 33 | * @author Tony Chemit - dev@tchemit.fr
|
| 34 | 34 | * @since 2.0.23
|
| 35 | 35 | */
|
| 36 | -public final class ReportVariableDefinition<V> extends ReportVariableSupportDefinition<V> {
|
|
| 36 | +public final class ReportVariableDefinition<V> extends ReportVariableDefinitionSupport<V> {
|
|
| 37 | 37 | |
| 38 | 38 | public ReportVariableDefinition(String name, Class<V> type, String request, String comment) {
|
| 39 | 39 | super(name, type, request, comment);
|
| ... | ... | @@ -37,13 +37,7 @@ import java.util.Objects; |
| 37 | 37 | * @author Tony Chemit - dev@tchemit.fr
|
| 38 | 38 | * @since 2.0.23
|
| 39 | 39 | */
|
| 40 | -public abstract class ReportVariableSupportDefinition<V> implements Serializable, JsonAware {
|
|
| 41 | - |
|
| 42 | - public final static String PROPERTY_NAME = "name";
|
|
| 43 | - public final static String PROPERTY_TYPE = "type";
|
|
| 44 | - public final static String PROPERTY_REQUEST = "request";
|
|
| 45 | - public final static String PROPERTY_COMMENT = "comment";
|
|
| 46 | - |
|
| 40 | +public abstract class ReportVariableDefinitionSupport<V> implements Serializable, JsonAware {
|
|
| 47 | 41 | /**
|
| 48 | 42 | * Name of the variable.
|
| 49 | 43 | */
|
| ... | ... | @@ -61,7 +55,7 @@ public abstract class ReportVariableSupportDefinition<V> implements Serializable |
| 61 | 55 | */
|
| 62 | 56 | private final String comment;
|
| 63 | 57 | |
| 64 | - public ReportVariableSupportDefinition(String name, Class<V> type, String request, String comment) {
|
|
| 58 | + public ReportVariableDefinitionSupport(String name, Class<V> type, String request, String comment) {
|
|
| 65 | 59 | this.name = Objects.requireNonNull(name);
|
| 66 | 60 | this.type = Objects.requireNonNull(type);
|
| 67 | 61 | this.request = Objects.requireNonNull(request);
|
| ... | ... | @@ -88,13 +82,13 @@ public abstract class ReportVariableSupportDefinition<V> implements Serializable |
| 88 | 82 | return comment != null;
|
| 89 | 83 | }
|
| 90 | 84 | |
| 91 | - public abstract ReportVariableSupport<?> toVariable();
|
|
| 85 | + public abstract ReportVariableSupport<?, ?> toVariable();
|
|
| 92 | 86 | |
| 93 | 87 | @Override
|
| 94 | 88 | public final boolean equals(Object o) {
|
| 95 | 89 | if (this == o) return true;
|
| 96 | 90 | if (o == null || !getClass().equals(o.getClass())) return false;
|
| 97 | - ReportVariableSupportDefinition<?> that = (ReportVariableSupportDefinition<?>) o;
|
|
| 91 | + ReportVariableDefinitionSupport<?> that = (ReportVariableDefinitionSupport<?>) o;
|
|
| 98 | 92 | return Objects.equals(name, that.name);
|
| 99 | 93 | }
|
| 100 | 94 |
| ... | ... | @@ -24,10 +24,8 @@ package fr.ird.observe.report.json; |
| 24 | 24 | |
| 25 | 25 | import com.google.auto.service.AutoService;
|
| 26 | 26 | import com.google.gson.JsonDeserializationContext;
|
| 27 | -import com.google.gson.JsonDeserializer;
|
|
| 28 | -import com.google.gson.JsonElement;
|
|
| 29 | 27 | import com.google.gson.JsonObject;
|
| 30 | -import com.google.gson.JsonParseException;
|
|
| 28 | +import com.google.gson.reflect.TypeToken;
|
|
| 31 | 29 | import fr.ird.observe.report.ReportRepeatVariable;
|
| 32 | 30 | import fr.ird.observe.report.definition.ReportRepeatVariableDefinition;
|
| 33 | 31 | import io.ultreia.java4all.util.json.JsonAdapter;
|
| ... | ... | @@ -41,7 +39,7 @@ import java.lang.reflect.Type; |
| 41 | 39 | * @since 9.0.22
|
| 42 | 40 | */
|
| 43 | 41 | @AutoService(JsonAdapter.class)
|
| 44 | -public class ReportRepeatVariableAdapter extends ReportVariableSupportAdapter implements JsonDeserializer<ReportRepeatVariable<?>> {
|
|
| 42 | +public class ReportRepeatVariableAdapter<V> extends ReportVariableSupportAdapter<V, ReportRepeatVariableDefinition<V>, ReportRepeatVariable<V>> {
|
|
| 45 | 43 | |
| 46 | 44 | @Override
|
| 47 | 45 | public Class<?> type() {
|
| ... | ... | @@ -49,22 +47,15 @@ public class ReportRepeatVariableAdapter extends ReportVariableSupportAdapter im |
| 49 | 47 | }
|
| 50 | 48 | |
| 51 | 49 | @Override
|
| 52 | - public ReportRepeatVariable<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
|
| 53 | - JsonObject jsonObject = json.getAsJsonObject();
|
|
| 54 | - |
|
| 55 | - String name = getVariableName(context, jsonObject);
|
|
| 56 | - Class<?> type = getVariableType(context, jsonObject);
|
|
| 57 | - String request = getVariableRequest(context, jsonObject);
|
|
| 58 | - String comment = getVariableComment(context, jsonObject);
|
|
| 59 | - boolean addNullValue = getAddNullValue(context, jsonObject);
|
|
| 60 | - ReportRepeatVariableDefinition<?> definition = new ReportRepeatVariableDefinition<>(name, type, request, comment, addNullValue);
|
|
| 61 | - ReportRepeatVariable<?> result = new ReportRepeatVariable<>(definition);
|
|
| 62 | - |
|
| 63 | - loadVariableValues(context, jsonObject, result);
|
|
| 64 | - return result;
|
|
| 50 | + protected Type definitionType() {
|
|
| 51 | + return new TypeToken<ReportRepeatVariableDefinition<V>>() {
|
|
| 52 | + }.getType();
|
|
| 65 | 53 | }
|
| 66 | 54 | |
| 67 | - protected boolean getAddNullValue(JsonDeserializationContext context, JsonObject jsonObject) {
|
|
| 68 | - return context.deserialize(jsonObject.get(ReportRepeatVariableDefinition.PROPERTY_ADD_NULL_VALUE), boolean.class);
|
|
| 55 | + @Override
|
|
| 56 | + protected ReportRepeatVariable<V> deserialize(JsonDeserializationContext context, JsonObject jsonObject, ReportRepeatVariableDefinition<V> definition) {
|
|
| 57 | + ReportRepeatVariable<V> result = new ReportRepeatVariable<>(definition);
|
|
| 58 | + deserializeValues(context, jsonObject, result);
|
|
| 59 | + return result;
|
|
| 69 | 60 | }
|
| 70 | 61 | } |
| ... | ... | @@ -25,10 +25,9 @@ package fr.ird.observe.report.json; |
| 25 | 25 | |
| 26 | 26 | import com.google.auto.service.AutoService;
|
| 27 | 27 | import com.google.gson.JsonDeserializationContext;
|
| 28 | -import com.google.gson.JsonDeserializer;
|
|
| 29 | 28 | import com.google.gson.JsonElement;
|
| 30 | 29 | import com.google.gson.JsonObject;
|
| 31 | -import com.google.gson.JsonParseException;
|
|
| 30 | +import com.google.gson.reflect.TypeToken;
|
|
| 32 | 31 | import fr.ird.observe.report.ReportVariable;
|
| 33 | 32 | import fr.ird.observe.report.definition.ReportVariableDefinition;
|
| 34 | 33 | import io.ultreia.java4all.util.json.JsonAdapter;
|
| ... | ... | @@ -39,7 +38,7 @@ import java.lang.reflect.Type; |
| 39 | 38 | * @author Tony Chemit - dev@tchemit.fr
|
| 40 | 39 | */
|
| 41 | 40 | @AutoService(JsonAdapter.class)
|
| 42 | -public class ReportVariableAdapter extends ReportVariableSupportAdapter implements JsonDeserializer<ReportVariable<?>> {
|
|
| 41 | +public class ReportVariableAdapter<V> extends ReportVariableSupportAdapter<V, ReportVariableDefinition<V>, ReportVariable<V>> {
|
|
| 43 | 42 | |
| 44 | 43 | @Override
|
| 45 | 44 | public Class<?> type() {
|
| ... | ... | @@ -47,27 +46,22 @@ public class ReportVariableAdapter extends ReportVariableSupportAdapter implemen |
| 47 | 46 | }
|
| 48 | 47 | |
| 49 | 48 | @Override
|
| 50 | - public ReportVariable<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
|
| 51 | - JsonObject jsonObject = json.getAsJsonObject();
|
|
| 52 | - |
|
| 53 | - String name = getVariableName(context, jsonObject);
|
|
| 54 | - Class<?> type = getVariableType(context, jsonObject);
|
|
| 55 | - String request = getVariableRequest(context, jsonObject);
|
|
| 56 | - String comment = getVariableComment(context, jsonObject);
|
|
| 57 | - |
|
| 58 | - ReportVariableDefinition<?> definition = new ReportVariableDefinition<>(name, type, request, comment);
|
|
| 59 | - ReportVariable<?> result = new ReportVariable<>(definition);
|
|
| 49 | + protected Type definitionType() {
|
|
| 50 | + return new TypeToken<ReportVariableDefinition<V>>() {
|
|
| 51 | + }.getType();
|
|
| 52 | + }
|
|
| 60 | 53 | |
| 61 | - loadVariableValues(context, jsonObject, result);
|
|
| 62 | - loadSelectedValue(context, jsonObject, result);
|
|
| 54 | + @Override
|
|
| 55 | + protected ReportVariable<V> deserialize(JsonDeserializationContext context, JsonObject jsonObject, ReportVariableDefinition<V> definition) {
|
|
| 56 | + ReportVariable<V> result = new ReportVariable<>(definition);
|
|
| 57 | + deserializeValues(context, jsonObject, result);
|
|
| 58 | + deserializeSelectedValue(context, jsonObject, result);
|
|
| 63 | 59 | return result;
|
| 64 | 60 | }
|
| 65 | 61 | |
| 66 | - protected <V> void loadSelectedValue(JsonDeserializationContext context, JsonObject jsonObject, ReportVariable<V> variable) {
|
|
| 62 | + protected void deserializeSelectedValue(JsonDeserializationContext context, JsonObject jsonObject, ReportVariable<V> variable) {
|
|
| 67 | 63 | JsonElement json = jsonObject.get(ReportVariable.PROPERTY_SELECTED_VALUE);
|
| 68 | - if (json != null) {
|
|
| 69 | - V selectedValue = context.deserialize(json, variable.getType());
|
|
| 70 | - variable.setSelectedValue(selectedValue);
|
|
| 71 | - }
|
|
| 64 | + V selectedValue = deserializeValue(context, variable.getType(), json);
|
|
| 65 | + variable.setSelectedValue(selectedValue);
|
|
| 72 | 66 | }
|
| 73 | 67 | } |
| ... | ... | @@ -22,13 +22,17 @@ package fr.ird.observe.report.json; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import com.google.gson.JsonArray;
|
|
| 25 | 26 | import com.google.gson.JsonDeserializationContext;
|
| 27 | +import com.google.gson.JsonDeserializer;
|
|
| 26 | 28 | import com.google.gson.JsonElement;
|
| 27 | 29 | import com.google.gson.JsonObject;
|
| 30 | +import com.google.gson.JsonParseException;
|
|
| 28 | 31 | import fr.ird.observe.report.ReportVariableSupport;
|
| 29 | -import fr.ird.observe.report.definition.ReportVariableSupportDefinition;
|
|
| 32 | +import fr.ird.observe.report.definition.ReportVariableDefinitionSupport;
|
|
| 30 | 33 | import io.ultreia.java4all.util.json.JsonAdapter;
|
| 31 | 34 | |
| 35 | +import java.lang.reflect.Type;
|
|
| 32 | 36 | import java.util.HashSet;
|
| 33 | 37 | import java.util.Set;
|
| 34 | 38 | |
| ... | ... | @@ -40,34 +44,38 @@ import java.util.Set; |
| 40 | 44 | * @author Tony Chemit - dev@tchemit.fr
|
| 41 | 45 | * @since 9.0.22
|
| 42 | 46 | */
|
| 43 | -public abstract class ReportVariableSupportAdapter implements JsonAdapter {
|
|
| 47 | +public abstract class ReportVariableSupportAdapter<V, D extends ReportVariableDefinitionSupport<V>, R extends ReportVariableSupport<V, D>> implements JsonAdapter, JsonDeserializer<R> {
|
|
| 44 | 48 | |
| 45 | - protected String getVariableName(JsonDeserializationContext context, JsonObject jsonObject) {
|
|
| 46 | - return context.deserialize(jsonObject.get(ReportVariableSupportDefinition.PROPERTY_NAME), String.class);
|
|
| 47 | - }
|
|
| 49 | + protected abstract Type definitionType();
|
|
| 48 | 50 | |
| 49 | - protected Class<?> getVariableType(JsonDeserializationContext context, JsonObject jsonObject) {
|
|
| 50 | - return context.deserialize(jsonObject.get(ReportVariableSupportDefinition.PROPERTY_TYPE), Class.class);
|
|
| 51 | - }
|
|
| 51 | + protected abstract R deserialize(JsonDeserializationContext context, JsonObject jsonObject, D definition);
|
|
| 52 | 52 | |
| 53 | - protected String getVariableRequest(JsonDeserializationContext context, JsonObject jsonObject) {
|
|
| 54 | - return context.deserialize(jsonObject.get(ReportVariableSupportDefinition.PROPERTY_REQUEST), String.class);
|
|
| 53 | + @Override
|
|
| 54 | + public final R deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
|
| 55 | + JsonObject jsonObject = json.getAsJsonObject();
|
|
| 56 | + D definition = deserializeDefinition(context, jsonObject);
|
|
| 57 | + return deserialize(context, jsonObject, definition);
|
|
| 55 | 58 | }
|
| 56 | 59 | |
| 57 | - protected String getVariableComment(JsonDeserializationContext context, JsonObject jsonObject) {
|
|
| 58 | - return context.deserialize(jsonObject.get(ReportVariableSupportDefinition.PROPERTY_COMMENT), String.class);
|
|
| 60 | + protected D deserializeDefinition(JsonDeserializationContext context, JsonObject jsonObject) {
|
|
| 61 | + return context.deserialize(jsonObject.get(ReportVariableSupport.PROPERTY_DEFINITION), definitionType());
|
|
| 59 | 62 | }
|
| 60 | 63 | |
| 61 | - protected <V> void loadVariableValues(JsonDeserializationContext context, JsonObject jsonObject, ReportVariableSupport<V> variable) {
|
|
| 64 | + protected void deserializeValues(JsonDeserializationContext context, JsonObject jsonObject, R variable) {
|
|
| 62 | 65 | JsonElement valuesJson = jsonObject.get(ReportVariableSupport.PROPERTY_VALUES);
|
| 63 | 66 | if (valuesJson != null) {
|
| 64 | - Set<V> values = new HashSet<>();
|
|
| 65 | 67 | Class<V> type = variable.getType();
|
| 66 | - for (JsonElement valueJson : valuesJson.getAsJsonArray()) {
|
|
| 67 | - V value = context.deserialize(valueJson, type);
|
|
| 68 | + JsonArray jsonArray = valuesJson.getAsJsonArray();
|
|
| 69 | + Set<V> values = new HashSet<>(jsonArray.size());
|
|
| 70 | + for (JsonElement valueJson : jsonArray) {
|
|
| 71 | + V value = deserializeValue(context, type, valueJson);
|
|
| 68 | 72 | values.add(value);
|
| 69 | 73 | }
|
| 70 | 74 | variable.setValues(values);
|
| 71 | 75 | }
|
| 72 | 76 | }
|
| 77 | + |
|
| 78 | + protected V deserializeValue(JsonDeserializationContext context, Class<V> variableType, JsonElement valueJson) {
|
|
| 79 | + return valueJson == null ? null : context.deserialize(valueJson, variableType);
|
|
| 80 | + }
|
|
| 73 | 81 | } |