mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 19:56:50 +00:00
commit
5c91e4d10f
@ -58,6 +58,13 @@ Hierzu ist die Option `--compact` vorgesehen. Es können, je nach Datei, bis zu
|
|||||||
Bei der Auflistung der Inhalte, kann die Option `--sorted` dazu verwendet werden, die angezeigten Einträge alphabetisch zu sortieren.
|
Bei der Auflistung der Inhalte, kann die Option `--sorted` dazu verwendet werden, die angezeigten Einträge alphabetisch zu sortieren.
|
||||||
Die Sortierung erfolgt dabei nach Namen des Katalogs oder des Formulars.
|
Die Sortierung erfolgt dabei nach Namen des Katalogs oder des Formulars.
|
||||||
|
|
||||||
|
##### Experimentell: Sortierung nach Modifikation
|
||||||
|
|
||||||
|
Beim Modifizieren der Inhalte kann die experimentelle Option `--x-sorted` dazu verwendet werden, die Einträge im Anschluss an die Modifikation
|
||||||
|
nach Namen zu sortieren.
|
||||||
|
Dies erlaubt eine konsistente Reihenfolge der Einträge, wodurch ein direkter Vergleich mit Vorversionen ermöglicht wird.
|
||||||
|
ACHTUNG: Es kann sein, dass dadurch ein Import der resultierenden OSC-Datei nicht mehr möglich ist, da das genaue Verhalten des Imports aktuell noch nicht bekannt ist.
|
||||||
|
|
||||||
## Profile
|
## Profile
|
||||||
|
|
||||||
Zum Erstellen von Varianten einer OSC-Datei wird eine Profildatei im YAML-Format verwendet.
|
Zum Erstellen von Varianten einer OSC-Datei wird eine Profildatei im YAML-Format verwendet.
|
||||||
|
@ -52,6 +52,11 @@ pub enum Command {
|
|||||||
outputfile: Option<String>,
|
outputfile: Option<String>,
|
||||||
#[arg(long = "compact", help = "Kompakte Ausgabe, ohne Einrücken (Optional)")]
|
#[arg(long = "compact", help = "Kompakte Ausgabe, ohne Einrücken (Optional)")]
|
||||||
compact: bool,
|
compact: bool,
|
||||||
|
#[arg(
|
||||||
|
long = "x-sorted",
|
||||||
|
help = "EXPERIMENTELL: Sortiere Kataloge und Formulare nach Name (Optional). Kann negative Auswirkungen auf den ordnungsgemäßen Import haben."
|
||||||
|
)]
|
||||||
|
sorted: bool,
|
||||||
},
|
},
|
||||||
#[command(about = "Vergleiche zwei Dateien anhand der Revision der enthaltenen Inhalte")]
|
#[command(about = "Vergleiche zwei Dateien anhand der Revision der enthaltenen Inhalte")]
|
||||||
Diff {
|
Diff {
|
||||||
|
@ -122,6 +122,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
profile,
|
profile,
|
||||||
outputfile,
|
outputfile,
|
||||||
compact,
|
compact,
|
||||||
|
sorted,
|
||||||
} => {
|
} => {
|
||||||
let data = &mut read_inputfile(inputfile)?;
|
let data = &mut read_inputfile(inputfile)?;
|
||||||
|
|
||||||
@ -132,6 +133,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
data.apply_profile(&profile);
|
data.apply_profile(&profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sorted {
|
||||||
|
data.sorted();
|
||||||
|
}
|
||||||
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
|
|
||||||
let mut serializer = Serializer::new(&mut buf);
|
let mut serializer = Serializer::new(&mut buf);
|
||||||
|
@ -70,6 +70,16 @@ impl Sortable for DataCatalogue {
|
|||||||
fn sorting_key(&self) -> String {
|
fn sorting_key(&self) -> String {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self {
|
||||||
|
self.entries
|
||||||
|
.entry
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
self.entries.entry.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comparable for DataCatalogue {
|
impl Comparable for DataCatalogue {
|
||||||
@ -151,6 +161,23 @@ pub struct Entry {
|
|||||||
revision: u16,
|
revision: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for Entry {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
if let Some(ref mut use_) = self.use_ {
|
||||||
|
use_.program_module
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key())
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Use {
|
pub struct Use {
|
||||||
@ -166,3 +193,9 @@ pub struct ProgramModule {
|
|||||||
#[serde(rename = "@name")]
|
#[serde(rename = "@name")]
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for ProgramModule {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
format!("{}-{}", self.program, self.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -192,6 +192,29 @@ impl Sortable for DataForm {
|
|||||||
fn sorting_key(&self) -> String {
|
fn sorting_key(&self) -> String {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self {
|
||||||
|
self.data_catalogues.data_catalogue.sort_unstable();
|
||||||
|
|
||||||
|
self.entries
|
||||||
|
.entry
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
|
||||||
|
self.entries.entry.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Some(ref mut plausibility_rule) = self.plausibility_rules.plausibility_rule {
|
||||||
|
plausibility_rule.sort_unstable_by_key(|item| item.bezeichnung.clone());
|
||||||
|
|
||||||
|
plausibility_rule.iter_mut().for_each(|item| {
|
||||||
|
if let Some(ref mut data_form_entry_names) = item.data_form_entries.entry_name {
|
||||||
|
data_form_entry_names.sort_unstable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comparable for DataForm {
|
impl Comparable for DataForm {
|
||||||
@ -433,6 +456,26 @@ impl FormEntry for Entry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for Entry {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
if let Some(ref mut filter) = self.filter {
|
||||||
|
if let Some(ref mut ref_entries) = filter.ref_entries {
|
||||||
|
if let Some(ref mut ref_entry) = ref_entries.ref_entry {
|
||||||
|
ref_entry.sort_unstable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct DataFormEntries {
|
pub struct DataFormEntries {
|
||||||
|
@ -239,6 +239,12 @@ pub trait Listable {
|
|||||||
|
|
||||||
pub trait Sortable {
|
pub trait Sortable {
|
||||||
fn sorting_key(&self) -> String;
|
fn sorting_key(&self) -> String;
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Comparable: Debug {
|
pub trait Comparable: Debug {
|
||||||
|
@ -79,17 +79,33 @@ impl OnkostarEditor {
|
|||||||
.property_catalogue
|
.property_catalogue
|
||||||
.sort_unstable_by_key(|e| e.sorting_key());
|
.sort_unstable_by_key(|e| e.sorting_key());
|
||||||
|
|
||||||
|
self.editor.property_catalogue.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
self.editor
|
self.editor
|
||||||
.data_catalogue
|
.data_catalogue
|
||||||
.sort_unstable_by_key(|e| e.sorting_key());
|
.sort_unstable_by_key(|e| e.sorting_key());
|
||||||
|
|
||||||
|
self.editor.data_catalogue.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
self.editor
|
self.editor
|
||||||
.data_form
|
.data_form
|
||||||
.sort_unstable_by_key(|e| e.sorting_key());
|
.sort_unstable_by_key(|e| e.sorting_key());
|
||||||
|
|
||||||
|
self.editor.data_form.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
self.editor
|
self.editor
|
||||||
.unterformular
|
.unterformular
|
||||||
.sort_unstable_by_key(|e| e.sorting_key());
|
.sort_unstable_by_key(|e| e.sorting_key());
|
||||||
|
|
||||||
|
self.editor.unterformular.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_diff(&mut self, other: &mut Self, strict: bool) {
|
pub fn print_diff(&mut self, other: &mut Self, strict: bool) {
|
||||||
@ -182,7 +198,7 @@ impl OnkostarEditor {
|
|||||||
_ => {
|
_ => {
|
||||||
if strict && entry_a.get_hash() != entry_b.get_hash() {
|
if strict && entry_a.get_hash() != entry_b.get_hash() {
|
||||||
println!(
|
println!(
|
||||||
"{}: {} (z.B. Reihenfolge von Unterelementen)",
|
"{}: {} (z.B. GUID oder Reihenfolge von Unterelementen)",
|
||||||
entry_a.get_name(),
|
entry_a.get_name(),
|
||||||
style("Inhaltlich verschieden").yellow()
|
style("Inhaltlich verschieden").yellow()
|
||||||
);
|
);
|
||||||
|
@ -67,6 +67,16 @@ impl Sortable for PropertyCatalogue {
|
|||||||
fn sorting_key(&self) -> String {
|
fn sorting_key(&self) -> String {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self {
|
||||||
|
if let Some(ref mut versions) = self.versions.entry {
|
||||||
|
versions.sort_unstable_by_key(|item| item.version_number);
|
||||||
|
versions.iter_mut().for_each(|version| {
|
||||||
|
version.sorted();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comparable for PropertyCatalogue {
|
impl Comparable for PropertyCatalogue {
|
||||||
@ -115,6 +125,40 @@ pub struct Version {
|
|||||||
categories: Categories,
|
categories: Categories,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for Version {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.oid.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
if let Some(ref mut abbildung) = self.abbildung {
|
||||||
|
abbildung.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
abbildung.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.entries
|
||||||
|
.content
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
self.entries.content.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
|
self.categories
|
||||||
|
.content
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
self.categories.content.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct VersionEntries {
|
pub struct VersionEntries {
|
||||||
@ -141,6 +185,12 @@ pub struct VersionEntry {
|
|||||||
position: String,
|
position: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for VersionEntry {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.code.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Categories {
|
pub struct Categories {
|
||||||
@ -165,6 +215,26 @@ pub struct Category {
|
|||||||
category_entries: CategoryEntries,
|
category_entries: CategoryEntries,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for Category {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self.category_entries
|
||||||
|
.content
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
self.category_entries.content.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CategoryEntries {
|
pub struct CategoryEntries {
|
||||||
@ -191,6 +261,12 @@ pub struct CategoryEntry {
|
|||||||
note: Option<String>,
|
note: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for CategoryEntry {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.code.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Abbildung {
|
pub struct Abbildung {
|
||||||
@ -200,6 +276,24 @@ pub struct Abbildung {
|
|||||||
content: Vec<AbbildungEintrag>,
|
content: Vec<AbbildungEintrag>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for Abbildung {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.ziel_mk_version_oid.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self.content.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
self.content.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct AbbildungEintrag {
|
pub struct AbbildungEintrag {
|
||||||
@ -209,6 +303,12 @@ pub struct AbbildungEintrag {
|
|||||||
entry_to: AbbildungEntry,
|
entry_to: AbbildungEntry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for AbbildungEintrag {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
format!("{}-{}", self.entry_from.code, self.entry_to.code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct AbbildungEntry {
|
pub struct AbbildungEntry {
|
||||||
|
@ -211,6 +211,29 @@ impl Sortable for Unterformular {
|
|||||||
fn sorting_key(&self) -> String {
|
fn sorting_key(&self) -> String {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self {
|
||||||
|
self.data_catalogues.data_catalogue.sort_unstable();
|
||||||
|
|
||||||
|
self.entries
|
||||||
|
.entry
|
||||||
|
.sort_unstable_by_key(|item| item.sorting_key());
|
||||||
|
|
||||||
|
self.entries.entry.iter_mut().for_each(|item| {
|
||||||
|
item.sorted();
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Some(ref mut plausibility_rule) = self.plausibility_rules.plausibility_rule {
|
||||||
|
plausibility_rule.sort_unstable_by_key(|item| item.bezeichnung.clone());
|
||||||
|
|
||||||
|
plausibility_rule.iter_mut().for_each(|item| {
|
||||||
|
if let Some(ref mut data_form_entry_names) = item.data_form_entries.entry_name {
|
||||||
|
data_form_entry_names.sort_unstable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comparable for Unterformular {
|
impl Comparable for Unterformular {
|
||||||
@ -453,6 +476,26 @@ impl FormEntry for Entry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sortable for Entry {
|
||||||
|
fn sorting_key(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sorted(&mut self) -> &Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
if let Some(ref mut filter) = self.filter {
|
||||||
|
if let Some(ref mut ref_entries) = filter.ref_entries {
|
||||||
|
if let Some(ref mut ref_entry) = ref_entries.ref_entry {
|
||||||
|
ref_entry.sort_unstable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct DataFormEntries {
|
pub struct DataFormEntries {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user