Skip to content

Commit

Permalink
[Fix #72] Implement fault event summary API for FHA and SNS failure e…
Browse files Browse the repository at this point in the history
…vent types.
  • Loading branch information
kostobog committed May 9, 2024
1 parent 434fbdb commit a4647ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cz.cvut.kbss.analysis.model.FailureMode;
import cz.cvut.kbss.analysis.model.FaultEvent;
import cz.cvut.kbss.analysis.model.FaultEventType;
import cz.cvut.kbss.analysis.model.diagram.Rectangle;
import cz.cvut.kbss.analysis.service.FaultEventRepositoryService;
import cz.cvut.kbss.analysis.service.IdentifierService;
Expand Down Expand Up @@ -73,6 +74,20 @@ public FailureMode getFailureMode(@PathVariable(name = "faultEventFragment") Str
return repositoryService.getFailureMode(faultEventUri);
}

@GetMapping(value = "/top-fault-events/{systemFragment}", produces = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public List<FaultEventType> getTopFaultEvents(@PathVariable String systemFragment){
log.info("> getFaultEventTypes - {}", systemFragment);
URI systemUri = identifierService.composeIdentifier(Vocabulary.s_c_system, systemFragment);
return repositoryService.getTopFaultEvents(systemUri);
}

@GetMapping(value = "/all-fault-events/{systemFragment}", produces = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public List<FaultEventType> getAllFaultEvents(@PathVariable String systemFragment){
log.info("> getFaultEventTypes - {}", systemFragment);
URI systemUri = identifierService.composeIdentifier(Vocabulary.s_c_system, systemFragment);
return repositoryService.getAllFaultEvents(systemUri);
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = "/{faultEventFragment}/failureMode", consumes = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public FailureMode addFailureMode(@PathVariable(name = "faultEventFragment") String faultEventFragment, @RequestBody FailureMode failureMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,10 @@ protected void setChange(FaultEvent instance){
faultTreeDao.setChangedByContext(context, new Date());
}

public List<FaultEventType> getTopFaultEvents(URI systemUri) {
return faultEventDao.getTopFaultEvents(systemUri);
}
public List<FaultEventType> getAllFaultEvents(URI systemUri) {
return faultEventDao.getAllFaultEvents(systemUri);
}
}

0 comments on commit a4647ad

Please sign in to comment.