#![allow(clippy::all, dead_code, unused)]
use cimdecoder::CimDataset;
use crate::Violation;
use crate::helpers::*;
pub fn validate_p61970_301_equipmentboundary_ap_con_complex_shacl(dataset: &CimDataset) -> Vec<Violation> {
let mut v = Vec::new();
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_base_voltage_base_voltage_nominal_voltage_etc(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_name_etc(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_na_etc(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_2(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_2(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_name_etc_2(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_na_etc_2(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_3(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_4(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_5(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_3(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_4(dataset));
v.extend(check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_5(dataset));
v
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_base_voltage_base_voltage_nominal_voltage_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BaseVoltage").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BaseVoltage>() {
Some(o) => o, None => continue,
};
if obj.nominal_voltage.is_none() { continue; }
if obj.nominal_voltage.unwrap() <= 0_f64 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BaseVoltage.nominalVoltage-valueRange".to_string(),
class: "BaseVoltage".to_string(),
property: "BaseVoltage.nominalVoltage".to_string(),
message: "The value is negative or zero.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BaseVoltage.nominalVoltage:valueRange".to_string(),
description: "Shall be a positive value and not zero.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_name_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_name.is_empty() { continue; }
if obj.to_end_name.chars().count() > 64 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndName-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndName".to_string(),
message: "String length is greater than 64 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndName:stringLength".to_string(),
description: "A human readable name with length of the string 64 characters maximum. ".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_na_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_name.is_empty() { continue; }
if obj.from_end_name.chars().count() > 64 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndName-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndName".to_string(),
message: "String length is greater than 64 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndName:stringLength".to_string(),
description: "A human readable name with length of the string 64 characters maximum. ".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_iso_code.is_empty() { continue; }
if obj.from_end_iso_code.chars().count() < 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndIsoCode-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndIsoCode".to_string(),
message: "String length is not 2 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndIsoCode:stringLength".to_string(),
description: "The length of the string is 2 characters maximum.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_iso_code.is_empty() { continue; }
if obj.from_end_iso_code.chars().count() > 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndIsoCode-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndIsoCode".to_string(),
message: "String length is not 2 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndIsoCode:stringLength".to_string(),
description: "The length of the string is 2 characters maximum.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_iso_code.is_empty() { continue; }
if obj.to_end_iso_code.chars().count() < 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndIsoCode-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndIsoCode".to_string(),
message: "String length is not 2 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndIsoCode:stringLength".to_string(),
description: "The length of the string is 2 characters maximum.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_iso_code.is_empty() { continue; }
if obj.to_end_iso_code.chars().count() > 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndIsoCode-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndIsoCode".to_string(),
message: "String length is not 2 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndIsoCode:stringLength".to_string(),
description: "The length of the string is 2 characters maximum.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_name_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_name_tso.is_empty() { continue; }
if obj.to_end_name_tso.chars().count() > 64 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndNameTso-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndNameTso".to_string(),
message: "String length is greater than 64 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndNameTso:stringLength".to_string(),
description: "The length of the string is 64 characters maximum.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_na_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_name_tso.is_empty() { continue; }
if obj.from_end_name_tso.chars().count() > 64 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndNameTso-stringLength".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndNameTso".to_string(),
message: "String length is greater than 64 characters.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndNameTso:stringLength".to_string(),
description: "The length of the string is 64 characters maximum.".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_3(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
const ALLOWED: &[&str] = &["AL", "AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU", "MT", "MD", "ME", "NL", "NO", "PL", "PT", "RO", "RS", "SK", "SI", "ES", "SE", "CH", "TR", "UA", "MK", "GB"];
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_iso_code.is_empty() { continue; }
if !ALLOWED.contains(&obj.from_end_iso_code.as_str()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndIsoCode-valueValidity".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndIsoCode".to_string(),
message: "Not valid two-character ISO code for Europe.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndIsoCode:valueValidity".to_string(),
description: "The ISO code is a two-character country code as defined by ISO 3166 (http://www.iso.org/iso/country_codes).".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_4(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_iso_code.is_empty() { continue; }
if obj.from_end_iso_code.chars().count() < 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndIsoCode-valueValidity".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndIsoCode".to_string(),
message: "Not valid two-character ISO code for Europe.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndIsoCode:valueValidity".to_string(),
description: "The ISO code is a two-character country code as defined by ISO 3166 (http://www.iso.org/iso/country_codes).".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_from_end_is_etc_5(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.from_end_iso_code.is_empty() { continue; }
if obj.from_end_iso_code.chars().count() > 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.fromEndIsoCode-valueValidity".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.fromEndIsoCode".to_string(),
message: "Not valid two-character ISO code for Europe.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.fromEndIsoCode:valueValidity".to_string(),
description: "The ISO code is a two-character country code as defined by ISO 3166 (http://www.iso.org/iso/country_codes).".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_3(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
const ALLOWED: &[&str] = &["AL", "AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU", "MT", "MD", "ME", "NL", "NO", "PL", "PT", "RO", "RS", "SK", "SI", "ES", "SE", "CH", "TR", "UA", "MK", "GB"];
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_iso_code.is_empty() { continue; }
if !ALLOWED.contains(&obj.to_end_iso_code.as_str()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndIsoCode-valueValidity".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndIsoCode".to_string(),
message: "Not valid two-character ISO code for Europe.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndIsoCode:valueValidity".to_string(),
description: "The ISO code is a two-character country code as defined by ISO 3166 (http://www.iso.org/iso/country_codes).".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_4(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_iso_code.is_empty() { continue; }
if obj.to_end_iso_code.chars().count() < 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndIsoCode-valueValidity".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndIsoCode".to_string(),
message: "Not valid two-character ISO code for Europe.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndIsoCode:valueValidity".to_string(),
description: "The ISO code is a two-character country code as defined by ISO 3166 (http://www.iso.org/iso/country_codes).".to_string(),
});
}
}
violations
}
pub fn check_p61970_301_equipmentboundary_ap_con_complex_shacl_boundary_point_boundary_point_to_end_iso_etc_5(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("BoundaryPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::BoundaryPoint>() {
Some(o) => o, None => continue,
};
if obj.to_end_iso_code.is_empty() { continue; }
if obj.to_end_iso_code.chars().count() > 2 {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "eqbdu:BoundaryPoint.toEndIsoCode-valueValidity".to_string(),
class: "BoundaryPoint".to_string(),
property: "BoundaryPoint.toEndIsoCode".to_string(),
message: "Not valid two-character ISO code for Europe.".to_string(),
severity: "sh:Violation".to_string(),
name: "C:301:EQBD:BoundaryPoint.toEndIsoCode:valueValidity".to_string(),
description: "The ISO code is a two-character country code as defined by ISO 3166 (http://www.iso.org/iso/country_codes).".to_string(),
});
}
}
violations
}