Project

General

Profile

« Previous | Next » 

Revision fcd9dc61

Added by Patrick Plitzner over 5 years ago

ref #7674 Fix class cas exceptions

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
131 131

  
132 132
    private LinkedMap<String, String> propertyToLabelMap = new LinkedMap<>();
133 133

  
134
    private EventList<RowWrapperDTO> descriptions;
134
    private EventList<Object> descriptions;
135 135

  
136 136
    private Collection<SpecimenNodeWrapper> specimenCache = null;
137 137

  
......
139 139

  
140 140
    private Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap = new HashMap<>();
141 141

  
142
    private ListDataProvider<RowWrapperDTO> bodyDataProvider;
142
    private ListDataProvider<Object> bodyDataProvider;
143 143

  
144 144
    private FreezeLayer freezeLayer;
145 145

  
......
277 277
    private void createLayers(boolean treeView) {
278 278
        // use the SortedList constructor with 'null' for the Comparator
279 279
        // because the Comparator will be set by configuration
280
        SortedList<RowWrapperDTO> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
280
        SortedList<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
281 281
        // wrap the SortedList with the TreeList
282
        TreeList<RowWrapperDTO> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
282
        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
283 283
        /**
284 284
         * data provider
285 285
         */
......
557 557
                    List<RowWrapperDTO> rowsWithoutTaxonNode = wrappers.stream().filter(row->row.getTaxonNode()==null).collect(Collectors.toList());
558 558
                    if(!rowsWithoutTaxonNode.isEmpty()){
559 559
                        String collect = rowsWithoutTaxonNode.stream().
560
                        map(row->row.getSpecimenDescription().toString())
560
                        map(row->row.getDescription().toString())
561 561
                        .collect(Collectors.joining("\n\n - ")); //$NON-NLS-1$
562 562
                        MessagingUtils.warningDialog(
563 563
                                Messages.CharacterMatrix_NO_NODE_FOUND_TITLE,
......
597 597
        return natTable;
598 598
    }
599 599

  
600
    public EventList<RowWrapperDTO> getDescriptions() {
600
    public EventList<Object> getDescriptions() {
601 601
        return descriptions;
602 602
    }
603 603

  
......
627 627
        return toolbar.getNatTableState();
628 628
    }
629 629

  
630
    public ListDataProvider<RowWrapperDTO> getBodyDataProvider() {
630
    public ListDataProvider<Object> getBodyDataProvider() {
631 631
        return bodyDataProvider;
632 632
    }
633 633

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
31 31
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
32 32
import eu.etaxonomy.cdm.api.service.UpdateResult;
33 33
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
34
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
34 35
import eu.etaxonomy.cdm.common.CdmUtils;
35 36
import eu.etaxonomy.cdm.model.description.CategoricalData;
36 37
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
......
125 126
                }
126 127
                toRemove.forEach(rowToRemove->{
127 128
                    matrix.getDescriptions().remove(rowToRemove);
128
                    matrix.getDescriptiveDataSet().removeDescription(rowToRemove.getSpecimenDescription());
129
                    matrix.getDescriptiveDataSet().removeDescription(rowToRemove.getDescription());
129 130
                    matrix.setDirty();
130 131
                });
131 132
            }
......
175 176
    @SuppressWarnings("unchecked")
176 177
    private void aggregateCategorcialHistogram(Map<Feature, CategoricalDataHistogram> featureToHistogramMap) {
177 178
        featureToHistogramMap.clear();
178
        matrix.getDescriptions()
179
                .forEach(o -> o.getSpecimenDescription().getElements().stream()
179
        matrix.getDescriptions().stream()
180
        .filter(desc->desc instanceof SpecimenRowWrapperDTO)
181
                .forEach(o -> ((SpecimenRowWrapperDTO) o).getDescription().getElements().stream()
180 182
                        .filter(descriptionElement -> descriptionElement instanceof CategoricalData)
181 183
                        .forEach(categoricalData -> {
182 184
                            Feature feature = ((CategoricalData) categoricalData).getFeature();
......
193 195
    @SuppressWarnings("unchecked")
194 196
    private void aggregateQuantitativeSummary(Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap) {
195 197
        featureToQuantDataStatisticsMap.clear();
196
        matrix.getDescriptions()
197
        .forEach(o -> o.getSpecimenDescription().getElements().stream()
198
        matrix.getDescriptions().stream()
199
        .filter(desc->desc instanceof SpecimenRowWrapperDTO)
200
        .forEach(o -> ((SpecimenRowWrapperDTO) o).getDescription().getElements().stream()
198 201
                .filter(descriptionElement -> descriptionElement instanceof QuantitativeData)
199 202
                .forEach(quantData -> {
200 203
                    Feature feature = ((QuantitativeData) quantData).getFeature();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixPart.java
188 188
    }
189 189

  
190 190
    private void save(RowWrapperDTO wrapper){
191
        CdmStore.getService(IDescriptionService.class).merge(wrapper.getSpecimenDescription());
191
        CdmStore.getService(IDescriptionService.class).merge(wrapper.getDescription());
192 192
    }
193 193

  
194 194
    @Focus
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java
21 21
 * @since Nov 26, 2017
22 22
 *
23 23
 */
24
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<RowWrapperDTO>{
24
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<Object>{
25 25

  
26 26
    private CharacterMatrix matrix;
27 27

  
......
34 34
     * {@inheritDoc}
35 35
     */
36 36
    @Override
37
    public Object getDataValue(RowWrapperDTO rowObject, int columnIndex) {
37
    public Object getDataValue(Object rowObject, int columnIndex) {
38 38
        if(rowObject instanceof SpecimenRowWrapperDTO){
39 39
            SpecimenRowWrapperDTO rowWrapper = (SpecimenRowWrapperDTO) rowObject;
40 40
            switch (columnIndex) {
......
67 67
     * {@inheritDoc}
68 68
     */
69 69
    @Override
70
    public void setDataValue(RowWrapperDTO rowObject, int columnIndex, Object newValue) {
71
        RowWrapperDTO rowWrapper = rowObject;
72
        Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
73
        rowWrapper.setDataValueForFeature(feature, newValue);
70
    public void setDataValue(Object rowObject, int columnIndex, Object newValue) {
71
        if(rowObject instanceof RowWrapperDTO){
72
            RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject;
73
            Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
74
            rowWrapper.setDataValueForFeature(feature, newValue);
75
        }
74 76
    }
75 77

  
76 78
    /**

Also available in: Unified diff