import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
private NatTable natTable;
+ private Collection<RowWrapperDTO<?>> rowsToSave = new HashSet<>();
+
private Map<Integer, Feature> indexToFeatureMap = new HashMap<>();
private Map<Feature, List<TermDto>> categoricalFeatureToStateMap = new HashMap<>();
.collect(Collectors.toList());
}
+ public void addRowToSave(RowWrapperDTO<?> row){
+ rowsToSave.add(row);
+ }
+
+ public Collection<RowWrapperDTO<?>> getRowsToSave() {
+ return rowsToSave;
+ }
+
public Properties getNatTableState() {
return toolbar.getNatTableState();
}
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
-import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
@Persist
@Override
public void save(IProgressMonitor monitor) {
- //save descriptions
- List<DescriptionBase> descriptions = matrix.getDescriptions().stream()
- .filter(o->o instanceof RowWrapperDTO)
- .map(o->((RowWrapperDTO)o).getDescription())
+ // save edited descriptions
+ List<DescriptionBase> descriptions = matrix.getRowsToSave().stream()
+ .map(row->row.getDescription())
.collect(Collectors.toList());
CdmStore.getService(IDescriptionService.class).merge(descriptions);
- //save data set
- CdmStore.getService(IDescriptiveDataSetService.class).merge(descriptiveDataSet, true);
+ matrix.getRowsToSave().clear();
conversation.commit();
dirty.setDirty(false);
public void setDataValue(Object rowObject, int columnIndex, Object newValue) {
if(rowObject instanceof RowWrapperDTO){
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)){
List<TermDto> dtos = (List<TermDto>)newValue;