Skip to content

Commit

Permalink
Merge pull request #70 from kbss-cvut/refactor/fta-fmea-ui-198-set-ir…
Browse files Browse the repository at this point in the history
…i-conventions-and-refactor-iris

Refactor/fta fmea UI 198 set iri conventions and refactor iris
  • Loading branch information
blcham authored Mar 18, 2024
2 parents 8ff3a53 + 13d044f commit 9c4d2cf
Show file tree
Hide file tree
Showing 45 changed files with 493 additions and 524 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## Ontology Vocabulary

Vocabulary is generated by maven plugin located in `ontology-generator` subproject.
When ontology definition is changed, the sources need to be regenerated.
When ontology definition is changed, the sources need to be regenerated.
For more details see [README.md](ontology-generator/README.md)

## Persistence

Expand Down
21 changes: 21 additions & 0 deletions ontology-generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Project Description

This project generates the `Vocabulary.java` source file based on the ontology specified in the mapping file.
For more details see configuration in [pom.xml](pom.xml)

## Project structure
- ./ontology - folder containing the ontology files
- ./src/main/resource/mapping - input mapping file used by the jopa-maven-plugin. The file maps ontology IRIs to files
in the ./ontology folder.


## Naming conventions
### RDF resources
- resources should be lower-case with words separated by "-"
- IRI fragment should be separated by "/" instead of "#"
- ontology IRI should start with http://onto.fel.cvut.cz/ontologies/
- resource IRI cannot end with "/" or "#" at the end of the IRI (applies also to ontology IRI)

### OWL resources
- object property should be named with "has-" and "is-" prefix
- datatype property should be named without "has-" and "is-" prefix
571 changes: 280 additions & 291 deletions ontology-generator/ontology/fta-fmea-model.ttl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import cz.cvut.kbss.analysis.model.FailureMode;
import cz.cvut.kbss.analysis.model.Function;
import cz.cvut.kbss.analysis.service.ComponentRepositoryService;
import cz.cvut.kbss.analysis.service.FunctionRepositoryService;
import cz.cvut.kbss.analysis.service.IdentifierService;
import cz.cvut.kbss.analysis.util.Vocabulary;
import cz.cvut.kbss.jsonld.JsonLd;
Expand Down Expand Up @@ -53,29 +52,29 @@ public Component update(@RequestBody ComponentUpdateDTO componentUpdate) {
public void delete(@PathVariable(name = "componentFragment") String componentFragment) {
log.info("> delete - {}", componentFragment);

URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
repositoryService.remove(componentUri);
}

@GetMapping(value = "/{componentFragment}/functions", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE})
public Set<Function> getFunctions(@PathVariable(name = "componentFragment") String componentFragment) {
log.info("> getFunctions - {}", componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
return repositoryService.getFunctions(componentUri);
}

@GetMapping(value = "/{componentFragment}/failureModes", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE})
public Set<FailureMode> getFailureModes(@PathVariable(name = "componentFragment") String componentFragment) {
log.info("> getFailureModes - {}", componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
return repositoryService.getFailureModes(componentUri);
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = "/{componentFragment}/failureModes", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public FailureMode addFailureMode(@PathVariable(name = "componentFragment") String componentFragment, @RequestBody FailureMode failureMode) {
log.info("> addFailureMode - {}, {}", componentFragment, failureMode);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);

return repositoryService.addFailureMode(componentUri,failureMode);
}
Expand All @@ -84,16 +83,16 @@ public FailureMode addFailureMode(@PathVariable(name = "componentFragment") Stri
@PostMapping(value = "/{componentFragment}/failureModes/{failureModeFragment}", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public void addFailureModeByURI(@PathVariable(name = "componentFragment") String componentFragment, @PathVariable(name = "failureModeFragment") String failureModeFragment) {
log.info("> addFailureModeByUri - {}, {}", componentFragment, failureModeFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
repositoryService.addFailureModeByUri(componentUri, failureModeUri);
}

@DeleteMapping(value = "/{componentFragment}/failureModes/{failureModeFragment}")
public void deleteFailureMode(@PathVariable(name = "componentFragment") String componentFragment, @PathVariable(name = "failureModeFragment") String failureModeFragment) {
log.info("> deleteFailureMode - {}, {}", componentFragment, failureModeFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);

repositoryService.deleteFailureMode(componentUri, failureModeUri);
log.info("< deleteFailureMode");
Expand All @@ -103,7 +102,7 @@ public void deleteFailureMode(@PathVariable(name = "componentFragment") String c
@PostMapping(value = "/{componentFragment}/functions", consumes = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public Function addFunction(@PathVariable(name = "componentFragment") String componentFragment, @RequestBody Function function) {
log.info("> addFunction - {}, {}", componentFragment, function);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);

return repositoryService.addFunction(componentUri, function);
}
Expand All @@ -112,17 +111,17 @@ public Function addFunction(@PathVariable(name = "componentFragment") String com
@PostMapping(value = "/{componentFragment}/functions/{functionFragment}", produces = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public Function addFunctionByURI(@PathVariable(name = "componentFragment") String componentFragment, @PathVariable(name = "functionFragment") String functionFragment) {
log.info("> addFunction - {}, {}", componentFragment, functionFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI functionUri = identifierService.composeIdentifier(Vocabulary.s_c_Function, functionFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
URI functionUri = identifierService.composeIdentifier(Vocabulary.s_c_function, functionFragment);

return repositoryService.addFunctionByURI(componentUri, functionUri);
}

@DeleteMapping(value = "/{componentFragment}/functions/{functionFragment}")
public void deleteFunction(@PathVariable(name = "componentFragment") String componentFragment, @PathVariable(name = "functionFragment") String functionFragment) {
log.info("> deleteFunction - {}, {}", componentFragment, functionFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI functionUri = identifierService.composeIdentifier(Vocabulary.s_c_Function, functionFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
URI functionUri = identifierService.composeIdentifier(Vocabulary.s_c_function, functionFragment);

repositoryService.deleteFunction(componentUri, functionUri);
log.info("< deleteFunction");
Expand All @@ -133,16 +132,16 @@ public Component linkComponents(
@PathVariable(name = "componentFragment") String componentFragment,
@PathVariable(name = "linkFragment") String linkFragment) {
log.info("> addFunction - {}, {}", componentFragment, linkFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI linkComponentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, linkFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);
URI linkComponentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, linkFragment);

return repositoryService.linkComponents(componentUri, linkComponentUri);
}

@DeleteMapping(value = "/{componentFragment}/linkComponent")
public void unlinkComponents(@PathVariable(name = "componentFragment") String componentFragment) {
log.info("> unlinkComponents - {}", componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, componentFragment);
URI componentUri = identifierService.composeIdentifier(Vocabulary.s_c_component, componentFragment);

repositoryService.unlinkComponents(componentUri);
log.info("< unlinkComponents");
Expand All @@ -153,8 +152,8 @@ public void mergeComponents(@PathVariable(name = "sourceFragment") String source
,@PathVariable(name = "targetFragment") String targetFragment){
log.info("> mergeComponents - {} {}", sourceFragment, targetFragment);

URI sourceUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, sourceFragment);
URI targetUri = identifierService.composeIdentifier(Vocabulary.s_c_Component, targetFragment);
URI sourceUri = identifierService.composeIdentifier(Vocabulary.s_c_component, sourceFragment);
URI targetUri = identifierService.composeIdentifier(Vocabulary.s_c_component, targetFragment);

repositoryService.mergeComponents(sourceUri, targetUri);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cz.cvut.kbss.analysis.controller;

import cz.cvut.kbss.analysis.model.*;
import cz.cvut.kbss.analysis.service.ComponentRepositoryService;
import cz.cvut.kbss.analysis.model.FailureMode;
import cz.cvut.kbss.analysis.service.FailureModeRepositoryService;
import cz.cvut.kbss.analysis.service.IdentifierService;
import cz.cvut.kbss.analysis.util.Vocabulary;
Expand All @@ -11,8 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

import java.net.URI;
Expand All @@ -36,7 +33,7 @@ public List<FailureMode> findAll() {
@GetMapping(value = "/{failureModeFragment}", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE})
public FailureMode findFailureMode(@PathVariable(name = "failureModeFragment") String failureModeFragment) {
log.info("> findFailureMode - {}", failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
return repositoryService.findRequired(failureModeUri);
}

Expand All @@ -62,75 +59,75 @@ public FailureMode update(@RequestBody FailureMode failureMode) {
public void delete(@PathVariable(name = "failureModeFragment") String failureModeFragment) {
log.info("> delete - {}", failureModeFragment);

URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
repositoryService.remove(failureModeUri);
}

@PostMapping(value = "/{failureModeFragment}/impairedBehavior/{impairedBehaviorFragment}")
public FailureMode addImpairedBehavior(@PathVariable(name = "failureModeFragment") String failureModeFragment
, @PathVariable(name = "impairedBehaviorFragment") String impairedBehaviorFragment) {
log.info("> addImpairedBehavior - {}, {}", failureModeFragment, impairedBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI impairedBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_Function, impairedBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
URI impairedBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_function, impairedBehaviorFragment);
return repositoryService.addImpairedBehavior(failureModeUri, impairedBehaviorUri);
}

@DeleteMapping(value = "/{failureModeFragment}/impairedBehavior/{impairedBehaviorFragment}")
public void removeImpairedBehavior(@PathVariable(name = "failureModeFragment") String failureModeFragment
, @PathVariable(name = "impairedBehaviorFragment") String impairedBehaviorFragment) {
log.info("> removeImpairedBehavior - {}, {}", failureModeFragment, impairedBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI impairedBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_Function, impairedBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
URI impairedBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_function, impairedBehaviorFragment);
repositoryService.removeImpairedBehavior(failureModeUri, impairedBehaviorUri);
}

@PostMapping(value = "/{failureModeFragment}/requiredBehavior/{requiredBehaviorFragment}")
public void addRequiredBehavior(@PathVariable(name = "failureModeFragment") String failureModeFragment
, @PathVariable(name = "requiredBehaviorFragment") String requiredBehaviorFragment) {
log.info("> addRequiredBehavior - {}, {}", failureModeFragment, requiredBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI requiredBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, requiredBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
URI requiredBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, requiredBehaviorFragment);
repositoryService.addRequiredBehavior(failureModeUri, requiredBehaviorUri);
}

@DeleteMapping(value = "/{failureModeFragment}/requiredBehavior/{requiredBehaviorFragment}")
public void removeRequiredBehavior(@PathVariable(name = "failureModeFragment") String failureModeFragment
, @PathVariable(name = "requiredBehaviorFragment") String requiredBehaviorFragment) {
log.info("> removeRequiredBehavior - {}, {}", failureModeFragment, requiredBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI requiredBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, requiredBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
URI requiredBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, requiredBehaviorFragment);
repositoryService.removeRequiredBehavior(failureModeUri, requiredBehaviorUri);
}

@PostMapping(value = "/{failureModeFragment}/childBehavior/{childBehaviorFragment}")
public void addChildBehavior(@PathVariable(name = "failureModeFragment") String failureModeFragment
, @PathVariable(name = "childBehaviorFragment") String childBehaviorFragment) {
log.info("> addChildBehavior - {}, {}", failureModeFragment, childBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI childBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, childBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
URI childBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, childBehaviorFragment);
repositoryService.addChildBehavior(failureModeUri, childBehaviorUri);
}

@DeleteMapping(value = "/{failureModeFragment}/childBehavior/{childBehaviorFragment}")
public void removeChildBehavior(@PathVariable(name = "failureModeFragment") String failureModeFragment
, @PathVariable(name = "childBehaviorFragment") String childBehaviorFragment) {
log.info("> removeChildBehavior - {}, {}", failureModeFragment, childBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI childBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, childBehaviorFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
URI childBehaviorUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, childBehaviorFragment);
repositoryService.removeChildBehavior(failureModeUri, childBehaviorUri);
}

@GetMapping(value = "/{failureModeFragment}/childTransitiveClosure", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE})
public Set<URI> getChildTransitiveClosure(@PathVariable(name = "failureModeFragment") String failureModeFragment) {
log.info("> getChildTransitiveClosure - {}", failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
return repositoryService.getTransitiveClosure(failureModeUri, "child");
}

@GetMapping(value = "/{failureModeFragment}/requiredTransitiveClosure", produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE})
public Set<URI> getRequiredTransitiveClosure(@PathVariable(name = "failureModeFragment") String failureModeFragment) {
log.info("> getRequiredTransitiveClosure - {}", failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureMode, failureModeFragment);
URI failureModeUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_mode, failureModeFragment);
return repositoryService.getTransitiveClosure(failureModeUri, "required");
}
}
Loading

0 comments on commit 9c4d2cf

Please sign in to comment.