From 6ea14d4ced0bff759f0e5a40f0ae368428eee70f Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Fri, 9 Aug 2024 15:02:05 +0200 Subject: [PATCH 1/2] [Fix partially kbss-cvut/fta-fmea-ui#541] Fix and allow renaming only non fha based fault trees --- .../cvut/kbss/analysis/dao/FaultTreeDao.java | 3 +++ .../kbss/analysis/model/FaultEventType.java | 3 +++ .../kbss/analysis/model/FaultTreeSummary.java | 3 +++ .../service/FaultTreeRepositoryService.java | 22 ++++++++++++------- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java b/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java index 4235081b..410a633b 100755 --- a/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java +++ b/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java @@ -118,6 +118,9 @@ public Query getSummariesQuery() { OPTIONAL{ ?rootEvent fta:probability ?calculatedFailureRate. } + OPTIONAL{ + ?rootEventType fta:auxiliary ?auxiliary. + } OPTIONAL{ ?rootEventType fta:has-failure-rate ?failureRate. ?failureRate fta:has-requirement ?failureRateRequirement. diff --git a/src/main/java/cz/cvut/kbss/analysis/model/FaultEventType.java b/src/main/java/cz/cvut/kbss/analysis/model/FaultEventType.java index 0ee6f831..a3dd62fc 100644 --- a/src/main/java/cz/cvut/kbss/analysis/model/FaultEventType.java +++ b/src/main/java/cz/cvut/kbss/analysis/model/FaultEventType.java @@ -21,6 +21,9 @@ public class FaultEventType extends Event{ @OWLDataProperty(iri = Vocabulary.s_p_fault_event_type) private String eventType; + @OWLDataProperty(iri = Vocabulary.s_p_auxiliary) + private Boolean auxiliary; + @Override public void setAs(NamedEntity namedEntity) { if(namedEntity instanceof FaultEventTypeSummary) diff --git a/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java b/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java index 8696b77e..6544776a 100644 --- a/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java +++ b/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java @@ -51,6 +51,8 @@ public class FaultTreeSummary extends ManagedEntity{ @OWLDataProperty(iri = Vocabulary.s_p_fha_based_failure_rate) protected Double fhaBasedFailureRate; + @OWLDataProperty(iri = Vocabulary.s_p_auxiliary) + protected Boolean auxiliary; public void copyTo(FaultTree faultTree){ super.copyTo(faultTree); @@ -63,6 +65,7 @@ public void copyTo(FaultTree faultTree){ rootType.setUri(this.getRootEventType()); root.setSupertypes(new HashSet<>()); root.getSupertypes().add(rootType); + rootType.setAuxiliary(auxiliary); } } if(this.getSystemUri() != null){ diff --git a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeRepositoryService.java b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeRepositoryService.java index b67119e0..a7609dbd 100755 --- a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeRepositoryService.java +++ b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeRepositoryService.java @@ -101,6 +101,7 @@ public void createTree(FaultTree faultTree){ // load and persist supertypes if(faultTree.getManifestingEvent().getSupertypes() == null || faultTree.getManifestingEvent().getSupertypes().isEmpty()) { FHAEventType evt = new FHAEventType(); + evt.setAuxiliary(true); evt.setName(faultTree.getManifestingEvent().getName()); faultTree.getManifestingEvent().setSupertypes(Collections.singleton(evt)); } @@ -202,14 +203,19 @@ public Status getInferedStatus(FaultTree faultTree ){ } public FaultTree update(FaultTree instance) { - if(instance.getManifestingEvent() == null && instance.getUri() != null){ - FaultTree managedInstance = getPrimaryDao().find(instance.getUri()).orElse(null); - if(managedInstance == null) - throw EntityNotFoundException.create("Could find instance to update", instance.getUri()); - managedInstance.setName(instance.getName()); - instance = managedInstance; - } - return super.update(instance); + if(instance.getUri() == null) + throw new IllegalArgumentException("Cannot updated fault tree, fault tree uri is not set."); + if(!Optional.ofNullable(instance.getManifestingEvent()) + .map(e -> e.getSupertypes()) + .filter(s -> !s.isEmpty()).map(s -> s.iterator().next()).map(et -> ((FaultEventType)et).getAuxiliary()).orElse(false)) + throw new IllegalArgumentException("Cannot updated name of fault tree connected to FHA event type."); + + FaultTree managedInstance = getPrimaryDao().find(instance.getUri()).orElse(null); + if(managedInstance == null) + throw EntityNotFoundException.create("Could find instance to update", instance.getUri()); + managedInstance.setName(instance.getName()); + + return super.update(managedInstance); } @Override From 55f1dc4f5668ee1242ee1ad5013311344ccb20cf Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Fri, 9 Aug 2024 15:08:14 +0200 Subject: [PATCH 2/2] [Fix partially kbss-cvut/fta-fmea-ui#541] Add auxiliary data property to distinguish between generated (auxiliary is true) and imported (auxiliary is false or missing) fha --- ontology-generator/ontology/fta-fmea-model.ttl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ontology-generator/ontology/fta-fmea-model.ttl b/ontology-generator/ontology/fta-fmea-model.ttl index f90958b6..3dba589a 100644 --- a/ontology-generator/ontology/fta-fmea-model.ttl +++ b/ontology-generator/ontology/fta-fmea-model.ttl @@ -540,6 +540,9 @@ fta-fmea:system-name rdf:type owl:DatatypeProperty ; fta-fmea:status rdf:type owl:DatatypeProperty ; rdfs:label "status" . +### http://onto.fel.cvut.cz/ontologies/fta-fmea-application/auxiliary + fta-fmea:auxiliary rdf:type owl:DatatypeProperty ; + rdfs:label "auxiliary" . ################################################################# # Classes