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 410a633..5745692 100755
--- a/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java
+++ b/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java
@@ -104,15 +104,16 @@ public Query getSummariesQuery() {
return em.createNativeQuery("""
PREFIX fta:
SELECT * WHERE {
- BIND(?_uri as ?uri)
- ?uri a ?type.
+ BIND(?_uri as ?uri)
+ ?uri a ?type.
?uri ?pName ?name.
- OPTIONAL{?uri ?pDescription ?description.}
+ OPTIONAL{?uri ?pDescription ?description.}
+ OPTIONAL{?uri ?pStatus ?status.}
OPTIONAL{?uri ?pCreated ?created.}
OPTIONAL{?uri ?pModified ?modified.}
OPTIONAL{?uri ?pCreator ?creator.}
OPTIONAL{?uri ?pLastEditor ?lastEditor.}
- OPTIONAL{
+ OPTIONAL{
?uri fta:is-manifested-by ?rootEvent .
?rootEvent fta:is-derived-from ?rootEventType.
OPTIONAL{
@@ -132,7 +133,7 @@ public Query getSummariesQuery() {
?fhaFailureRateQ fta:has-estimate ?fhaFailureRateP.
?fhaFailureRateP a fta:failure-rate-estimate;
fta:value ?fhaBasedFailureRate.
- }
+ }
OPTIONAL{
?rootEventType fta:is-manifestation-of ?behavior .
?behavior fta:has-component ?_subsystemUri.
@@ -141,7 +142,7 @@ public Query getSummariesQuery() {
?systemUri fta:is-part-of ?system2.
}
?systemUri fta:name ?systemName.
-
+
OPTIONAL{
FILTER(?systemUri != ?_subsystemUri)
BIND(?_subsystemUri as ?subsystemUri)
@@ -157,6 +158,7 @@ public Query getSummariesQuery() {
.setParameter("type", typeUri)
.setParameter("pName", P_HAS_NAME)
.setParameter("pDescription", P_HAS_DESCRIPTION)
+ .setParameter("pStatus", STATUS_PROP)
.setParameter("pCreated", P_CREATED)
.setParameter("pModified", P_MODIFIED)
.setParameter("pCreator", P_CREATOR)
diff --git a/src/main/java/cz/cvut/kbss/analysis/model/FaultEvent.java b/src/main/java/cz/cvut/kbss/analysis/model/FaultEvent.java
index 5101fba..c339bf7 100755
--- a/src/main/java/cz/cvut/kbss/analysis/model/FaultEvent.java
+++ b/src/main/java/cz/cvut/kbss/analysis/model/FaultEvent.java
@@ -51,6 +51,9 @@ public static FaultEvent create(){
@OWLDataProperty(iri = Vocabulary.s_p_probability)
private Double probability;
+ @Transient
+ private boolean probabilityUpdated = false;
+
@OWLObjectProperty(iri = Vocabulary.s_p_has_selected_estimation, fetch = FetchType.EAGER)
private URI selectedEstimate;
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 6544776..23cfe44 100644
--- a/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java
+++ b/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java
@@ -9,6 +9,7 @@
import java.net.URI;
import java.util.HashSet;
+import java.util.Optional;
@SparqlResultSetMappings(
@@ -22,7 +23,7 @@
public class FaultTreeSummary extends ManagedEntity{
@OWLDataProperty(iri = Vocabulary.s_p_status)
- protected Status status;
+ protected String status;
@OWLObjectProperty(iri = Vocabulary.s_p_is_derived_from)
protected URI rootEvent;
@@ -78,7 +79,7 @@ public void copyTo(FaultTree faultTree){
faultTree.getSubsystem().setUri(this.getSubsystemUri());
faultTree.getSubsystem().setName(this.getSubsystemName());
}
- faultTree.setStatus(this.getStatus());
+ Optional.ofNullable(this.getStatus()).map(Status::valueOf).ifPresent(faultTree::setStatus);
faultTree.setRequiredFailureRate(this.getRequiredFailureRate());
faultTree.setCalculatedFailureRate(this.getCalculatedFailureRate());
faultTree.setFhaBasedFailureRate(this.getFhaBasedFailureRate());
diff --git a/src/main/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryService.java b/src/main/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryService.java
index 607ea29..1bd2780 100755
--- a/src/main/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryService.java
+++ b/src/main/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryService.java
@@ -62,6 +62,7 @@ protected void preRemove(FaultEvent instance) {
@Transactional
public FaultEvent addInputEvent(URI eventUri, FaultEvent inputEvent) {
+ inputEvent.setProbabilityUpdated(true);
validateNew(inputEvent);
FaultEvent currentEvent = findRequired(eventUri);
@@ -76,11 +77,13 @@ public FaultEvent addInputEvent(URI eventUri, FaultEvent inputEvent) {
currentEvent.addChildSequenceUri(inputEvent.getUri());
update(currentEvent);
- setExternalReference(eventUri, inputEvent);
+ setExternalReference(inputEvent);
+ if(inputEvent.getReferences() != null)
+ inputEvent.setProbability(inputEvent.getReferences().getProbability());
return inputEvent;
}
- protected void setExternalReference(URI eventUri, FaultEvent inputEvent){
+ public void setExternalReference(FaultEvent inputEvent){
if(inputEvent.getSupertypes() == null || inputEvent.getEventType() != FtaEventType.EXTERNAL)
return;
@@ -93,8 +96,8 @@ protected void setExternalReference(URI eventUri, FaultEvent inputEvent){
inputEvent.setIsReference(true);
if(supertypes.size() > 1)
- log.warn("new event added to event <{}> has multiple supertypes [{}]",
- eventUri,
+ log.warn("event \"{}\"<{}> , has multiple supertypes [{}]",
+ inputEvent.getName(), inputEvent.getUri(),
supertypes.stream().map(e -> String.format("<%s>", e.getUri().toString()))
.collect(Collectors.joining(",")));
@@ -105,14 +108,22 @@ protected void setExternalReference(URI eventUri, FaultEvent inputEvent){
return;
if(referencedRoots.size() > 1)
- log.warn("new event added to event <{}> with supertype <{}> is used in multiple root fault events [{}]",
- eventUri, supertype.getUri(),
+ log.warn("event \"{}\"<{}> with supertype <{}> is used in multiple root fault events [{}]",
+ inputEvent.getName(), inputEvent.getUri(), supertype.getUri(),
referencedRoots.stream().map(u -> String.format("<%s>", u.toString()))
.collect(Collectors.joining(",")));
inputEvent.setReferences(referencedRoots.get(0));
}
+ @Transactional
+ public void updateProbabilityFromReferencedNode(FaultEvent faultEvent, URI faultTreeUri){
+ if(faultEvent.getReferences() == null || faultEvent.getReferences().getProbability() == null)
+ return;
+ faultEventDao.setProbability(faultEvent.getUri(), faultEvent.getReferences().getProbability(), faultTreeUri);
+ faultEvent.setProbability(faultEvent.getReferences().getProbability());
+ }
+
@Transactional(readOnly = true)
public Double propagateProbability(FaultEvent event) {
log.info("> propagateProbability - {}", event);
@@ -182,6 +193,8 @@ public FaultEvent update(FaultEvent instance) {
managedInstance.setDescription(instance.getDescription());
managedInstance.setGateType(instance.getGateType());
managedInstance.setEventType(instance.getEventType());
+ if(instance.getProbability() != managedInstance.getProbability())
+ managedInstance.setProbabilityUpdated(true);
managedInstance.setProbability(instance.getProbability());
managedInstance.setSupertypes(instance.getSupertypes());
managedInstance.setChildrenSequence(instance.getChildrenSequence());
@@ -220,12 +233,15 @@ protected void postUpdate(@NonNull FaultEvent instance) {
@Override
protected void postRemove(@NonNull FaultEvent instance) {
super.postRemove(instance);
+ instance.setProbabilityUpdated(true);
setChange(instance);
}
protected void setChange(FaultEvent instance){
URI context = faultEventDao.getContext(instance);
UserReference userReference = securityUtils.getCurrentUserReference();
+ if(instance.isProbabilityUpdated())
+ faultTreeDao.updateStatus(context, Status.outOfSync);
faultTreeDao.setChangedByContext(context, new Date(), userReference.getUri());
}
diff --git a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeEvaluationService.java b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeEvaluationService.java
index 4451b69..02ea468 100644
--- a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeEvaluationService.java
+++ b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeEvaluationService.java
@@ -35,8 +35,7 @@ public FaultTree evaluate(URI faultTreeUri, OperationalDataFilter filter) {
faultTree = faultTreeRepositoryService.evaluate(faultTree);
- Status status = faultTreeRepositoryService.getInferedStatus(faultTree);
- faultTreeDao.updateStatus(faultTree.getUri(), status);
+ faultTreeDao.updateStatus(faultTree.getUri(), Status.ok);
return faultTree;
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 c5d5dc8..86d0ce0 100755
--- a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeRepositoryService.java
+++ b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeRepositoryService.java
@@ -171,7 +171,6 @@ public List findAllSummaries(){
uri -> systemRepositoryService.findAllSummary(uri)
);
faultTreeSummary.setSystem(system);
- setInferStatus(faultTreeSummary);
}
return summaries;
}
@@ -564,9 +563,15 @@ public FaultTree performCutSetAnalysis(URI faultTreeUri){
@Transactional
public void updateFailureRates(FaultTree faultTree, OperationalDataFilter filter){
updateFHABasedOperationalFailureRates(faultTree, filter);
+ updateReferencedNodeFailureRates(faultTree);
updateFaultTreeOperationalFailureRates(faultTree, filter);
}
+ /**
+ * Updates the FHA based operational failure rate of the Root node
+ * @param faultTree
+ * @param filter
+ */
@Transactional
public void updateFHABasedOperationalFailureRates(FaultTree faultTree, OperationalDataFilter filter) {
FaultEventType fhaEvent = (FaultEventType)Optional.ofNullable(faultTree.getManifestingEvent())
@@ -595,6 +600,13 @@ public void updateFHABasedOperationalFailureRates(FaultTree faultTree, Operation
faultTree.getManifestingEvent(), fr);
}
+ @Transactional
+ public void updateReferencedNodeFailureRates(FaultTree faultTree){
+ for(FaultEvent faultEvent : faultTree.getAllEvents()){
+ faultEventRepositoryService.updateProbabilityFromReferencedNode(faultEvent, faultTree.getUri());
+ }
+ }
+
/**
* Updates the provided fault tree sns' failures with operational failure rate calculated based on filter. The update
* is reflected in the persistent storage and in the input fault tree.
diff --git a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeService.java b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeService.java
index e15fd2f..d97733b 100644
--- a/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeService.java
+++ b/src/main/java/cz/cvut/kbss/analysis/service/FaultTreeService.java
@@ -55,8 +55,6 @@ public FaultTree findWithDetails(URI id) {
.map(u -> systemRepositoryService.findAllSummary(u)).orElse( null)
);
ft.setSubsystem(summary.getSubsystem());
- if(ft.getSystem() != null)
- faultTreeRepositoryService.setInferStatus(ft);
return ft;
}
@@ -65,15 +63,8 @@ protected void setReferences(FaultTree faultTree){
if(faultTree.getManifestingEvent() == null)
return;
- Stack> stack = new Stack<>();
- stack.add(Pair.of(null,faultTree.getManifestingEvent()));
- while(!stack.isEmpty()){
- Pair p = stack.pop();
- FaultEvent fe = p.getSecond();
- faultEventRepositoryService.setExternalReference(p.getFirst(), fe);
- if(fe.getChildren() == null)
- continue;
- fe.getChildren().forEach(c -> stack.push(Pair.of(fe.getUri(), c)));
+ for(FaultEvent fe: faultTree.getAllEvents()){
+ faultEventRepositoryService.setExternalReference(fe);
}
}