Skip to content

Commit

Permalink
Merge pull request #81 from kbss-cvut/feature/fta-fmea-ui-245-add-get…
Browse files Browse the repository at this point in the history
…-fault-tree-of-fault-event-api

[FIX kbss-cvut/fta-fmea-ui#245] Extend FaultEvent.references field to include the fault tree of the referenced fault event
  • Loading branch information
blcham authored Apr 17, 2024
2 parents f1559df + 6b977b4 commit 38162c9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
15 changes: 8 additions & 7 deletions src/main/java/cz/cvut/kbss/analysis/dao/FaultEventDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cz.cvut.kbss.analysis.config.conf.PersistenceConf;
import cz.cvut.kbss.analysis.exception.PersistenceException;
import cz.cvut.kbss.analysis.model.FaultEvent;
import cz.cvut.kbss.analysis.model.FaultEventReference;
import cz.cvut.kbss.analysis.model.diagram.Rectangle;
import cz.cvut.kbss.analysis.service.IdentifierService;
import cz.cvut.kbss.analysis.util.Vocabulary;
Expand Down Expand Up @@ -73,16 +74,16 @@ public Rectangle update(Rectangle rect){
}


public List<URI> getFaultEventRootWithSupertype(URI supertype){
public List<FaultEventReference> getFaultEventRootWithSupertype(URI supertype){
try{
return em.createNativeQuery(
"""
SELECT DISTINCT ?uri WHERE{
?uri ?derivedFrom ?supertype.
?uri ?ftaEventTypeProp ?ftaEventType.
?uri a ?type.
?faultTree ?isManifestedByProp ?uri
}""", URI.class)
SELECT DISTINCT ?faultEvent ?faultTree WHERE{
?faultEvent ?derivedFrom ?supertype.
?faultEvent ?ftaEventTypeProp ?ftaEventType.
?faultEvent a ?type.
?faultTree ?isManifestedByProp ?faultEvent
}""", "FaultEventReference")
.setParameter("derivedFrom", DERIVED_FROM_PROP)
.setParameter("supertype", supertype)
.setParameter("ftaEventTypeProp", FTA_EVENT_TYPE_PROP)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cz/cvut/kbss/analysis/model/FaultEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static FaultEvent create(){

@Transient
@OWLObjectProperty(iri = Vocabulary.s_p_is_reference_to)
private URI references;
private FaultEventReference references;

@Transient
@OWLDataProperty(iri = Vocabulary.s_p_is_reference)
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/cz/cvut/kbss/analysis/model/FaultEventReference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cz.cvut.kbss.analysis.model;

import cz.cvut.kbss.analysis.util.Vocabulary;
import cz.cvut.kbss.jopa.model.annotations.*;
import lombok.Getter;
import lombok.Setter;

import java.net.URI;

@SparqlResultSetMapping(name = "FaultEventReference", classes =
@ConstructorResult(targetClass=FaultEventReference.class, variables={
@VariableResult(name="faultEvent"),
@VariableResult(name="faultTree")
})
)

@OWLClass(iri = Vocabulary.s_c_fault_event)
@Getter
@Setter
public class FaultEventReference {

public FaultEventReference() {
}

public FaultEventReference(URI faultEvent, URI faultTree) {
this.faultEvent = faultEvent;
this.faultTree = faultTree;
}

@Id
protected URI faultEvent;

@Transient
@OWLDataProperty(iri = Vocabulary.s_p_is_part_of)
protected URI faultTree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import cz.cvut.kbss.analysis.dao.FaultTreeDao;
import cz.cvut.kbss.analysis.dao.GenericDao;
import cz.cvut.kbss.analysis.exception.LogicViolationException;
import cz.cvut.kbss.analysis.model.Event;
import cz.cvut.kbss.analysis.model.FailureMode;
import cz.cvut.kbss.analysis.model.FaultEvent;
import cz.cvut.kbss.analysis.model.Item;
import cz.cvut.kbss.analysis.model.*;
import cz.cvut.kbss.analysis.model.diagram.Rectangle;
import cz.cvut.kbss.analysis.model.fta.FtaEventType;
import cz.cvut.kbss.analysis.service.strategy.DirectFtaEvaluation;
Expand Down Expand Up @@ -91,7 +88,7 @@ protected void setExternalReference(URI eventUri, FaultEvent inputEvent){
.collect(Collectors.joining(",")));

Event supertype = supertypes.get(0);
List<URI> referencedRoots = faultEventDao.getFaultEventRootWithSupertype(supertype.getUri());
List<FaultEventReference> referencedRoots = faultEventDao.getFaultEventRootWithSupertype(supertype.getUri());

if(referencedRoots == null || referencedRoots.isEmpty())
return;
Expand Down

0 comments on commit 38162c9

Please sign in to comment.