Project

General

Profile

« Previous | Next » 

Revision 0e1a7631

Added by Patrick Plitzner over 4 years ago

ref #8539 Add association taxon description to descriptive data set

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
103 103
                SpecimenSelectionDialog dialog = new SpecimenSelectionDialog(matrix.getShell(), matrix);
104 104
                if(dialog.open()==Window.OK){
105 105
                    Collection<SpecimenNodeWrapper> wrappers = dialog.getSpecimen();
106
                    if(wrappers.stream().anyMatch(wrapper->!wrapper.isIndividualsAssociation())
106
                    if(wrappers.stream().anyMatch(wrapper->wrapper.getTaxonDescription()==null)
107 107
                            && !MessagingUtils.confirmDialog(
108 108
                                    "Create Taxon Association",
109 109
                                    "Some specimens are not linked with taxon via IndividualsAssociation yet.\n"
......
111 111
                        return;
112 112
                    }
113 113
                    for (SpecimenNodeWrapper wrapper : wrappers) {
114
                        if(!wrapper.isIndividualsAssociation()){
114
                        TaxonDescription taxonDescription = wrapper.getTaxonDescription();
115
                        if(taxonDescription==null){
115 116
                            Optional<TaxonDescription> associationDescriptionOptional = wrapper.getTaxonNode().getTaxon().getDescriptions().stream()
116 117
                            .filter(desc->desc.getTypes().contains(DescriptionType.INDIVIDUALS_ASSOCIATION))
117 118
                            .findFirst();
118 119
                            Taxon taxon = wrapper.getTaxonNode().getTaxon();
119
                            TaxonDescription associationDescription;
120 120
                            if(!associationDescriptionOptional.isPresent()){
121
                                associationDescription = TaxonDescription.NewInstance(taxon);
121
                                taxonDescription = TaxonDescription.NewInstance(taxon);
122 122
                            }
123 123
                            else{
124
                                associationDescription = associationDescriptionOptional.get();
124
                                taxonDescription = associationDescriptionOptional.get();
125 125
                            }
126 126

  
127 127
                            SpecimenOrObservationBase specimen = CdmStore.getService(IOccurrenceService.class).load(wrapper.getUuidAndTitleCache().getUuid());
128 128
                            IndividualsAssociation association = IndividualsAssociation.NewInstance(specimen);
129
                            associationDescription.addElement(association);
129
                            taxonDescription.addElement(association);
130 130
                            CdmStore.getService(ITaxonService.class).saveOrUpdate(wrapper.getTaxonNode().getTaxon());
131 131
                        }
132 132
                        SpecimenDescription specimenDescription = CdmStore.getService(IDescriptiveDataSetService.class)
......
138 138
                            error += specimenDescription+"\n";
139 139
                            continue;
140 140
                        }
141
                        //add specimen description
141
                        //add wrapper to matrix
142 142
                        matrix.getDescriptions().add(rowWrapper);
143
                        //add specimen description to data set
143 144
                        matrix.getDescriptiveDataSet().addDescription(specimenDescription);
145
                        //add taxon description with IndividualsAssociation to the specimen to data set
146
                        matrix.getDescriptiveDataSet().addDescription(taxonDescription);
144 147
                        matrix.getCdmEntitiySession().load(specimenDescription, true);
148
                        matrix.getCdmEntitiySession().load(taxonDescription, true);
145 149

  
146 150
                        matrix.setDirty();
147 151
                        matrix.getSpecimenCache().remove(wrapper);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenSelectionDialog.java
247 247
        @Override
248 248
        public String getToolTipText(Object element) {
249 249
            if(element instanceof SpecimenNodeWrapper
250
                    && !((SpecimenNodeWrapper) element).isIndividualsAssociation()){
250
                    && ((SpecimenNodeWrapper) element).getTaxonDescription()==null){
251 251
                return "Does not have and IndividualsAssociation with the taxon";
252 252
            }
253 253
            return null;
......
256 256
        @Override
257 257
        public Image getColumnImage(Object element, int columnIndex) {
258 258
            if(element instanceof SpecimenNodeWrapper && columnIndex == 2
259
                    && !((SpecimenNodeWrapper) element).isIndividualsAssociation()){
259
                    && ((SpecimenNodeWrapper) element).getTaxonDescription()==null){
260 260
                return ImageResources.getImage(ImageResources.WARNING_ICON);
261 261
            }
262 262
            return null;

Also available in: Unified diff