Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBP 3273 Refactor Breeding View Class in BMSAPI #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public class BreedingViewXMLWriter implements InitializingBean, Serializable {
@Autowired
private ContextUtil contextUtil;

@Value("${web.api.url}")
private String webApiUrl;
@Value("${single.site.analysis.result.upload.url}")
private String singleSiteAnalysisResultUploadURL;

@Value("${workbench.is.server.app}")
private String isServerApp;
Expand Down Expand Up @@ -164,7 +164,7 @@ private Pipelines createPipelines(final DataConfiguration dataConfiguration) {

private SSAParameters createSSAParameters() {
final SSAParameters ssaParameters = new SSAParameters();
ssaParameters.setWebApiUrl(this.getWebApiUrl());
ssaParameters.setWebApiUrl(this.generateSingleSiteResultUploadURL());
ssaParameters.setStudyId(this.breedingViewInput.getStudyId());
ssaParameters.setInputDataSetId(this.breedingViewInput.getDatasetId());
ssaParameters.setOutputDataSetId(this.breedingViewInput.getOutputDatasetId());
Expand All @@ -190,8 +190,8 @@ protected Project getLastOpenedProject() {
return this.contextUtil.getProjectInContext();
}

protected String getWebApiUrl() {
final String url = this.webApiUrl + "?restartApplication";
protected String generateSingleSiteResultUploadURL() {
final String url = this.singleSiteAnalysisResultUploadURL + "?";
final Project project = this.contextUtil.getProjectInContext();

final String contextParameterString = org.generationcp.commons.util.ContextUtil
Expand All @@ -200,19 +200,19 @@ protected String getWebApiUrl() {
final String authenticationTokenString = org.generationcp.commons.util.ContextUtil
.addQueryParameter(ContextConstants.PARAM_AUTH_TOKEN, SecurityUtil.getEncodedToken());

String webApiUrlWithCropName = this.replaceCropNameInWebApiUrl(url, project.getCropType().getCropName());
String webApiUrlWithCropName = this.replaceCropNameInSingleSiteResultUploadURL(url, project.getCropType().getCropName());
webApiUrlWithCropName += contextParameterString + authenticationTokenString;
return webApiUrlWithCropName;
}

private String replaceCropNameInWebApiUrl(final String webApiUrl, final String cropNameValue) {
final StringBuilder containerWebApiUrl = new StringBuilder(webApiUrl);
private String replaceCropNameInSingleSiteResultUploadURL(final String singleSiteAnalysisResultUploadURL, final String cropNameValue) {
final StringBuilder builder = new StringBuilder(singleSiteAnalysisResultUploadURL);

final int startIndex = containerWebApiUrl.indexOf(BreedingViewXMLWriter.CROP_PLACEHOLDER);
final int startIndex = builder.indexOf(BreedingViewXMLWriter.CROP_PLACEHOLDER);
final int endIndex = startIndex + BreedingViewXMLWriter.CROP_PLACEHOLDER.length();

containerWebApiUrl.replace(startIndex, endIndex, cropNameValue);
return containerWebApiUrl.toString();
builder.replace(startIndex, endIndex, cropNameValue);
return builder.toString();
}

Environments createEnvironments() {
Expand Down Expand Up @@ -326,8 +326,8 @@ public void afterPropertiesSet() throws Exception {
// overridden method from interface
}

public void setWebApiUrl(final String webApiUrl) {
this.webApiUrl = webApiUrl;
public void setSingleSiteAnalysisResultUploadURL(final String singleSiteAnalysisResultUploadURL) {
this.singleSiteAnalysisResultUploadURL = singleSiteAnalysisResultUploadURL;
}

public void setContextUtil(final ContextUtil contextUtil) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/workbench.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#Fri Feb 21 13:22:51 CST 2014
bmsapi.url=${bmsapi.url}
germplasm.browser.default.url=${germplasm.browser.default.url}
web.api.url=${web.api.url}
single.site.analysis.result.upload.url=${single.site.analysis.result.upload.url}
ask.for.support.url=${ask.for.support.url}
about.bms.url=${about.bms.url}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void setUp() throws Exception {
this.breedingViewInput = this.createBreedingViewInput();
this.breedingViewXMLWriter = new BreedingViewXMLWriter();
this.breedingViewXMLWriter.setBreedingViewInput(this.breedingViewInput);
this.breedingViewXMLWriter.setWebApiUrl(WEB_API_URL);
this.breedingViewXMLWriter.setSingleSiteAnalysisResultUploadURL(WEB_API_URL);
this.breedingViewXMLWriter.setContextUtil(this.contextUtil);
this.breedingViewXMLWriter.setInstallationDirectoryUtil(this.installationDirectoryUtil);
this.createBreedingViewDirectories();
Expand Down Expand Up @@ -187,7 +187,7 @@ public void testWriteProjectXML() throws Exception {
public void testGetWebApiUrl() {
final Project project = ProjectTestDataInitializer.createProjectWithCropType();
Mockito.when(this.contextUtil.getProjectInContext()).thenReturn(project);
final String url = this.breedingViewXMLWriter.getWebApiUrl();
final String url = this.breedingViewXMLWriter.generateSingleSiteResultUploadURL();
Mockito.verify(this.contextUtil).getProjectInContext();
Assert.assertTrue(url.contains(project.getCropType().getCropName()));
}
Expand Down