Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit e2b6fec

Browse files
committed
Use a relational persistance layer and other things
MongoDB didn't lend itself well to the way we specified the HFCu interface. This adds classes and code to use the javax.persistance.* annotations to use a relational database layer. Currently it is an hibernate (in memory) database, but switching to another (like mysql) database shouldn't be hard. The downside of hibernate is that data doesn't persist between service restarts. During the hackathon, I also worked on implementing the other endpoints, so this is a complete prototype. It is still missing all kinds of access control and checks (e.g. not null checks for the controller and much more).
1 parent fdf9153 commit e2b6fec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1768
-330
lines changed

pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,20 @@
2525
</dependency>
2626
<dependency>
2727
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-data-mongodb</artifactId>
28+
<artifactId>spring-boot-starter-tomcat</artifactId>
29+
<scope>provided</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>com.h2database</groupId>
33+
<artifactId>h2</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.data</groupId>
37+
<artifactId>spring-data-jpa</artifactId>
2938
</dependency>
3039
<dependency>
3140
<groupId>org.springframework.boot</groupId>
32-
<artifactId>spring-boot-starter-tomcat</artifactId>
33-
<scope>provided</scope>
41+
<artifactId>spring-boot-starter-data-jpa</artifactId>
3442
</dependency>
3543
<!--SpringFox dependencies -->
3644
<dependency>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.swagger.api;
2+
3+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
4+
5+
public class ApiException extends Exception{
6+
private int code;
7+
public ApiException (int code, String msg) {
8+
super(msg);
9+
this.code = code;
10+
}
11+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.swagger.api;
2+
3+
import java.io.IOException;
4+
5+
import javax.servlet.*;
6+
import javax.servlet.http.HttpServletResponse;
7+
8+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
9+
10+
public class ApiOriginFilter implements javax.servlet.Filter {
11+
@Override
12+
public void doFilter(ServletRequest request, ServletResponse response,
13+
FilterChain chain) throws IOException, ServletException {
14+
HttpServletResponse res = (HttpServletResponse) response;
15+
res.addHeader("Access-Control-Allow-Origin", "*");
16+
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
17+
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
18+
chain.doFilter(request, response);
19+
}
20+
21+
@Override
22+
public void destroy() {
23+
}
24+
25+
@Override
26+
public void init(FilterConfig filterConfig) throws ServletException {
27+
}
28+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package io.swagger.api;
2+
3+
import javax.xml.bind.annotation.XmlTransient;
4+
5+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
6+
7+
@javax.xml.bind.annotation.XmlRootElement
8+
public class ApiResponseMessage {
9+
public static final int ERROR = 1;
10+
public static final int WARNING = 2;
11+
public static final int INFO = 3;
12+
public static final int OK = 4;
13+
public static final int TOO_BUSY = 5;
14+
15+
int code;
16+
String type;
17+
String message;
18+
19+
public ApiResponseMessage(){}
20+
21+
public ApiResponseMessage(int code, String message){
22+
this.code = code;
23+
switch(code){
24+
case ERROR:
25+
setType("error");
26+
break;
27+
case WARNING:
28+
setType("warning");
29+
break;
30+
case INFO:
31+
setType("info");
32+
break;
33+
case OK:
34+
setType("ok");
35+
break;
36+
case TOO_BUSY:
37+
setType("too busy");
38+
break;
39+
default:
40+
setType("unknown");
41+
break;
42+
}
43+
this.message = message;
44+
}
45+
46+
@XmlTransient
47+
public int getCode() {
48+
return code;
49+
}
50+
51+
public void setCode(int code) {
52+
this.code = code;
53+
}
54+
55+
public String getType() {
56+
return type;
57+
}
58+
59+
public void setType(String type) {
60+
this.type = type;
61+
}
62+
63+
public String getMessage() {
64+
return message;
65+
}
66+
67+
public void setMessage(String message) {
68+
this.message = message;
69+
}
70+
}
Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,26 @@
11
package io.swagger.api;
22

3-
import io.swagger.model.CohortData;
4-
import io.swagger.model.Error;
5-
import io.swagger.model.HFCurationListResponse;
6-
import io.swagger.model.HFCurationRequest;
7-
import io.swagger.model.HFCurationResponse;
8-
import io.swagger.model.HaplotypeFrequencyData;
9-
import io.swagger.model.LabelData;
10-
import io.swagger.model.PopulationData;
11-
import io.swagger.model.PopulationResponse;
12-
import io.swagger.model.PopulationSubmissionResponse;
13-
import io.swagger.model.ScopeData;
3+
import io.swagger.model.*;
144

155
import io.swagger.annotations.*;
16-
import org.springframework.http.HttpStatus;
176
import org.springframework.http.ResponseEntity;
187
import org.springframework.web.bind.annotation.PathVariable;
198
import org.springframework.web.bind.annotation.RequestBody;
20-
import org.springframework.web.bind.annotation.RequestHeader;
219
import org.springframework.web.bind.annotation.RequestMapping;
2210
import org.springframework.web.bind.annotation.RequestMethod;
23-
import org.springframework.web.bind.annotation.RequestParam;
24-
import org.springframework.web.bind.annotation.RequestPart;
25-
import org.springframework.web.multipart.MultipartFile;
2611

27-
import java.util.List;
28-
import javax.validation.constraints.*;
29-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-26T11:57:21.787-05:00")
12+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
3013

3114
@Api(value = "hfc", description = "the hfc API")
3215
public interface HfcApi {
3316

34-
@ApiOperation(value = "", notes = "Gets a list of all submission data sets ", response = HFCurationListResponse.class, tags={ })
17+
@ApiOperation(value = "", notes = "Gets a list of all submission data sets ", response = HFCurationResponseList.class, tags={ })
3518
@ApiResponses(value = {
36-
@ApiResponse(code = 200, message = "Successful response", response = HFCurationListResponse.class),
37-
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = HFCurationListResponse.class) })
19+
@ApiResponse(code = 200, message = "Successful response", response = HFCurationResponseList.class),
20+
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = HFCurationResponseList.class) })
3821
@RequestMapping(value = "/hfc",
3922
method = RequestMethod.GET)
40-
default ResponseEntity<HFCurationListResponse> hfcGet() {
41-
// do some magic!
42-
return new ResponseEntity<HFCurationListResponse>(HttpStatus.OK);
43-
}
23+
ResponseEntity<HFCurationResponseList> hfcGet();
4424

4525

4626
@ApiOperation(value = "", notes = "Get a list of all populations ", response = PopulationResponse.class, tags={ })
@@ -49,10 +29,7 @@ default ResponseEntity<HFCurationListResponse> hfcGet() {
4929
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = PopulationResponse.class) })
5030
@RequestMapping(value = "/hfc/population",
5131
method = RequestMethod.GET)
52-
default ResponseEntity<PopulationResponse> hfcPopulationGet() {
53-
// do some magic!
54-
return new ResponseEntity<PopulationResponse>(HttpStatus.OK);
55-
}
32+
ResponseEntity<PopulationResponse> hfcPopulationGet();
5633

5734

5835
@ApiOperation(value = "", notes = "Returns a population with its attached submissions", response = PopulationSubmissionResponse.class, tags={ })
@@ -61,10 +38,7 @@ default ResponseEntity<PopulationResponse> hfcPopulationGet() {
6138
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = PopulationSubmissionResponse.class) })
6239
@RequestMapping(value = "/hfc/population/{populationId}",
6340
method = RequestMethod.GET)
64-
default ResponseEntity<PopulationSubmissionResponse> hfcPopulationPopulationIdGet(@ApiParam(value = "The population id",required=true ) @PathVariable("populationId") String populationId) {
65-
// do some magic!
66-
return new ResponseEntity<PopulationSubmissionResponse>(HttpStatus.OK);
67-
}
41+
ResponseEntity<PopulationSubmissionResponse> hfcPopulationPopulationIdGet(@ApiParam(value = "The population id",required=true ) @PathVariable("populationId") String populationId);
6842

6943

7044
@ApiOperation(value = "", notes = "Storing of a new Haplotype Frequency set. ", response = HFCurationResponse.class, tags={ })
@@ -73,10 +47,7 @@ default ResponseEntity<PopulationSubmissionResponse> hfcPopulationPopulationIdGe
7347
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = HFCurationResponse.class) })
7448
@RequestMapping(value = "/hfc",
7549
method = RequestMethod.POST)
76-
default ResponseEntity<HFCurationResponse> hfcPost(@ApiParam(value = "Haplotype Frequency Curation Data" ,required=true ) @RequestBody HFCurationRequest hfCurationRequest) {
77-
// do some magic!
78-
return new ResponseEntity<HFCurationResponse>(HttpStatus.OK);
79-
}
50+
ResponseEntity<HFCurationResponse> hfcPost(@ApiParam(value = "Haplotype Frequency Curation Data" ,required=true ) @RequestBody HFCurationRequest hfCurationRequest);
8051

8152

8253
@ApiOperation(value = "", notes = "Returns the list of haplotypes attached to the given submission", response = CohortData.class, tags={ })
@@ -85,10 +56,7 @@ default ResponseEntity<HFCurationResponse> hfcPost(@ApiParam(value = "Haplotype
8556
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = CohortData.class) })
8657
@RequestMapping(value = "/hfc/{submissionId}/cohort",
8758
method = RequestMethod.GET)
88-
default ResponseEntity<CohortData> hfcSubmissionIdCohortGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId) {
89-
// do some magic!
90-
return new ResponseEntity<CohortData>(HttpStatus.OK);
91-
}
59+
ResponseEntity<CohortData> hfcSubmissionIdCohortGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId);
9260

9361

9462
@ApiOperation(value = "", notes = "Returns a submission of haplotypes", response = HFCurationResponse.class, tags={ })
@@ -97,10 +65,7 @@ default ResponseEntity<CohortData> hfcSubmissionIdCohortGet(@ApiParam(value = "T
9765
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = HFCurationResponse.class) })
9866
@RequestMapping(value = "/hfc/{submissionId}",
9967
method = RequestMethod.GET)
100-
default ResponseEntity<HFCurationResponse> hfcSubmissionIdGet(@ApiParam(value = "The submission id that the haplotype frequencies were submitted under",required=true ) @PathVariable("submissionId") String submissionId) {
101-
// do some magic!
102-
return new ResponseEntity<HFCurationResponse>(HttpStatus.OK);
103-
}
68+
ResponseEntity<HFCurationResponse> hfcSubmissionIdGet(@ApiParam(value = "The submission id that the haplotype frequencies were submitted under",required=true ) @PathVariable("submissionId") String submissionId);
10469

10570

10671
@ApiOperation(value = "", notes = "Returns the list of haplotypes attached to the given submission", response = HaplotypeFrequencyData.class, tags={ })
@@ -109,10 +74,7 @@ default ResponseEntity<HFCurationResponse> hfcSubmissionIdGet(@ApiParam(value =
10974
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = HaplotypeFrequencyData.class) })
11075
@RequestMapping(value = "/hfc/{submissionId}/haplotypes",
11176
method = RequestMethod.GET)
112-
default ResponseEntity<HaplotypeFrequencyData> hfcSubmissionIdHaplotypesGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId) {
113-
// do some magic!
114-
return new ResponseEntity<HaplotypeFrequencyData>(HttpStatus.OK);
115-
}
77+
ResponseEntity<HaplotypeFrequencyData> hfcSubmissionIdHaplotypesGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId);
11678

11779

11880
@ApiOperation(value = "", notes = "Returns the labels associated to the submission", response = LabelData.class, tags={ })
@@ -121,10 +83,7 @@ default ResponseEntity<HaplotypeFrequencyData> hfcSubmissionIdHaplotypesGet(@Api
12183
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = LabelData.class) })
12284
@RequestMapping(value = "/hfc/{submissionId}/labels",
12385
method = RequestMethod.GET)
124-
default ResponseEntity<LabelData> hfcSubmissionIdLabelsGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId) {
125-
// do some magic!
126-
return new ResponseEntity<LabelData>(HttpStatus.OK);
127-
}
86+
ResponseEntity<LabelData> hfcSubmissionIdLabelsGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId);
12887

12988

13089
@ApiOperation(value = "", notes = "Returns the population of the given submission", response = PopulationData.class, tags={ })
@@ -133,10 +92,7 @@ default ResponseEntity<LabelData> hfcSubmissionIdLabelsGet(@ApiParam(value = "Th
13392
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = PopulationData.class) })
13493
@RequestMapping(value = "/hfc/{submissionId}/population",
13594
method = RequestMethod.GET)
136-
default ResponseEntity<PopulationData> hfcSubmissionIdPopulationGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId) {
137-
// do some magic!
138-
return new ResponseEntity<PopulationData>(HttpStatus.OK);
139-
}
95+
ResponseEntity<PopulationData> hfcSubmissionIdPopulationGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId);
14096

14197

14298
@ApiOperation(value = "", notes = "Returns the scope of the genotypes used for creating the submitted haplotypes", response = ScopeData.class, tags={ })
@@ -145,9 +101,6 @@ default ResponseEntity<PopulationData> hfcSubmissionIdPopulationGet(@ApiParam(va
145101
@ApiResponse(code = 500, message = "An unexpected error ocurred", response = ScopeData.class) })
146102
@RequestMapping(value = "/hfc/{submissionId}/scope",
147103
method = RequestMethod.GET)
148-
default ResponseEntity<ScopeData> hfcSubmissionIdScopeGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId) {
149-
// do some magic!
150-
return new ResponseEntity<ScopeData>(HttpStatus.OK);
151-
}
104+
ResponseEntity<ScopeData> hfcSubmissionIdScopeGet(@ApiParam(value = "The submission id",required=true ) @PathVariable("submissionId") String submissionId);
152105

153106
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.swagger.api;
2+
3+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
4+
5+
public class NotFoundException extends ApiException {
6+
private int code;
7+
public NotFoundException (int code, String msg) {
8+
super(code, msg);
9+
this.code = code;
10+
}
11+
}

src/main/java/io/swagger/model/AccessData.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import com.fasterxml.jackson.annotation.JsonCreator;
66
import io.swagger.annotations.ApiModel;
77
import io.swagger.annotations.ApiModelProperty;
8-
import java.io.Serializable;
98
import javax.validation.constraints.*;
109
/**
1110
* AccessData
1211
*/
13-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-26T11:57:21.787-05:00")
12+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
1413

15-
public class AccessData implements Serializable {
14+
public class AccessData {
1615
@JsonProperty("typeOfAccess")
1716
private String typeOfAccess = null;
1817

src/main/java/io/swagger/model/CohortData.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
import io.swagger.annotations.ApiModel;
77
import io.swagger.annotations.ApiModelProperty;
88
import io.swagger.model.GenotypeList;
9-
import java.io.Serializable;
109
import javax.validation.constraints.*;
1110
/**
1211
* CohortData
1312
*/
14-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-26T11:57:21.787-05:00")
13+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
1514

16-
public class CohortData implements Serializable {
15+
public class CohortData {
1716
@JsonProperty("GenotypeList")
1817
private GenotypeList genotypeList = null;
1918

@@ -26,8 +25,7 @@ public CohortData genotypeList(GenotypeList genotypeList) {
2625
* Get genotypeList
2726
* @return genotypeList
2827
**/
29-
@ApiModelProperty(required = true, value = "")
30-
@NotNull
28+
@ApiModelProperty(value = "")
3129
public GenotypeList getGenotypeList() {
3230
return genotypeList;
3331
}

src/main/java/io/swagger/model/Error.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import com.fasterxml.jackson.annotation.JsonCreator;
66
import io.swagger.annotations.ApiModel;
77
import io.swagger.annotations.ApiModelProperty;
8-
import java.io.Serializable;
98
import javax.validation.constraints.*;
109
/**
1110
* Error
1211
*/
13-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-26T11:57:21.787-05:00")
12+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-05-30T13:04:33.940Z")
1413

15-
public class Error implements Serializable {
14+
public class Error {
1615
@JsonProperty("code")
1716
private String code = null;
1817

0 commit comments

Comments
 (0)