#![allow(clippy::all, dead_code, unused)]
use cimdecoder::CimDataset;
use crate::Violation;
use crate::helpers::*;
pub fn validate_p61970_552_header_ap_con_simple_shacl(dataset: &CimDataset) -> Vec<Violation> {
let mut v = Vec::new();
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_preconditions_has_v_etc(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_scenario_time_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_created_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_profile_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_forward_differences_etc(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_forward_differences_etc_2(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_created_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_reverse_differences_etc(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_modeling_authority_set_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_reverse_differences_etc_2(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_preconditions_min_c_etc(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_profile_min_count(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_scenario_time_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_description_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_version_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_modeling_authority_set_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_description_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_scenario_time_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_scenario_time_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_profile_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_profile_min_count(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_created_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_modeling_authority_set_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_created_datatype(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_modeling_authority_set_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_version_required(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_dependent_on_in(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_dependent_on_in(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_full_model_model_supersedes_in(dataset));
v.extend(check_p61970_552_header_ap_con_simple_shacl_difference_model_model_supersedes_in(dataset));
v
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_preconditions_has_v_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
for r in &obj.preconditions {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["Statements"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:DifferenceModel.preconditions-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "DifferenceModel.preconditions".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: "DifferenceModel.preconditions-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_scenario_time_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.scenario_time.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.scenarioTime-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.scenarioTime".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.scenarioTime-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_created_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.created.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.created-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.created".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.created-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_profile_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
for val in &obj.base.profile {
if val.is_empty() { continue; }
if !is_xsd_anyuri(val) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.profile-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.profile".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.profile-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_forward_differences_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.forward_differences.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:DifferenceModel.forwardDifferences-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "DifferenceModel.forwardDifferences".to_string(),
message: "Cardinality violation. Lower bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "DifferenceModel.forwardDifferences-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_forward_differences_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
for r in &obj.forward_differences {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["Statements"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:DifferenceModel.forwardDifferences-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "DifferenceModel.forwardDifferences".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: "DifferenceModel.forwardDifferences-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_created_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.created.is_empty() { continue; }
if !is_xsd_datetime(&obj.base.created) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.created-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.created".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.created-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_reverse_differences_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.reverse_differences.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:DifferenceModel.reverseDifferences-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "DifferenceModel.reverseDifferences".to_string(),
message: "Cardinality violation. Lower bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "DifferenceModel.reverseDifferences-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_modeling_authority_set_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.modeling_authority_set.is_empty() { continue; }
if !is_xsd_anyuri(&obj.base.modeling_authority_set) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.modelingAuthoritySet-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.modelingAuthoritySet".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.modelingAuthoritySet-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_reverse_differences_etc_2(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
for r in &obj.reverse_differences {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["Statements"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:DifferenceModel.reverseDifferences-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "DifferenceModel.reverseDifferences".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: "DifferenceModel.reverseDifferences-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_difference_model_preconditions_min_c_etc(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.preconditions.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:DifferenceModel.preconditions-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "DifferenceModel.preconditions".to_string(),
message: "Cardinality violation. Lower bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "DifferenceModel.preconditions-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_profile_min_count(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.profile.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.profile-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.profile".to_string(),
message: "Cardinality violation. Lower bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.profile-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_scenario_time_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.scenario_time.is_empty() { continue; }
if !is_xsd_datetime(&obj.base.scenario_time) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.scenarioTime-datatype".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.scenarioTime".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.scenarioTime-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_description_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.description.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.description-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.description".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.description-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_version_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.version.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.version-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.version".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.version-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_modeling_authority_set_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
if obj.base.modeling_authority_set.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.modelingAuthoritySet-cardinality".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.modelingAuthoritySet".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.modelingAuthoritySet-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_description_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.description.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.description-cardinality".to_string(),
class: "FullModel".to_string(),
property: "Model.description".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.description-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_scenario_time_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.scenario_time.is_empty() { continue; }
if !is_xsd_datetime(&obj.base.scenario_time) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.scenarioTime-datatype".to_string(),
class: "FullModel".to_string(),
property: "Model.scenarioTime".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.scenarioTime-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_scenario_time_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.scenario_time.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.scenarioTime-cardinality".to_string(),
class: "FullModel".to_string(),
property: "Model.scenarioTime".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.scenarioTime-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_profile_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
for val in &obj.base.profile {
if val.is_empty() { continue; }
if !is_xsd_anyuri(val) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.profile-datatype".to_string(),
class: "FullModel".to_string(),
property: "Model.profile".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.profile-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_profile_min_count(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.profile.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.profile-cardinality".to_string(),
class: "FullModel".to_string(),
property: "Model.profile".to_string(),
message: "Cardinality violation. Lower bound shall be 1".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.profile-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_created_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.created.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.created-cardinality".to_string(),
class: "FullModel".to_string(),
property: "Model.created".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.created-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_modeling_authority_set_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.modeling_authority_set.is_empty() { continue; }
if !is_xsd_anyuri(&obj.base.modeling_authority_set) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.modelingAuthoritySet-datatype".to_string(),
class: "FullModel".to_string(),
property: "Model.modelingAuthoritySet".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.modelingAuthoritySet-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_created_datatype(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.created.is_empty() { continue; }
if !is_xsd_datetime(&obj.base.created) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.created-datatype".to_string(),
class: "FullModel".to_string(),
property: "Model.created".to_string(),
message: "The datatype is not literal or it violates the xsd datatype.".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.created-datatype".to_string(),
description: "This constraint validates the datatype of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_modeling_authority_set_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.modeling_authority_set.is_empty() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.modelingAuthoritySet-cardinality".to_string(),
class: "FullModel".to_string(),
property: "Model.modelingAuthoritySet".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.modelingAuthoritySet-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_version_required(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
if obj.base.version.is_none() {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.version-cardinality".to_string(),
class: "FullModel".to_string(),
property: "Model.version".to_string(),
message: "Missing required property (attribute).".to_string(),
severity: "sh:Violation".to_string(),
name: "Model.version-cardinality".to_string(),
description: "This constraint validates the cardinality of the property (attribute).".to_string(),
});
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_dependent_on_in(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
for r in &obj.base.dependent_on {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["DifferenceModel", "FullModel"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.DependentOn-valueType".to_string(),
class: "FullModel".to_string(),
property: "Model.DependentOn".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: "Model.DependentOn-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_dependent_on_in(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
for r in &obj.base.dependent_on {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["DifferenceModel", "FullModel"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.DependentOn-valueType".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.DependentOn".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: "Model.DependentOn-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_full_model_model_supersedes_in(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("FullModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::FullModel>() {
Some(o) => o, None => continue,
};
for r in &obj.base.supersedes {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["DifferenceModel", "FullModel"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.Supersedes-valueType".to_string(),
class: "FullModel".to_string(),
property: "Model.Supersedes".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: "Model.Supersedes-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
}
violations
}
pub fn check_p61970_552_header_ap_con_simple_shacl_difference_model_model_supersedes_in(dataset: &CimDataset) -> Vec<Violation> {
let mut violations = Vec::new();
for mrid in dataset.by_type.get("DifferenceModel").into_iter().flatten() {
let entry = &dataset.entries[mrid];
let obj = match entry.element.as_any()
.downcast_ref::<cimstructs::DifferenceModel>() {
Some(o) => o, None => continue,
};
for r in &obj.base.supersedes {
let ref_id = r.mrid.trim_start_matches('#');
if ref_id.is_empty() { continue; }
if let Some(ref_entry) = dataset.entries.get(ref_id) {
let allowed: &[&str] = &["DifferenceModel", "FullModel"];
if !allowed.contains(&ref_entry.element.type_name()) {
violations.push(Violation {
object_id: mrid.clone(),
rule_id: "fh:Model.Supersedes-valueType".to_string(),
class: "DifferenceModel".to_string(),
property: "Model.Supersedes".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: "Model.Supersedes-valueType".to_string(),
description: "This constraint validates the value type of the association at the used direction.".to_string(),
});
}
}
}
}
violations
}