Revision 9dab9096
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/service/ISpecimenTypeDesignationWorkingSetService.java | ||
---|---|---|
42 | 42 |
*/ |
43 | 43 |
void save(SpecimenTypeDesignationWorkingSetDTO<? extends VersionableEntity> dto); |
44 | 44 |
|
45 |
/** |
|
46 |
* @param bean |
|
47 |
*/ |
|
48 |
public void delete(SpecimenTypeDesignationWorkingSetDTO bean); |
|
49 |
|
|
45 | 50 |
} |
src/main/java/eu/etaxonomy/cdm/service/SpecimenTypeDesignationWorkingSetServiceImpl.java | ||
---|---|---|
22 | 22 |
import org.springframework.transaction.annotation.Transactional; |
23 | 23 |
|
24 | 24 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
25 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator; |
|
25 | 26 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
26 | 27 |
import eu.etaxonomy.cdm.model.name.Registration; |
27 | 28 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
38 | 39 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO; |
39 | 40 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
40 | 41 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSet; |
42 |
import eu.etaxonomy.cdm.vaadin.view.name.stdDTOs; |
|
41 | 43 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
42 | 44 |
|
43 | 45 |
/** |
... | ... | |
162 | 164 |
// regAnalyzer.printCopyEntities(System.out); |
163 | 165 |
|
164 | 166 |
session.merge(dto.getOwner()); |
167 |
session.flush(); |
|
168 |
|
|
169 |
// ------------------------ perform delete of removed SpecimenTypeDesignations |
|
170 |
SpecimenDeleteConfigurator specimenDeleteConfigurer = new SpecimenDeleteConfigurator(); |
|
171 |
specimenDeleteConfigurer.setDeleteChildren(false); |
|
172 |
specimenDeleteConfigurer.setDeleteFromDescription(true); |
|
173 |
specimenDeleteConfigurer.setDeleteFromIndividualsAssociation(true); |
|
174 |
specimenDeleteConfigurer.setDeleteFromTypeDesignation(true); |
|
175 |
specimenDeleteConfigurer.setDeleteMolecularData(true); |
|
176 |
|
|
177 |
for(SpecimenTypeDesignation std : dto.deletedSpecimenTypeDesignations()){ |
|
178 |
DerivedUnit du = std.getTypeSpecimen(); |
|
179 |
du.removeSpecimenTypeDesignation(std); |
|
180 |
DerivationEvent derivationEvent = du.getDerivedFrom(); |
|
181 |
derivationEvent.removeDerivative(du); |
|
182 |
repo.getNameService().deleteTypeDesignation(dto.getTypifiedName(), std); |
|
183 |
repo.getOccurrenceService().delete(du, specimenDeleteConfigurer); |
|
184 |
// if(derivationEvent.getDerivatives().size() == 0){ |
|
185 |
// getRepo().getEventBaseService().delete(derivationEvent); |
|
186 |
// } |
|
187 |
} |
|
188 |
// ------------------------- |
|
165 | 189 |
|
166 | 190 |
|
167 |
session.flush(); |
|
168 | 191 |
} |
169 | 192 |
|
170 | 193 |
|
... | ... | |
231 | 254 |
return addCandidates; |
232 | 255 |
} |
233 | 256 |
|
257 |
/** |
|
258 |
* {@inheritDoc} |
|
259 |
*/ |
|
260 |
@Override |
|
261 |
public void delete(SpecimenTypeDesignationWorkingSetDTO bean) { |
|
262 |
for(stdDTOs : bean.getSpecimenTypeDesignationDTOs()){ |
|
263 |
|
|
264 |
} |
|
265 |
|
|
266 |
} |
|
267 |
|
|
234 | 268 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationWorkingSetDTO.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.model.registration; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
import java.util.HashSet; |
|
12 | 13 |
import java.util.List; |
13 | 14 |
import java.util.Set; |
14 | 15 |
|
... | ... | |
39 | 40 |
|
40 | 41 |
List<SpecimenTypeDesignation> specimenTypeDesignations = new ArrayList<>(); |
41 | 42 |
|
43 |
/** |
|
44 |
* List of all SpecimenTypeDesignation that have been loaded into the |
|
45 |
* DTO. By comparing this list with <code>specimenTypeDesignations</code> |
|
46 |
* it is possible to find those that have been deleted. |
|
47 |
*/ |
|
48 |
List<SpecimenTypeDesignation> specimenTypeDesignationsLoaded = new ArrayList<>(); |
|
49 |
|
|
42 | 50 |
List<SpecimenTypeDesignationDTO> specimenTypeDesignationsDTOs = new ArrayList<>(); |
43 | 51 |
|
44 | 52 |
OWNER owner; |
... | ... | |
315 | 323 |
this.typifiedName = typifiedName; |
316 | 324 |
} |
317 | 325 |
|
326 |
/** |
|
327 |
* |
|
328 |
* @return the set of SpecimenTypeDesignation that haven been deleted from the <code>SpecimenTypeDesignationWorkingSetDTO</code>. |
|
329 |
*/ |
|
330 |
public Set<SpecimenTypeDesignation> deletedSpecimenTypeDesignations() { |
|
331 |
Set<SpecimenTypeDesignation> deletedEntities = new HashSet<>(specimenTypeDesignationsLoaded); |
|
332 |
deletedEntities.removeAll(specimenTypeDesignations); |
|
333 |
return deletedEntities; |
|
334 |
} |
|
318 | 335 |
|
319 | 336 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 | 11 |
import java.util.EnumSet; |
12 |
import java.util.HashSet; |
|
13 |
import java.util.Set; |
|
14 | 12 |
|
15 | 13 |
import org.springframework.beans.factory.annotation.Autowired; |
16 | 14 |
import org.vaadin.viritin.fields.AbstractElementCollection; |
17 | 15 |
|
18 | 16 |
import eu.etaxonomy.cdm.api.service.IRegistrationService; |
19 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator; |
|
20 | 17 |
import eu.etaxonomy.cdm.cache.CdmEntityCache; |
21 | 18 |
import eu.etaxonomy.cdm.cache.EntityCache; |
22 | 19 |
import eu.etaxonomy.cdm.model.location.Country; |
23 | 20 |
import eu.etaxonomy.cdm.model.name.Registration; |
24 | 21 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
25 | 22 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
26 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
|
27 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
28 | 23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
29 | 24 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
30 | 25 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
... | ... | |
74 | 69 |
|
75 | 70 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto; |
76 | 71 |
|
77 |
Set<SpecimenTypeDesignation> deletedSpecimenTypeDesignations = new HashSet<>(); |
|
78 |
|
|
79 | 72 |
protected CdmStore<Registration, IRegistrationService> getStore() { |
80 | 73 |
if(store == null){ |
81 | 74 |
store = new CdmStore<>(getRepo(), getRepo().getRegistrationService()); |
... | ... | |
201 | 194 |
} |
202 | 195 |
|
203 | 196 |
specimenTypeDesignationWorkingSetService.save(dto); |
204 |
|
|
205 |
SpecimenDeleteConfigurator specimenDeleteConfigurer = new SpecimenDeleteConfigurator(); |
|
206 |
specimenDeleteConfigurer.setDeleteChildren(false); |
|
207 |
specimenDeleteConfigurer.setDeleteFromDescription(true); |
|
208 |
specimenDeleteConfigurer.setDeleteFromIndividualsAssociation(true); |
|
209 |
specimenDeleteConfigurer.setDeleteFromTypeDesignation(true); |
|
210 |
specimenDeleteConfigurer.setDeleteMolecularData(true); |
|
211 |
|
|
212 |
for(SpecimenTypeDesignation std : deletedSpecimenTypeDesignations){ |
|
213 |
DerivedUnit du = std.getTypeSpecimen(); |
|
214 |
du.removeSpecimenTypeDesignation(std); |
|
215 |
DerivationEvent derivationEvent = du.getDerivedFrom(); |
|
216 |
derivationEvent.removeDerivative(du); |
|
217 |
getRepo().getNameService().deleteTypeDesignation(dto.getTypifiedName(), std); |
|
218 |
getRepo().getOccurrenceService().delete(du, specimenDeleteConfigurer); |
|
219 |
// if(derivationEvent.getDerivatives().size() == 0){ |
|
220 |
// getRepo().getEventBaseService().delete(derivationEvent); |
|
221 |
// } |
|
222 |
} |
|
223 | 197 |
} |
224 | 198 |
|
225 | 199 |
/** |
... | ... | |
227 | 201 |
*/ |
228 | 202 |
@Override |
229 | 203 |
protected void deleteBean(SpecimenTypeDesignationWorkingSetDTO bean) { |
230 |
// TODO Auto-generated method stub |
|
231 |
|
|
204 |
specimenTypeDesignationWorkingSetService.delete(bean); |
|
232 | 205 |
} |
233 | 206 |
|
234 | 207 |
/** |
... | ... | |
256 | 229 |
|
257 | 230 |
reg.getTypeDesignations().remove(std); |
258 | 231 |
|
259 |
deletedSpecimenTypeDesignations.add(std); |
|
260 | 232 |
getView().updateAllowDelete(); |
261 | 233 |
} |
262 | 234 |
|
Also available in: Unified diff
moving bussiness logic from presenter into DTO Service