Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and allow renaming only non fha based fault trees #146

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kostobog Could find --> Could not find?

managedInstance.setName(instance.getName());

return super.update(managedInstance);
}

@Override
Expand Down
Loading