From 9e691005a3ad72b21dec8e6d5f3577a246e320ff Mon Sep 17 00:00:00 2001 From: Mirco Nasuti <mirco.nasuti@chuv.ch> Date: Thu, 28 Jan 2016 15:16:12 +0100 Subject: [PATCH] Many bugfixes, add bug-list in README, cleaned code, and so on --- README.md | 15 ++- src/main/java/org/hbp/mip/MIPApplication.java | 7 +- .../org/hbp/mip/controllers/ApiException.java | 1 - .../hbp/mip/controllers/ApiOriginFilter.java | 1 - .../mip/controllers/ApiResponseMessage.java | 1 - .../org/hbp/mip/controllers/ArticlesApi.java | 114 +++++++++++------ .../org/hbp/mip/controllers/DatasetsApi.java | 17 +-- .../org/hbp/mip/controllers/GroupsApi.java | 12 +- .../org/hbp/mip/controllers/ModelsApi.java | 117 +++++++++++------- .../mip/controllers/NotFoundException.java | 1 - .../org/hbp/mip/controllers/RequestsApi.java | 10 +- .../org/hbp/mip/controllers/UsersApi.java | 15 +-- .../org/hbp/mip/controllers/VariablesApi.java | 50 ++++---- src/main/java/org/hbp/mip/model/Article.java | 5 +- src/main/java/org/hbp/mip/model/Chart.java | 5 +- .../org/hbp/mip/model/ChartConfigSet.java | 5 +- src/main/java/org/hbp/mip/model/Dataset.java | 5 +- src/main/java/org/hbp/mip/model/Filter.java | 5 +- src/main/java/org/hbp/mip/model/Group.java | 5 +- src/main/java/org/hbp/mip/model/Model.java | 5 +- src/main/java/org/hbp/mip/model/Query.java | 5 +- .../java/org/hbp/mip/model/Statistics.java | 3 +- src/main/java/org/hbp/mip/model/Tag.java | 5 +- src/main/java/org/hbp/mip/model/User.java | 5 +- src/main/java/org/hbp/mip/model/Value.java | 5 +- src/main/java/org/hbp/mip/model/Variable.java | 5 +- src/main/resources/hibernate.cfg.xml | 2 +- 27 files changed, 251 insertions(+), 175 deletions(-) diff --git a/README.md b/README.md index 647a99298..1749d33b7 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,22 @@ The API documentation is available at `<BASE URL>/swagger-ui.html`. A JSON versi ## TODO -* Externalize configuration (DB parameters, security enabled/disabled, ...) +* Externalize configuration (DB parameters, security enabled/disabled, ...); * Sync backend with hand written Swagger specs (see Maintenance section below); * Implement logout; * Add some details to the group and variable models like descriptions; -* Update frontend (add introduction page, hide header/footer when not logged in, remove mock authors). +* Update frontend (add introduction page, hide header/footer when not logged in, remove mock authors, real stats like users count); +* Fix bugs; +* Add SoapUI tests. + +## BUGS + +* When adding a model to an article, the data table should be attached to the SVG plot; +* MyData and MyCommunity does not show articles when adding a model; +* Opening an existing model should auto-populate drop-down fields and execute query; +* `See more` buttons do not work (homepage), neither `Articles` and `Models` from the profile page; +* The '3 own models' tiles does not show on the homepage. + ### Maintenance diff --git a/src/main/java/org/hbp/mip/MIPApplication.java b/src/main/java/org/hbp/mip/MIPApplication.java index e06294e80..a80398d84 100644 --- a/src/main/java/org/hbp/mip/MIPApplication.java +++ b/src/main/java/org/hbp/mip/MIPApplication.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.Api; import org.hbp.mip.controllers.HibernateUtil; import org.hbp.mip.model.User; +import org.hibernate.Query; import org.hibernate.Session; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -82,8 +83,7 @@ import java.security.Principal; @RestController @EnableOAuth2Client @Api(value = "/", description = "MIP API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@EnableSwagger2 // available at <BASE URL>/swagger-ui.html +@EnableSwagger2 @Configuration public class MIPApplication extends WebSecurityConfigurerAdapter { @@ -104,7 +104,7 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { public static User getUser(Principal principal) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from User where username= :username"); + Query query = session.createQuery("from User where username= :username"); query.setString("username", principal.getName()); User user = (User) query.uniqueResult(); session.getTransaction().commit(); @@ -112,6 +112,7 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); user = new User(getUserInfos()); + user.setTeam("Default"); session.save(user); session.getTransaction().commit(); } diff --git a/src/main/java/org/hbp/mip/controllers/ApiException.java b/src/main/java/org/hbp/mip/controllers/ApiException.java index ae8590582..ef51b43db 100644 --- a/src/main/java/org/hbp/mip/controllers/ApiException.java +++ b/src/main/java/org/hbp/mip/controllers/ApiException.java @@ -4,7 +4,6 @@ package org.hbp.mip.controllers; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class ApiException extends Exception { private int code; diff --git a/src/main/java/org/hbp/mip/controllers/ApiOriginFilter.java b/src/main/java/org/hbp/mip/controllers/ApiOriginFilter.java index 35717bd8c..e0fb244fc 100644 --- a/src/main/java/org/hbp/mip/controllers/ApiOriginFilter.java +++ b/src/main/java/org/hbp/mip/controllers/ApiOriginFilter.java @@ -8,7 +8,6 @@ import javax.servlet.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class ApiOriginFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/src/main/java/org/hbp/mip/controllers/ApiResponseMessage.java b/src/main/java/org/hbp/mip/controllers/ApiResponseMessage.java index 801df4071..798562cda 100644 --- a/src/main/java/org/hbp/mip/controllers/ApiResponseMessage.java +++ b/src/main/java/org/hbp/mip/controllers/ApiResponseMessage.java @@ -7,7 +7,6 @@ package org.hbp.mip.controllers; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/src/main/java/org/hbp/mip/controllers/ArticlesApi.java b/src/main/java/org/hbp/mip/controllers/ArticlesApi.java index 8d25fe87a..5c2fb3b19 100644 --- a/src/main/java/org/hbp/mip/controllers/ArticlesApi.java +++ b/src/main/java/org/hbp/mip/controllers/ArticlesApi.java @@ -25,88 +25,128 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Controller @RequestMapping(value = "/articles", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/articles", description = "the articles API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class ArticlesApi { - @ApiOperation(value = "Get articles", notes = "", response = Article.class, responseContainer = "List") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET) + @ApiOperation(value = "Get articles", response = Article.class, responseContainer = "List") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) + @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<Article>> getArticles( @ApiParam(value = "Only ask own articles") @RequestParam(value = "own", required = false) Boolean own, @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 valid articles") @RequestParam(value = "valid", required = false) Boolean valid) throws NotFoundException { + Principal principal + ) throws NotFoundException { - String queryString = "from Article"; + // Get current user + User user = MIPApplication.getUser(principal); + + // Prepare HQL query using Article and User tables + String queryString = "SELECT a FROM Article a, User u where a.createdBy=u.id"; if(status != null) { - queryString += " where status= :status"; + queryString += " and status= :status"; + } + + if(own != null && own) + { + queryString += " and u.username= :username"; + } + else + { + if(team != null && team) + { + queryString += " and u.team= :team"; + } } + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Query query = session.createQuery(queryString); - if(status != null) { query.setString("status", status); } - + if(own != null && own) + { + query.setString("username", user.getUsername()); + } + else + { + if(team != null && team) + { + query.setString("team", user.getTeam()); + } + } List<Article> articles = query.list(); session.getTransaction().commit(); + return new ResponseEntity<List<Article>>(HttpStatus.OK).ok(articles); } - @ApiOperation(value = "Create an article", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Article created")}) - @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.POST) + @ApiOperation(value = "Create an article", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Article created") }) + @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Void> addAnArticle( - @RequestBody @ApiParam(value = "Article to create", required = true) Article article, Principal principal) throws NotFoundException { + @RequestBody @ApiParam(value = "Article to create", required = true) Article article, + Principal principal + ) throws NotFoundException { + + // Get current user User user = MIPApplication.getUser(principal); - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); + + // Set up article to save article.setCreatedAt(new Date()); if (article.getStatus().equals("published")) { article.setPublishedAt(new Date()); } - article.setSlug(article.getTitle().toLowerCase()); + article.setSlug(article.getTitle().toLowerCase().replaceAll(" ","_")); article.setCreatedBy(user); + + // Save article into DB + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); session.save(article); session.getTransaction().commit(); + return new ResponseEntity<Void>(HttpStatus.OK); } - @ApiOperation(value = "Get an article", notes = "", response = Article.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get an article", response = Article.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) + @RequestMapping(value = "/{slug}", method = RequestMethod.GET) public ResponseEntity<Article> getAnArticle( - @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from Article where slug= :slug"); + Query query = session.createQuery("from Article where slug= :slug"); query.setString("slug", slug); Article article = (Article) query.uniqueResult(); session.getTransaction().commit(); + return new ResponseEntity<Article>(HttpStatus.OK).ok(article); } - @ApiOperation(value = "Update an article", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Article updated")}) - @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.PUT) + @ApiOperation(value = "Update an article", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Article updated") }) + @RequestMapping(value = "/{slug}", method = RequestMethod.PUT) public ResponseEntity<Void> updateAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, - @RequestBody @ApiParam(value = "Article to update", required = true) Article article, Principal principal) throws NotFoundException { + @RequestBody @ApiParam(value = "Article to update", required = true) Article article, + Principal principal + ) throws NotFoundException { + + // Get current user User user = MIPApplication.getUser(principal); + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); session.update(article); @@ -116,13 +156,15 @@ public class ArticlesApi { } - @ApiOperation(value = "Delete an article", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Article deleted")}) - @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.DELETE) + @ApiOperation(value = "Delete an article", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Article deleted") }) + @RequestMapping(value = "/{slug}", method = RequestMethod.DELETE) public ResponseEntity<Void> deleteAnArticle( - @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { - // do some magic! + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug + ) throws NotFoundException { + + // TODO : Implement delete method + return new ResponseEntity<Void>(HttpStatus.OK); } diff --git a/src/main/java/org/hbp/mip/controllers/DatasetsApi.java b/src/main/java/org/hbp/mip/controllers/DatasetsApi.java index e4047d18b..5f7515f24 100644 --- a/src/main/java/org/hbp/mip/controllers/DatasetsApi.java +++ b/src/main/java/org/hbp/mip/controllers/DatasetsApi.java @@ -7,6 +7,7 @@ package org.hbp.mip.controllers; import io.swagger.annotations.*; import org.hbp.mip.model.Dataset; +import org.hibernate.Query; import org.hibernate.Session; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -20,22 +21,24 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Controller @RequestMapping(value = "/datasets", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/datasets", description = "the datasets API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class DatasetsApi { - @ApiOperation(value = "Get a dataset", notes = "", response = Dataset.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "/{code}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get a dataset", response = Dataset.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) + @RequestMapping(value = "/{code}", method = RequestMethod.GET) public ResponseEntity<Dataset> getADataset( - @ApiParam(value = "code", required = true) @PathVariable("code") String code) throws NotFoundException { + @ApiParam(value = "code", required = true) @PathVariable("code") String code + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from Dataset where code= :code"); + Query query = session.createQuery("from Dataset where code= :code"); query.setString("code", code); Dataset dataset = (Dataset) query.uniqueResult(); session.getTransaction().commit(); + return new ResponseEntity<Dataset>(HttpStatus.OK).ok(dataset); } diff --git a/src/main/java/org/hbp/mip/controllers/GroupsApi.java b/src/main/java/org/hbp/mip/controllers/GroupsApi.java index bee57f824..3ba21d67e 100644 --- a/src/main/java/org/hbp/mip/controllers/GroupsApi.java +++ b/src/main/java/org/hbp/mip/controllers/GroupsApi.java @@ -18,16 +18,18 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Controller @RequestMapping(value = "/groups", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/groups", description = "the groups API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class GroupsApi { - @ApiOperation(value = "Get the root group (containing all subgroups)", notes = "", response = Group.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get the root group (containing all subgroups)", response = Group.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) + @RequestMapping(method = RequestMethod.GET) public ResponseEntity<Group> getTheRootGroup() throws NotFoundException { + + // Set up root group String rootCode = "root"; + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); org.hibernate.Query query = session.createQuery("from Group where code= :code"); diff --git a/src/main/java/org/hbp/mip/controllers/ModelsApi.java b/src/main/java/org/hbp/mip/controllers/ModelsApi.java index a6bbd0a18..3367c8e7e 100644 --- a/src/main/java/org/hbp/mip/controllers/ModelsApi.java +++ b/src/main/java/org/hbp/mip/controllers/ModelsApi.java @@ -9,6 +9,7 @@ import io.swagger.annotations.*; import org.hbp.mip.MIPApplication; import org.hbp.mip.model.Model; import org.hbp.mip.model.User; +import org.hibernate.Query; import org.hibernate.Session; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -28,61 +29,77 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; public class ModelsApi { - @ApiOperation(value = "Get models", notes = "", response = Model.class, responseContainer = "List") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET) + @ApiOperation(value = "Get models", response = Model.class, responseContainer = "List") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) + @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<Model>> getModels( @ApiParam(value = "Max number of results") @RequestParam(value = "limit", required = false) Integer limit, @ApiParam(value = "Only ask own models") @RequestParam(value = "own", required = false) Boolean own, @ApiParam(value = "Only ask models from own team") @RequestParam(value = "team", required = false) Boolean team, - @ApiParam(value = "Only ask valid models") @RequestParam(value = "valid", required = false) Boolean valid, - Principal principal) throws NotFoundException { + Principal principal + ) throws NotFoundException { + // Get current user User user = MIPApplication.getUser(principal); + // Prepare HQL query from Model and User tables String queryString = "select m from Model m, User u where m.createdBy=u.id"; - - if(own != null) + if(own != null && own) { - if(own) - { - queryString += " and u.username= :username"; - } - else + queryString += " and u.username= :username"; + } + else + { + if(team != null && team) { - queryString += " and u.username!= :username"; + queryString += " and u.team= :team"; } } + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); - org.hibernate.Query query = session.createQuery(queryString); - if(own != null) + Query query = session.createQuery(queryString); + if(own != null && own) { query.setString("username", user.getUsername()); } + else + { + if(team != null && team) + { + query.setString("team", user.getTeam()); + } + } + if(limit != null) + { + query.setMaxResults(limit); // Pagination : Use query.setFirstResult(...) to set begining index + } List<Model> models = query.list(); session.getTransaction().commit(); + return new ResponseEntity<List<Model>>(HttpStatus.OK).ok(models); } - @ApiOperation(value = "Create a model", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Model created")}) - @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.POST) + @ApiOperation(value = "Create a model", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Model created") }) + @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Void> addAModel( - @RequestBody @ApiParam(value = "Model to create", required = true) Model model, Principal principal) throws NotFoundException { + @RequestBody @ApiParam(value = "Model to create", required = true) Model model, + Principal principal + ) throws NotFoundException { + + // Get current user User user = MIPApplication.getUser(principal); + // Set up model model.setSlug(model.getTitle().toLowerCase()); model.setValid(true); model.setCreatedBy(user); model.setCreatedAt(new Date()); - System.out.println(model); - + // Save model into DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); session.save(model); @@ -91,48 +108,56 @@ public class ModelsApi { return new ResponseEntity<Void>(HttpStatus.OK); } - @ApiOperation(value = "Get SVG", notes = "", response = Model.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found")}) + @ApiOperation(value = "Get SVG", response = Model.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) @RequestMapping(value = "/{slug}.svg", produces = {"image/svg+xml"}, method = RequestMethod.GET) public ResponseEntity<String> getSVG( - @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); org.hibernate.Query query = session.createQuery("from Model where slug= :slug"); query.setString("slug", slug); Model model = (Model) query.uniqueResult(); session.getTransaction().commit(); + return new ResponseEntity<String>(HttpStatus.OK).ok(model.getChart().getSvg()); } - @ApiOperation(value = "Get a model", notes = "", response = Model.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get a model", response = Model.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) + @RequestMapping(value = "/{slug}", method = RequestMethod.GET) public ResponseEntity<Model> getAModel( - @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); org.hibernate.Query query = session.createQuery("from Model where slug= :slug"); query.setString("slug", slug); Model model = (Model) query.uniqueResult(); session.getTransaction().commit(); + return new ResponseEntity<Model>(HttpStatus.OK).ok(model); } - @ApiOperation(value = "Update a model", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Model updated")}) - @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.PUT) + @ApiOperation(value = "Update a model", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Model updated") }) + @RequestMapping(value = "/{slug}", method = RequestMethod.PUT) public ResponseEntity<Void> updateAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, - @RequestBody @ApiParam(value = "Model to update", required = true) Model model, Principal principal) throws NotFoundException { + @RequestBody @ApiParam(value = "Model to update", required = true) Model model, + Principal principal + ) throws NotFoundException { + + // Get current user User user = MIPApplication.getUser(principal); + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); session.update(model); @@ -142,13 +167,15 @@ public class ModelsApi { } - @ApiOperation(value = "Delete a model", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Model deleted")}) - @RequestMapping(value = "/{slug}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.DELETE) + @ApiOperation(value = "Delete a model", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Model deleted") }) + @RequestMapping(value = "/{slug}", method = RequestMethod.DELETE) public ResponseEntity<Void> deleteAModel( - @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { - // do some magic! + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug + ) throws NotFoundException { + + // TODO : Implement delete method + return new ResponseEntity<Void>(HttpStatus.OK); } diff --git a/src/main/java/org/hbp/mip/controllers/NotFoundException.java b/src/main/java/org/hbp/mip/controllers/NotFoundException.java index bf34f7076..770a417af 100644 --- a/src/main/java/org/hbp/mip/controllers/NotFoundException.java +++ b/src/main/java/org/hbp/mip/controllers/NotFoundException.java @@ -4,7 +4,6 @@ package org.hbp.mip.controllers; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class NotFoundException extends ApiException { private int code; diff --git a/src/main/java/org/hbp/mip/controllers/RequestsApi.java b/src/main/java/org/hbp/mip/controllers/RequestsApi.java index ac4968792..587e5c49c 100644 --- a/src/main/java/org/hbp/mip/controllers/RequestsApi.java +++ b/src/main/java/org/hbp/mip/controllers/RequestsApi.java @@ -19,14 +19,13 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Controller @RequestMapping(value = "/queries/requests", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/queries/requests", description = "the groups API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class RequestsApi { - @ApiOperation(value = "", notes = "", response = Group.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.POST) + @ApiOperation(value = "Send a request", response = Group.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) + @RequestMapping(method = RequestMethod.POST) public ResponseEntity<String> postRequests() throws NotFoundException { + // Mock data String response = "{\n" + @@ -52,6 +51,7 @@ public class RequestsApi { " ]\n" + " }\n" + "}\n"; + return new ResponseEntity<Group>(HttpStatus.OK).ok(response); } diff --git a/src/main/java/org/hbp/mip/controllers/UsersApi.java b/src/main/java/org/hbp/mip/controllers/UsersApi.java index a2e80e253..5d1ca2267 100644 --- a/src/main/java/org/hbp/mip/controllers/UsersApi.java +++ b/src/main/java/org/hbp/mip/controllers/UsersApi.java @@ -19,22 +19,23 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Controller @RequestMapping(value = "/users", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/users", description = "the users API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class UsersApi { - @ApiOperation(value = "Get a user", notes = "", response = User.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{username}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get a user", response = User.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) + @RequestMapping(value = "/{username}", method = RequestMethod.GET) public ResponseEntity<User> getAUser( - @ApiParam(value = "username", required = true) @PathVariable("username") String username) throws NotFoundException { + @ApiParam(value = "username", required = true) @PathVariable("username") String username + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); org.hibernate.Query query = session.createQuery("from User where username= :username"); query.setString("username", username); User user = (User) query.uniqueResult(); session.getTransaction().commit(); + return new ResponseEntity<User>(HttpStatus.OK).ok(user); } } diff --git a/src/main/java/org/hbp/mip/controllers/VariablesApi.java b/src/main/java/org/hbp/mip/controllers/VariablesApi.java index ce2f8dd8a..2e7cf145f 100644 --- a/src/main/java/org/hbp/mip/controllers/VariablesApi.java +++ b/src/main/java/org/hbp/mip/controllers/VariablesApi.java @@ -26,21 +26,20 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @Controller @RequestMapping(value = "/variables", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/variables", description = "the variables API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") public class VariablesApi { - @ApiOperation(value = "Get variables", notes = "", response = Variable.class, responseContainer = "List") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success")}) - @RequestMapping(value = "", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get variables", response = Variable.class, responseContainer = "List") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) + @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<Variable>> getVariables( @ApiParam(value = "List of groups formatted like : (\"val1\", \"val2\", ...)") @RequestParam(value = "group", required = false) String group, @ApiParam(value = "List of subgroups formatted like : (\"val1\", \"val2\", ...)") @RequestParam(value = "subgroup", required = false) String subgroup, @ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isVariable", required = false) String isVariable, @ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isGrouping", required = false) String isGrouping, @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) throws NotFoundException { + @ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isFilter", required = false) String isFilter + ) throws NotFoundException { // Get variales from DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); @@ -48,10 +47,11 @@ public class VariablesApi { List<Variable> variables = session.createQuery("from Variable").list(); session.getTransaction().commit(); + // Get groups matching grpPath for(Variable v : variables) { Group g = null; - Group fils = null; + Group child = null; for(int i=v.getGrpPath().size()-1; i >= 0; i--) { session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); @@ -60,47 +60,51 @@ public class VariablesApi { g = (Group) query.uniqueResult(); session.getTransaction().commit(); g.setGroups(new LinkedList<>()); - if(fils != null) + if(child != null) { - g.addGroup(fils); + g.addGroup(child); } - fils = g.clone(); + child = g.clone(); } - v.setGroup(fils); + v.setGroup(child); } return new ResponseEntity<List<Variable>>(HttpStatus.OK).ok(variables); } - @ApiOperation(value = "Get a variable", notes = "", response = Variable.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{code}", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get a variable", response = Variable.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) + @RequestMapping(value = "/{code}", method = RequestMethod.GET) public ResponseEntity<Variable> getAVariable( - @ApiParam(value = "code of the variable ( multiple codes are allowed, separated by \",\" )", required = true) @PathVariable("code") String code) throws NotFoundException { + @ApiParam(value = "code of the variable ( multiple codes are allowed, separated by \",\" )", required = true) @PathVariable("code") String code + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); org.hibernate.Query query = session.createQuery("from Variable where code= :code"); query.setString("code", code); Variable variable = (Variable) query.uniqueResult(); session.getTransaction().commit(); + return new ResponseEntity<Variable>(HttpStatus.OK).ok(variable); } - @ApiOperation(value = "Get values from a variable", notes = "", response = Value.class, responseContainer = "List") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found")}) - @RequestMapping(value = "/{code}/values", produces = { APPLICATION_JSON_VALUE }, method = RequestMethod.GET) + @ApiOperation(value = "Get values from a variable", response = Value.class, responseContainer = "List") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) + @RequestMapping(value = "/{code}/values", method = RequestMethod.GET) public ResponseEntity<List<Value>> getValuesFromAVariable( @ApiParam(value = "code", required = true) @PathVariable("code") String code, - @ApiParam(value = "Pattern to match") @RequestParam(value = "q", required = false) String q) throws NotFoundException { + @ApiParam(value = "Pattern to match") @RequestParam(value = "q", required = false) String q + ) throws NotFoundException { + + // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List<Value> values = session.createQuery("select values from Variable where code= :code").setString("code", code).list(); session.getTransaction().commit(); + return new ResponseEntity<List<Value>>(HttpStatus.OK).ok(values); } diff --git a/src/main/java/org/hbp/mip/model/Article.java b/src/main/java/org/hbp/mip/model/Article.java index 1ef4d4112..6ff3c38ec 100644 --- a/src/main/java/org/hbp/mip/model/Article.java +++ b/src/main/java/org/hbp/mip/model/Article.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,8 +17,7 @@ import java.util.List; @Entity @Table(name = "`article`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Article { @Id private String slug = null; diff --git a/src/main/java/org/hbp/mip/model/Chart.java b/src/main/java/org/hbp/mip/model/Chart.java index 3e46b09b3..6ee9d0e43 100644 --- a/src/main/java/org/hbp/mip/model/Chart.java +++ b/src/main/java/org/hbp/mip/model/Chart.java @@ -5,8 +5,8 @@ package org.hbp.mip.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,9 +17,8 @@ import java.util.List; @Entity @Table(name = "`chart`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") @JsonIgnoreProperties(value = { "id" }) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Chart { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/org/hbp/mip/model/ChartConfigSet.java b/src/main/java/org/hbp/mip/model/ChartConfigSet.java index f3a928f2d..018705411 100644 --- a/src/main/java/org/hbp/mip/model/ChartConfigSet.java +++ b/src/main/java/org/hbp/mip/model/ChartConfigSet.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -16,8 +16,7 @@ import javax.persistence.Table; @Entity @Table(name = "`chart_config_set`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class ChartConfigSet { @Id private String code = null; diff --git a/src/main/java/org/hbp/mip/model/Dataset.java b/src/main/java/org/hbp/mip/model/Dataset.java index 723e4603b..21b2555ed 100644 --- a/src/main/java/org/hbp/mip/model/Dataset.java +++ b/src/main/java/org/hbp/mip/model/Dataset.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,8 +17,7 @@ import java.util.List; @Entity @Table(name = "`dataset`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Dataset { @Id private String code = null; diff --git a/src/main/java/org/hbp/mip/model/Filter.java b/src/main/java/org/hbp/mip/model/Filter.java index 2a0068cf7..d92fc5fc1 100644 --- a/src/main/java/org/hbp/mip/model/Filter.java +++ b/src/main/java/org/hbp/mip/model/Filter.java @@ -5,8 +5,8 @@ package org.hbp.mip.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -15,9 +15,8 @@ import javax.persistence.*; @Entity @Table(name = "`filter`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") @JsonIgnoreProperties(value = { "id" }) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Filter { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/org/hbp/mip/model/Group.java b/src/main/java/org/hbp/mip/model/Group.java index 5cf5ee374..76b6fbd6f 100644 --- a/src/main/java/org/hbp/mip/model/Group.java +++ b/src/main/java/org/hbp/mip/model/Group.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -16,8 +16,7 @@ import java.util.List; @Entity @Table(name = "`group`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Group { @Id private String code = null; diff --git a/src/main/java/org/hbp/mip/model/Model.java b/src/main/java/org/hbp/mip/model/Model.java index 3e11335f9..67db5e085 100644 --- a/src/main/java/org/hbp/mip/model/Model.java +++ b/src/main/java/org/hbp/mip/model/Model.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -15,8 +15,7 @@ import java.util.Date; @Entity @Table(name = "`model`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Model { @Id private String slug = null; diff --git a/src/main/java/org/hbp/mip/model/Query.java b/src/main/java/org/hbp/mip/model/Query.java index 7a81d3942..10ac94510 100644 --- a/src/main/java/org/hbp/mip/model/Query.java +++ b/src/main/java/org/hbp/mip/model/Query.java @@ -5,8 +5,8 @@ package org.hbp.mip.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,9 +17,8 @@ import java.util.List; @Entity @Table(name = "`query`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") @JsonIgnoreProperties(value = { "id" }) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Query { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/org/hbp/mip/model/Statistics.java b/src/main/java/org/hbp/mip/model/Statistics.java index bea5fa0e1..48ed59676 100644 --- a/src/main/java/org/hbp/mip/model/Statistics.java +++ b/src/main/java/org/hbp/mip/model/Statistics.java @@ -1,5 +1,6 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -8,7 +9,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-20T14:47:53.152Z") +@JsonInclude(JsonInclude.Include.NON_NULL) public class Statistics { public enum DataTypeEnum { diff --git a/src/main/java/org/hbp/mip/model/Tag.java b/src/main/java/org/hbp/mip/model/Tag.java index 6c3aa85b7..eba34ccb7 100644 --- a/src/main/java/org/hbp/mip/model/Tag.java +++ b/src/main/java/org/hbp/mip/model/Tag.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -16,8 +16,7 @@ import javax.persistence.Table; @Entity @Table(name = "`tag`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Tag { @Id private String name = null; diff --git a/src/main/java/org/hbp/mip/model/User.java b/src/main/java/org/hbp/mip/model/User.java index 42613acd6..7aaa62ecb 100644 --- a/src/main/java/org/hbp/mip/model/User.java +++ b/src/main/java/org/hbp/mip/model/User.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -18,8 +18,7 @@ import java.util.regex.Pattern; @Entity @Table(name = "`user`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class User { @Id private String username = null; diff --git a/src/main/java/org/hbp/mip/model/Value.java b/src/main/java/org/hbp/mip/model/Value.java index 75a6c08a1..150101367 100644 --- a/src/main/java/org/hbp/mip/model/Value.java +++ b/src/main/java/org/hbp/mip/model/Value.java @@ -4,8 +4,8 @@ package org.hbp.mip.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -16,8 +16,7 @@ import javax.persistence.Table; @Entity @Table(name = "`value`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Value { @Id diff --git a/src/main/java/org/hbp/mip/model/Variable.java b/src/main/java/org/hbp/mip/model/Variable.java index 1ad7d6e24..694b0d8d1 100644 --- a/src/main/java/org/hbp/mip/model/Variable.java +++ b/src/main/java/org/hbp/mip/model/Variable.java @@ -5,8 +5,8 @@ package org.hbp.mip.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,9 +17,8 @@ import java.util.List; @Entity @Table(name = "`variable`") @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") @JsonIgnoreProperties(value = { "grpPath", "queries" }) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Variable { @Id diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 6b6aa44b9..7ae742fb6 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -6,7 +6,7 @@ <hibernate-configuration> <session-factory> <property name="connection.driver_class">org.postgresql.Driver</property> - <property name="connection.url">jdbc:postgresql://portaldb:5432/postgres</property> + <property name="connection.url">jdbc:postgresql://localhost:55432/postgres</property> <property name="connection.username">postgres</property> <property name="connection.password">test</property> <property name="hibernate.format_sql">true</property> -- GitLab