@Controller
@RequestMapping("/setting")
public class SettingController
extends java.lang.Object
/setting/**
. All setting
requests including customizing data types and turning on or turning off the
periodically data fetching task are handled by this controller.Modifier and Type | Class | Description |
---|---|---|
private class |
SettingController.RunnableTask |
This is a nested inner class for creating scheduled task to fetching data periodically.
|
Modifier and Type | Field | Description |
---|---|---|
private AbstractAccessBorderRouterService |
accessBorderRouterService |
|
private AbstractAccessSensorService |
accessSensorService |
|
private org.springframework.context.ApplicationContext |
context |
|
private DataFetchingAndMappingService |
dataFetchingAndMappingService |
|
private static org.apache.log4j.Logger |
logger |
|
private org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler |
taskScheduler |
Constructor | Description |
---|---|
SettingController() |
Modifier and Type | Method | Description |
---|---|---|
java.util.List<java.lang.String> |
getAllSensorIp() |
Gets all sensor ip.
|
java.lang.String |
saveBorderRouter(java.lang.String[][] routerIpAndName) |
This handler sets up border router IP addresses for the server.
|
java.util.List<java.lang.String> |
setDataTypes(java.lang.String[] dataTypes) |
This handler accept request to set all data types the user want to query.
|
java.lang.String |
setSensorName(java.lang.String[][] sensorIpAndName) |
Set name for each sensor.
|
java.lang.String |
startSavingData(int period) |
Start the task that periodically saves data.
|
java.lang.String |
stopSavingData() |
Stop the task that periodically saves data if it exists.
|
@Autowired private DataFetchingAndMappingService dataFetchingAndMappingService
@Autowired @Qualifier("mockAccessSensorService") private AbstractAccessSensorService accessSensorService
@Autowired @Qualifier("mockAccessBorderRouterService") private AbstractAccessBorderRouterService accessBorderRouterService
@Autowired private org.springframework.context.ApplicationContext context
@Autowired private org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler taskScheduler
private static final org.apache.log4j.Logger logger
@RequestMapping(value="/dataTypes", method=POST, headers="ModelAttribute=DataTypes", produces="application/json", consumes="application/json") @ResponseBody public java.util.List<java.lang.String> setDataTypes(@RequestBody java.lang.String[] dataTypes)
dataTypeList
gets updated, the sensor_data
table in database will be cleared. Because the number of data fields have been
changed.
The response body contains JSON of the data type list. The input data type list
has to contains at least one data type.dataTypes
- An array of data types string, this array is generated from JSON
request body.@RequestMapping(value="/setBorderRouter", method=POST, headers="ModelAttribute=borderRouterIpAndName", produces="application/json", consumes="application/json") @ResponseBody public java.lang.String saveBorderRouter(@RequestBody java.lang.String[][] routerIpAndName) throws com.fasterxml.jackson.core.JsonProcessingException
routerIpAndName
- The input array of border router IP and name, key-value paircom.fasterxml.jackson.core.JsonProcessingException
@RequestMapping(value="/setSensorName", method=PUT, headers="ModelAttribute=sensorIpAndName", produces="application/json", consumes="application/json") @ResponseBody public java.lang.String setSensorName(@RequestBody java.lang.String[][] sensorIpAndName) throws com.fasterxml.jackson.core.JsonProcessingException
sensorIpAndName
- A 2D String array, each row is a sensorIP-sensorName pair.com.fasterxml.jackson.core.JsonProcessingException
@RequestMapping(value="/getAllSensorIp", method=GET, headers="ModelAttribute=getAllSensorIp", produces="application/json", consumes="application/json") @ResponseBody public java.util.List<java.lang.String> getAllSensorIp()
String
contains all sensor IP addresses.@RequestMapping(value="/startTask/savingData", method=POST, headers="ModelAttribute=startSavingData", produces="application/json", consumes="application/json") @ResponseBody public java.lang.String startSavingData(@RequestParam int period)
period
- The time period between each execution.@RequestMapping(value="/stopTask/savingData", method=POST, headers="ModelAttribute=stopSavingData", produces="application/json", consumes="application/json") @ResponseBody public java.lang.String stopSavingData()