diff --git a/ontology-generator/ontology/fta-fmea-model.ttl b/ontology-generator/ontology/fta-fmea-model.ttl index f90958b..3dba589 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 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 4235081..410a633 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 0ee6f83..a3dd62f 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 8696b77..6544776 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 b67119e..a7609db 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