1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use serde::{Deserialize, Serialize};

use std::fs;
use std::path::Path;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Report {
    pub(crate) statistics: ReportStatistics,
    pub(crate) xml_elements: Vec<ReportElement>,
    pub(crate) gml_id_duplicates: Vec<(String, usize)>,
    pub(crate) broken_object_relations: Vec<String>,
    pub(crate) broken_predecessor_hrefs: Vec<String>,
    pub(crate) broken_successor_hrefs: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportStatistics {
    pub(crate) number_of_gml_duplicates: usize,
    pub(crate) number_of_broken_object_relations: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportElement {
    pub(crate) element_name: String,
    pub(crate) number_total: usize,
    pub(crate) number_with_gml_id: usize,
    pub(crate) number_without_gml_id: usize,
}

impl Report {
    pub fn write(&self, path: impl AsRef<Path>) {
        let yaml = serde_yaml::to_string(&self).unwrap();
        fs::write(path, yaml).expect("Unable to write file");
    }
}