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 #279

Open
wants to merge 4 commits 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 @@ -9,23 +9,23 @@
*
*******************************************************************************/

package org.ibp.api.ibpworkbench.model;
package org.ibp.api.domain.breedingview;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name = "Response")
@XmlType(propOrder = {"successful", "message"})
public class DataResponse {
public class BreedingViewResponse {

private boolean successful;
private String message;

public DataResponse() {
public BreedingViewResponse() {
}

public DataResponse(boolean successful, String message) {
public BreedingViewResponse(final boolean successful, final String message) {
this.successful = successful;
this.message = message;
}
Expand All @@ -35,7 +35,7 @@ public boolean isSuccessful() {
return this.successful;
}

public void setSuccessful(boolean successful) {
public void setSuccessful(final boolean successful) {
this.successful = successful;
}

Expand All @@ -44,7 +44,7 @@ public String getMessage() {
return this.message;
}

public void setMessage(String message) {
public void setMessage(final String message) {
this.message = message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.ibp.api.ibpworkbench.exceptions;
package org.ibp.api.exception;

public class BreedingViewImportException extends Exception {

Expand All @@ -9,11 +9,11 @@ public BreedingViewImportException() {
super("Error with importing breeding view output file.");
}

public BreedingViewImportException(String message) {
public BreedingViewImportException(final String message) {
super(message);
}

public BreedingViewImportException(String message, Throwable cause) {
public BreedingViewImportException(final String message, final Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.ibp.api.ibpworkbench.exceptions;
package org.ibp.api.exception;

public class BreedingViewInvalidFormatException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.ibp.api.ibpworkbench.exceptions;
package org.ibp.api.exception;

public class IBPWebServiceException extends Exception {

Expand All @@ -9,7 +9,7 @@ public IBPWebServiceException() {
super();
}

public IBPWebServiceException(String message) {
public IBPWebServiceException(final String message) {
super(message);
}

Expand Down
121 changes: 0 additions & 121 deletions src/main/java/org/ibp/api/ibpworkbench/rest/BreedingView.java

This file was deleted.

52 changes: 0 additions & 52 deletions src/main/java/org/ibp/api/ibpworkbench/util/ObjectUtil.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*
*******************************************************************************/

package org.ibp.api.ibpworkbench.service;
package org.ibp.api.java.breedingview;

import org.ibp.api.ibpworkbench.exceptions.IBPWebServiceException;
import org.ibp.api.exception.IBPWebServiceException;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
*
*******************************************************************************/

package org.ibp.api.ibpworkbench.constants;
package org.ibp.api.java.impl.middleware.breedingview;

public enum WebAPIConstants {
public enum BreedingViewParameter {

MAIN_OUTPUT_FILE_PATH("mainOutputFilePath"), SUMMARY_OUTPUT_FILE_PATH("summaryOutputFilePath"), STUDY_ID("StudyId"), WORKBENCH_PROJECT_ID(
"WorkbenchProjectId"), INPUT_DATASET_ID("InputDataSetId"), OUTPUT_DATASET_ID("OutputDataSetId"), OUTLIER_OUTPUT_FILE_PATH(
"OutlierFilePath");
MAIN_OUTPUT_FILE_PATH("mainOutputFilePath"), SUMMARY_OUTPUT_FILE_PATH("summaryOutputFilePath"), STUDY_ID(
"StudyId"), WORKBENCH_PROJECT_ID(
"WorkbenchProjectId"), INPUT_DATASET_ID("InputDataSetId"), OUTPUT_DATASET_ID("OutputDataSetId"), OUTLIER_OUTPUT_FILE_PATH(
"OutlierFilePath");

private String paramValue;
private final String paramValue;

private WebAPIConstants(String param) {
private BreedingViewParameter(final String param) {
this.paramValue = param;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,29 @@
*
*******************************************************************************/

package org.ibp.api.ibpworkbench.service;

import java.io.File;
import java.util.List;
import java.util.Map;
package org.ibp.api.java.impl.middleware.breedingview;

import com.rits.cloning.Cloner;
import org.generationcp.commons.service.BreedingViewImportService;
import org.generationcp.middleware.domain.dms.ExperimentValues;
import org.generationcp.middleware.domain.dms.VariableTypeList;
import org.ibp.api.ibpworkbench.constants.WebAPIConstants;
import org.ibp.api.ibpworkbench.exceptions.IBPWebServiceException;
import org.ibp.api.exception.IBPWebServiceException;
import org.ibp.api.java.breedingview.BreedingViewService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.rits.cloning.Cloner;
import java.io.File;
import java.util.List;
import java.util.Map;

@Component
public class BreedingViewServiceImpl implements BreedingViewService {

@Autowired
private BreedingViewImportService importService;
private BreedingViewImportService breedingViewImportService;

@Autowired
private Cloner cloner;
Expand All @@ -50,19 +49,19 @@ public void execute(final Map<String, String> params, final List<String> errors)

try {

final String mainOutputFilePath = params.get(WebAPIConstants.MAIN_OUTPUT_FILE_PATH.getParamValue());
final String summaryOutputFilePath = params.get(WebAPIConstants.SUMMARY_OUTPUT_FILE_PATH.getParamValue());
final String outlierOutputFilePath = params.get(WebAPIConstants.OUTLIER_OUTPUT_FILE_PATH.getParamValue());
final int studyId = Integer.parseInt(params.get(WebAPIConstants.STUDY_ID.getParamValue()));
final String mainOutputFilePath = params.get(BreedingViewParameter.MAIN_OUTPUT_FILE_PATH.getParamValue());
final String summaryOutputFilePath = params.get(BreedingViewParameter.SUMMARY_OUTPUT_FILE_PATH.getParamValue());
final String outlierOutputFilePath = params.get(BreedingViewParameter.OUTLIER_OUTPUT_FILE_PATH.getParamValue());
final int studyId = Integer.parseInt(params.get(BreedingViewParameter.STUDY_ID.getParamValue()));

this.importService.importMeansData(new File(mainOutputFilePath), studyId);
this.breedingViewImportService.importMeansData(new File(mainOutputFilePath), studyId);

if (outlierOutputFilePath != null && !"".equals(outlierOutputFilePath)) {
this.importService.importOutlierData(new File(outlierOutputFilePath), studyId);
this.breedingViewImportService.importOutlierData(new File(outlierOutputFilePath), studyId);
}

if (summaryOutputFilePath != null && !"".equals(summaryOutputFilePath)) {
this.importService.importSummaryStatsData(new File(summaryOutputFilePath), studyId);
this.breedingViewImportService.importSummaryStatsData(new File(summaryOutputFilePath), studyId);
}

} catch (final Exception e) {
Expand Down Expand Up @@ -96,8 +95,8 @@ protected VariableTypeList getVariableTypeListSummaryStats() {
return this.variableTypeListSummaryStats;
}

public void setImportService(final BreedingViewImportService importService) {
this.importService = importService;
public void setBreedingViewImportService(final BreedingViewImportService breedingViewImportService) {
this.breedingViewImportService = breedingViewImportService;
}

}
Loading