RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject;
matrix.addRowToSave(rowWrapper);
Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
- if(newValue instanceof Collection && ((Collection) newValue).stream().allMatch(o->o instanceof TermDto)){
+ if(feature.isSupportsCategoricalData()
+ && newValue instanceof Collection
+ && ((Collection) newValue).stream().allMatch(o->o instanceof TermDto)){
List<TermDto> dtos = (List<TermDto>)newValue;
List<UUID> termUuids = dtos.stream().map(dto->dto.getUuid()).collect(Collectors.toList());
List<DefinedTermBase> terms = CdmStore.getService(ITermService.class).load(termUuids, null);
states.add((State) definedTermBase);
}
}
- rowWrapper.setDataValueForFeature(feature, states);
+ rowWrapper.setDataValueForCategoricalData(feature, states);
}
}
}
*/
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.eclipse.jface.window.Window;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
-import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix;
/**
}
private QuantitativeData editorValue;
+ private RowWrapperDTO<?> rowWrapperDTO;
private QuantitativeDataDialogComposite composite;
this.editorValue = editorValue;
}
+ void setRowWrapper(RowWrapperDTO<?> rowWrapperDTO) {
+ this.rowWrapperDTO = rowWrapperDTO;
+ }
+
@Override
public boolean close() {
if(getReturnCode()==Window.OK){
- updateQuantitativeData(editorValue);
+ //clear values
+ editorValue.getStatisticalValues().clear();
+ //add back all values from text fields
+ Map<StatisticalMeasure, List<String>> measureToValueMap = new HashMap<>();
+
+ Map<StatisticalMeasure, List<Text>> textFields = composite.getTextFields();
+ Set<Entry<StatisticalMeasure,List<Text>>> entrySet = textFields.entrySet();
+ for (Entry<StatisticalMeasure, List<Text>> entry : entrySet) {
+ StatisticalMeasure statisticalMeasure = entry.getKey();
+ List<String> values = entry.getValue().stream()
+ .filter(text->text.isEnabled())
+ .map(text->text.getText())
+ .collect(Collectors.toList());
+ measureToValueMap.put(statisticalMeasure, values);
+ }
+ rowWrapperDTO.setDataValueForQuantitativeData(editorValue.getFeature(), measureToValueMap);
matrix.setDirty();
}
return super.close();
}
- void updateQuantitativeData(QuantitativeData quantitativeData){
- //clear values
- quantitativeData.getStatisticalValues().clear();
- //add back all values from text fields
- Map<StatisticalMeasure, List<Text>> textFields = composite.getTextFields();
- textFields.forEach((measure, texts)->{
- texts.forEach(text->{
- if(text.isEnabled()){
- String string = text.getText();
- try {
- float exactValue = Float.parseFloat(string);
- quantitativeData.addStatisticalValue(StatisticalMeasurementValue.NewInstance(measure, exactValue));
- } catch (NumberFormatException e) {
- }
- }
- });
- });
- }
-
}
import org.eclipse.swt.widgets.Control;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix;
public class QuantitativeDataDialogEditor extends AbstractDialogCellEditor {
private QuantitativeData editorValue;
+ private RowWrapperDTO<?> rowWrapperDTO;
private boolean closed;
private CharacterMatrix matrix;
private Character initialInput;
@Override
public void setEditorValue(Object value) {
((QuantitativeDataDialog)this.dialog).setEditorValue((QuantitativeData) value);
+ ((QuantitativeDataDialog)this.dialog).setRowWrapper(rowWrapperDTO);
this.editorValue = (QuantitativeData) value;
}
Feature feature = matrix.getIndexToFeatureMap().get(cell.getColumnIndex());
QuantitativeData quantitativeData = null;
if(rowObject instanceof RowWrapperDTO){
- if(cell.getDataValue() instanceof QuantitativeData){
- quantitativeData = (QuantitativeData) cell.getDataValue();
+ rowWrapperDTO = (RowWrapperDTO<?>) rowObject;
+ DescriptionElementBase dataValueForFeature = rowWrapperDTO.getDataValueForFeature(feature);
+ if(dataValueForFeature instanceof QuantitativeData){
+ quantitativeData = (QuantitativeData) dataValueForFeature;
}
//create new Quantitative Data
- if (cell.getDataValue() == null) {
+ if (quantitativeData == null) {
quantitativeData = ((RowWrapperDTO) rowObject).addQuantitativeData(feature);
}
/**