mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-07-03 09:12:54 +00:00
Issue #15: Check OSC files for known issues
This commit is contained in:
@ -28,6 +28,7 @@ use std::collections::HashSet;
|
||||
use console::style;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::checks::{CheckNotice, Checkable};
|
||||
use crate::model::onkostar_editor::OnkostarEditor;
|
||||
use crate::model::requirements::{Requirement, Requires};
|
||||
use crate::model::{
|
||||
@ -380,6 +381,12 @@ impl FolderContent for DataForm {
|
||||
}
|
||||
}
|
||||
|
||||
impl Checkable for DataForm {
|
||||
fn check(&self) -> Vec<CheckNotice> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DataCatalogues {
|
||||
|
@ -24,12 +24,12 @@
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::fmt::Debug;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use crate::model::requirements::Requires;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::model::requirements::Requires;
|
||||
use crate::profile::{FormField, FormReference, Profile};
|
||||
|
||||
pub mod data_catalogue;
|
||||
@ -329,25 +329,3 @@ pub trait FolderContent {
|
||||
"ONKOSTAR Bibliothek" == self.get_library_folder()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum CheckNotice {
|
||||
/// This will result in Error if importing file
|
||||
Error { code: String, description: String },
|
||||
/// Other known issues
|
||||
Warning { description: String },
|
||||
}
|
||||
|
||||
impl Display for CheckNotice {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
CheckNotice::Error { code, description } => {
|
||||
write!(f, "[ERROR] ({}) {}", code, description)
|
||||
}
|
||||
CheckNotice::Warning { description } => write!(f, "[WARNING] {}", description),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Checkable {
|
||||
fn check(&self) -> Vec<CheckNotice>;
|
||||
}
|
||||
|
@ -30,14 +30,13 @@ use console::style;
|
||||
use quick_xml::de::from_str;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::checks::{CheckNotice, Checkable};
|
||||
use crate::model::data_catalogue::DataCatalogue;
|
||||
use crate::model::data_form::DataForm;
|
||||
use crate::model::property_catalogue::PropertyCatalogue;
|
||||
use crate::model::requirements::Requires;
|
||||
use crate::model::unterformular::Unterformular;
|
||||
use crate::model::{
|
||||
CheckNotice, Checkable, Comparable, FolderContent, FormEntryContainer, Listable, Sortable,
|
||||
};
|
||||
use crate::model::{Comparable, FolderContent, FormEntryContainer, Listable, Sortable};
|
||||
use crate::profile::Profile;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
@ -413,7 +412,23 @@ impl FromStr for OnkostarEditor {
|
||||
|
||||
impl Checkable for OnkostarEditor {
|
||||
fn check(&self) -> Vec<CheckNotice> {
|
||||
vec![]
|
||||
let mut result = self
|
||||
.editor
|
||||
.data_form
|
||||
.iter()
|
||||
.flat_map(|entity| entity.check())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let other = &mut self
|
||||
.editor
|
||||
.unterformular
|
||||
.iter()
|
||||
.flat_map(|entity| entity.check())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
result.append(other);
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::checks::{CheckNotice, Checkable};
|
||||
use console::style;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -377,6 +378,12 @@ impl FolderContent for Unterformular {
|
||||
}
|
||||
}
|
||||
|
||||
impl Checkable for Unterformular {
|
||||
fn check(&self) -> Vec<CheckNotice> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DataCatalogues {
|
||||
|
Reference in New Issue
Block a user