Skip to content

Commit

Permalink
Merge pull request #166 from kbss-cvut/fix/add-alternative-sns-labels
Browse files Browse the repository at this point in the history
Add alternative SNS labels
  • Loading branch information
kostobog authored Nov 5, 2024
2 parents 775e069 + 85e6932 commit 758c5b0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 46 deletions.
4 changes: 4 additions & 0 deletions ontology-generator/ontology/fta-fmea-model.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ fta-fmea:name rdf:type owl:DatatypeProperty ;
rdfs:range xsd:string ;
rdfs:label "name" .

### http://onto.fel.cvut.cz/ontologies/fta-fmea-application/alt-name
fta-fmea:alt-name rdf:type owl:DatatypeProperty ;
rdfs:range xsd:string ;
rdfs:label "alternative name" .

### http://onto.fel.cvut.cz/ontologies/fta-fmea-application/occurrence
fta-fmea:occurrence rdf:type owl:DatatypeProperty ;
Expand Down
95 changes: 52 additions & 43 deletions src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,54 +104,63 @@ public Query getSummariesQuery() {
return em.createNativeQuery("""
PREFIX fta: <http://onto.fel.cvut.cz/ontologies/fta-fmea-application/>
SELECT * WHERE {
BIND(?_uri as ?uri)
?uri a ?type.
?uri ?pName ?name.
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{
?uri fta:is-manifested-by ?rootEvent .
?rootEvent fta:is-derived-from ?rootEventType.
{SELECT ?uri ?type ?name ?description ?status ?created ?modified ?creator ?lastEditor
?rootEvent ?rootEventType ?calculatedFailureRate ?auxiliary ?failureRate ?failureRateRequirement
?requiredFailureRate ?fhaFailureRateQ ?fhaFailureRateP ?fhaBasedFailureRate ?behavior
?_subsystemUri ?systemUri ?systemName ?subsystemUri ?subsystemType ?subsystemName ?ataCode (GROUP_CONCAT(DISTINCT ?subsystemAltName; separator='\\n') as ?subsystemAltNames){
BIND(?_uri as ?uri)
?uri a ?type.
?uri ?pName ?name.
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{
?rootEvent fta:probability ?calculatedFailureRate.
}
OPTIONAL{
?rootEventType fta:auxiliary ?auxiliary.
}
OPTIONAL{
?rootEventType fta:has-failure-rate ?failureRate.
?failureRate fta:has-requirement ?failureRateRequirement.
?failureRateRequirement fta:to ?requiredFailureRate.
}
OPTIONAL{
?rootEventType fta:has-failure-rate ?fhaFailureRateQ.
?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.
?_subsystemUri fta:is-part-of* ?systemUri.
FILTER NOT EXISTS{
?systemUri fta:is-part-of ?system2.
?uri fta:is-manifested-by ?rootEvent .
?rootEvent fta:is-derived-from ?rootEventType.
OPTIONAL{
?rootEvent fta:probability ?calculatedFailureRate.
}
OPTIONAL{
?rootEventType fta:auxiliary ?auxiliary.
}
OPTIONAL{
?rootEventType fta:has-failure-rate ?failureRate.
?failureRate fta:has-requirement ?failureRateRequirement.
?failureRateRequirement fta:to ?requiredFailureRate.
}
OPTIONAL{
?rootEventType fta:has-failure-rate ?fhaFailureRateQ.
?fhaFailureRateQ fta:has-estimate ?fhaFailureRateP.
?fhaFailureRateP a fta:failure-rate-estimate;
fta:value ?fhaBasedFailureRate.
}
?systemUri fta:name ?systemName.
OPTIONAL{
FILTER(?systemUri != ?_subsystemUri)
BIND(?_subsystemUri as ?subsystemUri)
?subsystemUri fta:is-derived-from ?subsystemType.
?subsystemType fta:name ?subsystemTypeLabel.
?subsystemType fta:ata-code ?subsystemTypeCode.
BIND(CONCAT(str(?subsystemTypeCode), " - ", str(?subsystemTypeLabel)) as ?subsystemName)
?subsystemUri fta:is-part-of+ ?systemUri.
?rootEventType fta:is-manifestation-of ?behavior .
?behavior fta:has-component ?_subsystemUri.
?_subsystemUri fta:is-part-of* ?systemUri.
FILTER NOT EXISTS{
?systemUri fta:is-part-of ?system2.
}
?systemUri fta:name ?systemName.
OPTIONAL{
FILTER(?systemUri != ?_subsystemUri)
BIND(?_subsystemUri as ?subsystemUri)
?subsystemUri fta:is-part-of+ ?systemUri.
?subsystemUri fta:is-derived-from ?subsystemType.
?subsystemType fta:name ?subsystemName.
OPTIONAL{?subsystemType fta:alt-name ?subsystemAltName}
?subsystemType fta:ata-code ?ataCode.
}
}
}
} GROUP BY ?uri ?type ?name ?description ?status ?created ?modified ?creator ?lastEditor
?rootEvent ?rootEventType ?calculatedFailureRate ?auxiliary ?failureRate ?failureRateRequirement
?requiredFailureRate ?fhaFailureRateQ ?fhaFailureRateP ?fhaBasedFailureRate ?behavior
?_subsystemUri ?systemUri ?systemName ?subsystemUri ?subsystemType ?subsystemName ?ataCode
}
}""", "FaultTreeSummary")
.setParameter("type", typeUri)
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package cz.cvut.kbss.analysis.model;


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

import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;

Expand Down Expand Up @@ -43,6 +45,12 @@ public class FaultTreeSummary extends ManagedEntity{
@OWLDataProperty(iri = Vocabulary.s_p_subsystem_name)
protected String subsystemName;

@OWLDataProperty(iri = Vocabulary.s_p_ata_code, simpleLiteral = true)
private String ataCode;

@OWLDataProperty(iri = Vocabulary.s_p_alt_name)
protected String subsystemAltNames;

@OWLDataProperty(iri = Vocabulary.s_p_required_failure_rate)
protected Double requiredFailureRate;

Expand All @@ -69,16 +77,26 @@ public void copyTo(FaultTree faultTree){
rootType.setAuxiliary(auxiliary);
}
}

if(this.getSystemUri() != null){
faultTree.setSystem(new System());
faultTree.getSystem().setUri(this.getSystemUri());
faultTree.getSystem().setName(this.getSystemName());
}

if(this.getSubsystemUri() != null){
faultTree.setSubsystem(new Item());
faultTree.getSubsystem().setUri(this.getSubsystemUri());
faultTree.getSubsystem().setName(this.getSubsystemName());
ATASystem subsystem = new ATASystem();
subsystem.setUri(this.getSubsystemUri());
subsystem.setName(this.getSubsystemName());
subsystem.setAtaCode(this.getAtaCode());
subsystem.setAltNames(Optional.ofNullable(this.getSubsystemAltNames())
.filter(ns -> !ns.isBlank())
.map(ns -> new HashSet<>(Arrays.asList(ns.split("\\n"))))
.orElse(null)
);
faultTree.setSubsystem(subsystem);
}

Optional.ofNullable(this.getStatus()).map(Status::valueOf).ifPresent(faultTree::setStatus);
faultTree.setRequiredFailureRate(this.getRequiredFailureRate());
faultTree.setCalculatedFailureRate(this.getCalculatedFailureRate());
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cz/cvut/kbss/analysis/model/NamedEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.Getter;
import lombok.Setter;

import java.util.Set;

@SparqlResultSetMappings(
@SparqlResultSetMapping(name="Summary", entities = {
@EntityResult(entityClass=NamedEntity.class)
Expand All @@ -21,6 +23,8 @@ public class NamedEntity extends AbstractEntity{
@OWLDataProperty(iri = Vocabulary.s_p_name)
private String name;

@OWLDataProperty(iri = Vocabulary.s_p_alt_name)
private Set<String> altNames;

@OWLDataProperty(iri = Vocabulary.s_p_description)
private String description;
Expand Down

0 comments on commit 758c5b0

Please sign in to comment.