Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>7.7.3</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/io/swagger/model/germ/PedigreeSearchRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,20 +654,8 @@ public Integer getTotalParameterCount() {
count += this.germplasmNames.size();
if (this.germplasmPUIs != null)
count += this.germplasmPUIs.size();
if (this.includeFullTree != null)
count += 1;
if (this.includeParents != null)
count += 1;
if (this.includeProgeny != null)
count += 1;
if (this.includeSiblings != null)
count += 1;
if (this.instituteCodes != null)
count += this.instituteCodes.size();
if (this.pedigreeDepth != null)
count += 1;
if (this.progenyDepth != null)
count += 1;
if (this.programDbIds != null)
count += this.programDbIds.size();
if (this.programNames != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ public void addFormatters(FormatterRegistry registry) {
}
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.brapi.test.BrAPITestServer.auth.oldTokens;

import io.swagger.model.core.ServerInfoResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import org.brapi.test.BrAPITestServer.controller.core.BrAPIController;
import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.fasterxml.jackson.annotation.JsonProperty;

import javax.servlet.http.HttpServletRequest;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
@Controller
public class TokenController extends BrAPIController {

private static final Logger log = LoggerFactory.getLogger(TokenController.class);

private final HttpServletRequest request;

@org.springframework.beans.factory.annotation.Autowired
public TokenController(HttpServletRequest request) {
this.request = request;
}

@ApiOperation(value = "Get the list of implemented Calls", nickname = "tokenPost", response = ServerInfoResponse.class, authorizations = {
@Authorization(value = "AuthorizationToken") }, tags = { "Server Info", })
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ServerInfoResponse.class),
@ApiResponse(code = 400, message = "Bad Request", response = String.class),
@ApiResponse(code = 401, message = "Unauthorized", response = String.class),
@ApiResponse(code = 403, message = "Forbidden", response = String.class) })
@RequestMapping(value = "/token", produces = { "application/json" }, method = RequestMethod.POST)
@CrossOrigin
public ResponseEntity<TokenResponse> tokenPost(@RequestBody TokenRequest body)
throws BrAPIServerException {

log.debug("Request: " + request.getRequestURI());
validateSecurityContext(request, "ROLE_ANONYMOUS", "ROLE_USER");
validateAcceptHeader(request);

return new ResponseEntity<TokenResponse>(new TokenResponse(), HttpStatus.OK);
}

private class TokenResponse{
@JsonProperty("access_token")
private final String accessToken = "YYYY";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.brapi.test.BrAPITestServer.auth.oldTokens;

import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonProperty;

public class TokenRequest {
@JsonProperty("username")
private Optional<String> username = null;

@JsonProperty("password")
private Optional<String> password = null;

public TokenRequest() {
// TODO Auto-generated constructor stub
}

public Optional<String> getUsername() {
return username;
}

public void setUsername(Optional<String> username) {
this.username = username;
}

public Optional<String> getPassword() {
return password;
}

public void setPassword(Optional<String> password) {
this.password = password;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -308,5 +308,7 @@ public void setTrial(TrialEntity trial) {
this.trial = trial;
if (trial.getProgram() != null)
setProgram(trial.getProgram());
if (trial.getCrop() != null)
setCrop(trial.getCrop());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public void setTrial(TrialEntity trial) {
this.trial = trial;
if (trial.getProgram() != null)
setProgram(trial.getProgram());
if (trial.getCrop() != null)
setCrop(trial.getCrop());
}
public StudyEntity getStudy() {
return study;
Expand All @@ -83,6 +85,8 @@ public void setStudy(StudyEntity study) {
this.study = study;
if (study.getTrial() != null)
setTrial(study.getTrial());
if (study.getCrop() != null)
setCrop(study.getCrop());
}
public GermplasmEntity getGermplasm() {
return germplasm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ private void updateEntity(StudyEntity entity, StudyNewRequest body) throws BrAPI
if (body.getTrialDbId() != null) {
TrialEntity trial = trialService.getTrialEntity(body.getTrialDbId());
entity.setTrial(trial);
entity.setProgram(trial.getProgram());
entity.setCrop(trial.getCrop());
} else if (body.getCommonCropName() != null) {
CropEntity crop = cropService.getCropEntity(body.getCommonCropName());
entity.setCrop(crop);
Expand Down Expand Up @@ -374,11 +372,13 @@ private Study convertFromEntity(StudyEntity entity) {
study.setCommonCropName(entity.getTrial().getProgram().getCrop().getCropName());
}
}
} else if (entity.getProgram() != null) {
}
if (entity.getProgram() != null) {
if (entity.getProgram().getCrop() != null) {
study.setCommonCropName(entity.getProgram().getCrop().getCropName());
}
} else if (entity.getCrop() != null) {
}
if (entity.getCrop() != null) {
study.setCommonCropName(entity.getCrop().getCropName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ private Trial convertFromEntity(TrialEntity entity) {
if (entity.getProgram().getCrop() != null) {
trial.setCommonCropName(entity.getProgram().getCrop().getCropName());
}
} else if (entity.getCrop() != null) {
}
if (entity.getCrop() != null) {
trial.setCommonCropName(entity.getCrop().getCropName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,16 @@ private ObservationUnit convertFromEntity(ObservationUnitEntity entity) {
unit.setProgramName(entity.getStudy().getTrial().getProgram().getName());
}
}
} else if (entity.getTrial() != null) {
}
if (entity.getTrial() != null) {
unit.setTrialDbId(entity.getTrial().getId());
unit.setTrialName(entity.getTrial().getTrialName());
if (entity.getTrial().getProgram() != null) {
unit.setProgramDbId(entity.getTrial().getProgram().getId());
unit.setProgramName(entity.getTrial().getProgram().getName());
}
} else if (entity.getProgram() != null) {
}
if (entity.getProgram() != null) {
unit.setProgramDbId(entity.getProgram().getId());
unit.setProgramName(entity.getProgram().getName());
}
Expand Down
Loading