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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
use crate::{
Properties,
product::ProductId,
report::{
requirement::RequirementReference, requirements::RequirementsSummary,
review::ReviewReference, reviews::ReviewsSummary, test_run::TestRunReference,
tests::TestsSummary,
},
};
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct ProductReportSchema {
/// The schema version.
/// [req("exchange.versioned")]
#[serde(serialize_with = "crate::serialize_schema_version")]
pub schema_version: Option<String>,
#[serde(with = "time::serde::iso8601")]
#[schemars(with = "String")]
pub last_collected_date: time::OffsetDateTime,
pub summary: ProductSummary,
pub root_requirements: Vec<RequirementReference>,
pub root_test_runs: Vec<TestRunReference>,
pub reviews: Vec<ReviewReference>,
/// The product ID.
///
/// TODO: map to requirement
pub id: ProductId,
/// The name of the product.
///
/// TODO: map to requirement
pub name: String,
/// Optional baseline of the product.
/// e.g. git branch or commit hash
///
/// TODO: map to requirement
pub base: Option<String>,
/// Optional version of the product.
///
/// TODO: map to requirement
pub version: Option<String>,
/// Optional link to the homepage of the product.
///
/// TODO: map to requirement
pub homepage: Option<String>,
/// Optional link to the repository of the product.
///
/// TODO: map to requirement
pub repository: Option<String>,
/// Optional license of the product.
///
/// TODO: map to requirement
pub license: Option<String>,
/// Optional description of the product.
///
/// TODO: map to requirement
pub description: Option<String>,
/// Optional properties of the product.
///
/// TODO: map to requirement
pub properties: Option<Properties>,
}
impl ProductReportSchema {
pub fn metadata(&self) -> ProductMetadata {
ProductMetadata {
id: self.id.clone(),
name: self.name.clone(),
base: self.base.clone(),
version: self.version.clone(),
homepage: self.homepage.clone(),
repository: self.repository.clone(),
license: self.license.clone(),
}
}
}
#[derive(
Debug,
Clone,
Copy,
Default,
PartialEq,
serde::Serialize,
serde::Deserialize,
schemars::JsonSchema,
)]
#[serde(rename_all = "snake_case")]
pub struct ProductSummary {
pub requirements: RequirementsSummary,
pub test_cases: TestsSummary,
pub reviews: ReviewsSummary,
}
impl ProductSummary {
pub fn add(&mut self, other: &Self) {
self.requirements.add(&other.requirements);
self.test_cases.add(&other.test_cases);
self.reviews.add(&other.reviews);
}
}
#[derive(
Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema,
)]
#[serde(rename_all = "snake_case")]
pub struct ProductMetadata {
/// The product ID.
///
/// TODO: map to requirement
pub id: ProductId,
/// The name of the product.
///
/// TODO: map to requirement
pub name: String,
/// Optional baseline of the product.
/// e.g. git branch or commit hash
///
/// TODO: map to requirement
pub base: Option<String>,
/// Optional version of the product.
///
/// TODO: map to requirement
pub version: Option<String>,
/// Optional link to the homepage of the product.
///
/// TODO: map to requirement
pub homepage: Option<String>,
/// Optional link to the repository of the product.
///
/// TODO: map to requirement
pub repository: Option<String>,
/// Optional license of the product.
///
/// TODO: map to requirement
pub license: Option<String>,
}