Project

General

Profile

Revision e15dfd39

IDe15dfd39d00f03c158bd0911b0f32c1f96d9c9c8
Parent b1cce780
Child 7c245320

Added by Patrick Plitzner over 2 years ago

ref #7674 Adapt to cdmlib change(Add aggregated description to data set)

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
84 84
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
85 85
import eu.etaxonomy.cdm.api.service.UpdateResult;
86 86
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
87
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
87 88
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
88 89
import eu.etaxonomy.cdm.model.description.DescriptionBase;
89 90
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
......
130 131

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

  
133
    //FIXME use more concrete generic
134
    private EventList<Object> descriptions;
134
    private EventList<RowWrapperDTO> 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<Object> bodyDataProvider;
142
    private ListDataProvider<RowWrapperDTO> 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<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
280
        SortedList<RowWrapperDTO> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
281 281
        // wrap the SortedList with the TreeList
282
        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
282
        TreeList<RowWrapperDTO> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
283 283
        /**
284 284
         * data provider
285 285
         */
......
597 597
        return natTable;
598 598
    }
599 599

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

  
......
614 614
                .filter(wrapper ->
615 615
        //map descriptions on a list of uuids of the described specimen
616 616
        !this.descriptions.stream()
617
        .map(o->((RowWrapperDTO)o).getSpecimen().getUuid())
617
        .filter(rowWrapper->rowWrapper instanceof SpecimenRowWrapperDTO)
618
        .map(specimenRowWrapper->((SpecimenRowWrapperDTO) specimenRowWrapper).getSpecimen().getUuid())
618 619
        .collect(Collectors.toList())
619 620
        //an check if the specimen to add is already contained
620 621
        .contains(wrapper.getUuidAndTitleCache().getUuid())
......
626 627
        return toolbar.getNatTableState();
627 628
    }
628 629

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

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
90 90
                            Feature feature = descriptionElementBase.getFeature();
91 91
                            featureToElementMap.put(feature, descriptionElementBase);
92 92
                        }
93
                        RowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createRowWrapper(wrapper.getTaxonNode(), description, matrix.getDescriptiveDataSet());
93
                        RowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createSpecimenRowWrapper(description, matrix.getDescriptiveDataSet());
94 94
                        if(rowWrapper==null){
95 95
                            error += description;
96 96
                            continue;
......
161 161
                }
162 162
                List<UUID> descriptionUuids = new ArrayList<>();
163 163
                matrix.getDescriptiveDataSet().getDescriptions().forEach(desc->descriptionUuids.add(desc.getUuid()));
164
                UpdateResult result = CdmStore.getService(IDescriptionService.class).aggregateDescription(taxonUuid, descriptionUuids, matrix.getDescriptiveDataSet().getLabel());
164
                UpdateResult result = CdmStore.getService(IDescriptionService.class).aggregateDescription(taxonUuid, descriptionUuids, matrix.getDescriptiveDataSet().getLabel(), matrix.getDescriptiveDataSet().getUuid());
165 165
                matrix.addUpdateResult(result);
166 166
                matrix.setDirty();
167 167

  
......
176 176
    private void aggregateCategorcialHistogram(Map<Feature, CategoricalDataHistogram> featureToHistogramMap) {
177 177
        featureToHistogramMap.clear();
178 178
        matrix.getDescriptions()
179
                .forEach(o -> ((RowWrapperDTO) o).getSpecimenDescription().getElements().stream()
179
                .forEach(o -> o.getSpecimenDescription().getElements().stream()
180 180
                        .filter(descriptionElement -> descriptionElement instanceof CategoricalData)
181 181
                        .forEach(categoricalData -> {
182 182
                            Feature feature = ((CategoricalData) categoricalData).getFeature();
......
194 194
    private void aggregateQuantitativeSummary(Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap) {
195 195
        featureToQuantDataStatisticsMap.clear();
196 196
        matrix.getDescriptions()
197
        .forEach(o -> ((RowWrapperDTO) o).getSpecimenDescription().getElements().stream()
197
        .forEach(o -> o.getSpecimenDescription().getElements().stream()
198 198
                .filter(descriptionElement -> descriptionElement instanceof QuantitativeData)
199 199
                .forEach(quantData -> {
200 200
                    Feature feature = ((QuantitativeData) quantData).getFeature();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java
11 11
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
12 12

  
13 13
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
14
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
14 15
import eu.etaxonomy.cdm.model.description.Feature;
15 16

  
16 17
/**
......
20 21
 * @since Nov 26, 2017
21 22
 *
22 23
 */
23
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<Object>{
24
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<RowWrapperDTO>{
24 25

  
25 26
    private CharacterMatrix matrix;
26 27

  
......
33 34
     * {@inheritDoc}
34 35
     */
35 36
    @Override
36
    public Object getDataValue(Object rowObject, int columnIndex) {
37
        if(rowObject instanceof RowWrapperDTO){
38
            RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject;
37
    public Object getDataValue(RowWrapperDTO rowObject, int columnIndex) {
38
        if(rowObject instanceof SpecimenRowWrapperDTO){
39
            SpecimenRowWrapperDTO rowWrapper = (SpecimenRowWrapperDTO) rowObject;
39 40
            switch (columnIndex) {
40 41
            case 0:
41 42
                if(matrix.isTreeView()){
......
66 67
     * {@inheritDoc}
67 68
     */
68 69
    @Override
69
    public void setDataValue(Object rowObject, int columnIndex, Object newValue) {
70
        if(rowObject instanceof RowWrapperDTO){
71
            RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject;
72
            Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
73
            rowWrapper.setDataValueForFeature(feature, newValue);
74
        }
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);
75 74
    }
76 75

  
77 76
    /**
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/AggregateTaxonDescriptionsHandler.java
17 17
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
18 18
import eu.etaxonomy.taxeditor.model.MessagingUtils;
19 19
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
20
import eu.etaxonomy.taxeditor.navigation.navigator.operation.AggregateTaxonDescriptionsOperation;
21 20
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
22 21

  
23 22
public class AggregateTaxonDescriptionsHandler extends RemotingCdmHandlerE4 {
......
51 50
            MPart activePart,
52 51
            MHandledMenuItem menuItem) {
53 52

  
54
      return new AggregateTaxonDescriptionsOperation(getTrigger(),
55
              false,
56
              ((TaxonNodeDto) selection.getFirstElement()).getUuid()
57
              );
53
        //FIXME: this handler will probably be removed and secondary aggregation will be handled in the matrix editor
54
      return null;
55
//              new AggregateTaxonDescriptionsOperation(getTrigger(),
56
//              false,
57
//              ((TaxonNodeDto) selection.getFirstElement()).getUuid()
58
//              );
58 59
    }
59 60

  
60 61
    @CanExecute
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/AggregateTaxonDescriptionsOperation.java
16 16

  
17 17
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
18 18
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
19
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
20 19
import eu.etaxonomy.cdm.api.service.UpdateResult;
21 20
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
22 21
import eu.etaxonomy.taxeditor.event.EventUtility;
23 22
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
24 23
import eu.etaxonomy.taxeditor.model.AbstractUtility;
25
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
26 24
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
27 25
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
28 26

  
......
35 33
public class AggregateTaxonDescriptionsOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled {
36 34

  
37 35
    private UUID nodeUuid;
36
    private UUID descriptiveDataSetUuid;
38 37
    private UUID monitorUuid;
39 38

  
40 39
    public AggregateTaxonDescriptionsOperation(Object source,
41 40
            boolean async,
42
            UUID nodeUuid) {
41
            UUID nodeUuid,
42
            UUID descriptiveDataSetUuid
43
            ) {
43 44
        super("Aggregate taxon descriptions", Action.Update, source,async);
44 45
        this.nodeUuid = nodeUuid;
46
        this.descriptiveDataSetUuid = descriptiveDataSetUuid;
45 47

  
46 48
    }
47 49

  
......
52 54
    }
53 55

  
54 56
    public void runMoniteredOperation() {
55
        monitorUuid = CdmApplicationState.getLongRunningTasksService().aggregateComputedTaxonDescriptions(nodeUuid);
57
        monitorUuid = CdmApplicationState.getLongRunningTasksService().aggregateComputedTaxonDescriptions(nodeUuid, descriptiveDataSetUuid);
56 58

  
57 59
                Display.getDefault().asyncExec(new Runnable() {
58 60
                    @Override

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)