Project

General

Profile

Revision 1dc37073

ID1dc37073556859ea37a848507732c6f35bb87889
Parent e0812cf2
Child 57a2a42f

Added by Patrick Plitzner over 3 years ago

ref #7674 Create default taxon description when adding specimens

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
97 97
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
98 98
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
99 99
import eu.etaxonomy.taxeditor.model.MessagingUtils;
100
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
100 101
import eu.etaxonomy.taxeditor.store.CdmStore;
101 102
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
102 103

  
......
664 665
        return isShowTooltips;
665 666
    }
666 667

  
668
    public ICdmEntitySession getCdmEntitiySession(){
669
        return part.getCdmEntitySession();
670
    }
671

  
667 672
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
10 10

  
11 11
import java.util.ArrayList;
12 12
import java.util.Collection;
13
import java.util.HashMap;
14 13
import java.util.List;
15 14
import java.util.Map;
16
import java.util.Set;
17 15
import java.util.UUID;
18 16
import java.util.stream.Collectors;
19 17

  
......
32 30
import eu.etaxonomy.cdm.api.service.UpdateResult;
33 31
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
34 32
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
33
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
35 34
import eu.etaxonomy.cdm.common.CdmUtils;
36 35
import eu.etaxonomy.cdm.model.description.CategoricalData;
37
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
38 36
import eu.etaxonomy.cdm.model.description.Feature;
39 37
import eu.etaxonomy.cdm.model.description.QuantitativeData;
40 38
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
......
81 79
                if(dialog.open()==Window.OK){
82 80
                    Collection<SpecimenNodeWrapper> wrappers = dialog.getSpecimen();
83 81
                    for (SpecimenNodeWrapper wrapper : wrappers) {
84
                        SpecimenDescription description = CdmStore.getService(IDescriptiveDataSetService.class)
85
                                .findDescriptionForDescriptiveDataSet(matrix.getDescriptiveDataSet().getUuid(),
82
                        SpecimenDescription specimenDescription = CdmStore.getService(IDescriptiveDataSetService.class)
83
                                .findSpecimenDescription(matrix.getDescriptiveDataSet().getUuid(),
86 84
                                        wrapper.getUuidAndTitleCache().getUuid());
87
                        // description elements
88
                        Map<Feature, DescriptionElementBase> featureToElementMap = new HashMap<>();
89
                        Set<DescriptionElementBase> elements = description.getElements();
90
                        for (DescriptionElementBase descriptionElementBase : elements) {
91
                            Feature feature = descriptionElementBase.getFeature();
92
                            featureToElementMap.put(feature, descriptionElementBase);
93
                        }
94
                        RowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createSpecimenRowWrapper(description, matrix.getDescriptiveDataSet());
85
                        SpecimenRowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class)
86
                                .createSpecimenRowWrapper(specimenDescription, matrix.getDescriptiveDataSet(), true);
95 87
                        if(rowWrapper==null){
96
                            error += description;
88
                            error += specimenDescription;
97 89
                            continue;
98 90
                        }
91
                        //add specimen description
99 92
                        matrix.getDescriptions().add(rowWrapper);
100
                        matrix.getDescriptiveDataSet().addDescription(description);
93
                        matrix.getDescriptiveDataSet().addDescription(specimenDescription);
94
                        matrix.getCdmEntitiySession().load(specimenDescription, true);
95

  
96
                        //add taxon description
97
                        TaxonRowWrapperDTO taxonDescription = rowWrapper.getDefaultTaxonDescription();
98
                        matrix.getDescriptiveDataSet().addDescription(taxonDescription.getDescription());
99
                        matrix.getCdmEntitiySession().load(taxonDescription.getDescription(), true);
100

  
101 101
                        matrix.setDirty();
102 102
                        matrix.getSpecimenCache().remove(wrapper);
103 103
                    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)