diff --git a/src/main/java/org/hbp/mip/ApiException.java b/src/main/java/org/hbp/mip/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..1db90dc1b2ed43d971e44a5d89b96a6525345e02 --- /dev/null +++ b/src/main/java/org/hbp/mip/ApiException.java @@ -0,0 +1,11 @@ +package org.hbp.mip; + +@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; + + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/src/main/java/org/hbp/mip/ApiOriginFilter.java b/src/main/java/org/hbp/mip/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..947af9b6aeca7167f123b8b69efec6d7da110d7e --- /dev/null +++ b/src/main/java/org/hbp/mip/ApiOriginFilter.java @@ -0,0 +1,26 @@ +package org.hbp.mip; + +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, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} \ No newline at end of file diff --git a/src/main/java/org/hbp/mip/ApiResponseMessage.java b/src/main/java/org/hbp/mip/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..13659d6b993bb070d402571d085a6eef9b019c1a --- /dev/null +++ b/src/main/java/org/hbp/mip/ApiResponseMessage.java @@ -0,0 +1,70 @@ +package org.hbp.mip; + +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; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage() { + } + + public ApiResponseMessage(int code, String message) { + this.code = code; + switch (code) { + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/org/hbp/mip/ArticlesApi.java b/src/main/java/org/hbp/mip/ArticlesApi.java new file mode 100644 index 0000000000000000000000000000000000000000..c2f06bb2aaa589f31945963c724a53394b5d1d67 --- /dev/null +++ b/src/main/java/org/hbp/mip/ArticlesApi.java @@ -0,0 +1,104 @@ +package org.hbp.mip; + + +import io.swagger.annotations.*; +import org.hbp.mip.model.Article; +import org.hbp.mip.model.User; +import org.hibernate.Session; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.security.Principal; +import java.util.Date; +import java.util.List; + +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) + 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") @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 { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + List<Article> articles = session.createQuery("from Article").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"}, method = RequestMethod.POST) + public ResponseEntity<Void> addAnArticle( + @RequestBody @ApiParam(value = "Article to create", required = true) Article article, Principal principal) throws NotFoundException { + User user = MIPApplication.getUser(principal); + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + article.setCreatedAt(new Date()); + if (article.getStatus().equals("published")) { + article.setPublishedAt(new Date()); + } + article.setSlug(article.getTitle().toLowerCase()); + article.setCreatedBy(user); + 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"}, method = RequestMethod.GET) + public ResponseEntity<Article> getAnArticle( + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + org.hibernate.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"}, method = RequestMethod.PUT) + public ResponseEntity<Void> updateAnArticle( + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, + @ApiParam(value = "Article to update", required = true) Article article) throws NotFoundException { + // do some magic! + return new ResponseEntity<Void>(HttpStatus.OK); + } + + + @ApiOperation(value = "Delete an article", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Article deleted")}) + @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.DELETE) + public ResponseEntity<Void> deleteAnArticle( + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + // do some magic! + return new ResponseEntity<Void>(HttpStatus.OK); + } + + +} diff --git a/src/main/java/org/hbp/mip/DatasetsApi.java b/src/main/java/org/hbp/mip/DatasetsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..35a24ba7bfcf573f6bfe19b61326308f39c84d8e --- /dev/null +++ b/src/main/java/org/hbp/mip/DatasetsApi.java @@ -0,0 +1,39 @@ +package org.hbp.mip; + + +import io.swagger.annotations.*; +import org.hbp.mip.model.Dataset; +import org.hibernate.Session; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +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"}, method = RequestMethod.GET) + public ResponseEntity<Dataset> getADataset( + @ApiParam(value = "code", required = true) @PathVariable("code") String code) throws NotFoundException { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + org.hibernate.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/GroupsApi.java b/src/main/java/org/hbp/mip/GroupsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..83d7e04c9acadef20bf49a448e52c14d463daa3e --- /dev/null +++ b/src/main/java/org/hbp/mip/GroupsApi.java @@ -0,0 +1,41 @@ +package org.hbp.mip; + + +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.Group; +import org.hibernate.Session; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +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"}, method = RequestMethod.GET) + public ResponseEntity<Group> getTheRootGroup() throws NotFoundException { + String rootCode = "root"; + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + org.hibernate.Query query = session.createQuery("from Group where code= :code"); + query.setString("code", rootCode); + Group group = (Group) query.uniqueResult(); + session.getTransaction().commit(); + return new ResponseEntity<Group>(HttpStatus.OK).ok(group); + } + + +} diff --git a/src/main/java/org/hbp/mip/HibernateUtil.java b/src/main/java/org/hbp/mip/HibernateUtil.java index 713abb0cdd86f54181b4c27bedab20c88a5688f1..4732c8acdecdfc85c2a68efbc32c106327ccd1e6 100644 --- a/src/main/java/org/hbp/mip/HibernateUtil.java +++ b/src/main/java/org/hbp/mip/HibernateUtil.java @@ -10,8 +10,8 @@ import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; public class HibernateUtil { - private static SessionFactory sessionFactory = buildSessionFactory(); private static ServiceRegistry serviceRegistry; + private static SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { @@ -21,8 +21,7 @@ public class HibernateUtil { configuration.getProperties()).build(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; - } - catch (Throwable ex) { + } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } diff --git a/src/main/java/org/hbp/mip/MIPApplication.java b/src/main/java/org/hbp/mip/MIPApplication.java index ecb36651d5909472485004d2e33df0ea39b0dc53..28751d2e2da326c6857894b65685f47d8914c5ca 100644 --- a/src/main/java/org/hbp/mip/MIPApplication.java +++ b/src/main/java/org/hbp/mip/MIPApplication.java @@ -22,8 +22,8 @@ package org.hbp.mip; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.annotations.*; -import org.hbp.mip.model.*; +import io.swagger.annotations.Api; +import org.hbp.mip.model.User; import org.hibernate.Session; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -33,8 +33,6 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoT import org.springframework.boot.context.embedded.FilterRegistrationBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.Authentication; @@ -53,7 +51,9 @@ import org.springframework.security.web.csrf.CsrfFilter; import org.springframework.security.web.csrf.CsrfToken; import org.springframework.security.web.csrf.CsrfTokenRepository; import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.util.WebUtils; @@ -67,8 +67,6 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.security.Principal; -import java.util.Date; -import java.util.List; @SpringBootApplication @RestController @@ -80,6 +78,34 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { @Autowired OAuth2ClientContext oauth2ClientContext; + public static void main(String[] args) { + SpringApplication.run(MIPApplication.class, args); + } + + public static String getUserInfos() { + OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) SecurityContextHolder.getContext().getAuthentication(); + Authentication userAuthentication = oAuth2Authentication.getUserAuthentication(); + System.out.println(userAuthentication.getDetails().toString()); + return userAuthentication.getDetails().toString(); + } + + 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.setString("username", principal.getName()); + User user = (User) query.uniqueResult(); + session.getTransaction().commit(); + if (user == null) { + session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + user = new User(getUserInfos()); + session.save(user); + session.getTransaction().commit(); + } + return user; + } + @RequestMapping("/user") @ResponseBody public Principal user(Principal principal, HttpServletResponse response) { @@ -87,7 +113,7 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { try { String userJSON = mapper.writeValueAsString(getUser(principal)); - Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON,"UTF-8")); + Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON, "UTF-8")); cookie.setPath("/"); response.addCookie(cookie); } catch (JsonProcessingException e) { @@ -110,11 +136,6 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { .and().csrf().csrfTokenRepository(csrfTokenRepository()) .and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class) .addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class); - // @formatter:on - } - - public static void main(String[] args) { - SpringApplication.run(MIPApplication.class, args); } @Bean @@ -172,303 +193,4 @@ public class MIPApplication extends WebSecurityConfigurerAdapter { return repository; } - private String getUserInfos() { - OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) SecurityContextHolder.getContext().getAuthentication(); - Authentication userAuthentication = oAuth2Authentication.getUserAuthentication(); - System.out.println(userAuthentication.getDetails().toString()); - return userAuthentication.getDetails().toString(); - } - - private User getUser(Principal principal) { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from User where username= :username"); - query.setString("username", principal.getName()); - User user = (User) query.uniqueResult(); - session.getTransaction().commit(); - if(user == null) - { - session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - user = new User(getUserInfos()); - session.save(user); - session.getTransaction().commit(); - } - return user; - } - - @RequestMapping(value = "/articles", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "Get articles", notes = "", response = Article.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 200, message = "Success") }) - 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") @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 { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - List<Article> articles = session.createQuery("from Article").list(); - session.getTransaction().commit(); - return new ResponseEntity<List<Article>>(HttpStatus.OK).ok(articles); - } - - @RequestMapping(value = "/articles", method = RequestMethod.POST) - @ApiOperation(value = "Create an article", notes = "", response = Void.class) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Article created") }) - public ResponseEntity<Void> addAnArticle( - @RequestBody @ApiParam(value = "Article to create" ,required=true ) Article article, Principal principal - ) - throws NotFoundException { - User user = getUser(principal); - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - article.setCreatedAt(new Date()); - if(article.getStatus().equals("published")) { - article.setPublishedAt(new Date()); - } - article.setSlug(article.getTitle().toLowerCase()); - article.setCreatedBy(user); - session.save(article); - session.getTransaction().commit(); - return new ResponseEntity<Void>(HttpStatus.OK); - } - - @RequestMapping(value = "/articles/{slug}", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "Get an article", notes = "", response = Article.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found") }) - public ResponseEntity<Article> getAnArticle( - @ApiParam(value = "slug",required=true ) @PathVariable("slug") String slug - ) - throws NotFoundException { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - org.hibernate.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); - } - - @RequestMapping(value = "/articles/{slug}", method = RequestMethod.PUT) - @ApiOperation(value = "Update an article", notes = "", response = Void.class) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Article updated") }) - public ResponseEntity<Void> updateAnArticle( - @ApiParam(value = "slug",required=true ) @PathVariable("slug") String slug, - @ApiParam(value = "Article to update" ,required=true ) Article article - ) - throws NotFoundException { - //TODO - // do some magic! - return new ResponseEntity<Void>(HttpStatus.OK); - } - - @RequestMapping(value = "/articles/{slug}", method = RequestMethod.DELETE) - @ApiOperation(value = "Delete an article", notes = "", response = Void.class) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Article deleted") }) - public ResponseEntity<Void> deleteAnArticle( - @ApiParam(value = "slug",required=true ) @PathVariable("slug") String slug - - ) - throws NotFoundException { - //TODO - // do some magic! - return new ResponseEntity<Void>(HttpStatus.OK); - } - - @RequestMapping(value = "/datasets/{code}", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "Get a dataset", notes = "", response = Dataset.class) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - public ResponseEntity<Dataset> getADataset( - @ApiParam(value = "code",required=true ) @PathVariable("code") String code - ) - throws NotFoundException { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from Dataset where code= :code"); - query.setString("code", code); - Dataset ds = (Dataset) query.uniqueResult(); - session.getTransaction().commit(); - return new ResponseEntity<Dataset>(HttpStatus.OK).ok(ds); - } - - @RequestMapping(value = "/models", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "Get models", notes = "", response = Model.class, responseContainer = "List") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - 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 - ) - throws NotFoundException { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - List<Model> models = session.createQuery("from Model").list(); - session.getTransaction().commit(); - return new ResponseEntity<List<Model>>(HttpStatus.OK).ok(models); - } - - @RequestMapping(value = "/models", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "Create a model", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Model created") }) - public ResponseEntity<Void> addAModel( - @RequestBody @ApiParam(value = "Model to create" ,required=true ) Model model - ) - throws NotFoundException { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - model.setCreatedAt(new Date()); - model.setSlug(model.getTitle().toLowerCase()); - session.save(model); - session.getTransaction().commit(); - return new ResponseEntity<Void>(HttpStatus.OK); - } - - @RequestMapping(value = "/models/{slug}", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "Get a model", notes = "", response = Model.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found") }) - public ResponseEntity<Model> getAModel( - @ApiParam(value = "slug",required=true ) @PathVariable("slug") String slug - - ) - throws NotFoundException { - 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); - } - - @RequestMapping(value = "/models/{slug}", method = RequestMethod.PUT) - @ResponseBody - @ApiOperation(value = "Update a model", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Model updated") }) - public ResponseEntity<Void> updateAModel( - @ApiParam(value = "slug",required=true ) @PathVariable("slug") String slug, - @ApiParam(value = "Model to update" ,required=true ) Model model - ) - throws NotFoundException { - // TODO - // do some magic! - return new ResponseEntity<Void>(HttpStatus.OK); - } - - @RequestMapping(value = "/models/{slug}", method = RequestMethod.DELETE) - @ApiOperation(value = "Delete a model", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Model deleted") }) - public ResponseEntity<Void> deleteAModel( - @ApiParam(value = "slug",required=true ) @PathVariable("slug") String slug - ) - throws NotFoundException { - // TODO - // do some magic! - return new ResponseEntity<Void>(HttpStatus.OK); - } - - @RequestMapping(value = "/groups") - @ResponseBody - @ApiOperation(value = "Get the root group (containing all subgroups)", notes = "", response = Group.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success") }) - public ResponseEntity<Group> getTheRootGroup() - throws NotFoundException { - String rootCode = "root"; - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - org.hibernate.Query query = session.createQuery("from Group where code= :code"); - query.setString("code", rootCode); - Group group = (Group) query.uniqueResult(); - session.getTransaction().commit(); - return new ResponseEntity<Group>(HttpStatus.OK).ok(group); - } - - @RequestMapping(value = "/variables") - @ResponseBody - @ApiOperation(value = "Get variables", notes = "", response = Variable.class, responseContainer = "List") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success") }) - 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 { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); - List<Variable> variables = session.createQuery("from Variable").list(); - session.getTransaction().commit(); - return new ResponseEntity<List<Variable>>(HttpStatus.OK).ok(variables); - } - - @RequestMapping(value = "/variables/{code}") - @ResponseBody - @ApiOperation(value = "Get a variable", notes = "", response = Variable.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Found"), - @ApiResponse(code = 404, message = "Not found") }) - public ResponseEntity<Variable> getAVariable( - @ApiParam(value = "code ( multiple codes are allowed, separeted by \",\" )",required=true ) @PathVariable("code") String code - ) - throws NotFoundException { - 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); - } - - @RequestMapping(value = "/variables/{code}/values") - @ResponseBody - @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") }) - 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 { - 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); - } - -} - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -class NotFoundException extends ApiException { - private int code; - public NotFoundException (int code, String msg) { - super(code, msg); - this.code = code; - } -} - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-06T09:32:22.266Z") -class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } } diff --git a/src/main/java/org/hbp/mip/ModelsApi.java b/src/main/java/org/hbp/mip/ModelsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..b32be220c15e5f0240f90d6fef2ab29b26db7a2f --- /dev/null +++ b/src/main/java/org/hbp/mip/ModelsApi.java @@ -0,0 +1,97 @@ +package org.hbp.mip; + + +import io.swagger.annotations.*; +import org.hbp.mip.model.Model; +import org.hibernate.Session; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.List; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +@Controller +@RequestMapping(value = "/models", produces = {APPLICATION_JSON_VALUE}) +@Api(value = "/models", description = "the models API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-07T07:38:20.227Z") +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) + 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) throws NotFoundException { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + List<Model> models = session.createQuery("from Model").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"}, method = RequestMethod.POST) + public ResponseEntity<Void> addAModel( + @RequestBody @ApiParam(value = "Model to create", required = true) Model model) throws NotFoundException { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + model.setCreatedAt(new Date()); + model.setSlug(model.getTitle().toLowerCase()); + session.save(model); + session.getTransaction().commit(); + return new ResponseEntity<Void>(HttpStatus.OK); + } + + + @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"}, method = RequestMethod.GET) + public ResponseEntity<Model> getAModel( + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + 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"}, method = RequestMethod.PUT) + public ResponseEntity<Void> updateAModel( + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, + @ApiParam(value = "Model to update", required = true) Model model) throws NotFoundException { + // do some magic! + return new ResponseEntity<Void>(HttpStatus.OK); + } + + + @ApiOperation(value = "Delete a model", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Model deleted")}) + @RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.DELETE) + public ResponseEntity<Void> deleteAModel( + @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException { + // do some magic! + return new ResponseEntity<Void>(HttpStatus.OK); + } + + +} diff --git a/src/main/java/org/hbp/mip/NotFoundException.java b/src/main/java/org/hbp/mip/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..d017a2525fd2f438bfb8c9a465d5027c1cf08458 --- /dev/null +++ b/src/main/java/org/hbp/mip/NotFoundException.java @@ -0,0 +1,11 @@ +package org.hbp.mip; + +@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; + + public NotFoundException(int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/src/main/java/org/hbp/mip/VariablesApi.java b/src/main/java/org/hbp/mip/VariablesApi.java new file mode 100644 index 0000000000000000000000000000000000000000..75a3cfa9f20639658c35db386241b4313a0f99e4 --- /dev/null +++ b/src/main/java/org/hbp/mip/VariablesApi.java @@ -0,0 +1,79 @@ +package org.hbp.mip; + + +import io.swagger.annotations.*; +import org.hbp.mip.model.Value; +import org.hbp.mip.model.Variable; +import org.hibernate.Session; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +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.RequestParam; + +import java.util.List; + +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"}, 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 { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + session.beginTransaction(); + List<Variable> variables = session.createQuery("from Variable").list(); + session.getTransaction().commit(); + 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"}, method = RequestMethod.GET) + public ResponseEntity<Variable> getAVariable( + @ApiParam(value = "code ( multiple codes are allowed, separeted by \",\" )", required = true) @PathVariable("code") String code) throws NotFoundException { + 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"}, 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 { + 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 ffe787707a8a85bc5297b8b6e3aa12e21ee05e11..49439438c445d1d3dfe5903c31e6516d8022c7f0 100644 --- a/src/main/java/org/hbp/mip/model/Article.java +++ b/src/main/java/org/hbp/mip/model/Article.java @@ -47,6 +47,7 @@ public class Article { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -59,6 +60,7 @@ public class Article { public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } @@ -71,6 +73,7 @@ public class Article { public String getTitle() { return title; } + public void setTitle(String title) { this.title = title; } @@ -83,6 +86,7 @@ public class Article { public String getSlug() { return slug; } + public void setSlug(String slug) { this.slug = slug; } @@ -95,6 +99,7 @@ public class Article { public String getAbstract() { return _abstract; } + public void setAbstract(String _abstract) { this._abstract = _abstract; } @@ -107,6 +112,7 @@ public class Article { public String getContent() { return content; } + public void setContent(String content) { this.content = content; } @@ -119,6 +125,7 @@ public class Article { public Date getPublishedAt() { return publishedAt; } + public void setPublishedAt(Date publishedAt) { this.publishedAt = publishedAt; } @@ -131,6 +138,7 @@ public class Article { public Date getCreatedAt() { return createdAt; } + public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } @@ -143,6 +151,7 @@ public class Article { public Date getUpdatedAt() { return updatedAt; } + public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; } @@ -155,6 +164,7 @@ public class Article { public User getCreatedBy() { return createdBy; } + public void setCreatedBy(User createdBy) { this.createdBy = createdBy; } @@ -167,6 +177,7 @@ public class Article { public User getUpdatedBy() { return updatedBy; } + public void setUpdatedBy(User updatedBy) { this.updatedBy = updatedBy; } @@ -178,12 +189,13 @@ public class Article { public List<Tag> getTags() { return tags; } + public void setTags(List<Tag> tags) { this.tags = tags; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Article {\n"); diff --git a/src/main/java/org/hbp/mip/model/Chart.java b/src/main/java/org/hbp/mip/model/Chart.java index 203152a54a8788bf0d1531582fbc9cf95f98bbe2..339f6951652b991d399afa3bac246b89c4f10eac 100644 --- a/src/main/java/org/hbp/mip/model/Chart.java +++ b/src/main/java/org/hbp/mip/model/Chart.java @@ -36,6 +36,7 @@ public class Chart { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -48,6 +49,7 @@ public class Chart { public String getChartType() { return chartType; } + public void setChartType(String chartType) { this.chartType = chartType; } @@ -60,6 +62,7 @@ public class Chart { public String getXAxis() { return xAxis; } + public void setXAxis(String xAxis) { this.xAxis = xAxis; } @@ -72,12 +75,13 @@ public class Chart { public List<ChartConfigSet> getChartConfigSets() { return chartConfigSets; } + public void setChartConfigSets(List<ChartConfigSet> chartConfigSets) { this.chartConfigSets = chartConfigSets; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Chart {\n"); diff --git a/src/main/java/org/hbp/mip/model/ChartConfigSet.java b/src/main/java/org/hbp/mip/model/ChartConfigSet.java index 4bee73b6406a55c6e190d33de0a3836a61a914e6..521ec94b116ba103c238f60859747db963d35be5 100644 --- a/src/main/java/org/hbp/mip/model/ChartConfigSet.java +++ b/src/main/java/org/hbp/mip/model/ChartConfigSet.java @@ -33,6 +33,7 @@ public class ChartConfigSet { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -45,6 +46,7 @@ public class ChartConfigSet { public String getCode() { return code; } + public void setCode(String code) { this.code = code; } @@ -57,6 +59,7 @@ public class ChartConfigSet { public String getLabel() { return label; } + public void setLabel(String label) { this.label = label; } @@ -69,13 +72,14 @@ public class ChartConfigSet { public String getColor() { return color; } + public void setColor(String color) { this.color = color; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ChartConfigSet {\n"); diff --git a/src/main/java/org/hbp/mip/model/Dataset.java b/src/main/java/org/hbp/mip/model/Dataset.java index b8c207d9ef073636587cc0bab4877ccd5780d40e..e1651fbd15d2505dd9a3e150643e335ea7c05df6 100644 --- a/src/main/java/org/hbp/mip/model/Dataset.java +++ b/src/main/java/org/hbp/mip/model/Dataset.java @@ -37,6 +37,7 @@ public class Dataset { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -49,6 +50,7 @@ public class Dataset { public String getCode() { return code; } + public void setCode(String code) { this.code = code; } @@ -61,6 +63,7 @@ public class Dataset { public Date getDate() { return date; } + public void setDate(Date date) { this.date = date; } @@ -73,13 +76,14 @@ public class Dataset { public List<String> getHeader() { return header; } + public void setHeader(List<String> header) { this.header = header; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Dataset {\n"); diff --git a/src/main/java/org/hbp/mip/model/Filter.java b/src/main/java/org/hbp/mip/model/Filter.java index 2ccba488244175c6be975862c8162fd6477367cb..a3a61d517051ac616d9e7aee9f3664adc6c3dfa5 100644 --- a/src/main/java/org/hbp/mip/model/Filter.java +++ b/src/main/java/org/hbp/mip/model/Filter.java @@ -33,6 +33,7 @@ public class Filter { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -45,6 +46,7 @@ public class Filter { public Variable getVariable() { return variable; } + public void setVariable(Variable variable) { this.variable = variable; } @@ -57,12 +59,13 @@ public class Filter { public String getOperator() { return operator; } + public void setOperator(String operator) { this.operator = operator; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Filter {\n"); diff --git a/src/main/java/org/hbp/mip/model/Group.java b/src/main/java/org/hbp/mip/model/Group.java index dfc405941bd4202a39dc6472110464e9dcf9b661..7ee0dc08fdb8748bef9538a279f325cc2d6b7532 100644 --- a/src/main/java/org/hbp/mip/model/Group.java +++ b/src/main/java/org/hbp/mip/model/Group.java @@ -36,6 +36,7 @@ public class Group { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -48,6 +49,7 @@ public class Group { public String getCode() { return code; } + public void setCode(String code) { this.code = code; } @@ -60,6 +62,7 @@ public class Group { public String getLabel() { return label; } + public void setLabel(String label) { this.label = label; } @@ -72,12 +75,13 @@ public class Group { public List<Group> getGroups() { return groups; } + public void setGroups(List<Group> groups) { this.groups = groups; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Group {\n"); diff --git a/src/main/java/org/hbp/mip/model/Model.java b/src/main/java/org/hbp/mip/model/Model.java index 89c668061cbeb20b88c312a50a7d20d180babaa6..3f957c962d6f83ef0f635d8fcc1d365b5b15c71d 100644 --- a/src/main/java/org/hbp/mip/model/Model.java +++ b/src/main/java/org/hbp/mip/model/Model.java @@ -47,6 +47,7 @@ public class Model { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -59,6 +60,7 @@ public class Model { public String getTitle() { return title; } + public void setTitle(String title) { this.title = title; } @@ -71,6 +73,7 @@ public class Model { public String getSlug() { return slug; } + public void setSlug(String slug) { this.slug = slug; } @@ -83,6 +86,7 @@ public class Model { public String getDescription() { return description; } + public void setDescription(String description) { this.description = description; } @@ -95,6 +99,7 @@ public class Model { public Query getQuery() { return query; } + public void setQuery(Query query) { this.query = query; } @@ -107,6 +112,7 @@ public class Model { public Dataset getDataset() { return dataset; } + public void setDataset(Dataset dataset) { this.dataset = dataset; } @@ -119,6 +125,7 @@ public class Model { public Boolean getValid() { return valid; } + public void setValid(Boolean valid) { this.valid = valid; } @@ -131,6 +138,7 @@ public class Model { public Chart getChart() { return chart; } + public void setChart(Chart chart) { this.chart = chart; } @@ -143,6 +151,7 @@ public class Model { public Date getCreatedAt() { return createdAt; } + public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } @@ -155,6 +164,7 @@ public class Model { public Date getUpdatedAt() { return updatedAt; } + public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; } @@ -167,6 +177,7 @@ public class Model { public User getCreatedBy() { return createdBy; } + public void setCreatedBy(User createdBy) { this.createdBy = createdBy; } @@ -179,12 +190,13 @@ public class Model { public User getUpdatedBy() { return updatedBy; } + public void setUpdatedBy(User updatedBy) { this.updatedBy = updatedBy; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Model {\n"); diff --git a/src/main/java/org/hbp/mip/model/Query.java b/src/main/java/org/hbp/mip/model/Query.java index 2ec1937b1ee972a6039b43009ee40fe38a2600a9..9f579e9d35f9ea12077d7198f491c2c26248bb96 100644 --- a/src/main/java/org/hbp/mip/model/Query.java +++ b/src/main/java/org/hbp/mip/model/Query.java @@ -41,6 +41,7 @@ public class Query { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -53,6 +54,7 @@ public class Query { public List<Variable> getVariables() { return variables; } + public void setVariables(List<Variable> variables) { this.variables = variables; } @@ -65,6 +67,7 @@ public class Query { public List<Variable> getCovariables() { return covariables; } + public void setCovariables(List<Variable> covariables) { this.covariables = covariables; } @@ -77,6 +80,7 @@ public class Query { public List<Variable> getGrouping() { return grouping; } + public void setGrouping(List<Variable> grouping) { this.grouping = grouping; } @@ -89,6 +93,7 @@ public class Query { public List<Filter> getFilters() { return filters; } + public void setFilters(List<Filter> filters) { this.filters = filters; } @@ -101,12 +106,13 @@ public class Query { public String getRequest() { return request; } + public void setRequest(String request) { this.request = request; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Query {\n"); diff --git a/src/main/java/org/hbp/mip/model/Tag.java b/src/main/java/org/hbp/mip/model/Tag.java index d744eec793fd1cccd84a1414fba9263944a33a4a..b8ec4397013e2f7ba577c6535da2b1221f33bcc7 100644 --- a/src/main/java/org/hbp/mip/model/Tag.java +++ b/src/main/java/org/hbp/mip/model/Tag.java @@ -31,6 +31,7 @@ public class Tag { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -43,12 +44,13 @@ public class Tag { public String getName() { return name; } + public void setName(String name) { this.name = name; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Tag {\n"); diff --git a/src/main/java/org/hbp/mip/model/User.java b/src/main/java/org/hbp/mip/model/User.java index a61231db1f4787c056096f3985c95867d9b4d70a..924e8406a39effda1172deee2b54fe471318d24e 100644 --- a/src/main/java/org/hbp/mip/model/User.java +++ b/src/main/java/org/hbp/mip/model/User.java @@ -46,8 +46,7 @@ public class User { public User() { } - public User(String userInfo) - { + public User(String userInfo) { Pattern p; Matcher m; @@ -90,20 +89,16 @@ public class User { m = p.matcher(userInfo); if (m.find()) { System.out.println(m.group(1)); - if(m.group(1).equals("Mr")) - { + if (m.group(1).equals("Mr")) { this.gender = "Male"; System.out.println("->Male"); - } - else - { + } else { this.gender = "Female"; System.out.println("->Female"); } } - if(this.picture == null || this.picture.isEmpty()) - { + if (this.picture == null || this.picture.isEmpty()) { this.picture = "images/users/default_user.png"; } @@ -117,6 +112,7 @@ public class User { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -129,6 +125,7 @@ public class User { public String getFullname() { return fullname; } + public void setFullname(String fullname) { this.fullname = fullname; } @@ -141,6 +138,7 @@ public class User { public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } @@ -153,6 +151,7 @@ public class User { public String getFirstname() { return firstname; } + public void setFirstname(String firstname) { this.firstname = firstname; } @@ -165,6 +164,7 @@ public class User { public String getLastname() { return lastname; } + public void setLastname(String lastname) { this.lastname = lastname; } @@ -177,6 +177,7 @@ public class User { public String getPicture() { return picture; } + public void setPicture(String picture) { this.picture = picture; } @@ -189,6 +190,7 @@ public class User { public String getWeb() { return web; } + public void setWeb(String web) { this.web = web; } @@ -201,6 +203,7 @@ public class User { public String getPhone() { return phone; } + public void setPhone(String phone) { this.phone = phone; } @@ -213,6 +216,7 @@ public class User { public String getBirthday() { return birthday; } + public void setBirthday(String birthday) { this.birthday = birthday; } @@ -225,6 +229,7 @@ public class User { public String getGender() { return gender; } + public void setGender(String gender) { this.gender = gender; } @@ -237,6 +242,7 @@ public class User { public String getCity() { return city; } + public void setCity(String city) { this.city = city; } @@ -249,6 +255,7 @@ public class User { public String getCountry() { return country; } + public void setCountry(String country) { this.country = country; } @@ -261,6 +268,7 @@ public class User { public String getPassword() { return password; } + public void setPassword(String password) { this.password = password; } @@ -273,6 +281,7 @@ public class User { public String getEmail() { return email; } + public void setEmail(String email) { this.email = email; } @@ -285,6 +294,7 @@ public class User { public String getApikey() { return apikey; } + public void setApikey(String apikey) { this.apikey = apikey; } @@ -297,6 +307,7 @@ public class User { public String getTeam() { return team; } + public void setTeam(String team) { this.team = team; } @@ -309,6 +320,7 @@ public class User { public Boolean getIsActive() { return isActive; } + public void setIsActive(Boolean isActive) { this.isActive = isActive; } @@ -321,6 +333,7 @@ public class User { public List<String> getLanguages() { return languages; } + public void setLanguages(List<String> languages) { this.languages = languages; } @@ -333,12 +346,13 @@ public class User { public List<String> getRoles() { return roles; } + public void setRoles(List<String> roles) { this.roles = roles; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class User {\n"); diff --git a/src/main/java/org/hbp/mip/model/Value.java b/src/main/java/org/hbp/mip/model/Value.java index bc7853d59c62ffb7931051a5296f59180a761a64..887cabc60fc367036d54266929f4edc83fb8bb7f 100644 --- a/src/main/java/org/hbp/mip/model/Value.java +++ b/src/main/java/org/hbp/mip/model/Value.java @@ -30,6 +30,7 @@ public class Value { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -43,6 +44,7 @@ public class Value { public String getCode() { return code; } + public void setCode(String code) { this.code = code; } @@ -56,14 +58,14 @@ public class Value { public String getLabel() { return label; } + public void setLabel(String label) { this.label = label; } - @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Value {\n"); diff --git a/src/main/java/org/hbp/mip/model/Variable.java b/src/main/java/org/hbp/mip/model/Variable.java index 44b33731732bf86d302ea88716678f25fd200337..9acd571f12f4e3786f357a4bf5ccf970aa4ebdf1 100644 --- a/src/main/java/org/hbp/mip/model/Variable.java +++ b/src/main/java/org/hbp/mip/model/Variable.java @@ -43,6 +43,7 @@ public class Variable { public Long getId() { return id; } + public void setId(Long id) { this.id = id; } @@ -55,6 +56,7 @@ public class Variable { public Group getGroup() { return group; } + public void setGroup(Group group) { this.group = group; } @@ -67,6 +69,7 @@ public class Variable { public String getCode() { return code; } + public void setCode(String code) { this.code = code; } @@ -79,6 +82,7 @@ public class Variable { public String getLabel() { return label; } + public void setLabel(String label) { this.label = label; } @@ -91,6 +95,7 @@ public class Variable { public String getType() { return type; } + public void setType(String type) { this.type = type; } @@ -103,6 +108,7 @@ public class Variable { public Integer getLength() { return length; } + public void setLength(Integer length) { this.length = length; } @@ -115,6 +121,7 @@ public class Variable { public Boolean getIsVariable() { return isVariable; } + public void setIsVariable(Boolean isVariable) { this.isVariable = isVariable; } @@ -127,6 +134,7 @@ public class Variable { public Boolean getIsGrouping() { return isGrouping; } + public void setIsGrouping(Boolean isGrouping) { this.isGrouping = isGrouping; } @@ -139,6 +147,7 @@ public class Variable { public Boolean getIsFilter() { return isFilter; } + public void setIsFilter(Boolean isFilter) { this.isFilter = isFilter; } @@ -150,12 +159,13 @@ public class Variable { public List<Value> getValues() { return values; } + public void setValues(List<Value> values) { this.values = values; } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Variable {\n");