cimoxide-validation 0.3.1

SHACL validation of CGMES datasets against the ENTSO-E profile constraints
Documentation
// Generated by cimgen — do not edit by hand.
#![allow(clippy::all, dead_code, unused)]
use cimdecoder::CimDataset;
use crate::Violation;
use crate::helpers::*;

pub fn validate_p61970_453_diagramlayout_ap_con_complex_shacl(dataset: &CimDataset) -> Vec<Violation> {
    let mut v = Vec::new();
    v.extend(check_p61970_453_diagramlayout_ap_con_complex_shacl_diagram_style_identified_object_name_in(dataset));
    v
}

pub fn check_p61970_453_diagramlayout_ap_con_complex_shacl_diagram_style_identified_object_name_in(dataset: &CimDataset) -> Vec<Violation> {
    let mut violations = Vec::new();
    const ALLOWED: &[&str] = &["node-breaker", "bus-branch", "hybrid (node-breaker and bus-branch)", "geoschematic"];
    for mrid in dataset.by_type.get("DiagramStyle").into_iter().flatten() {
        let entry = &dataset.entries[mrid];
        let obj = match entry.element.as_any()
            .downcast_ref::<cimstructs::DiagramStyle>() {
            Some(o) => o, None => continue,
        };
        if obj.base.name.is_empty() { continue; }
        if !ALLOWED.contains(&obj.base.name.as_str()) {
            violations.push(Violation {
                object_id:   mrid.clone(),
                rule_id:     "dl453:DiagramStyle-allowedNameValues".to_string(),
                class:       "DiagramStyle".to_string(),
                property:    "IdentifiedObject.name".to_string(),
                message:     "Not allowed value.".to_string(),
                severity:    "sh:Violation".to_string(),
                name:        "C:453:DL:DiagramStyle:name".to_string(),
                description: "The inherited IdentifiedObject.name shall have one of the following names: node-breaker, bus-branch, hybrid (node-breaker and bus-branch) or geoschematic.".to_string(),
            });
        }
    }
    violations
}