Skip to content
Snippets Groups Projects
Commit 0eb6972d authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

Merge branch 'add_logs' into 'master'

add logs for each API call and each time something is saved in the DB



See merge request !26
parents ede06671 07f64cd0
Branches
Tags
No related merge requests found
...@@ -49,6 +49,8 @@ public class AppsApi { ...@@ -49,6 +49,8 @@ public class AppsApi {
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Iterable> getApps( public ResponseEntity<Iterable> getApps(
) { ) {
LOGGER.info("Get apps");
return ResponseEntity.ok(appRepository.findAll()); return ResponseEntity.ok(appRepository.findAll());
} }
...@@ -59,6 +61,8 @@ public class AppsApi { ...@@ -59,6 +61,8 @@ public class AppsApi {
@ApiParam(value = "id", required = true) @PathVariable("id") Integer id, @ApiParam(value = "id", required = true) @PathVariable("id") Integer id,
@ApiParam(value = "value", required = true) @PathVariable("value") Integer value @ApiParam(value = "value", required = true) @PathVariable("value") Integer value
) { ) {
LOGGER.info("Post a vote");
User user = userRepository.findOne(securityConfiguration.getUser().getUsername()); User user = userRepository.findOne(securityConfiguration.getUser().getUsername());
App app = appRepository.findOne(id); App app = appRepository.findOne(id);
Vote vote; Vote vote;
...@@ -78,6 +82,8 @@ public class AppsApi { ...@@ -78,6 +82,8 @@ public class AppsApi {
vote.setValue(value); vote.setValue(value);
voteRepository.save(vote); voteRepository.save(vote);
LOGGER.info("Vote saved");
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }
......
...@@ -45,6 +45,7 @@ public class ArticlesApi { ...@@ -45,6 +45,7 @@ public class ArticlesApi {
@ApiParam(value = "Only ask results matching status", allowableValues = "{values=[draft, published, closed]}") @RequestParam(value = "status", required = false) String status, @ApiParam(value = "Only ask results matching status", allowableValues = "{values=[draft, published, closed]}") @RequestParam(value = "status", required = false) String status,
@ApiParam(value = "Only ask articles from own team") @RequestParam(value = "team", required = false) Boolean team @ApiParam(value = "Only ask articles from own team") @RequestParam(value = "team", required = false) Boolean team
) { ) {
LOGGER.info("Get articles");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
Iterable<Article> articles; Iterable<Article> articles;
...@@ -80,6 +81,7 @@ public class ArticlesApi { ...@@ -80,6 +81,7 @@ public class ArticlesApi {
public ResponseEntity<Void> addAnArticle( public ResponseEntity<Void> addAnArticle(
@RequestBody @ApiParam(value = "Article to create", required = true) @Valid Article article @RequestBody @ApiParam(value = "Article to create", required = true) @Valid Article article
) { ) {
LOGGER.info("Create an article");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
...@@ -129,6 +131,8 @@ public class ArticlesApi { ...@@ -129,6 +131,8 @@ public class ArticlesApi {
} }
articleRepository.save(article); articleRepository.save(article);
LOGGER.info("Article saved");
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }
...@@ -139,6 +143,7 @@ public class ArticlesApi { ...@@ -139,6 +143,7 @@ public class ArticlesApi {
public ResponseEntity<Article> getAnArticle( public ResponseEntity<Article> getAnArticle(
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug
) { ) {
LOGGER.info("Get an article");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
Article article; Article article;
...@@ -147,6 +152,7 @@ public class ArticlesApi { ...@@ -147,6 +152,7 @@ public class ArticlesApi {
{ {
return new ResponseEntity<>(HttpStatus.FORBIDDEN); return new ResponseEntity<>(HttpStatus.FORBIDDEN);
} }
return ResponseEntity.ok(article); return ResponseEntity.ok(article);
} }
...@@ -158,6 +164,7 @@ public class ArticlesApi { ...@@ -158,6 +164,7 @@ public class ArticlesApi {
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug,
@RequestBody @ApiParam(value = "Article to update", required = true) @Valid Article article @RequestBody @ApiParam(value = "Article to update", required = true) @Valid Article article
) { ) {
LOGGER.info("Update an article");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
...@@ -189,6 +196,8 @@ public class ArticlesApi { ...@@ -189,6 +196,8 @@ public class ArticlesApi {
articleRepository.save(article); articleRepository.save(article);
LOGGER.info("Article updated");
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
......
...@@ -8,6 +8,7 @@ package eu.hbp.mip.controllers; ...@@ -8,6 +8,7 @@ package eu.hbp.mip.controllers;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import eu.hbp.mip.model.Dataset; import eu.hbp.mip.model.Dataset;
import eu.hbp.mip.repositories.DatasetRepository; import eu.hbp.mip.repositories.DatasetRepository;
import org.apache.log4j.Logger;
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.PathVariable;
...@@ -22,6 +23,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -22,6 +23,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Api(value = "/datasets", description = "the datasets API") @Api(value = "/datasets", description = "the datasets API")
public class DatasetsApi { public class DatasetsApi {
private static final Logger LOGGER = Logger.getLogger(DatasetsApi.class);
@Autowired @Autowired
DatasetRepository datasetRepository; DatasetRepository datasetRepository;
...@@ -31,6 +34,8 @@ public class DatasetsApi { ...@@ -31,6 +34,8 @@ public class DatasetsApi {
public ResponseEntity<Dataset> getADataset( public ResponseEntity<Dataset> getADataset(
@ApiParam(value = "code", required = true) @PathVariable("code") String code @ApiParam(value = "code", required = true) @PathVariable("code") String code
) { ) {
LOGGER.info("Get a dataset");
return ResponseEntity.ok(datasetRepository.findOne(code)); return ResponseEntity.ok(datasetRepository.findOne(code));
} }
......
...@@ -72,6 +72,8 @@ public class ExperimentApi { ...@@ -72,6 +72,8 @@ public class ExperimentApi {
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> runExperiment(@RequestBody String incomingQueryString) { public ResponseEntity<String> runExperiment(@RequestBody String incomingQueryString) {
LOGGER.info("Run an experiment");
JsonObject incomingQuery = gson.fromJson(incomingQueryString, JsonObject.class); JsonObject incomingQuery = gson.fromJson(incomingQueryString, JsonObject.class);
Experiment experiment = new Experiment(); Experiment experiment = new Experiment();
...@@ -85,6 +87,8 @@ public class ExperimentApi { ...@@ -85,6 +87,8 @@ public class ExperimentApi {
experiment.setModel(modelRepository.findOne(incomingQuery.get("model").getAsString())); experiment.setModel(modelRepository.findOne(incomingQuery.get("model").getAsString()));
experimentRepository.save(experiment); experimentRepository.save(experiment);
LOGGER.info("Experiment saved");
try { try {
if(isExaremeAlgo(experiment)) if(isExaremeAlgo(experiment))
{ {
...@@ -103,6 +107,8 @@ public class ExperimentApi { ...@@ -103,6 +107,8 @@ public class ExperimentApi {
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @RequestMapping(value = "/{uuid}", method = RequestMethod.GET)
public ResponseEntity<String> getExperiment(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { public ResponseEntity<String> getExperiment(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
LOGGER.info("Get an experiment");
Experiment experiment; Experiment experiment;
UUID experimentUuid; UUID experimentUuid;
try { try {
...@@ -121,10 +127,11 @@ public class ExperimentApi { ...@@ -121,10 +127,11 @@ public class ExperimentApi {
return new ResponseEntity<>(gson.toJson(experiment), HttpStatus.OK); return new ResponseEntity<>(gson.toJson(experiment), HttpStatus.OK);
} }
@ApiOperation(value = "get an experiment", response = Experiment.class) @ApiOperation(value = "Mark an experiment as viewed", response = Experiment.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(value = "/{uuid}/markAsViewed", method = RequestMethod.GET) @RequestMapping(value = "/{uuid}/markAsViewed", method = RequestMethod.GET)
public ResponseEntity<String> markExperimentAsViewed(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { public ResponseEntity<String> markExperimentAsViewed(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
LOGGER.info("Mark an experiment as viewed");
Experiment experiment; Experiment experiment;
UUID experimentUuid; UUID experimentUuid;
...@@ -142,20 +149,27 @@ public class ExperimentApi { ...@@ -142,20 +149,27 @@ public class ExperimentApi {
return new ResponseEntity<>("You're not the owner of this experiment", HttpStatus.BAD_REQUEST); return new ResponseEntity<>("You're not the owner of this experiment", HttpStatus.BAD_REQUEST);
experiment.setResultsViewed(true); experiment.setResultsViewed(true);
experimentRepository.save(experiment); experimentRepository.save(experiment);
LOGGER.info("Experiment updated (marked as viewed)");
return new ResponseEntity<>(gson.toJson(experiment), HttpStatus.OK); return new ResponseEntity<>(gson.toJson(experiment), HttpStatus.OK);
} }
@ApiOperation(value = "get an experiment", response = Experiment.class) @ApiOperation(value = "Mark an experiment as shared", response = Experiment.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(value = "/{uuid}/markAsShared", method = RequestMethod.GET) @RequestMapping(value = "/{uuid}/markAsShared", method = RequestMethod.GET)
public ResponseEntity<String> markExperimentAsShared(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { public ResponseEntity<String> markExperimentAsShared(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
LOGGER.info("Mark an experiment as shared");
return doMarkExperimentAsShared(uuid, true); return doMarkExperimentAsShared(uuid, true);
} }
@ApiOperation(value = "get an experiment", response = Experiment.class) @ApiOperation(value = "Mark an experiment as unshared", response = Experiment.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(value = "/{uuid}/markAsUnshared", method = RequestMethod.GET) @RequestMapping(value = "/{uuid}/markAsUnshared", method = RequestMethod.GET)
public ResponseEntity<String> markExperimentAsUnshared(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { public ResponseEntity<String> markExperimentAsUnshared(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) {
LOGGER.info("Mark an experiment as unshared");
return doMarkExperimentAsShared(uuid, false); return doMarkExperimentAsShared(uuid, false);
} }
...@@ -165,6 +179,8 @@ public class ExperimentApi { ...@@ -165,6 +179,8 @@ public class ExperimentApi {
public ResponseEntity<String> listExperiments( public ResponseEntity<String> listExperiments(
@ApiParam(value = "maxResultCount", required = false) @RequestParam int maxResultCount @ApiParam(value = "maxResultCount", required = false) @RequestParam int maxResultCount
) { ) {
LOGGER.info("List experiments");
return doListExperiments(true, maxResultCount, null); return doListExperiments(true, maxResultCount, null);
} }
...@@ -175,6 +191,7 @@ public class ExperimentApi { ...@@ -175,6 +191,7 @@ public class ExperimentApi {
@ApiParam(value = "slug", required = false) @RequestParam("slug") String modelSlug, @ApiParam(value = "slug", required = false) @RequestParam("slug") String modelSlug,
@ApiParam(value = "maxResultCount", required = false) @RequestParam("maxResultCount") int maxResultCount @ApiParam(value = "maxResultCount", required = false) @RequestParam("maxResultCount") int maxResultCount
) { ) {
LOGGER.info("List experiments");
if (maxResultCount <= 0 && (modelSlug == null || "".equals(modelSlug))) { if (maxResultCount <= 0 && (modelSlug == null || "".equals(modelSlug))) {
return new ResponseEntity<>("You must provide at least a slug or a limit of result", HttpStatus.BAD_REQUEST); return new ResponseEntity<>("You must provide at least a slug or a limit of result", HttpStatus.BAD_REQUEST);
...@@ -187,6 +204,7 @@ public class ExperimentApi { ...@@ -187,6 +204,7 @@ public class ExperimentApi {
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(path = "/methods", method = RequestMethod.GET) @RequestMapping(path = "/methods", method = RequestMethod.GET)
public ResponseEntity<String> listAvailableMethodsAndValidations() throws IOException { public ResponseEntity<String> listAvailableMethodsAndValidations() throws IOException {
LOGGER.info("List available methods and validations");
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
...@@ -260,6 +278,8 @@ public class ExperimentApi { ...@@ -260,6 +278,8 @@ public class ExperimentApi {
experiment.setShared(shared); experiment.setShared(shared);
experimentRepository.save(experiment); experimentRepository.save(experiment);
LOGGER.info("Experiment updated (marked as shared)");
return new ResponseEntity<>(gson.toJson(experiment), HttpStatus.OK); return new ResponseEntity<>(gson.toJson(experiment), HttpStatus.OK);
} }
...@@ -314,6 +334,8 @@ public class ExperimentApi { ...@@ -314,6 +334,8 @@ public class ExperimentApi {
{ {
experiment.setFinished(new Date()); experiment.setFinished(new Date());
experimentRepository.save(experiment); experimentRepository.save(experiment);
LOGGER.info("Experiment updated (finished)");
} }
private static void executeExperiment(String url, String query, Experiment experiment) throws IOException { private static void executeExperiment(String url, String query, Experiment experiment) throws IOException {
......
...@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiResponse; ...@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import eu.hbp.mip.model.Group; import eu.hbp.mip.model.Group;
import eu.hbp.mip.repositories.GroupRepository; import eu.hbp.mip.repositories.GroupRepository;
import org.apache.log4j.Logger;
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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -23,6 +24,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -23,6 +24,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Api(value = "/groups", description = "the groups API") @Api(value = "/groups", description = "the groups API")
public class GroupsApi { public class GroupsApi {
private static final Logger LOGGER = Logger.getLogger(GroupsApi.class);
private static final String ROOT_CODE = "root"; private static final String ROOT_CODE = "root";
@Autowired @Autowired
...@@ -32,6 +35,8 @@ public class GroupsApi { ...@@ -32,6 +35,8 @@ public class GroupsApi {
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Group> getTheRootGroup() { public ResponseEntity<Group> getTheRootGroup() {
LOGGER.info("Get root group and its whole sub-groups tree");
return ResponseEntity.ok(groupRepository.findOne(ROOT_CODE)); return ResponseEntity.ok(groupRepository.findOne(ROOT_CODE));
} }
......
...@@ -64,6 +64,7 @@ public class ModelsApi { ...@@ -64,6 +64,7 @@ public class ModelsApi {
@ApiParam(value = "Only ask models from own team") @RequestParam(value = "team", required = false) Boolean team, @ApiParam(value = "Only ask models from own team") @RequestParam(value = "team", required = false) Boolean team,
@ApiParam(value = "Only ask published models") @RequestParam(value = "valid", required = false) Boolean valid @ApiParam(value = "Only ask published models") @RequestParam(value = "valid", required = false) Boolean valid
) { ) {
LOGGER.info("Get models");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
Iterable<Model> models = null; Iterable<Model> models = null;
...@@ -102,6 +103,8 @@ public class ModelsApi { ...@@ -102,6 +103,8 @@ public class ModelsApi {
@RequestBody @ApiParam(value = "Model to create", required = true) Model model @RequestBody @ApiParam(value = "Model to create", required = true) Model model
) { ) {
LOGGER.info("Create a model");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
model.setTitle(model.getConfig().getTitle().get("text")); model.setTitle(model.getConfig().getTitle().get("text"));
...@@ -160,6 +163,8 @@ public class ModelsApi { ...@@ -160,6 +163,8 @@ public class ModelsApi {
datasetRepository.save(model.getDataset()); datasetRepository.save(model.getDataset());
modelRepository.save(model); modelRepository.save(model);
LOGGER.info("Model saved (also saved model.config, model.query and model.dataset)");
return new ResponseEntity<Model>(HttpStatus.CREATED).ok(model); return new ResponseEntity<Model>(HttpStatus.CREATED).ok(model);
} }
...@@ -169,6 +174,7 @@ public class ModelsApi { ...@@ -169,6 +174,7 @@ public class ModelsApi {
public ResponseEntity<Model> getAModel( public ResponseEntity<Model> getAModel(
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug
) { ) {
LOGGER.info("Get a model");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
...@@ -226,6 +232,7 @@ public class ModelsApi { ...@@ -226,6 +232,7 @@ public class ModelsApi {
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug,
@RequestBody @ApiParam(value = "Model to update", required = true) Model model @RequestBody @ApiParam(value = "Model to update", required = true) Model model
) { ) {
LOGGER.info("Update a model");
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
...@@ -267,6 +274,8 @@ public class ModelsApi { ...@@ -267,6 +274,8 @@ public class ModelsApi {
datasetRepository.save(model.getDataset()); datasetRepository.save(model.getDataset());
modelRepository.save(model); modelRepository.save(model);
LOGGER.info("Model updated (also saved/updated model.config, model.query and model.dataset)");
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
......
...@@ -8,6 +8,7 @@ import io.swagger.annotations.*; ...@@ -8,6 +8,7 @@ import io.swagger.annotations.*;
import eu.hbp.mip.model.Dataset; import eu.hbp.mip.model.Dataset;
import eu.hbp.mip.model.Query; import eu.hbp.mip.model.Query;
import eu.hbp.mip.utils.CSVUtil; import eu.hbp.mip.utils.CSVUtil;
import org.apache.log4j.Logger;
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.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -22,17 +23,21 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -22,17 +23,21 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Api(value = "/queries/requests", description = "the requests API") @Api(value = "/queries/requests", description = "the requests API")
public class RequestsApi { public class RequestsApi {
private static final Logger LOGGER = Logger.getLogger(RequestsApi.class);
private static final String DATA_FILE = "data/values.csv"; private static final String DATA_FILE = "data/values.csv";
@Autowired @Autowired
CSVUtil csvUtil; CSVUtil csvUtil;
@ApiOperation(value = "Send a request", response = Dataset.class) @ApiOperation(value = "Post a request", response = Dataset.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Dataset> postRequests( public ResponseEntity<Dataset> postRequests(
@RequestBody @ApiParam(value = "Query to process", required = true) Query query @RequestBody @ApiParam(value = "Query to process", required = true) Query query
) { ) {
LOGGER.info("Post a request");
return ResponseEntity.ok(csvUtil.parseValues(DATA_FILE, query)); return ResponseEntity.ok(csvUtil.parseValues(DATA_FILE, query));
} }
......
...@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiResponses; ...@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiResponses;
import eu.hbp.mip.model.GeneralStats; import eu.hbp.mip.model.GeneralStats;
import eu.hbp.mip.repositories.ArticleRepository; import eu.hbp.mip.repositories.ArticleRepository;
import eu.hbp.mip.repositories.UserRepository; import eu.hbp.mip.repositories.UserRepository;
import org.apache.log4j.Logger;
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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -25,6 +26,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -25,6 +26,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Api(value = "/stats", description = "the stats API") @Api(value = "/stats", description = "the stats API")
public class StatsApi { public class StatsApi {
private static final Logger LOGGER = Logger.getLogger(StatsApi.class);
@Autowired @Autowired
UserRepository userRepository; UserRepository userRepository;
...@@ -38,6 +41,7 @@ public class StatsApi { ...@@ -38,6 +41,7 @@ public class StatsApi {
@ApiResponses(value = {@ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) @ApiResponses(value = {@ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") })
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
public ResponseEntity<GeneralStats> getGeneralStatistics() { public ResponseEntity<GeneralStats> getGeneralStatistics() {
LOGGER.info("Get statistics (count on users, articles and variables)");
GeneralStats stats = new GeneralStats(); GeneralStats stats = new GeneralStats();
......
...@@ -7,6 +7,7 @@ package eu.hbp.mip.controllers; ...@@ -7,6 +7,7 @@ package eu.hbp.mip.controllers;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import eu.hbp.mip.model.User; import eu.hbp.mip.model.User;
import eu.hbp.mip.repositories.UserRepository; import eu.hbp.mip.repositories.UserRepository;
import org.apache.log4j.Logger;
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.PathVariable;
...@@ -21,6 +22,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -21,6 +22,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Api(value = "/users", description = "the users API") @Api(value = "/users", description = "the users API")
public class UsersApi { public class UsersApi {
private static final Logger LOGGER = Logger.getLogger(UsersApi.class);
@Autowired @Autowired
UserRepository userRepository; UserRepository userRepository;
...@@ -30,6 +33,8 @@ public class UsersApi { ...@@ -30,6 +33,8 @@ public class UsersApi {
public ResponseEntity<User> getAUser( public ResponseEntity<User> getAUser(
@ApiParam(value = "username", required = true) @PathVariable("username") String username @ApiParam(value = "username", required = true) @PathVariable("username") String username
) { ) {
LOGGER.info("Get a user");
return ResponseEntity.ok(userRepository.findOne(username)); return ResponseEntity.ok(userRepository.findOne(username));
} }
} }
...@@ -9,6 +9,7 @@ import eu.hbp.mip.repositories.VariableRepository; ...@@ -9,6 +9,7 @@ import eu.hbp.mip.repositories.VariableRepository;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import eu.hbp.mip.model.Value; import eu.hbp.mip.model.Value;
import eu.hbp.mip.model.Variable; import eu.hbp.mip.model.Variable;
import org.apache.log4j.Logger;
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.*; import org.springframework.web.bind.annotation.*;
...@@ -22,6 +23,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; ...@@ -22,6 +23,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Api(value = "/variables", description = "the variables API") @Api(value = "/variables", description = "the variables API")
public class VariablesApi { public class VariablesApi {
private static final Logger LOGGER = Logger.getLogger(VariablesApi.class);
@Autowired @Autowired
VariableRepository variableRepository; VariableRepository variableRepository;
...@@ -36,6 +39,8 @@ public class VariablesApi { ...@@ -36,6 +39,8 @@ public class VariablesApi {
@ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isCovariable", required = false) String isCovariable, @ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isCovariable", required = false) String isCovariable,
@ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isFilter", required = false) String isFilter @ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isFilter", required = false) String isFilter
) { ) {
LOGGER.info("Get variables");
return ResponseEntity.ok(variableRepository.findAll()); return ResponseEntity.ok(variableRepository.findAll());
} }
...@@ -45,6 +50,8 @@ public class VariablesApi { ...@@ -45,6 +50,8 @@ public class VariablesApi {
public ResponseEntity<Variable> getAVariable( public ResponseEntity<Variable> getAVariable(
@ApiParam(value = "code of the variable ( multiple codes are allowed, separated by \",\" )", required = true) @PathVariable("code") String code @ApiParam(value = "code of the variable ( multiple codes are allowed, separated by \",\" )", required = true) @PathVariable("code") String code
) { ) {
LOGGER.info("Get a variable");
return ResponseEntity.ok(variableRepository.findOne(code)); return ResponseEntity.ok(variableRepository.findOne(code));
} }
...@@ -56,6 +63,8 @@ public class VariablesApi { ...@@ -56,6 +63,8 @@ public class VariablesApi {
@ApiParam(value = "code", required = true) @PathVariable("code") String code, @ApiParam(value = "code", required = true) @PathVariable("code") String code,
@ApiParam(value = "Pattern to match") @RequestParam(value = "q", required = false) String q @ApiParam(value = "Pattern to match") @RequestParam(value = "q", required = false) String q
) { ) {
LOGGER.info("Get values from a variable");
return ResponseEntity.ok(variableRepository.findOne(code).getValues()); return ResponseEntity.ok(variableRepository.findOne(code).getValues());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment