use knowdit_kg_model::audit_finding::FindingSeverity;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(32))")]
pub enum ReflectionResult {
#[sea_orm(string_value = "OutOfScope")]
OutOfScope,
#[sea_orm(string_value = "IncompleteSpecification")]
IncompleteSpecification,
#[sea_orm(string_value = "IncompleteStep")]
IncompleteStep,
#[sea_orm(string_value = "ExpectedViolation")]
ExpectedViolation,
#[sea_orm(string_value = "ValidFinding")]
ValidFinding,
}
impl ReflectionResult {
pub fn as_str(&self) -> &'static str {
match self {
Self::OutOfScope => "OutOfScope",
Self::IncompleteSpecification => "IncompleteSpecification",
Self::IncompleteStep => "IncompleteStep",
Self::ExpectedViolation => "ExpectedViolation",
Self::ValidFinding => "ValidFinding",
}
}
}
impl fmt::Display for ReflectionResult {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
#[sea_orm(table_name = "reflection")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(indexed)]
pub code_id: i32,
#[sea_orm(indexed)]
pub spec_id: i32,
#[sea_orm(indexed)]
pub result: ReflectionResult,
#[sea_orm(column_type = "Text")]
pub reason: String,
#[sea_orm(nullable)]
pub severity: Option<FindingSeverity>,
#[sea_orm(belongs_to, from = "code_id", to = "id")]
pub code_gen: HasOne<super::code_gen::Entity>,
#[sea_orm(belongs_to, from = "spec_id", to = "id")]
pub specification: HasOne<super::specification::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}