Skip to content

Commit

Permalink
Merge branch 'master' into BMS-5074-EditDeleteFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaletta committed Aug 27, 2018
2 parents 30cbc71 + f632b7e commit 1e950ae
Show file tree
Hide file tree
Showing 54 changed files with 3,896 additions and 2,391 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/generationcp/ibpworkbench/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum Message {
, STUDY_EFFECT, DATASET_OF_TEXT, NAME_HEADER, DESCRIPTION_HEADER, PROPERTY_HEADER, SCALE_HEADER, METHOD_HEADER, DATATYPE_HEADER, ERROR_IN_GETTING_DATASET_FACTOR, ERROR_IN_GETTING_DATASET_VARIATE, ERROR_PLEASE_CONTACT_ADMINISTRATOR

// Breeding View Input
, ENVIRONMENT, DESIGN_TYPE, RUN_BREEDING_VIEW, BACK, NEXT, BV_VERSION, BV_PROJECT_TYPE, BV_ANALYSIS_NAME, BV_SITE_ENVIRONMENT, BV_SPECIFY_ENV_FACTOR, BV_SELECT_ENV_FOR_ANALYSIS, BV_SPECIFY_NAME_FOR_ANALYSIS_ENV, BV_DESIGN, BV_SPECIFY_REPLICATES, BV_SPECIFY_BLOCKS, BV_SPECIFY_ROW_FACTOR, BV_SPECIFY_COLUMN_FACTOR, BV_GENOTYPES, BV_TITLE, BV_DATASET_NAME, BV_DATASOURCE_NAME, BV_DATA_SELECTED_FOR_ANALYSIS_HEADER, BV_ANALYSIS_NAME_HEADER, BV_CHOOSE_ENVIRONMENT_HEADER, BV_CHOOSE_ENVIRONMENT_DESCRIPTION, BV_CHOOSE_ENVIRONMENT_FOR_ANALYSIS_DESC, BV_SPECIFY_DESIGN_DETAILS_HEADER, BV_SPECIFY_GENOTYPES_HEADER, BV_STUDY_TREE_TITLE, BV_STUDY_TREE_DESCRIPTION, BV_DATASET_DETAIL_TITLE, BV_DATASET_DETAIL_DESCRIPTION
, ENVIRONMENT, DESIGN_TYPE, RUN_BREEDING_VIEW, BACK, NEXT, BV_VERSION, BV_PROJECT_TYPE, BV_ANALYSIS_NAME, BV_SITE_ENVIRONMENT, BV_SPECIFY_ENV_FACTOR, BV_SELECT_ENV_FOR_ANALYSIS, BV_SPECIFY_NAME_FOR_ANALYSIS_ENV, BV_DESIGN, BV_DESIGN_DETAILS_DESCRIPTION, BV_SPECIFY_REPLICATES, BV_SPECIFY_BLOCKS, BV_SPECIFY_ROW_FACTOR, BV_SPECIFY_COLUMN_FACTOR, BV_GENOTYPES, BV_TITLE, BV_DATASET_NAME, BV_DATASOURCE_NAME, BV_DATA_SELECTED_FOR_ANALYSIS_HEADER, BV_ANALYSIS_NAME_HEADER, BV_CHOOSE_ENVIRONMENT_HEADER, BV_CHOOSE_ENVIRONMENT_DESCRIPTION, BV_CHOOSE_ENVIRONMENT_FOR_ANALYSIS_DESC, BV_SPECIFY_DESIGN_DETAILS_HEADER, BV_SPECIFY_GENOTYPES_HEADER, BV_STUDY_TREE_TITLE, BV_STUDY_TREE_DESCRIPTION, BV_DATASET_DETAIL_TITLE, BV_DATASET_DETAIL_DESCRIPTION
, STUDY_TYPE_FILTER

// Project Location
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.generationcp.ibpworkbench.actions;

import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Window;


public class AskForSupportAction implements ClickListener {

private static final long serialVersionUID = 1L;
private Window sourceWindow;
private String url;

public AskForSupportAction(Window sourceWindow, String url) {
super();
this.sourceWindow = sourceWindow;
this.url = url;
}

@Override
public void buttonClick(ClickEvent event) {
this.sourceWindow.open(new ExternalResource(url), "_blank");
}

public Window getSourceWindow() {
return sourceWindow;
}

public String getUrl() {
return url;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.generationcp.ibpworkbench.actions;

import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;


public class HelpButtonClickAction implements ClickListener {

private static final long serialVersionUID = 1L;
private Window sourceWindow;
private String url;

public HelpButtonClickAction(Window sourceWindow, String url) {
super();
this.sourceWindow = sourceWindow;
this.url = url;
}

@Override
public void buttonClick(ClickEvent event) {
this.sourceWindow.open(new ExternalResource(url), "_blank");
}

public Window getSourceWindow() {
return sourceWindow;
}

public String getUrl() {
return url;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public void buttonClick(final ClickEvent event) {
breedingViewInput.setVersion(breedingViewTool.getVersion());
breedingViewInput.setProjectType(ProjectType.FIELD_TRIAL.getName());
breedingViewInput.setDatasetName(this.datasetName);
breedingViewInput.setDescription(this.study.getDescription());
breedingViewInput.setObjective(this.study.getObjective());

// THe study name is stored in the database as escaped html. We need to decode it to use it properly in generating filenames.
final String studyName = HtmlEscape.unescapeHtml(this.study.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
package org.generationcp.ibpworkbench.actions;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.generationcp.commons.exceptions.BreedingViewImportException;
Expand All @@ -20,13 +17,11 @@
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.BMSOutputParser.ZipFileInvalidContentException;
import org.generationcp.ibpworkbench.ui.window.FileUploadBreedingViewOutputWindow;
import org.generationcp.ibpworkbench.ui.window.FileUploadBreedingViewOutputWindow.CustomFileFactory;
import org.generationcp.middleware.domain.dms.DMSVariableType;
import org.generationcp.middleware.domain.dms.DataSet;
import org.generationcp.middleware.domain.dms.DataSetType;
import org.generationcp.middleware.domain.dms.TrialEnvironment;
import org.generationcp.middleware.domain.dms.TrialEnvironments;
import org.generationcp.middleware.domain.dms.Variable;
import org.generationcp.middleware.domain.dms.VariableTypeList;
import org.generationcp.middleware.manager.api.StudyDataManager;
import org.generationcp.middleware.pojos.workbench.Project;
import org.slf4j.Logger;
Expand All @@ -49,8 +44,6 @@ public class UploadBreedingViewOutputAction implements ClickListener {

private static final Logger LOG = LoggerFactory.getLogger(UploadBreedingViewOutputAction.class);

private static final String REGEX_VALID_BREEDING_VIEW_CHARACTERS = "[^a-zA-Z0-9-_%']+";

@Autowired
private SimpleResourceBundleMessageSource messageSource;

Expand Down Expand Up @@ -106,12 +99,12 @@ public void buttonClick(final ClickEvent event) {

@Override
public void run() {
UploadBreedingViewOutputAction.this.processTheUploadedFile(event, studyId, project);
UploadBreedingViewOutputAction.this.processTheUploadedFile(studyId, project);
}

});
} else {
this.processTheUploadedFile(event, studyId, project);
this.processTheUploadedFile(studyId, project);
}

} catch (final RuntimeException e) {
Expand Down Expand Up @@ -217,7 +210,7 @@ protected boolean isUploadedZipFileCompatibleWithCurrentStudy(final BMSOutputInf

}

public void processTheUploadedFile(final ClickEvent event, final int studyId, final Project project) {
public void processTheUploadedFile(final int studyId, final Project project) {

final TransactionTemplate transactionTemplate = new TransactionTemplate(this.transactionManager);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
Expand All @@ -241,7 +234,7 @@ protected void doInTransactionWithoutResult(final TransactionStatus arg0) {

UploadBreedingViewOutputAction.this.bmsOutputParser.deleteUploadedZipFile();

event.getComponent().getWindow().getParent().removeWindow(UploadBreedingViewOutputAction.this.window);
UploadBreedingViewOutputAction.this.window.getParent().removeWindow(UploadBreedingViewOutputAction.this.window);

} catch (final BreedingViewImportException e) {

Expand All @@ -260,6 +253,11 @@ protected void doInTransactionWithoutResult(final TransactionStatus arg0) {

}


public FileUploadBreedingViewOutputWindow getWindow() {
return window;
}

public void setWindow(FileUploadBreedingViewOutputWindow window) {
this.window = window;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package org.generationcp.ibpworkbench.actions;

package org.generationcp.ibpworkbench.actions.breedingview.singlesiteanalysis;

import org.generationcp.commons.breedingview.xml.DesignType;
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisDetailsPanel;
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisDesignDetails;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.GridLayout;

public class BreedingViewDesignTypeValueChangeListener implements ValueChangeListener {

private static final long serialVersionUID = -6425208753343322313L;

SingleSiteAnalysisDetailsPanel source;
private SingleSiteAnalysisDesignDetails source;

public BreedingViewDesignTypeValueChangeListener(final SingleSiteAnalysisDetailsPanel source) {
public BreedingViewDesignTypeValueChangeListener(final SingleSiteAnalysisDesignDetails source) {
this.source = source;
}

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

package org.generationcp.ibpworkbench.actions;
package org.generationcp.ibpworkbench.actions.breedingview.singlesiteanalysis;

import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisDetailsPanel;
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisEnvironmentsComponent;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
Expand All @@ -10,14 +10,14 @@ public class BreedingViewEnvFactorValueChangeListener implements ValueChangeList

private static final long serialVersionUID = -6425208753343322313L;

SingleSiteAnalysisDetailsPanel source;
private final SingleSiteAnalysisEnvironmentsComponent source;

public BreedingViewEnvFactorValueChangeListener(SingleSiteAnalysisDetailsPanel source) {
public BreedingViewEnvFactorValueChangeListener(final SingleSiteAnalysisEnvironmentsComponent source) {
this.source = source;
}

@Override
public void valueChange(ValueChangeEvent event) {
public void valueChange(final ValueChangeEvent event) {
this.source.populateChoicesForEnvForAnalysis();
}

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

package org.generationcp.ibpworkbench.actions.breedingview.singlesiteanalysis;

import java.util.List;

import org.generationcp.commons.util.StringUtil;
import org.generationcp.commons.vaadin.util.MessageNotifier;
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisDetailsPanel;
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisEnvironmentsComponent;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;

public class GenotypeFactorValueChangeListener implements ValueChangeListener {

private static final long serialVersionUID = 1L;

private final SingleSiteAnalysisEnvironmentsComponent environmentsComponent;

public GenotypeFactorValueChangeListener(final SingleSiteAnalysisEnvironmentsComponent environmentsComponent) {
super();
this.environmentsComponent = environmentsComponent;
}

@Override
public void valueChange(final ValueChangeEvent event) {
final List<String> invalidEnvironments = this.environmentsComponent.getInvalidEnvironments();
if (!invalidEnvironments.isEmpty()) {

MessageNotifier.showError(this.environmentsComponent.getWindow(), SingleSiteAnalysisDetailsPanel.INVALID_SELECTION_STRING,
this.environmentsComponent.getSelEnvFactorValue() + " " + StringUtil.joinIgnoreEmpty(",", invalidEnvironments) + " "
+ SingleSiteAnalysisDetailsPanel.INCOMPLETE_PLOT_DATA_ERROR);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@

package org.generationcp.ibpworkbench.actions.breedingview.singlesiteanalysis;

import java.util.List;

import org.generationcp.commons.vaadin.ui.ConfirmDialog;
import org.generationcp.ibpworkbench.model.SeaEnvironmentModel;
import org.generationcp.ibpworkbench.ui.breedingview.singlesiteanalysis.SingleSiteAnalysisDetailsPanel;
import org.generationcp.middleware.domain.dms.DataSet;
import org.generationcp.middleware.domain.dms.DataSetType;
import org.generationcp.middleware.domain.dms.TrialEnvironment;
import org.generationcp.middleware.domain.dms.TrialEnvironments;
import org.generationcp.middleware.manager.api.StudyDataManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;

import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

@Configurable
public class RunBreedingViewButtonClickListener implements ClickListener {

private static final long serialVersionUID = -6682011023617457906L;
private static final Logger LOG = LoggerFactory.getLogger(RunBreedingViewButtonClickListener.class);

@Autowired
private StudyDataManager studyDataManager;

private final SingleSiteAnalysisDetailsPanel ssaDetailsPanel;
private RunSingleSiteAction runSingleSiteAction;

public RunBreedingViewButtonClickListener(final SingleSiteAnalysisDetailsPanel ssaDetailsPanel) {
super();
this.ssaDetailsPanel = ssaDetailsPanel;
this.runSingleSiteAction = new RunSingleSiteAction(ssaDetailsPanel);
}

@Override
public void buttonClick(final ClickEvent event) {

if (Boolean.parseBoolean(this.ssaDetailsPanel.getIsServerApp())) {
this.runSingleSiteAction.buttonClick(event);
return;
}

final List<DataSet> dataSets;
try {

dataSets = this.studyDataManager.getDataSetsByType(this.ssaDetailsPanel.getBreedingViewInput().getStudyId(),
DataSetType.MEANS_DATA);
if (!dataSets.isEmpty()) {

final DataSet meansDataSet = dataSets.get(0);
final TrialEnvironments envs = this.studyDataManager.getTrialEnvironmentsInDataset(meansDataSet.getId());

Boolean environmentExists = false;
for (final SeaEnvironmentModel model : this.ssaDetailsPanel.getSelectedEnvironments()) {

final TrialEnvironment env = envs
.findOnlyOneByLocalName(this.ssaDetailsPanel.getBreedingViewInput().getTrialInstanceName(), model.getTrialno());
if (env != null) {
environmentExists = true;
break;
}

}

if (environmentExists) {
ConfirmDialog.show(event.getComponent().getWindow(), "",
"One or more of the selected traits has existing means data. If you save the results of this analysis, the existing values will be overwritten.",
"OK", "Cancel", new Runnable() {

@Override
public void run() {

new RunSingleSiteAction(RunBreedingViewButtonClickListener.this.ssaDetailsPanel).buttonClick(event);
}

});
} else {
this.runSingleSiteAction.buttonClick(event);
}

} else {
this.runSingleSiteAction.buttonClick(event);
}

} catch (final Exception e) {
this.runSingleSiteAction.buttonClick(event);
RunBreedingViewButtonClickListener.LOG.error(e.getMessage(), e);
}

}

protected void setRunSingleSiteAction(final RunSingleSiteAction runSingleSiteAction) {
this.runSingleSiteAction = runSingleSiteAction;
}

}
Loading

0 comments on commit 1e950ae

Please sign in to comment.