add AnomalyController
This commit is contained in:
parent
292e774d8e
commit
a8b6cf7d29
40
src/main/java/ru/ulstu/controller/AnomalyController.java
Normal file
40
src/main/java/ru/ulstu/controller/AnomalyController.java
Normal file
@ -0,0 +1,40 @@
|
||||
package ru.ulstu.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.configuration.ApiConfiguration;
|
||||
import ru.ulstu.datamodel.exception.ModelingException;
|
||||
import ru.ulstu.datamodel.ts.TimeSeries;
|
||||
import ru.ulstu.estimate.CompressionMetricService;
|
||||
import ru.ulstu.service.UtilService;
|
||||
import ru.ulstu.target.AnomalyDifferenceSmoothed;
|
||||
import ru.ulstu.target.Target;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(ApiConfiguration.API_1_0)
|
||||
public class AnomalyController {
|
||||
|
||||
private final UtilService utilService;
|
||||
private final Target target;
|
||||
|
||||
public AnomalyController(UtilService utilService, CompressionMetricService compressionMetricService, AnomalyDifferenceSmoothed anomalyDifferenceSmoothed) {
|
||||
this.utilService = utilService;
|
||||
this.target = anomalyDifferenceSmoothed;
|
||||
}
|
||||
|
||||
@PostMapping("getAnomalyAtDifferenceSmothed")
|
||||
@Operation(description = "Получить метрику сжатия")
|
||||
public ResponseEntity<TimeSeries> getRandomTimeSeries(@RequestParam("length") int length) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
|
||||
var randomTS = utilService.getRandomTimeSeries(length);
|
||||
var tsResult = target.calculate(randomTS);
|
||||
return new ResponseEntity<>( tsResult, HttpStatus.OK);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user