Revision 7cc57f1d
Added by Patrick Plitzner almost 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.Collection; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
import java.util.stream.Collectors; |
|
16 |
|
|
11 | 17 |
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor; |
12 | 18 |
|
19 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
13 | 20 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
14 | 21 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO; |
15 | 22 |
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO; |
16 | 23 |
import eu.etaxonomy.cdm.model.description.Feature; |
24 |
import eu.etaxonomy.cdm.model.description.State; |
|
25 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
26 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
17 | 28 |
|
18 | 29 |
/** |
19 | 30 |
* Property accessor class which maps setting and getting data for |
... | ... | |
74 | 85 |
if(rowObject instanceof RowWrapperDTO){ |
75 | 86 |
RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject; |
76 | 87 |
Feature feature = matrix.getIndexToCharacterMap().get(columnIndex); |
77 |
rowWrapper.setDataValueForFeature(feature, newValue); |
|
88 |
if(newValue instanceof Collection && ((Collection) newValue).stream().allMatch(o->o instanceof TermDto)){ |
|
89 |
List<TermDto> dtos = (List<TermDto>)newValue; |
|
90 |
List<UUID> termUuids = dtos.stream().map(dto->dto.getUuid()).collect(Collectors.toList()); |
|
91 |
List<DefinedTermBase> terms = CdmStore.getService(ITermService.class).load(termUuids, null); |
|
92 |
List<State> states = new ArrayList<>(); |
|
93 |
for (DefinedTermBase definedTermBase : terms) { |
|
94 |
if(definedTermBase instanceof State){ |
|
95 |
states.add((State) definedTermBase); |
|
96 |
} |
|
97 |
} |
|
98 |
rowWrapper.setDataValueForFeature(feature, states); |
|
99 |
} |
|
78 | 100 |
} |
79 | 101 |
} |
80 | 102 |
|
Also available in: Unified diff
ref #8242 Refactor states to use DTOs