actes_legislatifs.rs 87.4 KB
Newer Older
1
use acteurs::Acteur;
2
use agendas::Reunion;
3
use chrono::{Date, DateTime, FixedOffset};
4
use commun::{Codier, EmptyChoice, InfoJo, Rapporteur};
5
use contexts::Context;
6
7
use mandats::Mandat;
use organes::Organe;
8
use points_odj::PointOdj;
9
use scrutins::Scrutin;
10
use serde_utils::{map_to_vec, str_to_vec};
11
use std::cmp;
12
use textes_legislatifs::Document;
13
14
15
16

#[derive(Clone, Debug, Deserialize)]
#[serde(tag = "@xsi:type")]
pub enum ActeLegislatif {
17
18
    #[serde(rename = "Adoption_Europe_Type")]
    AdoptionEurope(AdoptionEurope),
19
20
21
22
23
24
    #[serde(rename = "ConclusionEtapeCC_Type")]
    ConclusionEtapeCc(ConclusionEtapeCc),
    #[serde(rename = "CreationOrganeTemporaire_Type")]
    CreationOrganeTemporaire(CreationOrganeTemporaire),
    #[serde(rename = "Decision_Type")]
    Decision(Decision),
25
26
27
28
29
30
    #[serde(rename = "DecisionMotionCensure_Type")]
    DecisionMotionCensure(DecisionMotionCensure),
    #[serde(rename = "DecisionRecevabiliteBureau_Type")]
    DecisionRecevabiliteBureau(DecisionRecevabiliteBureau),
    #[serde(rename = "DeclarationGouvernement_Type")]
    DeclarationGouvernement(DeclarationGouvernement),
31
32
33
34
35
36
37
38
    #[serde(rename = "DepotAccordInternational_Type")]
    DepotAccordInternational(DepotAccordInternational),
    #[serde(rename = "DepotAvisConseilEtat_Type")]
    DepotAvisConseilEtat(DepotAvisConseilEtat),
    #[serde(rename = "DepotInitiative_Type")]
    DepotInitiative(DepotInitiative),
    #[serde(rename = "DepotInitiativeNavette_Type")]
    DepotInitiativeNavette(DepotInitiativeNavette),
39
40
41
42
43
44
    #[serde(rename = "DepotLettreRectificative_Type")]
    DepotLettreRectificative(DepotLettreRectificative),
    #[serde(rename = "DepotMotionCensure_Type")]
    DepotMotionCensure(DepotMotionCensure),
    #[serde(rename = "DepotMotionReferendaire_Type")]
    DepotMotionReferendaire(DepotMotionReferendaire),
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    #[serde(rename = "DepotRapport_Type")]
    DepotRapport(DepotRapport),
    #[serde(rename = "DiscussionCommission_Type")]
    DiscussionCommission(DiscussionCommission),
    #[serde(rename = "DiscussionSeancePublique_Type")]
    DiscussionSeancePublique(DiscussionSeancePublique),
    #[serde(rename = "Etape_Type")]
    Etape(Etape),
    #[serde(rename = "EtudeImpact_Type")]
    EtudeImpact(EtudeImpact),
    #[serde(rename = "MotionProcedure_Type")]
    MotionProcedure(MotionProcedure),
    #[serde(rename = "NominRapporteurs_Type")]
    NominRapporteurs(NominRapporteurs),
    #[serde(rename = "ProcedureAccelere_Type")]
60
    ProcedureAcceleree(ProcedureAcceleree),
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
    #[serde(rename = "Promulgation_Type")]
    Promulgation(Promulgation),
    #[serde(rename = "RenvoiCMP_Type")]
    RenvoiCmp(RenvoiCmp),
    #[serde(rename = "RenvoiPrealable_Type")]
    RenvoiPrealable(RenvoiPrealable),
    #[serde(rename = "RetraitInitiative_Type")]
    RetraitInitiative(RetraitInitiative),
    #[serde(rename = "SaisieComAvis_Type")]
    SaisieComAvis(SaisieComAvis),
    #[serde(rename = "SaisieComFond_Type")]
    SaisieComFond(SaisieComFond),
    #[serde(rename = "SaisineConseilConstit_Type")]
    SaisineConseilConstit(SaisineConseilConstit),
}

Emmanuel Raviart's avatar
Emmanuel Raviart committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
impl ActeLegislatif {
    pub fn actes_legislatifs(&self) -> Option<&[ActeLegislatif]> {
        match *self {
            ActeLegislatif::Etape(Etape {
                ref actes_legislatifs,
                ..
            }) => match &actes_legislatifs {
                None => None,
                Some(actes_legislatifs) => Some(&actes_legislatifs.actes),
            },
            _ => None,
        }
    }

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    //     pub fn code_acte(&self) -> &str {
    //         match *self {
    //             ActeLegislatif::AdoptionEurope(AdoptionEurope { ref code_acte, .. })
    //             | ActeLegislatif::ConclusionEtapeCc(ConclusionEtapeCc { ref code_acte, .. })
    //             | ActeLegislatif::CreationOrganeTemporaire(CreationOrganeTemporaire {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::Decision(Decision { ref code_acte, .. })
    //             | ActeLegislatif::DecisionMotionCensure(DecisionMotionCensure {
    //                 ref code_acte, ..
    //             })
    //             | ActeLegislatif::DecisionRecevabiliteBureau(DecisionRecevabiliteBureau {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DeclarationGouvernement(DeclarationGouvernement {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotAccordInternational(DepotAccordInternational {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotAvisConseilEtat(DepotAvisConseilEtat {
    //                 ref code_acte, ..
    //             })
    //             | ActeLegislatif::DepotInitiative(DepotInitiative { ref code_acte, .. })
    //             | ActeLegislatif::DepotInitiativeNavette(DepotInitiativeNavette {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotLettreRectificative(DepotLettreRectificative {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotMotionCensure(DepotMotionCensure { ref code_acte, .. })
    //             | ActeLegislatif::DepotMotionReferendaire(DepotMotionReferendaire {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotRapport(DepotRapport { ref code_acte, .. })
    //             | ActeLegislatif::DiscussionCommission(DiscussionCommission {
    //                 ref code_acte, ..
    //             })
    //             | ActeLegislatif::DiscussionSeancePublique(DiscussionSeancePublique {
    //                 ref code_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::Etape(Etape { ref code_acte, .. })
    //             | ActeLegislatif::EtudeImpact(EtudeImpact { ref code_acte, .. })
    //             | ActeLegislatif::MotionProcedure(MotionProcedure { ref code_acte, .. })
    //             | ActeLegislatif::NominRapporteurs(NominRapporteurs { ref code_acte, .. })
144
    //             | ActeLegislatif::ProcedureAcceleree(ProcedureAcceleree { ref code_acte, .. })
145
146
147
148
149
150
151
152
153
154
155
    //             | ActeLegislatif::Promulgation(Promulgation { ref code_acte, .. })
    //             | ActeLegislatif::RenvoiCmp(RenvoiCmp { ref code_acte, .. })
    //             | ActeLegislatif::RenvoiPrealable(RenvoiPrealable { ref code_acte, .. })
    //             | ActeLegislatif::RetraitInitiative(RetraitInitiative { ref code_acte, .. })
    //             | ActeLegislatif::SaisieComAvis(SaisieComAvis { ref code_acte, .. })
    //             | ActeLegislatif::SaisieComFond(SaisieComFond { ref code_acte, .. })
    //             | ActeLegislatif::SaisineConseilConstit(SaisineConseilConstit {
    //                 ref code_acte, ..
    //             }) => &code_acte,
    //         }
    //     }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
156

157
    pub fn date_acte(&self) -> Option<&DateTime<FixedOffset>> {
Emmanuel Raviart's avatar
Emmanuel Raviart committed
158
        match *self {
159
160
            ActeLegislatif::AdoptionEurope(AdoptionEurope { ref date_acte, .. })
            | ActeLegislatif::ConclusionEtapeCc(ConclusionEtapeCc { ref date_acte, .. })
Emmanuel Raviart's avatar
Emmanuel Raviart committed
161
162
163
164
            | ActeLegislatif::CreationOrganeTemporaire(CreationOrganeTemporaire {
                ref date_acte,
                ..
            })
165
            | ActeLegislatif::Decision(Decision { ref date_acte, .. })
Emmanuel Raviart's avatar
Emmanuel Raviart committed
166
            | ActeLegislatif::DecisionMotionCensure(DecisionMotionCensure {
167
                ref date_acte, ..
Emmanuel Raviart's avatar
Emmanuel Raviart committed
168
169
170
171
172
173
174
175
176
177
178
179
180
181
            })
            | ActeLegislatif::DecisionRecevabiliteBureau(DecisionRecevabiliteBureau {
                ref date_acte,
                ..
            })
            | ActeLegislatif::DeclarationGouvernement(DeclarationGouvernement {
                ref date_acte,
                ..
            })
            | ActeLegislatif::DepotAccordInternational(DepotAccordInternational {
                ref date_acte,
                ..
            })
            | ActeLegislatif::DepotAvisConseilEtat(DepotAvisConseilEtat {
182
                ref date_acte, ..
Emmanuel Raviart's avatar
Emmanuel Raviart committed
183
            })
184
            | ActeLegislatif::DepotInitiative(DepotInitiative { ref date_acte, .. })
Emmanuel Raviart's avatar
Emmanuel Raviart committed
185
186
187
188
189
190
191
192
            | ActeLegislatif::DepotInitiativeNavette(DepotInitiativeNavette {
                ref date_acte,
                ..
            })
            | ActeLegislatif::DepotLettreRectificative(DepotLettreRectificative {
                ref date_acte,
                ..
            })
193
            | ActeLegislatif::DepotMotionCensure(DepotMotionCensure { ref date_acte, .. })
Emmanuel Raviart's avatar
Emmanuel Raviart committed
194
195
196
197
            | ActeLegislatif::DepotMotionReferendaire(DepotMotionReferendaire {
                ref date_acte,
                ..
            })
198
            | ActeLegislatif::DepotRapport(DepotRapport { ref date_acte, .. })
Emmanuel Raviart's avatar
Emmanuel Raviart committed
199
            | ActeLegislatif::DiscussionCommission(DiscussionCommission {
200
                ref date_acte, ..
Emmanuel Raviart's avatar
Emmanuel Raviart committed
201
202
203
204
205
            })
            | ActeLegislatif::DiscussionSeancePublique(DiscussionSeancePublique {
                ref date_acte,
                ..
            })
206
207
            | ActeLegislatif::EtudeImpact(EtudeImpact { ref date_acte, .. })
            | ActeLegislatif::MotionProcedure(MotionProcedure { ref date_acte, .. })
208
            | ActeLegislatif::NominRapporteurs(NominRapporteurs { ref date_acte, .. })
209
            | ActeLegislatif::ProcedureAcceleree(ProcedureAcceleree { ref date_acte, .. })
210
211
212
213
214
215
            | ActeLegislatif::Promulgation(Promulgation { ref date_acte, .. })
            | ActeLegislatif::RenvoiCmp(RenvoiCmp { ref date_acte, .. })
            | ActeLegislatif::RenvoiPrealable(RenvoiPrealable { ref date_acte, .. })
            | ActeLegislatif::RetraitInitiative(RetraitInitiative { ref date_acte, .. })
            | ActeLegislatif::SaisieComAvis(SaisieComAvis { ref date_acte, .. })
            | ActeLegislatif::SaisieComFond(SaisieComFond { ref date_acte, .. })
Emmanuel Raviart's avatar
Emmanuel Raviart committed
216
            | ActeLegislatif::SaisineConseilConstit(SaisineConseilConstit {
217
                ref date_acte, ..
218
            }) => match &date_acte {
219
220
221
                None => None,
                Some(ref date_acte) => Some(&date_acte),
            },
222
            ActeLegislatif::Etape(_) => None,
Emmanuel Raviart's avatar
Emmanuel Raviart committed
223
224
225
        }
    }

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
    pub fn distance_min_date_actes_legislatifs_futurs(
        &self,
        date: Date<FixedOffset>,
    ) -> Option<i64> {
        let mut min: Option<i64> = match self.date_acte() {
            None => None,
            Some(date_time) => {
                let days = -date.signed_duration_since(date_time.date()).num_days();
                if days >= 0 {
                    Some(days)
                } else {
                    None
                }
            }
        };
        if let Some(actes_legislatifs) = self.actes_legislatifs() {
            for acte_legislatif in actes_legislatifs {
                let min_acte = acte_legislatif.distance_min_date_actes_legislatifs_futurs(date);
                min = match (min, min_acte) {
                    (Some(min), Some(min_acte)) => Some(cmp::min(min, min_acte)),
                    (None, Some(min_acte)) => Some(min_acte),
                    _ => min,
                }
            }
        }
        min
    }

    pub fn distance_min_date_actes_legislatifs_passes(
        &self,
        date: Date<FixedOffset>,
    ) -> Option<i64> {
        let mut min: Option<i64> = match self.date_acte() {
            None => None,
            Some(date_time) => {
                let days = date.signed_duration_since(date_time.date()).num_days();
                if days >= 0 {
                    Some(days)
                } else {
                    None
                }
            }
        };
        if let Some(actes_legislatifs) = self.actes_legislatifs() {
            for acte_legislatif in actes_legislatifs {
                let min_acte = acte_legislatif.distance_min_date_actes_legislatifs_passes(date);
                min = match (min, min_acte) {
                    (Some(min), Some(min_acte)) => Some(cmp::min(min, min_acte)),
                    (None, Some(min_acte)) => Some(min_acte),
                    _ => min,
                }
            }
        }
        min
    }

282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
    //     pub fn libelle_acte(&self) -> &LibelleActe {
    //         match *self {
    //             ActeLegislatif::AdoptionEurope(AdoptionEurope {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::ConclusionEtapeCc(ConclusionEtapeCc {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::CreationOrganeTemporaire(CreationOrganeTemporaire {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::Decision(Decision {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::DecisionMotionCensure(DecisionMotionCensure {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DecisionRecevabiliteBureau(DecisionRecevabiliteBureau {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DeclarationGouvernement(DeclarationGouvernement {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotAccordInternational(DepotAccordInternational {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotAvisConseilEtat(DepotAvisConseilEtat {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::DepotInitiative(DepotInitiative {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::DepotInitiativeNavette(DepotInitiativeNavette {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotLettreRectificative(DepotLettreRectificative {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotMotionCensure(DepotMotionCensure {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::DepotMotionReferendaire(DepotMotionReferendaire {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotRapport(DepotRapport {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::DiscussionCommission(DiscussionCommission {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::DiscussionSeancePublique(DiscussionSeancePublique {
    //                 ref libelle_acte,
    //                 ..
    //             })
    //             | ActeLegislatif::Etape(Etape {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::EtudeImpact(EtudeImpact {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::MotionProcedure(MotionProcedure {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::NominRapporteurs(NominRapporteurs {
    //                 ref libelle_acte, ..
    //             })
356
    //             | ActeLegislatif::ProcedureAcceleree(ProcedureAcceleree {
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::Promulgation(Promulgation {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::RenvoiCmp(RenvoiCmp {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::RenvoiPrealable(RenvoiPrealable {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::RetraitInitiative(RetraitInitiative {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::SaisieComAvis(SaisieComAvis {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::SaisieComFond(SaisieComFond {
    //                 ref libelle_acte, ..
    //             })
    //             | ActeLegislatif::SaisineConseilConstit(SaisineConseilConstit {
    //                 ref libelle_acte,
    //                 ..
    //             }) => &libelle_acte,
    //         }
    //     }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
383

384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
    //     pub fn organe_ref(&self) -> Option<&str> {
    //         match *self {
    //             ActeLegislatif::AdoptionEurope(_) => None,
    //             ActeLegislatif::ConclusionEtapeCc(ConclusionEtapeCc { ref organe_ref, .. })
    //             | ActeLegislatif::CreationOrganeTemporaire(CreationOrganeTemporaire {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::Decision(Decision { ref organe_ref, .. })
    //             | ActeLegislatif::DecisionMotionCensure(DecisionMotionCensure {
    //                 ref organe_ref, ..
    //             })
    //             | ActeLegislatif::DecisionRecevabiliteBureau(DecisionRecevabiliteBureau {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::DeclarationGouvernement(DeclarationGouvernement {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotAccordInternational(DepotAccordInternational {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotAvisConseilEtat(DepotAvisConseilEtat {
    //                 ref organe_ref, ..
    //             })
    //             | ActeLegislatif::DepotInitiative(DepotInitiative { ref organe_ref, .. })
    //             | ActeLegislatif::DepotInitiativeNavette(DepotInitiativeNavette {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotLettreRectificative(DepotLettreRectificative {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotMotionCensure(DepotMotionCensure { ref organe_ref, .. })
    //             | ActeLegislatif::DepotMotionReferendaire(DepotMotionReferendaire {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::DepotRapport(DepotRapport { ref organe_ref, .. })
    //             | ActeLegislatif::DiscussionCommission(DiscussionCommission {
    //                 ref organe_ref, ..
    //             })
    //             | ActeLegislatif::DiscussionSeancePublique(DiscussionSeancePublique {
    //                 ref organe_ref,
    //                 ..
    //             })
    //             | ActeLegislatif::EtudeImpact(EtudeImpact { ref organe_ref, .. })
    //             | ActeLegislatif::MotionProcedure(MotionProcedure { ref organe_ref, .. })
    //             | ActeLegislatif::NominRapporteurs(NominRapporteurs { ref organe_ref, .. })
436
    //             | ActeLegislatif::ProcedureAcceleree(ProcedureAcceleree { ref organe_ref, .. })
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
    //             | ActeLegislatif::Promulgation(Promulgation { ref organe_ref, .. })
    //             | ActeLegislatif::RenvoiCmp(RenvoiCmp { ref organe_ref, .. })
    //             | ActeLegislatif::RenvoiPrealable(RenvoiPrealable { ref organe_ref, .. })
    //             | ActeLegislatif::RetraitInitiative(RetraitInitiative { ref organe_ref, .. })
    //             | ActeLegislatif::SaisieComAvis(SaisieComAvis { ref organe_ref, .. })
    //             | ActeLegislatif::SaisieComFond(SaisieComFond { ref organe_ref, .. })
    //             | ActeLegislatif::SaisineConseilConstit(SaisineConseilConstit {
    //                 ref organe_ref, ..
    //             }) => Some(&organe_ref),
    //             ActeLegislatif::Etape(Etape { ref organe_ref, .. }) => match &organe_ref {
    //                 None => None,
    //                 Some(ref organe_ref) => Some(&organe_ref),
    //             },
    //         }
    //     }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
452

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
    pub fn uid(&self) -> &str {
        match *self {
            ActeLegislatif::AdoptionEurope(AdoptionEurope { ref uid, .. })
            | ActeLegislatif::ConclusionEtapeCc(ConclusionEtapeCc { ref uid, .. })
            | ActeLegislatif::CreationOrganeTemporaire(CreationOrganeTemporaire {
                ref uid, ..
            })
            | ActeLegislatif::Decision(Decision { ref uid, .. })
            | ActeLegislatif::DecisionMotionCensure(DecisionMotionCensure { ref uid, .. })
            | ActeLegislatif::DecisionRecevabiliteBureau(DecisionRecevabiliteBureau {
                ref uid,
                ..
            })
            | ActeLegislatif::DeclarationGouvernement(DeclarationGouvernement {
                ref uid, ..
            })
            | ActeLegislatif::DepotAccordInternational(DepotAccordInternational {
                ref uid, ..
            })
            | ActeLegislatif::DepotAvisConseilEtat(DepotAvisConseilEtat { ref uid, .. })
            | ActeLegislatif::DepotInitiative(DepotInitiative { ref uid, .. })
            | ActeLegislatif::DepotInitiativeNavette(DepotInitiativeNavette { ref uid, .. })
            | ActeLegislatif::DepotLettreRectificative(DepotLettreRectificative {
                ref uid, ..
            })
            | ActeLegislatif::DepotMotionCensure(DepotMotionCensure { ref uid, .. })
            | ActeLegislatif::DepotMotionReferendaire(DepotMotionReferendaire {
                ref uid, ..
            })
            | ActeLegislatif::DepotRapport(DepotRapport { ref uid, .. })
            | ActeLegislatif::DiscussionCommission(DiscussionCommission { ref uid, .. })
            | ActeLegislatif::DiscussionSeancePublique(DiscussionSeancePublique {
                ref uid, ..
            })
            | ActeLegislatif::Etape(Etape { ref uid, .. })
            | ActeLegislatif::EtudeImpact(EtudeImpact { ref uid, .. })
            | ActeLegislatif::MotionProcedure(MotionProcedure { ref uid, .. })
            | ActeLegislatif::NominRapporteurs(NominRapporteurs { ref uid, .. })
            | ActeLegislatif::ProcedureAcceleree(ProcedureAcceleree { ref uid, .. })
            | ActeLegislatif::Promulgation(Promulgation { ref uid, .. })
            | ActeLegislatif::RenvoiCmp(RenvoiCmp { ref uid, .. })
            | ActeLegislatif::RenvoiPrealable(RenvoiPrealable { ref uid, .. })
            | ActeLegislatif::RetraitInitiative(RetraitInitiative { ref uid, .. })
            | ActeLegislatif::SaisieComAvis(SaisieComAvis { ref uid, .. })
            | ActeLegislatif::SaisieComFond(SaisieComFond { ref uid, .. })
            | ActeLegislatif::SaisineConseilConstit(SaisineConseilConstit { ref uid, .. }) => &uid,
        }
    }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
501
502
}

503
504
// Using graphql_union because instance_resolvers of graphql_interface does not work with Juniper 0.9.2.
// graphql_interface!(ActeLegislatif: () |&self| {
505
graphql_union!(ActeLegislatif: Context |&self| {
506
507
508
    // field actes_legislatifs() -> Option<&[ActeLegislatif]> {
    //     self.actes_legislatifs()
    // }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
509

510
511
512
    // field code_acte() -> &str {
    //     self.code_acte()
    // }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
513

514
515
516
    // field date_acte() -> Option<&DateTime<FixedOffset>> {
    //     self.date_acte()
    // }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
517

518
519
520
    // field libelle_acte() -> &LibelleActe {
    //     self.libelle_acte()
    // }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
521

522
523
524
525
526
    // field organe(&executor) -> Option<&Organe> {
    //     let context = &executor.context();
    //     context.get_organe_at_uid(&self.organe_ref())
    // }

527
528
529
    // field organe_ref() -> Option<&str> {
    //     self.organe_ref()
    // }
Emmanuel Raviart's avatar
Emmanuel Raviart committed
530

531
532
533
    // field uid() -> &str {
    //     self.uid()
    // }
534
535

    instance_resolvers: |_| {
536
537
538
539
        &AdoptionEurope => match *self {
            ActeLegislatif::AdoptionEurope(ref acte) => Some(acte),
            _ => None,
        },
540
541
542
543
544
545
546
547
548
549
550
551
        &ConclusionEtapeCc => match *self {
            ActeLegislatif::ConclusionEtapeCc(ref acte) => Some(acte),
            _ => None,
        },
        &CreationOrganeTemporaire => match *self {
            ActeLegislatif::CreationOrganeTemporaire(ref acte) => Some(acte),
            _ => None,
        },
        &Decision => match *self {
            ActeLegislatif::Decision(ref acte) => Some(acte),
            _ => None,
        },
552
553
554
555
556
557
558
559
560
561
562
563
        &DecisionMotionCensure => match *self {
            ActeLegislatif::DecisionMotionCensure(ref acte) => Some(acte),
            _ => None,
        },
        &DecisionRecevabiliteBureau => match *self {
            ActeLegislatif::DecisionRecevabiliteBureau(ref acte) => Some(acte),
            _ => None,
        },
        &DeclarationGouvernement => match *self {
            ActeLegislatif::DeclarationGouvernement(ref acte) => Some(acte),
            _ => None,
        },
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
        &DepotAccordInternational => match *self {
            ActeLegislatif::DepotAccordInternational(ref acte) => Some(acte),
            _ => None,
        },
        &DepotAvisConseilEtat => match *self {
            ActeLegislatif::DepotAvisConseilEtat(ref acte) => Some(acte),
            _ => None,
        },
        &DepotInitiative => match *self {
            ActeLegislatif::DepotInitiative(ref acte) => Some(acte),
            _ => None,
        },
        &DepotInitiativeNavette => match *self {
            ActeLegislatif::DepotInitiativeNavette(ref acte) => Some(acte),
            _ => None,
        },
580
581
582
583
584
585
586
587
588
589
590
591
        &DepotLettreRectificative => match *self {
            ActeLegislatif::DepotLettreRectificative(ref acte) => Some(acte),
            _ => None,
        },
        &DepotMotionCensure => match *self {
            ActeLegislatif::DepotMotionCensure(ref acte) => Some(acte),
            _ => None,
        },
        &DepotMotionReferendaire => match *self {
            ActeLegislatif::DepotMotionReferendaire(ref acte) => Some(acte),
            _ => None,
        },
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
        &DepotRapport => match *self {
            ActeLegislatif::DepotRapport(ref acte) => Some(acte),
            _ => None,
        },
        &DiscussionCommission => match *self {
            ActeLegislatif::DiscussionCommission(ref acte) => Some(acte),
            _ => None,
        },
        &DiscussionSeancePublique => match *self {
            ActeLegislatif::DiscussionSeancePublique(ref acte) => Some(acte),
            _ => None,
        },
        &Etape => match *self {
            ActeLegislatif::Etape(ref acte) => Some(acte),
            _ => None,
        },
        &EtudeImpact => match *self {
            ActeLegislatif::EtudeImpact(ref acte) => Some(acte),
            _ => None,
        },
        &MotionProcedure => match *self {
            ActeLegislatif::MotionProcedure(ref acte) => Some(acte),
            _ => None,
        },
        &NominRapporteurs => match *self {
            ActeLegislatif::NominRapporteurs(ref acte) => Some(acte),
            _ => None,
        },
620
621
        &ProcedureAcceleree => match *self {
            ActeLegislatif::ProcedureAcceleree(ref acte) => Some(acte),
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
            _ => None,
        },
        &Promulgation => match *self {
            ActeLegislatif::Promulgation(ref acte) => Some(acte),
            _ => None,
        },
        &RenvoiCmp => match *self {
            ActeLegislatif::RenvoiCmp(ref acte) => Some(acte),
            _ => None,
        },
        &RenvoiPrealable => match *self {
            ActeLegislatif::RenvoiPrealable(ref acte) => Some(acte),
            _ => None,
        },
        &RetraitInitiative => match *self {
            ActeLegislatif::RetraitInitiative(ref acte) => Some(acte),
            _ => None,
        },
        &SaisieComAvis => match *self {
            ActeLegislatif::SaisieComAvis(ref acte) => Some(acte),
            _ => None,
        },
        &SaisieComFond => match *self {
            ActeLegislatif::SaisieComFond(ref acte) => Some(acte),
            _ => None,
        },
        &SaisineConseilConstit => match *self {
            ActeLegislatif::SaisineConseilConstit(ref acte) => Some(acte),
            _ => None,
        },
    }
});

655
#[derive(Clone, Debug, Deserialize)]
656
657
658
659
#[serde(deny_unknown_fields)]
pub struct ActesLegislatifs {
    #[serde(deserialize_with = "map_to_vec", rename = "acteLegislatif")]
    pub actes: Vec<ActeLegislatif>,
660
661
662
    // Field actes_indexes is not present in Assemblée's JSON. It is added later.
    #[serde(default)]
    pub actes_indexes: Vec<i32>,
663
664
}

665
graphql_object!(ActesLegislatifs: Context |&self| {
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
    field actes() -> Vec<&ActeLegislatif> {
        // Generate a flat array of "actes" instead of a tree, because a tree is not adapted to GraphQL.
        let mut actes: Vec<&ActeLegislatif> = Vec::new();
        for acte in &self.actes {
            actes.push(acte);
            if let ActeLegislatif::Etape(etape) = acte {
                actes.extend(etape.flatten_actes_legislatifs());
            }
        }
        actes
    }

    field actes_indexes() -> &Vec<i32> {
        &self.actes_indexes
    }
});

683
#[derive(Clone, Debug, Deserialize)]
684
#[serde(deny_unknown_fields)]
685
pub struct ActeurInitiateur {
686
687
688
689
690
691
    #[serde(rename = "acteurRef")]
    pub acteur_ref: String,
    #[serde(rename = "mandatRef")]
    pub mandat_ref: String,
}

692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
graphql_object!(ActeurInitiateur: Context |&self| {
    field acteur(&executor) -> Option<&Acteur> {
        let context = &executor.context();
        context.get_acteur_at_uid(&self.acteur_ref)
    }

    field acteur_ref() -> &str {
        &self.acteur_ref
    }

    field mandat(&executor) -> Option<&Mandat> {
        let context = &executor.context();
        match context.get_acteur_at_uid(&self.acteur_ref) {
            None => None,
            Some(ref acteur) => {
                for mandat in &acteur.mandats.mandats {
                    if mandat.uid() == &self.mandat_ref {
                        return Some(mandat)
                    }
                }
                None
            },
        }
    }

    field mandat_ref() -> &str {
        return &self.mandat_ref
    }
});

#[derive(Clone, Debug, Deserialize)]
723
#[serde(deny_unknown_fields)]
724
pub struct ActeursInitiateur {
725
    #[serde(deserialize_with = "map_to_vec", rename = "acteur")]
726
    pub acteurs: Vec<ActeurInitiateur>,
727
728
}

729
#[derive(Clone, Debug, Deserialize)]
730
731
732
733
734
735
736
#[serde(deny_unknown_fields)]
pub struct AdoptionEurope {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
737
    pub date_acte: Option<DateTime<FixedOffset>>,
738
739
740
741
742
743
744
745
746
747
748
    #[serde(rename = "infoJOCE")]
    pub info_joce: InfoJoce,
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "statutAdoption")]
    pub statut_adoption: Codier,
    #[serde(rename = "texteEuropeen")]
    pub texte_europeen: TexteEuropeen,
    pub uid: String,
}

749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
graphql_object!(AdoptionEurope: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field info_joce() -> &InfoJoce {
        &self.info_joce
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

    field statut_adoption() -> &Codier {
        &self.statut_adoption
    }

    field texte_europeen() -> &TexteEuropeen {
        &self.texte_europeen
    }

    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
780
781
782
783
784
785
786
787
788
#[serde(deny_unknown_fields)]
pub struct ConclusionEtapeCc {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "anneeDecision")]
    pub annee_decision: String,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
789
    pub date_acte: Option<DateTime<FixedOffset>>,
790
791
792
793
794
795
796
797
798
799
800
801
802
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "numDecision")]
    pub num_decision: String,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "statutConclusion")]
    pub statut_conclusion: Codier,
    pub uid: String,
    #[serde(rename = "urlConclusion")]
    pub url_conclusion: String,
}

803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
graphql_object!(ConclusionEtapeCc: Context |&self| {
    field annee_decision() -> &str {
        &self.annee_decision
    }

    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

    field num_decision() -> &str {
        &self.num_decision
    }

824
825
826
827
828
829
830
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
    }

    field statut_conclusion() -> &Codier {
        &self.statut_conclusion
    }

    field uid() -> &str {
        &self.uid
    }

    field url_conclusion() -> &str {
        &self.url_conclusion
    }
});

846
847
848
849
#[derive(Clone, Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
pub struct ContributionInternaute {
    #[serde(rename = "dateFermeture")]
850
    // TODO: Date<FixedOffset> type is not able to deserialize dates with timezone (`YYYY-MM-DD±HH:MM`).
851
852
    pub date_fermeture: Option<String>,
    #[serde(rename = "dateOuverture")]
853
    // TODO: Date<FixedOffset> type is not able to deserialize dates with timezone (`YYYY-MM-DD±HH:MM`).
854
    pub date_ouverture: Option<String>,
855
856
}

857
#[derive(Clone, Debug, Deserialize)]
858
859
860
861
862
863
864
#[serde(deny_unknown_fields)]
pub struct CreationOrganeTemporaire {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
865
    pub date_acte: Option<DateTime<FixedOffset>>,
866
    pub initiateurs: Option<InitiateursCreationOrganeTemporaire>,
867
868
869
870
871
872
873
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    pub uid: String,
}

874
875
876
877
878
879
880
881
882
graphql_object!(CreationOrganeTemporaire: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
    field initiateurs(&executor) -> Option<&Organe> {
        match &self.initiateurs {
            None => None,
            Some(ref initiateurs) => {
                let context = &executor.context();
                context.get_organe_at_uid(&initiateurs.organe_ref)
            },
        }
    }

    field initiateurs_ref() -> Option<&str> {
        match &self.initiateurs {
            None => None,
            Some(ref initiateurs) => Some(initiateurs.organe_ref.as_str()),
        }
898
899
900
901
902
903
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

904
905
906
907
908
909
910
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
911
912
913
914
915
916
917
918
    }

    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
919
920
921
922
923
924
925
#[serde(deny_unknown_fields)]
pub struct Decision {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
926
    pub date_acte: Option<DateTime<FixedOffset>>,
927
928
929
930
931
932
933
934
935
936
937
938
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "reunionRef")]
    pub reunion_ref: Option<String>,
    #[serde(rename = "statutConclusion")]
    pub statut_conclusion: Codier,
    #[serde(rename = "textesAssocies")]
    pub textes_associes: Option<TextesAssocies>,
    pub uid: String,
    #[serde(rename = "voteRefs")]
939
    pub vote_refs: Option<VoteRefs>,
940
941
}

942
943
944
945
946
947
948
949
950
951
952
953
954
graphql_object!(Decision: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
    }

    field reunion(&executor) -> Option<&Reunion> {
        match &self.reunion_ref {
            None => None,
            Some(ref reunion_ref) => {
                let context = &executor.context();
                context.get_reunion_at_uid(&reunion_ref)
            },
        }
972
973
974
975
976
977
978
979
980
981
982
983
984
    }

    field reunion_ref() -> Option<&str> {
        match &self.reunion_ref {
            None => None,
            Some(ref s) => Some(s.as_str()),
        }
    }

    field statut_conclusion() -> &Codier {
        &self.statut_conclusion
    }

985
986
987
988
989
990
991
992
993
    field textes_associes() -> Vec<&TexteAssocie> {
        match &self.textes_associes {
            None => vec![],
            Some(ref textes_associes) => {
                textes_associes.textes_associes
                    .iter()
                    .collect()
            },
        }
994
995
996
997
998
999
    }

    field uid() -> &str {
        &self.uid
    }

1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
    field vote_refs() -> Vec<&str> {
        match &self.vote_refs {
            None => vec![],
            Some(ref vote_refs) => {
                vote_refs.vote_refs
                    .iter()
                    .map(|ref vote_ref| vote_ref.as_str())
                    .collect()
            },
        }
    }

    field votes(&executor) -> Vec<&Scrutin> {
        match &self.vote_refs {
            None => vec![],
            Some(ref vote_refs) => {
                let context = &executor.context();
                vote_refs.vote_refs
                    .iter()
                    .filter_map(|ref vote_ref| context.get_scrutin_at_uid(&vote_ref))
                    .collect()
            },
        }
1023
1024
1025
1026
    }
});

#[derive(Clone, Debug, Deserialize)]
1027
1028
1029
1030
1031
1032
1033
#[serde(deny_unknown_fields)]
pub struct DecisionMotionCensure {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1034
    pub date_acte: Option<DateTime<FixedOffset>>,
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
    pub decision: Codier,
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "odSeancejRef")]
    pub odj_seance_ref: Option<EmptyChoice>,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    pub uid: String,
    #[serde(rename = "voteRefs")]
    pub vote_refs: Option<VoteRefs>,
}

1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
graphql_object!(DecisionMotionCensure: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field decision() -> &Codier {
        &self.decision
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1064
1065
1066
1067
1068
1069
1070
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1071
1072
1073
1074
1075
1076
    }

    field uid() -> &str {
        &self.uid
    }

1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
    field vote_refs() -> Vec<&str> {
        match &self.vote_refs {
            None => vec![],
            Some(ref vote_refs) => {
                vote_refs.vote_refs
                    .iter()
                    .map(|ref vote_ref| vote_ref.as_str())
                    .collect()
            },
        }
    }

    field votes(&executor) -> Vec<&Scrutin> {
        match &self.vote_refs {
            None => vec![],
            Some(ref vote_refs) => {
                let context = &executor.context();
                vote_refs.vote_refs
                    .iter()
                    .filter_map(|ref vote_ref| context.get_scrutin_at_uid(&vote_ref))
                    .collect()
            },
        }
1100
1101
1102
1103
    }
});

#[derive(Clone, Debug, Deserialize)]
1104
1105
1106
1107
1108
1109
1110
#[serde(deny_unknown_fields)]
pub struct DecisionRecevabiliteBureau {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1111
    pub date_acte: Option<DateTime<FixedOffset>>,
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
    pub decision: Codier,
    #[serde(rename = "formuleDecision")]
    pub formule_decision: String,
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    pub uid: String,
}

1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
graphql_object!(DecisionRecevabiliteBureau: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field decision() -> &Codier {
        &self.decision
    }

    field formule_decision() -> &str {
        &self.formule_decision
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1143
1144
1145
1146
1147
1148
1149
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1150
1151
1152
1153
1154
1155
1156
1157
    }

    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1158
1159
1160
1161
1162
1163
1164
#[serde(deny_unknown_fields)]
pub struct DeclarationGouvernement {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1165
    pub date_acte: Option<DateTime<FixedOffset>>,
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    #[serde(rename = "typeDeclaration")]
    pub type_declaration: Codier,
    pub uid: String,
}

1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
graphql_object!(DeclarationGouvernement: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1190
1191
1192
1193
1194
1195
1196
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1197
1198
    }

1199
    field texte_associe(&executor) -> Vec<&Document> {
1200
        let context = &executor.context();
1201
1202
1203
1204
1205
1206
1207
1208
        match context.get_document_at_uid(&self.texte_associe) {
            None => vec![],
            Some(ref document) => {
                // Generate a flat vector from document and its sub-documents (aka divisions),
                // because a tree is not adapted to GraphQL.
                document.flatten_document()
            },
        }
1209
1210
    }

1211
1212
1213
1214
    field texte_associe_ref() -> &str {
        &self.texte_associe
    }

1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
    field type_declaration() -> &Codier {
        &self.type_declaration
    }

    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1225
1226
1227
1228
1229
1230
1231
#[serde(deny_unknown_fields)]
pub struct DepotAccordInternational {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1232
    pub date_acte: Option<DateTime<FixedOffset>>,
1233
1234
1235
1236
1237
1238
1239
1240
1241
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    pub uid: String,
}

1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
graphql_object!(DepotAccordInternational: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1267
1268
    }

1269
    field texte_associe(&executor) -> Vec<&Document> {
1270
        let context = &executor.context();
1271
1272
1273
1274
1275
1276
1277
1278
        match context.get_document_at_uid(&self.texte_associe) {
            None => vec![],
            Some(ref document) => {
                // Generate a flat vector from document and its sub-documents (aka divisions),
                // because a tree is not adapted to GraphQL.
                document.flatten_document()
            },
        }
1279
1280
    }

1281
1282
1283
1284
    field texte_associe_ref() -> &str {
        &self.texte_associe
    }

1285
1286
1287
1288
1289
1290
    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1291
1292
1293
1294
1295
1296
1297
#[serde(deny_unknown_fields)]
pub struct DepotAvisConseilEtat {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1298
    pub date_acte: Option<DateTime<FixedOffset>>,
1299
1300
1301
1302
1303
1304
1305
1306
1307
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    pub uid: String,
}

1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
graphql_object!(DepotAvisConseilEtat: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1321
1322
1323
1324
1325
1326
1327
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1328
1329
    }

1330
    field texte_associe(&executor) -> Vec<&Document> {
1331
        let context = &executor.context();
1332
1333
1334
1335
1336
1337
1338
1339
        match context.get_document_at_uid(&self.texte_associe) {
            None => vec![],
            Some(ref document) => {
                // Generate a flat vector from document and its sub-documents (aka divisions),
                // because a tree is not adapted to GraphQL.
                document.flatten_document()
            },
        }
1340
1341
    }

1342
1343
1344
1345
    field texte_associe_ref() -> &str {
        &self.texte_associe
    }

1346
1347
1348
1349
1350
1351
    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1352
1353
1354
1355
1356
1357
1358
#[serde(deny_unknown_fields)]
pub struct DepotInitiative {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1359
    pub date_acte: Option<DateTime<FixedOffset>>,
1360
1361
1362
1363
1364
1365
1366
1367
1368
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    pub uid: String,
}

1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
graphql_object!(DepotInitiative: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1382
1383
1384
1385
1386
1387
1388
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1389
1390
    }

1391
    field texte_associe(&executor) -> Vec<&Document> {
1392
        let context = &executor.context();
1393
1394
1395
1396
1397
1398
1399
1400
        match context.get_document_at_uid(&self.texte_associe) {
            None => vec![],
            Some(ref document) => {
                // Generate a flat vector from document and its sub-documents (aka divisions),
                // because a tree is not adapted to GraphQL.
                document.flatten_document()
            },
        }
1401
1402
    }

1403
1404
1405
1406
    field texte_associe_ref() -> &str {
        &self.texte_associe
    }

1407
1408
1409
1410
1411
1412
    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1413
1414
1415
1416
1417
1418
1419
#[serde(deny_unknown_fields)]
pub struct DepotInitiativeNavette {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1420
    pub date_acte: Option<DateTime<FixedOffset>>,
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    pub provenance: String,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    pub uid: String,
}

1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
graphql_object!(DepotInitiativeNavette: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1444
1445
1446
1447
1448
1449
1450
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1451
1452
    }

1453
1454
1455
1456
1457
1458
    field provenance(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.provenance)
    }

    field provenance_ref() -> &str {
1459
1460
1461
        &self.provenance
    }

1462
    field texte_associe(&executor) -> Vec<&Document> {
1463
        let context = &executor.context();
1464
1465
1466
1467
1468
1469
1470
1471
        match context.get_document_at_uid(&self.texte_associe) {
            None => vec![],
            Some(ref document) => {
                // Generate a flat vector from document and its sub-documents (aka divisions),
                // because a tree is not adapted to GraphQL.
                document.flatten_document()
            },
        }
1472
1473
    }

1474
1475
1476
1477
    field texte_associe_ref() -> &str {
        &self.texte_associe
    }

1478
1479
1480
1481
1482
    field uid() -> &str {
        &self.uid
    }
});

1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
/// Extrait Fiche de synthèse n°33
/// http://www.assemblee-nationale.fr/connaissance/fiches_synthese/septembre2012/fiche_33.asp
/// Le projet est accompagné d’un décret de présentation au Parlement qui indique les
/// organes qui ont délibéré, détermine l’assemblée devant laquelle le texte est déposé
/// en premier lieu et désigne les membres du Gouvernement qui soutiendront le texte
/// devant les assemblées. Ce décret est signé par le Premier ministre et contresigné
/// par les ministres ainsi désignés. À ce stade, le Gouvernement ne peut plus modifier
/// le projet de loi que par une lettre rectificative. Cette procédure usuelle, que
/// ne prévoit aucun texte, prend la forme d’une lettre du Premier ministre rectifiant
/// directement le contenu d’un projet de loi préalablement déposé. Comme ce dernier, la
/// lettre rectificative est soumise au Conseil d’État. Elle conduit à remanier le texte
/// devant servir de base à la discussion parlementaire.
1495
#[derive(Clone, Debug, Deserialize)]
1496
1497
1498
1499
1500
1501
1502
#[serde(deny_unknown_fields)]
pub struct DepotLettreRectificative {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1503
    pub date_acte: Option<DateTime<FixedOffset>>,
1504
1505
1506
1507
1508
1509
1510
1511
1512
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    pub uid: String,
}

1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
graphql_object!(DepotLettreRectificative: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1526
1527
1528
1529
1530
1531
1532
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1533
1534
    }

1535
    field texte_associe(&executor) -> Vec<&Document> {
1536
        let context = &executor.context();
1537
1538
1539
1540
1541
1542
1543
1544
        match context.get_document_at_uid(&self.texte_associe) {
            None => vec![],
            Some(ref document) => {
                // Generate a flat vector from document and its sub-documents (aka divisions),
                // because a tree is not adapted to GraphQL.
                document.flatten_document()
            },
        }
1545
1546
    }

1547
1548
1549
1550
    field texte_associe_ref() -> &str {
        &self.texte_associe
    }

1551
1552
1553
1554
1555
1556
    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1557
1558
1559
1560
1561
1562
1563
1564
#[serde(deny_unknown_fields)]
pub struct DepotMotionCensure {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    pub auteurs: ListeActeursRef,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1565
    pub date_acte: Option<DateTime<FixedOffset>>,
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
    #[serde(rename = "dateRetrait")]
    pub date_retrait: Option<EmptyChoice>,
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "typeMotionCensure")]
    pub type_motion_censure: Codier,
    pub uid: String,
}

1577
graphql_object!(DepotMotionCensure: Context |&self| {
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
    field auteurs(&executor) -> Vec<&Acteur> {
        let context = &executor.context();
        self.auteurs.acteurs_refs
            .iter()
            .filter_map(|ref acteur_ref| context.get_acteur_at_uid(&acteur_ref))
            .collect()
    }

    field auteurs_refs() -> &Vec<String> {
        &self.auteurs.acteurs_refs
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
    }

    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1602
1603
1604
1605
1606
1607
1608
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
    }

    field type_motion_censure() -> &Codier {
        &self.type_motion_censure
    }

    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1621
1622
1623
1624
1625
1626
1627
1628
#[serde(deny_unknown_fields)]
pub struct DepotMotionReferendaire {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    pub auteurs: Option<ListeActeursRef>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1629
    pub date_acte: Option<DateTime<FixedOffset>>,
1630
1631
1632
1633
1634
1635
1636
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    pub uid: String,
}

1637
graphql_object!(DepotMotionReferendaire: Context |&self| {
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
    field auteurs(&executor) -> Vec<&Acteur> {
        match &self.auteurs {
            None => vec![],
            Some(ref auteurs) => {
                let context = &executor.context();
                auteurs.acteurs_refs
                    .iter()
                    .filter_map(|ref acteur_ref| context.get_acteur_at_uid(&acteur_ref))
                    .collect()
            },
        }
    }

    field auteurs_refs() -> Vec<&str> {
        match &self.auteurs {
            None => vec![],
            Some(ref auteurs) =>
                auteurs.acteurs_refs
                    .iter()
                    .map(|ref acteur_ref| acteur_ref.as_str())
                    .collect(),
        }
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
    }

    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1674
1675
1676
1677
1678
1679
1680
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1681
1682
1683
1684
1685
1686
1687
1688
    }

    field uid() -> &str {
        &self.uid
    }
});

#[derive(Clone, Debug, Deserialize)]
1689
1690
1691
1692
1693
1694
1695
#[serde(deny_unknown_fields)]
pub struct DepotRapport {
    #[serde(rename = "actesLegislatifs")]
    pub actes_legislatifs: Option<EmptyChoice>,
    #[serde(rename = "codeActe")]
    pub code_acte: String,
    #[serde(rename = "dateActe")]
1696
    pub date_acte: Option<DateTime<FixedOffset>>,
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
    #[serde(rename = "libelleActe")]
    pub libelle_acte: LibelleActe,
    #[serde(rename = "organeRef")]
    pub organe_ref: String,
    #[serde(rename = "texteAdopte")]
    pub texte_adopte: Option<String>,
    #[serde(rename = "texteAssocie")]
    pub texte_associe: String,
    pub uid: String,
}

1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
graphql_object!(DepotRapport: Context |&self| {
    field code_acte() -> &str {
        &self.code_acte
    }

    field date_acte() -> Option<DateTime<FixedOffset>> {
        self.date_acte
    }

    field libelle_acte() -> &LibelleActe {
        &self.libelle_acte
    }

1721
1722
1723
1724
1725
1726
1727
    field organe(&executor) -> Option<&Organe> {
        let context = &executor.context();
        context.get_organe_at_uid(&self.organe_ref)
    }

    field organe_ref() -> Option<&str> {
        Some(self.organe_ref.as_str())
1728
1729
    }

1730
    field texte_adopte(&executor) -> Vec<&Document> {
1731
        match &self.texte_adopte {
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
            None => vec![],
            Some(ref texte_adopte_ref) => {
                let context = &executor.context();
                match context.get_document_at_uid(&texte_adopte_ref) {
                    None => vec![],
                    Some(ref document) => {
                        // Generate a flat vector from document and its sub-documents (aka divisions),
                        // because a tree is not adapted to GraphQL.
                        document.flatten_document()
                    },
                }
            },
1744
1745
1746
        }
    }

1747
1748
1749
1750
1751
    field texte_adopte_ref() -> Option<&str> {
        match &self.texte_adopte {
            None => None,
            Some(ref s) => Some(s.as_str()),
        }
1752
1753
    }

1754
    field texte_associe(&executor) -> Vec<&Document> {
1755
        let context = &executor.context();
1756
1757
1758
1759
1760
1761
1762
1763
        match context.get_document_at_uid(&self.texte_associe