Skip to content

Commit

Permalink
Merge pull request #93 from fscheel/MigrateToSpringBoot2
Browse files Browse the repository at this point in the history
Migrate to spring boot2
  • Loading branch information
mmaiers-nmdp authored Feb 18, 2019
2 parents 3fe038d + ee4c16f commit da7e7de
Show file tree
Hide file tree
Showing 24 changed files with 190 additions and 625 deletions.
15 changes: 9 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.7.0</springfox-version>
<springfox-version>2.9.2</springfox-version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<version>2.1.0.RELEASE</version>
<relativePath/>
</parent>

Expand All @@ -37,6 +37,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
Expand All @@ -57,11 +61,10 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ResponseEntity<CohortData> createCohort(@ApiParam(value = "Cohort Request

@Override
public ResponseEntity<CohortData> getCohortForId(@ApiParam(value = "Cohort ID",required=true ) @PathVariable("cohortId") Long cohortId) {
Cohort cohort = cohortRepository.findOne(cohortId);
Cohort cohort = cohortRepository.findById(cohortId).orElse(null);
ResponseEntity<CohortData> responseEntity;
if (cohort != null) {
responseEntity = ResponseEntity.ok(cohort.toSwaggerObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private <ModelType, ResponseType> ResponseEntity<ResponseType> RetrieveSubdataFr
Function<ModelType, ResponseType> converter
) {
ResponseEntity<ResponseType> responseEntity;
HFCuration curation = repositoryContainer.getCurationRepository().findOne(submissionId);
HFCuration curation = repositoryContainer.getCurationRepository().findById(submissionId).orElse(null);
if (curation != null) {
ModelType dataModel = getDataItem.apply(curation);
if (dataModel != null) {
Expand Down Expand Up @@ -138,7 +138,7 @@ public ResponseEntity<LabelResponse> hfcLabelGet() {
public ResponseEntity<PopulationSubmissionResponse> hfcPopulationPopulationIdGet(
@ApiParam(value = "The populationId id", required = true) @PathVariable("populationId") Long populationId
) {
Population population = repositoryContainer.getPopulationRepository().findOne(populationId);
Population population = repositoryContainer.getPopulationRepository().findById(populationId).orElse(null);
ResponseEntity<PopulationSubmissionResponse> responseEntity;
if (population != null) {
PopulationSubmissionData pop = new PopulationSubmissionData();
Expand Down Expand Up @@ -177,13 +177,13 @@ public ResponseEntity<HFCurationResponse> hfcSubmissionIdGet(
public ResponseEntity<Void> hfcSubmissionIdDelete(
@ApiParam(value = "", required = true) @PathVariable("submissionId") Long submissionId
) {
HFCuration curation = repositoryContainer.getCurationRepository().findOne(submissionId);
HFCuration curation = repositoryContainer.getCurationRepository().findById(submissionId).orElse(null);
if (curation != null) {
curation.setPopulationData(null);
repositoryContainer.getCurationRepository().delete(curation);
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} else {
return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ResponseEntity<PopulationData> createPopulation(@ApiParam(value = "Popula

@Override
public ResponseEntity<PopulationData> getPopulationForId(@ApiParam(value = "Population ID",required=true ) @PathVariable("populationId") Long populationId) {
Population population = populationRepository.findOne(populationId);
Population population = populationRepository.findById(populationId).orElse(null);
ResponseEntity<PopulationData> responseEntity;
if (population != null) {
responseEntity = ResponseEntity.ok(population.toSwaggerObject());
Expand Down
27 changes: 6 additions & 21 deletions src/main/java/org/nmdp/hfcus/model/Access.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.nmdp.hfcus.model;

import io.swagger.model.AccessData;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.nmdp.hfcus.model.exceptions.RequiredFieldInvalidException;

import javax.persistence.Entity;
Expand All @@ -9,39 +11,22 @@
import javax.persistence.Id;

@Entity
@Data
@NoArgsConstructor
public class Access implements ICurationDataModel<AccessData> {
public Access(){
//intentionally left empty
}

public Access(AccessData swaggerObject) {
Access(AccessData swaggerObject) {
typeOfAccess = swaggerObject.getTypeOfAccess();
if (typeOfAccess == null){
throw new RequiredFieldInvalidException("Requires type of access");
}
}

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String typeOfAccess;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getTypeOfAccess() {
return typeOfAccess;
}

public void setTypeOfAccess(String typeOfAccess) {
this.typeOfAccess = typeOfAccess;
}

@Override
public AccessData toSwaggerObject(){
AccessData data = new AccessData();
Expand Down
32 changes: 5 additions & 27 deletions src/main/java/org/nmdp/hfcus/model/Cohort.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@


import io.swagger.model.CohortData;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.nmdp.hfcus.model.exceptions.RequiredFieldInvalidException;

import javax.persistence.*;

@Entity
@Data
@NoArgsConstructor
public class Cohort implements ICurationDataModel<CohortData> {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToOne(cascade = CascadeType.ALL)
private GenotypeList genotypeList;
private String name;

public Cohort(){
//intentionally left empty
}

public Cohort(CohortData swaggerObject){
if (swaggerObject.getGenotypeList() != null) {
genotypeList = new GenotypeList(swaggerObject.getGenotypeList());
Expand All @@ -34,28 +34,6 @@ public Cohort(CohortData swaggerObject){
}
}

public Long getId() { return id; }

public void setId(Long id) {
this.id = id;
}

public GenotypeList getGenotypeList() {
return genotypeList;
}

public void setGenotypeList(GenotypeList genotypeList) {
this.genotypeList = genotypeList;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public CohortData toSwaggerObject(){
CohortData data = new CohortData();
Expand Down
34 changes: 6 additions & 28 deletions src/main/java/org/nmdp/hfcus/model/FrequencyError.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,29 @@
package org.nmdp.hfcus.model;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
@Data
@NoArgsConstructor
public class FrequencyError implements ICurationDataModel<io.swagger.model.FrequencyError> {
public FrequencyError(){
//intentionally left empty
}

public FrequencyError(io.swagger.model.FrequencyError error) {
value = error.getValue();
typeOfError = error.getTypeOfError();
}

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Double value;
private String typeOfError;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Double getValue() {
return value;
}

public void setValue(Double value) {
this.value = value;
}

public String getTypeOfError() {
return typeOfError;
}

public void setTypeOfError(String typeOfError) {
this.typeOfError = typeOfError;
}

@Override
public io.swagger.model.FrequencyError toSwaggerObject(){
io.swagger.model.FrequencyError data = new io.swagger.model.FrequencyError();
Expand Down
34 changes: 5 additions & 29 deletions src/main/java/org/nmdp/hfcus/model/Genotype.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package org.nmdp.hfcus.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.nmdp.hfcus.model.exceptions.RequiredFieldInvalidException;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Data
@NoArgsConstructor
public class Genotype implements ICurationDataModel<io.swagger.model.Genotype> {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long genotypeId;
private String genotypeString;
@OneToMany(cascade = CascadeType.ALL)
private List<GenotypeMethod> genotypingMethods;

public Genotype(){
//intentionally left empty
}

public Genotype(io.swagger.model.Genotype swaggerObject){
genotypeString = swaggerObject.getGenotypeString();
if (genotypeString == null){
Expand All @@ -33,30 +33,6 @@ public Genotype(io.swagger.model.Genotype swaggerObject){
}
}

public Long getGenotypeId() {
return genotypeId;
}

public void setGenotypeId(Long genotypeId) {
this.genotypeId = genotypeId;
}

public String getGenotypeString() {
return genotypeString;
}

public void setGenotypeString(String genotypeString) {
this.genotypeString = genotypeString;
}

public List<GenotypeMethod> getGenotypingMethods() {
return genotypingMethods;
}

public void setGenotypingMethods(List<GenotypeMethod> genotypingMethods) {
this.genotypingMethods = genotypingMethods;
}

@Override
public io.swagger.model.Genotype toSwaggerObject(){
io.swagger.model.Genotype data = new io.swagger.model.Genotype();
Expand Down
34 changes: 5 additions & 29 deletions src/main/java/org/nmdp/hfcus/model/GenotypeList.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package org.nmdp.hfcus.model;

import io.swagger.model.License;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Data
@NoArgsConstructor
public class GenotypeList implements ICurationDataModel<io.swagger.model.GenotypeList> {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
private License.TypeOfLicenseEnum license;
@OneToMany(cascade = CascadeType.ALL)
private List<Genotype> genotypeList;

public GenotypeList(){
//intentionallyLeftEmpty
}

public GenotypeList(io.swagger.model.GenotypeList swaggerObject){
if (swaggerObject.getLicense() != null) {
license = swaggerObject.getLicense().getTypeOfLicense();
Expand All @@ -33,30 +33,6 @@ public GenotypeList(io.swagger.model.GenotypeList swaggerObject){
}
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public License.TypeOfLicenseEnum getLicense() {
return license;
}

public void setLicense(License.TypeOfLicenseEnum license) {
this.license = license;
}

public List<Genotype> getGenotypeList() {
return genotypeList;
}

public void setGenotypeList(List<Genotype> genotypeList) {
this.genotypeList = genotypeList;
}

@Override
public io.swagger.model.GenotypeList toSwaggerObject(){
io.swagger.model.GenotypeList data = new io.swagger.model.GenotypeList();
Expand Down
Loading

0 comments on commit da7e7de

Please sign in to comment.