Skip to content
Snippets Groups Projects
Commit eb160204 authored by Manuel Spuhler's avatar Manuel Spuhler
Browse files

Dumb static api

parent f1e84f94
No related branches found
No related tags found
No related merge requests found
...@@ -5,21 +5,22 @@ ...@@ -5,21 +5,22 @@
package eu.hbp.mip.controllers; package eu.hbp.mip.controllers;
import io.swagger.annotations.*; import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import eu.hbp.mip.model.Dataset; import eu.hbp.mip.model.Dataset;
import io.swagger.annotations.*;
import eu.hbp.mip.repositories.DatasetRepository; import eu.hbp.mip.repositories.DatasetRepository;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
// TODO: deprecate this
@RestController @RestController
@RequestMapping(value = "/datasets", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/datasets", produces = {APPLICATION_JSON_VALUE})
...@@ -27,18 +28,30 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -27,18 +28,30 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
public class DatasetsApi { public class DatasetsApi {
private static final Logger LOGGER = LoggerFactory.getLogger(DatasetsApi.class); private static final Logger LOGGER = LoggerFactory.getLogger(DatasetsApi.class);
private static final Gson gson = new Gson();
@Autowired @Autowired
private DatasetRepository datasetRepository; private DatasetRepository datasetRepository;
@ApiOperation(value = "Get a dataset", response = Dataset.class) @ApiOperation(value = "Get dataset list", response = Dataset.class, responseContainer = "List")
@RequestMapping(value = "/{code}", method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Dataset> getADataset( public ResponseEntity getDatasets(
@ApiParam(value = "code", required = true) @PathVariable("code") String code
) { ) {
LOGGER.info("Get a dataset"); LOGGER.info("Get dataset list");
JsonArray datasets = new JsonArray();
JsonObject o = new JsonObject();
o.addProperty("code", "chuv");
o.addProperty("label", "ĈHUV");
datasets.add(o);
JsonObject p = new JsonObject();
p.addProperty("code", "brescia");
p.addProperty("label", "Brescia");
datasets.add(p);
return ResponseEntity.ok(datasetRepository.findOne(code)); return ResponseEntity.ok(gson.toJson(datasets));
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment