Project

General

Profile

Revision 9d368a18

ID9d368a188d94e0c3268c42b23b60c83d5fb891c0
Parent 1118cbec
Child b3d82392

Added by Katja Luther about 3 years ago

fix media delete, remove descriptionElement from description if it does not contain any media anymore

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/MediaServiceImpl.java
130 130
                            } else if ( (config.isDeleteFromDescription() && config.getDeleteFrom() instanceof Taxon  && config.getDeleteFrom().getId() == desc.getTaxon().getId())|| config.isDeleteFromEveryWhere()){
131 131
                                Taxon taxon = desc.getTaxon();
132 132
                                updatedObject = taxon;
133
                                desc.removeElement(textData);
134
                                textData.removeMedia(media);
133

  
134
                                while(textData.getMedia().contains(media)){
135
                                    textData.removeMedia(media);
136
                                }
137
                                if (textData.getMedia().isEmpty()){
138
                                    desc.removeElement(textData);
139
                                }
135 140
                                if (desc.getElements().isEmpty()){
136 141
                                    taxon.removeDescription(desc);
137 142
                                }
......
181 186
                            }
182 187
                        }
183 188
                    }
184
                }else if (ref instanceof MediaRepresentation){
185
                    MediaRepresentation mediaRep = HibernateProxyHelper.deproxy(ref, MediaRepresentation.class);
186
                    media.removeRepresentation(mediaRep);
187
                } else if (ref instanceof MediaSpecimen){
189
                } else if ((ref instanceof MediaSpecimen && config.getDeleteFrom().getId() == ref.getId() && config.getDeleteFrom() instanceof MediaSpecimen)
190
                        || (ref instanceof MediaSpecimen && config.isDeleteFromEveryWhere())){
188 191
                    MediaSpecimen mediaSpecimen = HibernateProxyHelper.deproxy(ref, MediaSpecimen.class);
189 192
                    if (config.getDeleteFrom().getId() == mediaSpecimen.getId() || config.isDeleteFromEveryWhere()){
190 193
                        mediaSpecimen.setMediaSpecimen(null);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)