#![allow(clippy::all, dead_code, unused)]
use cimdecoder::CimDataset;
use crate::Violation;
use crate::helpers::*;
pub fn validate_p61970_456_topology_ap_con_complex_shacl(dataset: &CimDataset) -> Vec<Violation> {
let mut v = Vec::new();
v.extend(check_p61970_456_topology_ap_con_complex_shacl_topological_node_identified_object_name_required(dataset));
v.extend(check_p61970_456_topology_ap_con_complex_shacl_dc_topological_node_identified_object_name_required(dataset));
v
}
pub fn check_p61970_456_topology_ap_con_complex_shacl_topological_node_identified_object_name_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("TopologicalNode").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::TopologicalNode>() {
Some(o) => o, None => continue,
};
if obj.base.name.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "tp456:IdentifiedObject.name-cardinality".to_string(),
class: "TopologicalNode".to_string(),
property: "IdentifiedObject.name".to_string(),
message: "Missing required property (attribute). ".to_string(),
severity: "sh:Violation".to_string(),
name: "C:456:TP:IdentifiedObject.name:instance".to_string(),
description: "Name is required for all classes in the profile except ACDCTerminal.".to_string(),
});
}
}
violations
}
pub fn check_p61970_456_topology_ap_con_complex_shacl_dc_topological_node_identified_object_name_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DCTopologicalNode").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DCTopologicalNode>() {
Some(o) => o, None => continue,
};
if obj.base.name.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "tp456:IdentifiedObject.name-cardinality".to_string(),
class: "DCTopologicalNode".to_string(),
property: "IdentifiedObject.name".to_string(),
message: "Missing required property (attribute). ".to_string(),
severity: "sh:Violation".to_string(),
name: "C:456:TP:IdentifiedObject.name:instance".to_string(),
description: "Name is required for all classes in the profile except ACDCTerminal.".to_string(),
});
}
}
violations
}