Skip to content

Commit

Permalink
[Fix kbss-cvut/fta-fmea-ui#198] Refactor Vocabulary usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kostobog committed Mar 14, 2024
1 parent a43d61f commit e37376a
Show file tree
Hide file tree
Showing 42 changed files with 168 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,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 +84,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 +103,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 +112,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 +133,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 +153,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
Expand Up @@ -36,7 +36,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 +62,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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ public FailureModesTable update(@RequestBody FailureModesTableUpdateDTO tableUpd
public void delete(@PathVariable(name = "failureModeTableFragment") String failureModeTableFragment) {
log.info("> delete - {}", failureModeTableFragment);

URI tableUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureModesTable, failureModeTableFragment);
URI tableUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_modes_table, failureModeTableFragment);
repositoryService.remove(tableUri);
}

@GetMapping(value = "/{failureModeTableFragment}/computeTableData")
public FailureModesTableDataDTO computeTableData(@PathVariable(name = "failureModeTableFragment") String failureModeTableFragment) {
log.info("> computeTableData - {}", failureModeTableFragment);

URI tableUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureModesTable, failureModeTableFragment);
URI tableUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_modes_table, failureModeTableFragment);
return repositoryService.computeTableData(tableUri);
}

@GetMapping(value = "/{failureModeTableFragment}/export", produces = "text/csv")
public String export(@PathVariable(name = "failureModeTableFragment") String failureModeTableFragment, HttpServletResponse response) {
log.info("> export - {}", failureModeTableFragment);

URI tableUri = identifierService.composeIdentifier(Vocabulary.s_c_FailureModesTable, failureModeTableFragment);
URI tableUri = identifierService.composeIdentifier(Vocabulary.s_c_failure_modes_table, failureModeTableFragment);

response.setContentType("text/csv");
response.addHeader("Content-Disposition", "attachment; filename=\"table.csv\"");
Expand Down
Loading

0 comments on commit e37376a

Please sign in to comment.