diff --git a/src/main/java/org/hbp/mip/MIPApplication.java b/src/main/java/org/hbp/mip/MIPApplication.java index c4706516e7fe0539d4a16e6b008a271ea666d908..0d0671caafb69dbbd0d788197e3101ff1de11b84 100644 --- a/src/main/java/org/hbp/mip/MIPApplication.java +++ b/src/main/java/org/hbp/mip/MIPApplication.java @@ -1,3 +1,8 @@ +/** + * Created by mirco on 04.12.15. + * Based on gregturn code at : 'https://github.com/spring-guides/tut-spring-boot-oauth2'. + */ + /* * Copyright 2012-2015 the original author or authors. * @@ -17,8 +22,7 @@ package org.hbp.mip; import java.io.IOException; import java.security.Principal; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.*; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -27,6 +31,10 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.hbp.mip.mock.ArticleMock; +import org.hbp.mip.mock.ModelMock; +import org.hbp.mip.model.Article; +import org.hbp.mip.model.Model; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -51,6 +59,7 @@ 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.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.util.WebUtils; @@ -59,94 +68,102 @@ import org.springframework.web.util.WebUtils; @RestController @EnableOAuth2Client public class MIPApplication extends WebSecurityConfigurerAdapter { - - @Autowired - OAuth2ClientContext oauth2ClientContext; - - @RequestMapping("/user") - public Principal user(Principal principal) { - return principal; - } - - @RequestMapping("/articles") - public Map<String, String> articles(){ - Map<String, String> map = new LinkedHashMap<>(); - map.put("Test", "This is a test"); - return map; - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http.antMatcher("/**") - .authorizeRequests() - .antMatchers("/", "/frontend/**", "/webjars/**").permitAll() - .anyRequest().authenticated() - .and().exceptionHandling().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/")) - .and().logout().logoutSuccessUrl("/").permitAll() - .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 - public FilterRegistrationBean oauth2ClientFilterRegistration( - OAuth2ClientContextFilter filter) { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setFilter(filter); - registration.setOrder(-100); - return registration; - } - - private Filter ssoFilter() { - OAuth2ClientAuthenticationProcessingFilter hbpFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/hbp"); - OAuth2RestTemplate hbpTemplate = new OAuth2RestTemplate(hbp(), oauth2ClientContext); - hbpFilter.setRestTemplate(hbpTemplate); - hbpFilter.setTokenServices(new UserInfoTokenServices(hbpResource().getUserInfoUri(), hbp().getClientId())); - return hbpFilter; - } - - @Bean - @ConfigurationProperties("hbp.client") - OAuth2ProtectedResourceDetails hbp() { - return new AuthorizationCodeResourceDetails(); - } - - @Bean - @ConfigurationProperties("hbp.resource") - ResourceServerProperties hbpResource() { - return new ResourceServerProperties(); - } - - private Filter csrfHeaderFilter() { - return new OncePerRequestFilter() { - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { - CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); - if (csrf != null) { - Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN"); - String token = csrf.getToken(); - if (cookie == null || token != null && !token.equals(cookie.getValue())) { - cookie = new Cookie("XSRF-TOKEN", token); - cookie.setPath("/"); - response.addCookie(cookie); - } - } - filterChain.doFilter(request, response); - } - }; - } - - private CsrfTokenRepository csrfTokenRepository() { - HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository(); - repository.setHeaderName("X-XSRF-TOKEN"); - return repository; - } + + @Autowired + OAuth2ClientContext oauth2ClientContext; + + @RequestMapping("/user") + public Principal user(Principal principal) { + return principal; + } + + @RequestMapping(value = "/articles", method = RequestMethod.GET) + public List<Article> articles() { + List<Article> articles = new LinkedList<>(); + articles.add(new ArticleMock(1)); + articles.add(new ArticleMock(2)); + return articles; + } + + @RequestMapping(value = "/models", method = RequestMethod.GET) + public List<Model> getModels() { + List<Model> models = new LinkedList<>(); + models.add(new ModelMock(1)); + return models; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http.antMatcher("/**") + .authorizeRequests() + .antMatchers("/", "/frontend/**", "/webjars/**").permitAll() + .anyRequest().authenticated() + .and().exceptionHandling().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/")) + .and().logout().logoutSuccessUrl("/").permitAll() + .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 + public FilterRegistrationBean oauth2ClientFilterRegistration( + OAuth2ClientContextFilter filter) { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(filter); + registration.setOrder(-100); + return registration; + } + + private Filter ssoFilter() { + OAuth2ClientAuthenticationProcessingFilter hbpFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/hbp"); + OAuth2RestTemplate hbpTemplate = new OAuth2RestTemplate(hbp(), oauth2ClientContext); + hbpFilter.setRestTemplate(hbpTemplate); + hbpFilter.setTokenServices(new UserInfoTokenServices(hbpResource().getUserInfoUri(), hbp().getClientId())); + return hbpFilter; + } + + @Bean + @ConfigurationProperties("hbp.client") + OAuth2ProtectedResourceDetails hbp() { + return new AuthorizationCodeResourceDetails(); + } + + @Bean + @ConfigurationProperties("hbp.resource") + ResourceServerProperties hbpResource() { + return new ResourceServerProperties(); + } + + private Filter csrfHeaderFilter() { + return new OncePerRequestFilter() { + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, + FilterChain filterChain) throws ServletException, IOException { + CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); + if (csrf != null) { + Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN"); + String token = csrf.getToken(); + if (cookie == null || token != null && !token.equals(cookie.getValue())) { + cookie = new Cookie("XSRF-TOKEN", token); + cookie.setPath("/"); + response.addCookie(cookie); + } + } + filterChain.doFilter(request, response); + } + }; + } + + private CsrfTokenRepository csrfTokenRepository() { + HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository(); + repository.setHeaderName("X-XSRF-TOKEN"); + return repository; + } } diff --git a/src/main/java/org/hbp/mip/mock/ArticleMock.java b/src/main/java/org/hbp/mip/mock/ArticleMock.java new file mode 100644 index 0000000000000000000000000000000000000000..1d2768990ce3173f93739531d062c785d8d65c05 --- /dev/null +++ b/src/main/java/org/hbp/mip/mock/ArticleMock.java @@ -0,0 +1,47 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.mock; + +import org.hbp.mip.model.Article; +import org.hbp.mip.model.User; + +import java.util.Date; +import java.util.LinkedList; + +public class ArticleMock extends Article { + public ArticleMock(int id) { + Date currentDate = new Date(); + User currentUser = new UserMock(1); + this.setId(id); + switch (id) { + case 1: + this.setTitle("Test1"); + this.setStatus("published"); + this.setSlug("test1"); + this.setPublishedAt(currentDate); + this.setUpdatedAt(currentDate); + this.setTags(new LinkedList<>()); + this.setAbst("This is a first test article."); + this.setContent("<!DOCTYPE html><html><head></head><body><p>This is the content of my first test article.</p></body></html>"); + this.setCreatedAt(currentDate); + this.setCreatedBy(currentUser); + this.setUpdatedBy(currentUser); + break; + case 2: + this.setTitle("Test2"); + this.setStatus("published"); + this.setSlug("test2"); + this.setPublishedAt(currentDate); + this.setUpdatedAt(currentDate); + this.setTags(new LinkedList<>()); + this.setAbst("This is a second test article."); + this.setContent("<!DOCTYPE html><html><head></head><body><p>This is the content of my second test article.</p></body></html>"); + this.setCreatedAt(currentDate); + this.setCreatedBy(currentUser); + this.setUpdatedBy(currentUser); + break; + } + } +} diff --git a/src/main/java/org/hbp/mip/mock/ModelMock.java b/src/main/java/org/hbp/mip/mock/ModelMock.java new file mode 100644 index 0000000000000000000000000000000000000000..9f8de2fe1ccbf1ab4a8003f828ae17a4ae15e4e5 --- /dev/null +++ b/src/main/java/org/hbp/mip/mock/ModelMock.java @@ -0,0 +1,17 @@ +package org.hbp.mip.mock; + +import org.hbp.mip.model.Model; + +/** + * Created by mirco on 04.12.15. + */ +public class ModelMock extends Model { + public ModelMock(int id) { + this.setId(id); + switch (id) { + case 1: + this.setTitle("Model1"); + break; + } + } +} diff --git a/src/main/java/org/hbp/mip/mock/UserMock.java b/src/main/java/org/hbp/mip/mock/UserMock.java new file mode 100644 index 0000000000000000000000000000000000000000..5ae44fe6f03144d90667c0502cc5498715b67922 --- /dev/null +++ b/src/main/java/org/hbp/mip/mock/UserMock.java @@ -0,0 +1,34 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.mock; + +import org.hbp.mip.model.User; + +public class UserMock extends User { + public UserMock(int id) { + this.setId(id); + switch (id) { + case 1: + this.setFirstname("Linda"); + this.setFullname("Linda DIB"); + this.setLastname("DIB"); + this.setPicture("images/users/Linda.jpg"); + this.setWeb("http://www.hbpproject.eu"); + this.setPhone("+33 6 00 00 00 00"); + this.setBirthday("1982-01-22"); + this.setGender("Female"); + this.addLanguage("French"); + this.addLanguage("English"); + this.setPassword("user"); + this.setEmail("l.dib@hbpproject.eu"); + this.setIsActive(true); + this.setApikey("kiliaanapikey"); + this.setTeam("Scientist"); + this.addRole("ROLE_ADMIN"); + this.addRole("ROLE_SCIENTIST"); + break; + } + } +} diff --git a/src/main/java/org/hbp/mip/model/Article.java b/src/main/java/org/hbp/mip/model/Article.java new file mode 100644 index 0000000000000000000000000000000000000000..fae7d61772e62670262f531a93fed86f3fa22dd3 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Article.java @@ -0,0 +1,130 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +public class Article { + private int id; + private String status; + private String title; + private String slug; + private String abst; + private String content; + private Date publishedAt; + private List<Tag> tags; + private Date createdAt; + private Date updatedAt; + private User createdBy; + private User updatedBy; + + public Article() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSlug() { + return slug; + } + + public void setSlug(String slug) { + this.slug = slug; + } + + public String getAbst() { + return abst; + } + + public void setAbst(String abst) { + this.abst = abst; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Date getPublishedAt() { + return publishedAt; + } + + public void setPublishedAt(Date publishedAt) { + this.publishedAt = publishedAt; + } + + public List<Tag> getTags() { + return tags; + } + + public void setTags(List<Tag> tags) { + this.tags = tags; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public User getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(User createdBy) { + this.createdBy = createdBy; + } + + public User getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(User updatedBy) { + this.updatedBy = updatedBy; + } + + public void addTag(Tag tag) { + if(this.tags == null) { + this.tags = new LinkedList<>(); + } + this.tags.add(tag); + } +} diff --git a/src/main/java/org/hbp/mip/model/Chart.java b/src/main/java/org/hbp/mip/model/Chart.java new file mode 100644 index 0000000000000000000000000000000000000000..323be5c13306f2a27811cc136699082638c5c743 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Chart.java @@ -0,0 +1,57 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.LinkedList; +import java.util.List; + +public class Chart { + private int id; + private String chartType; + private String xAxis; + private List<ChartConfigSet> chartConfigSets; + + public Chart() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getChartType() { + return chartType; + } + + public void setChartType(String chartType) { + this.chartType = chartType; + } + + public String getxAxis() { + return xAxis; + } + + public void setxAxis(String xAxis) { + this.xAxis = xAxis; + } + + public List<ChartConfigSet> getChartConfigSets() { + return chartConfigSets; + } + + public void setChartConfigSets(List<ChartConfigSet> chartConfigSets) { + this.chartConfigSets = chartConfigSets; + } + + public void addChartConfigSet(ChartConfigSet chartConfigSet) { + if(this.chartConfigSets == null) { + this.chartConfigSets = new LinkedList<>(); + } + 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 new file mode 100644 index 0000000000000000000000000000000000000000..d197be05e70b30fb1d8ffbd0f090b4cf9fed1ca3 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/ChartConfigSet.java @@ -0,0 +1,47 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +public class ChartConfigSet { + private int id; + private String code; + private String label; + private String color; + + public ChartConfigSet() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } +} diff --git a/src/main/java/org/hbp/mip/model/Dataset.java b/src/main/java/org/hbp/mip/model/Dataset.java new file mode 100644 index 0000000000000000000000000000000000000000..ff50d694a8592d2bb5a183abeeea30e2441cab47 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Dataset.java @@ -0,0 +1,74 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class Dataset { + private int id; + private String code; + private Date date; + private List<String> header; + private List<Map<String, List<Object>>> data; + + public Dataset() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public List<String> getHeader() { + return header; + } + + public void setHeader(List<String> header) { + this.header = header; + } + + public List<Map<String, List<Object>>> getData() { + return data; + } + + public void setData(List<Map<String, List<Object>>> data) { + this.data = data; + } + + public void addHeaderValue(String value) { + if(this.header == null) { + this.header = new LinkedList<>(); + } + this.header.add(value); + } + public void addDataMap(Map<String, List<Object>> map) { + if(this.data == null) { + this.data = new LinkedList<>(); + } + this.data.add(map); + } +} diff --git a/src/main/java/org/hbp/mip/model/Filter.java b/src/main/java/org/hbp/mip/model/Filter.java new file mode 100644 index 0000000000000000000000000000000000000000..b5363269b4e7f1fc0b7e75c12ddd8fef10496b8c --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Filter.java @@ -0,0 +1,38 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +public class Filter { + private int id; + private Variable variable; + private String operator; + + public Filter() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Variable getVariable() { + return variable; + } + + public void setVariable(Variable variable) { + this.variable = variable; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } +} diff --git a/src/main/java/org/hbp/mip/model/Group.java b/src/main/java/org/hbp/mip/model/Group.java new file mode 100644 index 0000000000000000000000000000000000000000..956d3d583799dd1434b3876640154a4ca2c84760 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Group.java @@ -0,0 +1,57 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.LinkedList; +import java.util.List; + +public class Group { + private int id; + private String code; + private String label; + private List<Group> groups; + + public Group() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List<Group> getGroups() { + return groups; + } + + public void setGroups(List<Group> groups) { + this.groups = groups; + } + + public void addGroup(Group group) { + if(this.groups == null) { + this.groups = new LinkedList<>(); + } + this.groups.add(group); + } +} diff --git a/src/main/java/org/hbp/mip/model/Model.java b/src/main/java/org/hbp/mip/model/Model.java new file mode 100644 index 0000000000000000000000000000000000000000..872634fa90f8fba18bce6031f6611fc5d2480b61 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Model.java @@ -0,0 +1,121 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.Date; + +public class Model { + private int id; + private String title; + private String slug; + private String description; + private Query query; + private Dataset dataset; + private boolean valid; + private Chart chart; + private Date createdAt; + private Date updatedAt; + private User createdBy; + private User updatedBy; + + public Model() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSlug() { + return slug; + } + + public void setSlug(String slug) { + this.slug = slug; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Query getQuery() { + return query; + } + + public void setQuery(Query query) { + this.query = query; + } + + public Dataset getDataset() { + return dataset; + } + + public void setDataset(Dataset dataset) { + this.dataset = dataset; + } + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public Chart getChart() { + return chart; + } + + public void setChart(Chart chart) { + this.chart = chart; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public User getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(User createdBy) { + this.createdBy = createdBy; + } + + public User getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(User updatedBy) { + this.updatedBy = updatedBy; + } +} diff --git a/src/main/java/org/hbp/mip/model/Query.java b/src/main/java/org/hbp/mip/model/Query.java new file mode 100644 index 0000000000000000000000000000000000000000..d4097830a678d3de126bcc42ff7d5f54e732174a --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Query.java @@ -0,0 +1,96 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.LinkedList; +import java.util.List; + +public class Query { + private int id; + private List<Variable> variables; + private List<Variable> covariables; + private List<Variable> grouping; + private List<Filter> filters; + private String request; + + public Query() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public List<Variable> getVariables() { + return variables; + } + + public void setVariables(List<Variable> variables) { + this.variables = variables; + } + + public List<Variable> getCovariables() { + return covariables; + } + + public void setCovariables(List<Variable> covariables) { + this.covariables = covariables; + } + + public List<Variable> getGrouping() { + return grouping; + } + + public void setGrouping(List<Variable> grouping) { + this.grouping = grouping; + } + + public List<Filter> getFilters() { + return filters; + } + + public void setFilters(List<Filter> filters) { + this.filters = filters; + } + + public String getRequest() { + return request; + } + + public void setRequest(String request) { + this.request = request; + } + + public void addVariable(Variable variable) { + if(this.variables == null) { + this.variables = new LinkedList<>(); + } + this.variables.add(variable); + } + + public void addCovariable(Variable covariable) { + if(this.covariables == null) { + this.covariables = new LinkedList<>(); + } + this.covariables.add(covariable); + } + + public void addGroupingVariable(Variable groupingVariable) { + if(this.grouping == null) { + this.grouping = new LinkedList<>(); + } + this.grouping.add(groupingVariable); + } + + public void addFilter(Filter filter) { + if(this.filters == null) { + this.filters = new LinkedList<>(); + } + this.filters.add(filter); + } +} diff --git a/src/main/java/org/hbp/mip/model/Tag.java b/src/main/java/org/hbp/mip/model/Tag.java new file mode 100644 index 0000000000000000000000000000000000000000..723b30ecc01603c507508041eedf374a0c7d2f02 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Tag.java @@ -0,0 +1,29 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +public class Tag { + private int id; + private String name; + + public Tag() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/org/hbp/mip/model/User.java b/src/main/java/org/hbp/mip/model/User.java new file mode 100644 index 0000000000000000000000000000000000000000..e10e684c6e6b8a0e0a723625829c67d14ad4012a --- /dev/null +++ b/src/main/java/org/hbp/mip/model/User.java @@ -0,0 +1,199 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.LinkedList; +import java.util.List; + +public class User { + private int id; + private String fullname; + private String username; + private String firstname; + private String lastname; + private String picture; + private String web; + private String phone; + private String birthday; + private String gender; + private List<String> languages; + private String city; + private String country; + private String password; + private String email; + private boolean isActive; + private String apikey; + private String team; + private List<String> roles; + + public User() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFullname() { + return fullname; + } + + public void setFullname(String fullname) { + this.fullname = fullname; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public String getPicture() { + return picture; + } + + public void setPicture(String picture) { + this.picture = picture; + } + + public String getWeb() { + return web; + } + + public void setWeb(String web) { + this.web = web; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getBirthday() { + return birthday; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public List<String> getLanguages() { + return languages; + } + + public void setLanguages(List<String> languages) { + this.languages = languages; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public boolean isActive() { + return isActive; + } + + public void setIsActive(boolean isActive) { + this.isActive = isActive; + } + + public String getApikey() { + return apikey; + } + + public void setApikey(String apikey) { + this.apikey = apikey; + } + + public String getTeam() { + return team; + } + + public void setTeam(String team) { + this.team = team; + } + + public List<String> getRoles() { + return roles; + } + + public void setRoles(List<String> roles) { + this.roles = roles; + } + + public void addLanguage(String language) { + if(this.languages == null) { + this.languages = new LinkedList<>(); + } + this.languages.add(language); + } + + public void addRole(String role) { + if(this.roles == null) { + this.roles = new LinkedList<>(); + } + this.roles.add(role); + } +} diff --git a/src/main/java/org/hbp/mip/model/Value.java b/src/main/java/org/hbp/mip/model/Value.java new file mode 100644 index 0000000000000000000000000000000000000000..3c8cbad44bf2b0f3e64f51b51f4bd27bbb3896cd --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Value.java @@ -0,0 +1,38 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +public class Value { + private int id; + private String code; + private String label; + + public Value() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } +} diff --git a/src/main/java/org/hbp/mip/model/Variable.java b/src/main/java/org/hbp/mip/model/Variable.java new file mode 100644 index 0000000000000000000000000000000000000000..38359b39a9f9ec5e0efd26cb3ea2254aff5ee74f --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Variable.java @@ -0,0 +1,120 @@ +/** + * Created by mirco on 04.12.15. + */ + +package org.hbp.mip.model; + +import java.util.LinkedList; +import java.util.List; + +public class Variable { + private int id; + private Group group; + private String code; + private String label; + private String type; + private int length; + private boolean isVariable; + private boolean isGrouping; + private boolean isCovariable; + private boolean isFilter; + private List<Value> values; + + public Variable() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public boolean isVariable() { + return isVariable; + } + + public void setIsVariable(boolean isVariable) { + this.isVariable = isVariable; + } + + public boolean isGrouping() { + return isGrouping; + } + + public void setIsGrouping(boolean isGrouping) { + this.isGrouping = isGrouping; + } + + public boolean isCovariable() { + return isCovariable; + } + + public void setIsCovariable(boolean isCovariable) { + this.isCovariable = isCovariable; + } + + public boolean isFilter() { + return isFilter; + } + + public void setIsFilter(boolean isFilter) { + this.isFilter = isFilter; + } + + public List<Value> getValues() { + return values; + } + + public void setValues(List<Value> values) { + this.values = values; + } + + public void addValue(Value value) { + if(this.values == null) { + this.values = new LinkedList<>(); + } + this.values.add(value); + } +} diff --git a/src/main/resources/static/frontend/app/scripts/app/home/home.html b/src/main/resources/static/frontend/app/scripts/app/home/home.html index 6d1115e1aa2f6920bc32f02fc667ad927213c39f..5276422dec321afa763de764a4717e5aaf0184b4 100644 --- a/src/main/resources/static/frontend/app/scripts/app/home/home.html +++ b/src/main/resources/static/frontend/app/scripts/app/home/home.html @@ -1,114 +1,114 @@ -<div class="container-fluid intro-container" ng-show="isNewVisitor()"> - <a href="" ng-click="closePanel($event)" class="trigger-close-intro"> - <i class="ti ti-close"></i> - </a> - <div class="intro block-header"> - <h3>Access the largest</h3> - <h2>Brain</h2> - <ul> - <li>clinical</li> - <li>database</li> - </ul> - <img src="images/intro.png" /> - </div> - - <div class="block-content row intro-txt"> - <div class="col-md-6 col-md-offset-3"> - <h4>Titre chapitre :</h4> - <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p> - <h3>Titre chapitre :</h3> - <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p> - </div> - </div> - <a class="trigger-intro" ng-click="animateIntro()"> - <i class="ti ti-arrow-down"></i> - </a> -</div> - -<div class="container-fluid mt" ng-show="!isNewVisitor()"> - <div class="row"> - <div class="col-md-3"> - <div class="info-tile tile-orange"> - <div class="tile-icon"><i class="icon-glasses"></i></div> - <div class="tile-heading"><span>Scientists</span></div> - <div class="tile-body"><span>{{datas.scientists}}</span></div> - <div class="tile-footer">Scientists registered <br />on the platform sipides</div> - </div> - </div> - <div class="col-md-3"> - <div class="info-tile tile-blue"> - <div class="tile-icon"><i class="icon-exam"></i></div> - <div class="tile-heading"><span>Articles</span></div> - <div class="tile-body"><span>{{datas.articles}}</span></div> - <div class="tile-footer">Articles written on <br />the platform</div> - </div> - </div> - <div class="col-md-3"> - <div class="info-tile tile-gray"> - <div class="tile-icon"><i class="icon-molecular"></i></div> - <div class="tile-heading"><span>Records</span></div> - <div class="tile-body"><span>{{datas.patients}}</span></div> - <div class="tile-footer">Records in database</div> - </div> - </div> - <div class="col-md-3"> - <div class="info-tile tile-edit"> - <div class="tile-icon"><i class="icon-write"></i></div> - <div class="tile-heading"><span> </span></div> - <div class="tile-body"><span> </span></div> - <a href="#/articles/create" class="tile-title"> - <big>write</big> - <span>an article</span> - - <span class="icon">+</span> - </a> - </div> - </div> - </div> - <div data-widget-group="group1" class="ui-sortable"> - <div class="row"> - - <div class="col-md-4" ng-repeat="model in models"> - <div class="panel panel-default ui-state-default panel-height-fixe" data-widget="{'draggable': 'false'}" data-widget-static=""> - <div class="panel-heading"> - <h2>{{model.title}}</h2> - <div class="panel-ctrls button-icon-bg" - data-actions-container="" - data-action-collapse='{"target": ".panel-body"}' - data-action-refresh-demo='{"type": "circular"}' > - </div> - </div> - <div class="panel-body panel-body-graph"> - <highchart config="model.chartConfig"></highchart> - </div> - <a ng-href="#/models/{{model.slug}}/false" class="panel-link"><i>+</i></a> - </div> - </div> - - </div> - <div class="row"> - <div class="col-md-6"> - <div ng-include="'scripts/app/articles/articles.html'" ng-controller="ArticlesController"></div> - </div> - <div class="col-md-6"> - <div class="panel" data-widget='{"draggable": "false"}'> - <div class="panel-heading"> - <h2>Recent Models</h2> - <div class="panel-ctrls button-icon-bg" - data-actions-container="" - data-action-collapse='{"target": ".panel-body"}' - data-action-refresh-demo='{"type": "circular"}' - > - </div> - </div> - <div class="panel-body scroll-pane" style="height: 320px;"> - <div class="custom-scrollbar" scrollbar> - <div ng-include="'scripts/app/models/models.html'" ng-controller="ModelsController" params='{"limit":10,"team":1,"valid":1}'></div> - </div> - </div> - </div> - </div> - </div> - - </div> -</div> +<div class="container-fluid intro-container" ng-show="isNewVisitor()"> + <a href="" ng-click="closePanel($event)" class="trigger-close-intro"> + <i class="ti ti-close"></i> + </a> + <div class="intro block-header"> + <h3>Access the largest</h3> + <h2>Brain</h2> + <ul> + <li>clinical</li> + <li>database</li> + </ul> + <img src="images/intro.png" /> + </div> + + <div class="block-content row intro-txt"> + <div class="col-md-6 col-md-offset-3"> + <h4>Titre chapitre :</h4> + <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p> + <h3>Titre chapitre :</h3> + <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p> + </div> + </div> + <a class="trigger-intro" ng-click="animateIntro()"> + <i class="ti ti-arrow-down"></i> + </a> +</div> + +<div class="container-fluid mt" ng-show="!isNewVisitor()"> + <div class="row"> + <div class="col-md-3"> + <div class="info-tile tile-orange"> + <div class="tile-icon"><i class="icon-glasses"></i></div> + <div class="tile-heading"><span>Scientists</span></div> + <div class="tile-body"><span>{{datas.scientists}}</span></div> + <div class="tile-footer">Scientists registered <br />on the platform sipides</div> + </div> + </div> + <div class="col-md-3"> + <div class="info-tile tile-blue"> + <div class="tile-icon"><i class="icon-exam"></i></div> + <div class="tile-heading"><span>Articles</span></div> + <div class="tile-body"><span>{{datas.articles}}</span></div> + <div class="tile-footer">Articles written on <br />the platform</div> + </div> + </div> + <div class="col-md-3"> + <div class="info-tile tile-gray"> + <div class="tile-icon"><i class="icon-molecular"></i></div> + <div class="tile-heading"><span>Records</span></div> + <div class="tile-body"><span>{{datas.patients}}</span></div> + <div class="tile-footer">Records in database</div> + </div> + </div> + <div class="col-md-3"> + <div class="info-tile tile-edit"> + <div class="tile-icon"><i class="icon-write"></i></div> + <div class="tile-heading"><span> </span></div> + <div class="tile-body"><span> </span></div> + <a href="#/articles/create" class="tile-title"> + <big>write</big> + <span>an article</span> + + <span class="icon">+</span> + </a> + </div> + </div> + </div> + <div data-widget-group="group1" class="ui-sortable"> + <div class="row"> + + <div class="col-md-4" ng-repeat="model in models"> + <div class="panel panel-default ui-state-default panel-height-fixe" data-widget="{'draggable': 'false'}" data-widget-static=""> + <div class="panel-heading"> + <h2>{{model.title}}</h2> + <div class="panel-ctrls button-icon-bg" + data-actions-container="" + data-action-collapse='{"target": ".panel-body"}' + data-action-refresh-demo='{"type": "circular"}' > + </div> + </div> + <div class="panel-body panel-body-graph"> + <highchart config="model.chartConfig"></highchart> + </div> + <a ng-href="#/models/{{model.slug}}/false" class="panel-link"><i>+</i></a> + </div> + </div> + + </div> + <div class="row"> + <div class="col-md-6"> + <div ng-include="'scripts/app/articles/articles.html'" ng-controller="ArticlesController"></div> + </div> + <div class="col-md-6"> + <div class="panel" data-widget='{"draggable": "false"}'> + <div class="panel-heading"> + <h2>Recent Models</h2> + <div class="panel-ctrls button-icon-bg" + data-actions-container="" + data-action-collapse='{"target": ".panel-body"}' + data-action-refresh-demo='{"type": "circular"}' + > + </div> + </div> + <div class="panel-body scroll-pane" style="height: 320px;"> + <div class="custom-scrollbar" scrollbar> + <div ng-include="'scripts/app/models/models.html'" ng-controller="ModelsController" params='{"limit":10,"team":1,"valid":1}'></div> + </div> + </div> + </div> + </div> + </div> + + </div> +</div> diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 1ff821eda310647bed32ea64b5318e670c53b924..eda642e94b71383f0a15ddd32c07853f78126a01 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -22,7 +22,10 @@ </div> <div class="container" ng-show="home.authenticated"> Logged in as: <span ng-bind="home.user"></span> + <br /> E-mail: <span ng-bind="home.email"></span> + <br /> + (Id, Contractor and so on are also available) <hr /> <div> <button ng-click="home.logout()" class="btn btn-primary">Logout</button>