#![allow(clippy::all, dead_code, unused)]
use cimdecoder::CimDataset;
use crate::Violation;
use crate::helpers::*;
pub fn validate_p61970_600_2_geographicallocation_ap_con_simple_shacl(dataset: &CimDataset) -> Vec<Violation> {
let mut v = Vec::new();
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_coordinate_system_identified_object_n_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_coordinate_system_identified_object_m_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_coordinate_system_coordinate_system_c_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_coordinate_system_h_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_identified_object_m_rid_requ_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_max_count(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_identified_object_name_max_c_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value_2(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_datatype(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value_3(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_power_system_resour_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value_4(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_coordinate_system_r_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_locatio_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_sequenc_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_z_posit_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_x_posit_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_y_posit_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_locatio_etc_2(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_coordinate_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_power_syste_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_2(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_3(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_identified_object_na_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_4(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_coordinate_etc_2(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_5(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_identified_object_m_etc(dataset));
v.extend(check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_6(dataset));
v
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_coordinate_system_identified_object_n_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("CoordinateSystem").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("IdentifiedObject.name") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "ido:IdentifiedObject.name-cardinality".to_string(),
class: "CoordinateSystem".to_string(),
property: "IdentifiedObject.name".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "IdentifiedObject.name-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_coordinate_system_identified_object_m_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("CoordinateSystem").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::CoordinateSystem>() {
Some(o) => o, None => continue,
};
if obj.base.m_rid.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "ido:IdentifiedObject.mRID-cardinality".to_string(),
class: "CoordinateSystem".to_string(),
property: "IdentifiedObject.mRID".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "IdentifiedObject.mRID-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_coordinate_system_coordinate_system_c_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("CoordinateSystem").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::CoordinateSystem>() {
Some(o) => o, None => continue,
};
if obj.crs_urn.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:CoordinateSystem.crsUrn-cardinality".to_string(),
class: "CoordinateSystem".to_string(),
property: "CoordinateSystem.crsUrn".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "CoordinateSystem.crsUrn-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_coordinate_system_h_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
let ref_mrid = match obj.coordinate_system.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
if let Some(ref_entry) = dataset.entries.get(ref_mrid) {
let allowed: &[&str] = &["CoordinateSystem"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.CoordinateSystem-valueType".to_string(),
class: "Location".to_string(),
property: "Location.CoordinateSystem".to_string(),
message: "One of the following does not conform: 1) The value type shall be IRI; 2) The value type shall be an instance of the class: cim:CoordinateSystem".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.CoordinateSystem-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_identified_object_m_rid_requ_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
if obj.base.m_rid.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "ido:IdentifiedObject.mRID-cardinality".to_string(),
class: "Location".to_string(),
property: "IdentifiedObject.mRID".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "IdentifiedObject.mRID-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.town_detail.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let allowed: &[&str] = &["TownDetail"];
if !allowed.contains(&entry1.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:StreetAddress.townDetail-datatype".to_string(),
class: "Location".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "StreetAddress.townDetail-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_max_count(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("Location.mainAddress") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.mainAddress-cardinality".to_string(),
class: "Location".to_string(),
property: "Location.mainAddress".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.mainAddress-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_identified_object_name_max_c_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("IdentifiedObject.name") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "ido:IdentifiedObject.name-cardinality".to_string(),
class: "Location".to_string(),
property: "IdentifiedObject.name".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "IdentifiedObject.name-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.status.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let allowed: &[&str] = &["Status"];
if !allowed.contains(&entry1.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:StreetAddress.status-datatype".to_string(),
class: "Location".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "StreetAddress.status-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.status.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let leaf = match entry1.element.as_any()
.downcast_ref::<cimstructs::Status>() {
Some(o) => o, None => continue,
};
if leaf.date_time.is_empty() { continue; }
if !is_xsd_datetime(&leaf.date_time) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Status.dateTime-datatype".to_string(),
class: "Location".to_string(),
property: "Location.mainAddress".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Status.dateTime-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value_3(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
let ref_mrid = match obj.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
if let Some(ref_entry) = dataset.entries.get(ref_mrid) {
let allowed: &[&str] = &["StreetAddress"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.mainAddress-datatype".to_string(),
class: "Location".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.mainAddress-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_power_system_resour_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
if obj.power_system_resources.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.PowerSystemResources-cardinality".to_string(),
class: "Location".to_string(),
property: "Location.PowerSystemResources".to_string(),
message: "Missing required association.".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.PowerSystemResources-cardinality".to_string(),
description: "This constraint validates the cardinality of the association at the used direction.".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_main_address_has_value_4(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.street_detail.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let allowed: &[&str] = &["StreetDetail"];
if !allowed.contains(&entry1.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:StreetAddress.streetDetail-datatype".to_string(),
class: "Location".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "StreetAddress.streetDetail-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_location_location_coordinate_system_r_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("Location").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::Location>() {
Some(o) => o, None => continue,
};
if obj.coordinate_system.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.CoordinateSystem-cardinality".to_string(),
class: "Location".to_string(),
property: "Location.CoordinateSystem".to_string(),
message: "Missing required association.".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.CoordinateSystem-cardinality".to_string(),
description: "This constraint validates the cardinality of the association at the used direction.".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_locatio_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("PositionPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::PositionPoint>() {
Some(o) => o, None => continue,
};
if obj.location.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:PositionPoint.Location-cardinality".to_string(),
class: "PositionPoint".to_string(),
property: "PositionPoint.Location".to_string(),
message: "Missing required association.".to_string(),
severity: "sh:Violation".to_string(),
name: "PositionPoint.Location-cardinality".to_string(),
description: "This constraint validates the cardinality of the association at the used direction.".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_sequenc_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("PositionPoint").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("PositionPoint.sequenceNumber") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:PositionPoint.sequenceNumber-cardinality".to_string(),
class: "PositionPoint".to_string(),
property: "PositionPoint.sequenceNumber".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "PositionPoint.sequenceNumber-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_z_posit_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("PositionPoint").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("PositionPoint.zPosition") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:PositionPoint.zPosition-cardinality".to_string(),
class: "PositionPoint".to_string(),
property: "PositionPoint.zPosition".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "PositionPoint.zPosition-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_x_posit_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("PositionPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::PositionPoint>() {
Some(o) => o, None => continue,
};
if obj.x_position.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:PositionPoint.xPosition-cardinality".to_string(),
class: "PositionPoint".to_string(),
property: "PositionPoint.xPosition".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "PositionPoint.xPosition-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_y_posit_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("PositionPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::PositionPoint>() {
Some(o) => o, None => continue,
};
if obj.y_position.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:PositionPoint.yPosition-cardinality".to_string(),
class: "PositionPoint".to_string(),
property: "PositionPoint.yPosition".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "PositionPoint.yPosition-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_position_point_position_point_locatio_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("PositionPoint").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::PositionPoint>() {
Some(o) => o, None => continue,
};
let ref_mrid = match obj.location.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
if let Some(ref_entry) = dataset.entries.get(ref_mrid) {
let allowed: &[&str] = &["Location", "ServiceLocation"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:PositionPoint.Location-valueType".to_string(),
class: "PositionPoint".to_string(),
property: "PositionPoint.Location".to_string(),
message: "One of the following occurs: 1) The value type is not IRI; 2) The value type is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "PositionPoint.Location-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("Location.mainAddress") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.mainAddress-cardinality".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.mainAddress".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.mainAddress-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_coordinate_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
let ref_mrid = match obj.base.base.coordinate_system.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
if let Some(ref_entry) = dataset.entries.get(ref_mrid) {
let allowed: &[&str] = &["CoordinateSystem"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.CoordinateSystem-valueType".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.CoordinateSystem".to_string(),
message: "One of the following does not conform: 1) The value type shall be IRI; 2) The value type shall be an instance of the class: cim:CoordinateSystem".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.CoordinateSystem-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_power_syste_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
if obj.base.base.power_system_resources.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.PowerSystemResources-cardinality".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.PowerSystemResources".to_string(),
message: "Missing required association.".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.PowerSystemResources-cardinality".to_string(),
description: "This constraint validates the cardinality of the association at the used direction.".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.base.base.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.town_detail.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let allowed: &[&str] = &["TownDetail"];
if !allowed.contains(&entry1.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:StreetAddress.townDetail-datatype".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "StreetAddress.townDetail-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_3(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.base.base.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.street_detail.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let allowed: &[&str] = &["StreetDetail"];
if !allowed.contains(&entry1.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:StreetAddress.streetDetail-datatype".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "StreetAddress.streetDetail-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_identified_object_na_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
if dataset.entries[mrid].block.duplicate_fields.contains("IdentifiedObject.name") {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "ido:IdentifiedObject.name-cardinality".to_string(),
class: "ServiceLocation".to_string(),
property: "IdentifiedObject.name".to_string(),
message: "Cardinality violation. Upper bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "IdentifiedObject.name-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_4(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
let ref_mrid = match obj.base.base.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
if let Some(ref_entry) = dataset.entries.get(ref_mrid) {
let allowed: &[&str] = &["StreetAddress"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.mainAddress-datatype".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.mainAddress-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_coordinate_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
if obj.base.base.coordinate_system.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Location.CoordinateSystem-cardinality".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.CoordinateSystem".to_string(),
message: "Missing required association.".to_string(),
severity: "sh:Violation".to_string(),
name: "Location.CoordinateSystem-cardinality".to_string(),
description: "This constraint validates the cardinality of the association at the used direction.".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_5(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.base.base.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.status.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let leaf = match entry1.element.as_any()
.downcast_ref::<cimstructs::Status>() {
Some(o) => o, None => continue,
};
if leaf.date_time.is_empty() { continue; }
if !is_xsd_datetime(&leaf.date_time) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:Status.dateTime-datatype".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.mainAddress".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Status.dateTime-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_identified_object_m_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
if obj.base.base.base.m_rid.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "ido:IdentifiedObject.mRID-cardinality".to_string(),
class: "ServiceLocation".to_string(),
property: "IdentifiedObject.mRID".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "IdentifiedObject.mRID-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_600_2_geographicallocation_ap_con_simple_shacl_service_location_location_main_addres_etc_6(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("ServiceLocation").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::ServiceLocation>() {
Some(o) => o, None => continue,
};
let ref0 = match obj.base.base.main_address.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry0 = match dataset.entries.get(ref0) {
Some(e) => e, None => continue,
};
let hop1 = match entry0.element.as_any()
.downcast_ref::<cimstructs::StreetAddress>() {
Some(o) => o, None => continue,
};
let ref1 = match hop1.status.as_ref() {
Some(r) => r.mrid.trim_start_matches('#'), None => continue,
};
let entry1 = match dataset.entries.get(ref1) {
Some(e) => e, None => continue,
};
let allowed: &[&str] = &["Status"];
if !allowed.contains(&entry1.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "gl:StreetAddress.status-datatype".to_string(),
class: "ServiceLocation".to_string(),
property: "Location.mainAddress".to_string(),
message: "Blank node (compound datatype) violation. Either it is not a blank node (nested structure, compound datatype) or it is not the right class.".to_string(),
severity: "sh:Violation".to_string(),
name: "StreetAddress.status-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}