diff --git a/README.md b/README.md index 647a99298518fb89c26ace4230046a0ad1ef9a81..1749d33b7c8ca771d384f257d6b993ef8624d91a 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 e06294e80a49e15f83c8d83f7b35d671dcfd70f7..a80398d84259ebd41c592a0e942b46f56325f51e 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 ae8590582557e5525156459b28fad33dbe6549bf..ef51b43dbeae2b75032b1369a140f9417dcc5387 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 35717bd8ce0ff667526b3396c032adaef9e8d8b1..e0fb244fc00ec76496a8d12ca7187ee7303e636d 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 801df4071378b3f4c4c68c91b64ae888d81f3fac..798562cda5e33cd823bd09893dd8d1886392655e 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 8d25fe87ae2542a236113e053220d6dd1d2fb081..5c2fb3b1975ab0472667bc74f1ecb32b86f413fc 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 e4047d18bcad304e5d9a2caa92c97e573647e279..5f7515f24ac6679841dc8efbe8d80019463b410d 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 bee57f824d2e22e18e78be375aec65737c3dda06..3ba21d67e6e1281acd4c343d7167203089fb3a86 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 a6bbd0a188020913cf0725e34e44867cd7086fd4..3367c8e7ef47eaf15bd320396804f1b12c7cf131 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 bf34f707646ffee8c51067055899efe328d30fd5..770a417af9009ab1eddccc97c7335761376029a7 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 ac4968792d8025dd8bc7bad085dd8f5f07ea56e8..587e5c49c407a4d9b31a3c3fcb93d805ee2b5ff5 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 a2e80e253bd55edebb44b3a462b5deb1c0456ff5..5d1ca2267118dc6d08f3c04e16e52f5978cbdb25 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 ce2f8dd8a909787718eb31cb0c233f2e61fd6d6d..2e7cf145f4aaffb5006117fd453bff739db9c1c1 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 1ef4d41123631b711ef457f1cbc05ebcd08868ba..6ff3c38eca75ea61840e719a321990477ea9a7f1 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 3e46b09b3fe52fcb0da27a9673a69946f5cf96eb..6ee9d0e43f72814c27f0f5978330c8d8281984c9 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 f3a928f2da34130d334759be89e4d13df33116ab..0187054117712d8ddd3f1983d3b682e855330ccd 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 723e4603b6816f03f473dedbac2d13347021a6f8..21b2555ed19f980fa50110540e505b6aa41f4f69 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 2a0068cf7ba67a93323510de9d534a9a2a45838a..d92fc5fc13f66a4d58f25521a66b4533eabb5d2d 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 5cf5ee374ba1805d727b952ccc6894a06a51e5fa..76b6fbd6f7c49993bd5ef3a16687c70bb68953f8 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 3e11335f97a21ed09eec97d38739ab670890d95d..67db5e0853f71f3f08cba1fe650acb36cc077072 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 7a81d3942a3704a8d0bcd486bf8e0abf05422147..10ac94510ed6bc7068ee085724f78fea5583b587 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 bea5fa0e1511f0325c403c2e429e82734883a6cc..48ed59676c86506e1f23822f9fa05bad0490e4e5 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 6c3aa85b7725e24f4bde4245493a62fcd404d14b..eba34ccb7585226904f225dd87fef13c83889700 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 42613acd6c5b57b20301d46d91365a1e56d7b176..7aaa62ecbc0ee9648fca002cc71560167c5e3c94 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 75a6c08a1516e8c94b49d033c86c2ac84b38829a..150101367a6dcdfb3e9f72ad5a13f2b93c7cc28e 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 1ad7d6e2473d79c2d0d3f6bc51c0667c2fcb9100..694b0d8d13bfc57b4eec0d4b1e8327ac47a1ec97 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 6b6aa44b988ba71497dcd9cbca4abea3cc784e1e..7ae742fb6ea9906fb7002d64dc3864b5bb04c47b 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>