From 35d9464a7d666ff29277ef0eec7f76fdd33a8d60 Mon Sep 17 00:00:00 2001 From: Mirco Nasuti <mirco.nasuti@chuv.ch> Date: Fri, 4 Mar 2016 14:03:20 +0100 Subject: [PATCH] clean code --- .../org/hbp/mip/controllers/ArticlesApi.java | 38 ++---- .../org/hbp/mip/controllers/DatasetsApi.java | 5 +- .../org/hbp/mip/controllers/GroupsApi.java | 7 +- .../org/hbp/mip/controllers/ModelsApi.java | 49 ++++---- .../org/hbp/mip/controllers/RequestsApi.java | 3 +- .../org/hbp/mip/controllers/StatsApi.java | 34 +++--- .../org/hbp/mip/controllers/UsersApi.java | 4 +- .../org/hbp/mip/controllers/VariablesApi.java | 16 ++- .../org/hbp/mip/controllers/WorkflowApi.java | 7 +- src/main/java/org/hbp/mip/model/Chart.java | 114 ------------------ .../org/hbp/mip/model/ChartConfigSet.java | 80 ------------ .../java/org/hbp/mip/model/Statistics.java | 61 ---------- src/main/resources/hibernate.cfg.xml | 2 - 13 files changed, 64 insertions(+), 356 deletions(-) delete mode 100644 src/main/java/org/hbp/mip/model/Chart.java delete mode 100644 src/main/java/org/hbp/mip/model/ChartConfigSet.java delete mode 100644 src/main/java/org/hbp/mip/model/Statistics.java diff --git a/src/main/java/org/hbp/mip/controllers/ArticlesApi.java b/src/main/java/org/hbp/mip/controllers/ArticlesApi.java index dca595e5c..14bc9e07a 100644 --- a/src/main/java/org/hbp/mip/controllers/ArticlesApi.java +++ b/src/main/java/org/hbp/mip/controllers/ArticlesApi.java @@ -34,37 +34,33 @@ public class ArticlesApi { @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( + public ResponseEntity<List> 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 ) { - // Get current user User user = mipApplication.getUser(); - // Prepare HQL query using Article and User tables - String queryString = "SELECT a FROM Article a, User u where a.createdBy=u.id"; + String queryString = "SELECT a FROM Article a, User u WHERE a.createdBy=u.id"; if(status != null) { - queryString += " and status= :status"; + queryString += " AND status= :status"; } - if(own != null && own) { - queryString += " and u.username= :username"; + queryString += " AND u.username= :username"; } else { if(team != null && team) { - queryString += " and u.team= :team"; + queryString += " AND u.team= :team"; } } Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - List<Article> articles = new LinkedList<>(); - // Query DB + List articles = new LinkedList<>(); try{ session.beginTransaction(); Query query = session.createQuery(queryString); @@ -85,7 +81,6 @@ public class ArticlesApi { } articles = query.list(); session.getTransaction().commit(); - } catch (Exception e) { if(session.getTransaction() != null) @@ -94,7 +89,7 @@ public class ArticlesApi { } } - return new ResponseEntity<List<Article>>(HttpStatus.OK).ok(articles); + return ResponseEntity.ok(articles); } @@ -105,10 +100,8 @@ public class ArticlesApi { @RequestBody @ApiParam(value = "Article to create", required = true) Article article ) { - // Get current user User user = mipApplication.getUser(); - // Set up article to save article.setCreatedAt(new Date()); if (article.getStatus().equals("published")) { article.setPublishedAt(new Date()); @@ -116,7 +109,6 @@ public class ArticlesApi { article.setSlug(article.getTitle().toLowerCase().replaceAll(" ","_")); article.setCreatedBy(user); - // Save article into DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try{ session.beginTransaction(); @@ -130,7 +122,7 @@ public class ArticlesApi { } } - return new ResponseEntity<Void>(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @@ -141,12 +133,11 @@ public class ArticlesApi { @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug ) { - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Article article = null; try{ session.beginTransaction(); - Query query = session.createQuery("from Article where slug= :slug"); + Query query = session.createQuery("FROM Article WHERE slug= :slug"); query.setString("slug", slug); article = (Article) query.uniqueResult(); session.getTransaction().commit(); @@ -158,7 +149,7 @@ public class ArticlesApi { } } - return new ResponseEntity<Article>(HttpStatus.OK).ok(article); + return ResponseEntity.ok(article); } @@ -170,10 +161,6 @@ public class ArticlesApi { @RequestBody @ApiParam(value = "Article to update", required = true) Article article ) { - // Get current user - User user = mipApplication.getUser(); - - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try{ session.beginTransaction(); @@ -187,7 +174,7 @@ public class ArticlesApi { } } - return new ResponseEntity<Void>(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @@ -200,8 +187,7 @@ public class ArticlesApi { // TODO : Implement delete method - return new ResponseEntity<Void>(HttpStatus.OK); + return new ResponseEntity<>(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 9a70a4829..35671ac13 100644 --- a/src/main/java/org/hbp/mip/controllers/DatasetsApi.java +++ b/src/main/java/org/hbp/mip/controllers/DatasetsApi.java @@ -10,7 +10,6 @@ import org.hbp.mip.model.Dataset; import org.hbp.mip.utils.HibernateUtil; import org.hibernate.Query; import org.hibernate.Session; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -31,7 +30,6 @@ public class DatasetsApi { @ApiParam(value = "code", required = true) @PathVariable("code") String code ) { - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Dataset dataset = null; try{ @@ -48,8 +46,7 @@ public class DatasetsApi { } } - return new ResponseEntity<Dataset>(HttpStatus.OK).ok(dataset); + return ResponseEntity.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 11e2f8171..2f6a86774 100644 --- a/src/main/java/org/hbp/mip/controllers/GroupsApi.java +++ b/src/main/java/org/hbp/mip/controllers/GroupsApi.java @@ -8,7 +8,6 @@ import io.swagger.annotations.ApiResponses; import org.hbp.mip.model.Group; import org.hbp.mip.utils.HibernateUtil; import org.hibernate.Session; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -26,15 +25,13 @@ public class GroupsApi { @RequestMapping(method = RequestMethod.GET) public ResponseEntity<Group> getTheRootGroup() { - // Set up root group String rootCode = "root"; - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Group group = null; try{ session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from Group where code= :code"); + org.hibernate.Query query = session.createQuery("FROM Group WHERE code= :code"); query.setString("code", rootCode); group = (Group) query.uniqueResult(); session.getTransaction().commit(); @@ -46,7 +43,7 @@ public class GroupsApi { } } - return new ResponseEntity<Group>(HttpStatus.OK).ok(group); + return ResponseEntity.ok(group); } diff --git a/src/main/java/org/hbp/mip/controllers/ModelsApi.java b/src/main/java/org/hbp/mip/controllers/ModelsApi.java index 5c20bb255..4de19c02b 100644 --- a/src/main/java/org/hbp/mip/controllers/ModelsApi.java +++ b/src/main/java/org/hbp/mip/controllers/ModelsApi.java @@ -44,24 +44,21 @@ public class ModelsApi { @ApiParam(value = "Only ask models from own team") @RequestParam(value = "team", required = false) Boolean team ) { - // Get current user User user = mipApplication.getUser(); - // Prepare HQL query from Model and User tables - String queryString = "select m from Model m, User u where m.createdBy=u.id"; + String queryString = "SELECT m FROM Model m, User u WHERE m.createdBy=u.id"; if(own != null && own) { - queryString += " and u.username= :username"; + queryString += " AND u.username= :username"; } else { if(team != null && team) { - queryString += " and u.team= :team"; + queryString += " AND u.team= :team"; } } - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); List<Model> models = new LinkedList<>(); try{ @@ -103,17 +100,14 @@ public class ModelsApi { @RequestBody @ApiParam(value = "Model to create", required = true) Model model ) { - // Get current user User user = mipApplication.getUser(); - // Set up model model.setSlug(model.getConfig().getTitle().get("text").toLowerCase()); model.setTitle(model.getConfig().getTitle().get("text")); model.setValid(true); model.setCreatedBy(user); model.setCreatedAt(new Date()); - // Save model into DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try{ session.beginTransaction(); @@ -137,20 +131,27 @@ public class ModelsApi { @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug ) { - // 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(); + Model model = null; + org.hibernate.Query query; + try { + session.beginTransaction(); + query = session.createQuery("FROM Model WHERE slug= :slug").setString("slug", slug); + model = (Model) query.uniqueResult(); + session.getTransaction().commit(); + } catch (Exception e) + { + if(session.getTransaction() != null) + { + session.getTransaction().rollback(); + } + } if(model != null) { session = HibernateUtil.getSessionFactory().getCurrentSession(); try{ session.beginTransaction(); - query = session.createQuery("from Query where id= :id"); - query.setLong("id", model.getQuery().getId()); + query = session.createQuery("FROM Query WHERE id= :id").setLong("id", model.getQuery().getId()); org.hbp.mip.model.Query q = (org.hbp.mip.model.Query) query.uniqueResult(); session.getTransaction().commit(); @@ -205,7 +206,7 @@ public class ModelsApi { } } - return new ResponseEntity<Model>(HttpStatus.OK).ok(model); + return new ResponseEntity<>(HttpStatus.OK).ok(model); } @@ -217,10 +218,8 @@ public class ModelsApi { @RequestBody @ApiParam(value = "Model to update", required = true) Model model ) { - // Get current user User user = mipApplication.getUser(); - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try{ session.beginTransaction(); @@ -234,7 +233,7 @@ public class ModelsApi { } } - return new ResponseEntity<Void>(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "Copy a model", response = Model.class) @@ -244,10 +243,9 @@ public class ModelsApi { @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, @RequestBody @ApiParam(value = "Model to update", required = true) Model model ) { - // Get current user + User user = mipApplication.getUser(); - // Set slug String originalSlug = model.getSlug(); String copySlug; do { @@ -255,7 +253,6 @@ public class ModelsApi { } while (getAModel(copySlug) == null); model.setSlug(copySlug); - // Save model into DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try{ session.beginTransaction(); @@ -269,7 +266,7 @@ public class ModelsApi { } } - return new ResponseEntity<Model>(HttpStatus.OK).ok(model); + return new ResponseEntity<>(HttpStatus.OK).ok(model); } private String randomStr(int length) { @@ -292,7 +289,7 @@ public class ModelsApi { // TODO : Implement delete method - return new ResponseEntity<Void>(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } diff --git a/src/main/java/org/hbp/mip/controllers/RequestsApi.java b/src/main/java/org/hbp/mip/controllers/RequestsApi.java index b892cb507..c1d767f04 100644 --- a/src/main/java/org/hbp/mip/controllers/RequestsApi.java +++ b/src/main/java/org/hbp/mip/controllers/RequestsApi.java @@ -4,7 +4,6 @@ import io.swagger.annotations.*; import org.hbp.mip.model.Dataset; import org.hbp.mip.model.Query; import org.hbp.mip.utils.CSVUtil; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -32,7 +31,7 @@ public class RequestsApi { Dataset dataset = CSVUtil.parseValues(DATA_FILE, query); - return new ResponseEntity<Dataset>(HttpStatus.OK).ok(dataset); + return ResponseEntity.ok(dataset); } } diff --git a/src/main/java/org/hbp/mip/controllers/StatsApi.java b/src/main/java/org/hbp/mip/controllers/StatsApi.java index e19a548a9..ce22204d2 100644 --- a/src/main/java/org/hbp/mip/controllers/StatsApi.java +++ b/src/main/java/org/hbp/mip/controllers/StatsApi.java @@ -1,20 +1,18 @@ package org.hbp.mip.controllers; -import io.swagger.annotations.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.hbp.mip.model.GeneralStats; -import org.hbp.mip.model.Statistics; import org.hbp.mip.utils.HibernateUtil; import org.hibernate.Query; import org.hibernate.Session; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @RestController @@ -26,22 +24,28 @@ public class StatsApi { @ApiResponses(value = {@ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) @RequestMapping(method = RequestMethod.GET) public ResponseEntity<GeneralStats> getGeneralStatistics() { - GeneralStats stats = new GeneralStats(); - - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + GeneralStats stats = new GeneralStats(); Long nbUsers = 0L; Long nbArticles = 0L; Long nbVariables = 0L; + + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + try{ + session.beginTransaction(); + Query countUsersQuery = session.createQuery("SELECT COUNT(*) FROM User"); Query countArticlesQuery = session.createQuery("SELECT COUNT(*) FROM Article"); Query countVariablesQuery = session.createQuery("SELECT COUNT(*) FROM Variable"); + nbUsers = (Long) countUsersQuery.uniqueResult(); nbArticles = (Long) countArticlesQuery.uniqueResult(); nbVariables = (Long) countVariablesQuery.uniqueResult(); + session.getTransaction().commit(); + } catch (Exception e) { if(session.getTransaction() != null) @@ -54,17 +58,7 @@ public class StatsApi { stats.setArticles(nbArticles); stats.setVariables(nbVariables); - return new ResponseEntity<GeneralStats>(HttpStatus.OK).ok(stats); - } - - @ApiOperation(value = "Get the statistics for a group or a variable", response = Statistics.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/{code}", produces = { "application/json" }, method = RequestMethod.GET) - public ResponseEntity<List<Statistics>> getTheStatisticsForAGroupOrAVariable( - @ApiParam(value = "code of the group or variable",required=true ) @PathVariable("code") String code - ) { - // TODO: Implement this method - return new ResponseEntity<List<Statistics>>(HttpStatus.OK); + return ResponseEntity.ok(stats); } } diff --git a/src/main/java/org/hbp/mip/controllers/UsersApi.java b/src/main/java/org/hbp/mip/controllers/UsersApi.java index e302ebeff..93d785964 100644 --- a/src/main/java/org/hbp/mip/controllers/UsersApi.java +++ b/src/main/java/org/hbp/mip/controllers/UsersApi.java @@ -4,7 +4,6 @@ import io.swagger.annotations.*; import org.hbp.mip.model.User; import org.hbp.mip.utils.HibernateUtil; import org.hibernate.Session; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -30,7 +29,6 @@ public class UsersApi { @ApiParam(value = "username", required = true) @PathVariable("username") String username ) { - // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); User user = null; try{ @@ -47,6 +45,6 @@ public class UsersApi { } } - return new ResponseEntity<User>(HttpStatus.OK).ok(user); + return ResponseEntity.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 a7f1e873d..a98bbc384 100644 --- a/src/main/java/org/hbp/mip/controllers/VariablesApi.java +++ b/src/main/java/org/hbp/mip/controllers/VariablesApi.java @@ -10,7 +10,6 @@ import org.hbp.mip.model.Value; import org.hbp.mip.model.Variable; import org.hbp.mip.utils.HibernateUtil; import org.hibernate.Session; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -27,7 +26,7 @@ public class VariablesApi { @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( + public ResponseEntity<List> 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, @@ -36,9 +35,8 @@ public class VariablesApi { @ApiParam(value = "Boolean value formatted like : (\"0\") or (\"1\") or (\"false\") or (\"true\")") @RequestParam(value = "isFilter", required = false) String isFilter ) { - // Get variables from DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - List<Variable> variables = new LinkedList<>(); + List variables = new LinkedList<>(); try{ session.beginTransaction(); variables = session.createQuery("from Variable").list(); @@ -51,7 +49,7 @@ public class VariablesApi { } } - return new ResponseEntity<List<Variable>>(HttpStatus.OK).ok(variables); + return ResponseEntity.ok(variables); } @ApiOperation(value = "Get a variable", response = Variable.class) @@ -78,21 +76,21 @@ public class VariablesApi { } } - return new ResponseEntity<Variable>(HttpStatus.OK).ok(variable); + return ResponseEntity.ok(variable); } @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( + public ResponseEntity<List> getValuesFromAVariable( @ApiParam(value = "code", required = true) @PathVariable("code") String code, @ApiParam(value = "Pattern to match") @RequestParam(value = "q", required = false) String q ) { // Query DB Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - List<Value> values = new LinkedList<>(); + List values = new LinkedList<>(); try{ session.beginTransaction(); values = session.createQuery("select values from Variable where code= :code").setString("code", code).list(); @@ -105,7 +103,7 @@ public class VariablesApi { } } - return new ResponseEntity<List<Value>>(HttpStatus.OK).ok(values); + return ResponseEntity.ok(values); } diff --git a/src/main/java/org/hbp/mip/controllers/WorkflowApi.java b/src/main/java/org/hbp/mip/controllers/WorkflowApi.java index 0e7a1dcd0..b6cfba3e2 100644 --- a/src/main/java/org/hbp/mip/controllers/WorkflowApi.java +++ b/src/main/java/org/hbp/mip/controllers/WorkflowApi.java @@ -1,7 +1,6 @@ package org.hbp.mip.controllers; import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -41,7 +40,7 @@ public class WorkflowApi { results = ""; } - return new ResponseEntity<>(HttpStatus.OK).ok(results); + return ResponseEntity.ok(results); } @@ -66,7 +65,7 @@ public class WorkflowApi { BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; - StringBuffer response = new StringBuffer(); + StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); @@ -95,7 +94,7 @@ public class WorkflowApi { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); con.setSSLSocketFactory(sc.getSocketFactory()); - } catch (Exception e) { + } catch (Exception ignored) { } } } diff --git a/src/main/java/org/hbp/mip/model/Chart.java b/src/main/java/org/hbp/mip/model/Chart.java deleted file mode 100644 index 6ee9d0e43..000000000 --- a/src/main/java/org/hbp/mip/model/Chart.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Created by mirco on 04.12.15. - */ - -package org.hbp.mip.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.persistence.*; -import java.util.LinkedList; -import java.util.List; - -@Entity -@Table(name = "`chart`") -@ApiModel(description = "") -@JsonIgnoreProperties(value = { "id" }) -@JsonInclude(JsonInclude.Include.NON_NULL) -public class Chart { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id = null; - private String chartType = null; - private String xAxis = null; - // TODO: Should I use @Lob ? - @Column(columnDefinition = "text") - private String svg = null; - @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) - private List<ChartConfigSet> chartConfigSets = new LinkedList<ChartConfigSet>(); - - public Chart() { - } - - /** - * Unique identifier - **/ - @ApiModelProperty(value = "Unique identifier") - @JsonProperty("id") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - /** - * Chart type - **/ - @ApiModelProperty(value = "Chart type") - @JsonProperty("chartType") - public String getChartType() { - return chartType; - } - - public void setChartType(String chartType) { - this.chartType = chartType; - } - - /** - * X axis label - **/ - @ApiModelProperty(value = "X axis label") - @JsonProperty("xAxis") - public String getXAxis() { - return xAxis; - } - - public void setXAxis(String xAxis) { - this.xAxis = xAxis; - } - - public String getSvg() { - return svg; - } - - public void setSvg(String svg) { - this.svg = svg; - } - - /** - * Chart configuration - **/ - @ApiModelProperty(value = "Chart configuration") - @JsonProperty("chartConfigSets") - public List<ChartConfigSet> getChartConfigSets() { - return chartConfigSets; - } - - public void setChartConfigSets(List<ChartConfigSet> chartConfigSets) { - this.chartConfigSets = chartConfigSets; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Chart {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" chartType: ").append(chartType).append("\n"); - sb.append(" xAxis: ").append(xAxis).append("\n"); - sb.append(" svg: ").append(svg).append("\n"); - sb.append(" chartConfigSets: ").append(chartConfigSets).append("\n"); - sb.append("}\n"); - return sb.toString(); - } - - public void addChartConfigSet(ChartConfigSet chartConfigSet) { - this.chartConfigSets.add(chartConfigSet); - } -} diff --git a/src/main/java/org/hbp/mip/model/ChartConfigSet.java b/src/main/java/org/hbp/mip/model/ChartConfigSet.java deleted file mode 100644 index 018705411..000000000 --- a/src/main/java/org/hbp/mip/model/ChartConfigSet.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Created by mirco on 04.12.15. - */ - -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; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "`chart_config_set`") -@ApiModel(description = "") -@JsonInclude(JsonInclude.Include.NON_NULL) -public class ChartConfigSet { - @Id - private String code = null; - private String label = null; - private String color = null; - - public ChartConfigSet() { - } - - /** - * Code - **/ - @ApiModelProperty(value = "Code") - @JsonProperty("code") - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - /** - * Label - **/ - @ApiModelProperty(value = "Label") - @JsonProperty("label") - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - /** - * Color - **/ - @ApiModelProperty(value = "Color") - @JsonProperty("color") - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ChartConfigSet {\n"); - - sb.append(" code: ").append(code).append("\n"); - sb.append(" label: ").append(label).append("\n"); - sb.append(" color: ").append(color).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/src/main/java/org/hbp/mip/model/Statistics.java b/src/main/java/org/hbp/mip/model/Statistics.java deleted file mode 100644 index 48ed59676..000000000 --- a/src/main/java/org/hbp/mip/model/Statistics.java +++ /dev/null @@ -1,61 +0,0 @@ -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; - -import java.util.Objects; - - -@ApiModel(description = "") -@JsonInclude(JsonInclude.Include.NON_NULL) -public class Statistics { - - public enum DataTypeEnum { - SummaryStatistics, DatasetStatistics, - }; - private DataTypeEnum dataType = null; - - - /** - * Type of the data - **/ - @ApiModelProperty(required = true, value = "Type of the data") - @JsonProperty("dataType") - public DataTypeEnum getDataType() { - return dataType; - } - public void setDataType(DataTypeEnum dataType) { - this.dataType = dataType; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Statistics statistics = (Statistics) o; - return Objects.equals(dataType, statistics.dataType); - } - - @Override - public int hashCode() { - return Objects.hash(dataType); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Statistics {\n"); - - sb.append(" dataType: ").append(dataType).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 6e00ac17f..d6a47ee25 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -18,8 +18,6 @@ <property name="hibernate.hbm2ddl.auto">update</property> <mapping class="org.hbp.mip.model.Article"/> - <mapping class="org.hbp.mip.model.Chart"/> - <mapping class="org.hbp.mip.model.ChartConfigSet"/> <mapping class="org.hbp.mip.model.Dataset"/> <mapping class="org.hbp.mip.model.Model"/> <mapping class="org.hbp.mip.model.Query"/> -- GitLab