Skip to content

Commit

Permalink
Merge pull request #146 from kbss-cvut/fix/fta-fmea-ui-541-fix-renami…
Browse files Browse the repository at this point in the history
…ng-fault-trees

Fix and allow renaming only non fha based fault trees
  • Loading branch information
kostobog authored Aug 9, 2024
2 parents fcc5cd0 + 55f1dc4 commit f9a4120
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
3 changes: 3 additions & 0 deletions ontology-generator/ontology/fta-fmea-model.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cz/cvut/kbss/analysis/model/FaultEventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f9a4120

Please sign in to comment.