diff --git a/ontology-generator/ontology/fta-fmea-model.ttl b/ontology-generator/ontology/fta-fmea-model.ttl index 3dba589..0b7a01a 100644 --- a/ontology-generator/ontology/fta-fmea-model.ttl +++ b/ontology-generator/ontology/fta-fmea-model.ttl @@ -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 ; 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 aaf86d2..d31b9d7 100755 --- a/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java +++ b/src/main/java/cz/cvut/kbss/analysis/dao/FaultTreeDao.java @@ -104,54 +104,63 @@ public Query getSummariesQuery() { return em.createNativeQuery(""" PREFIX fta: 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) 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 23cfe44..c220842 100644 --- a/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java +++ b/src/main/java/cz/cvut/kbss/analysis/model/FaultTreeSummary.java @@ -1,6 +1,7 @@ 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.*; @@ -8,6 +9,7 @@ import lombok.Setter; import java.net.URI; +import java.util.Arrays; import java.util.HashSet; import java.util.Optional; @@ -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; @@ -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()); diff --git a/src/main/java/cz/cvut/kbss/analysis/model/NamedEntity.java b/src/main/java/cz/cvut/kbss/analysis/model/NamedEntity.java index d0e25ac..8cd1d3a 100644 --- a/src/main/java/cz/cvut/kbss/analysis/model/NamedEntity.java +++ b/src/main/java/cz/cvut/kbss/analysis/model/NamedEntity.java @@ -6,6 +6,8 @@ import lombok.Getter; import lombok.Setter; +import java.util.Set; + @SparqlResultSetMappings( @SparqlResultSetMapping(name="Summary", entities = { @EntityResult(entityClass=NamedEntity.class) @@ -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 altNames; @OWLDataProperty(iri = Vocabulary.s_p_description) private String description;