Revision 6ab3b976
Added by Andreas Kohlbecker over 6 years ago
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.DeleteResult; |
|
25 | 26 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator; |
26 | 27 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
27 | 28 |
import eu.etaxonomy.cdm.model.name.Registration; |
... | ... | |
39 | 40 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO; |
40 | 41 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
41 | 42 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSet; |
42 |
import eu.etaxonomy.cdm.vaadin.view.name.stdDTOs; |
|
43 | 43 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
44 | 44 |
|
45 | 45 |
/** |
... | ... | |
53 | 53 |
|
54 | 54 |
private final Logger logger = Logger.getLogger(SpecimenTypeDesignationWorkingSetServiceImpl.class); |
55 | 55 |
|
56 |
static SpecimenDeleteConfigurator specimenDeleteConfigurer = new SpecimenDeleteConfigurator(); |
|
57 |
static { |
|
58 |
specimenDeleteConfigurer.setDeleteChildren(true); |
|
59 |
specimenDeleteConfigurer.setDeleteFromDescription(true); |
|
60 |
specimenDeleteConfigurer.setDeleteFromIndividualsAssociation(true); |
|
61 |
specimenDeleteConfigurer.setDeleteFromTypeDesignation(true); |
|
62 |
specimenDeleteConfigurer.setDeleteMolecularData(true); |
|
63 |
} |
|
64 |
|
|
56 | 65 |
public static final List<String> TAXON_NAME_INIT_STRATEGY = Arrays.asList(new String []{ |
57 | 66 |
"name.$", |
58 | 67 |
"name.nomenclaturalReference.authorship", |
... | ... | |
167 | 176 |
session.flush(); |
168 | 177 |
|
169 | 178 |
// ------------------------ 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 | 179 |
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 |
// } |
|
180 |
deleteSpecimenTypeDesignation(dto, std); |
|
187 | 181 |
} |
188 |
// ------------------------- |
|
189 |
|
|
190 | 182 |
|
191 | 183 |
} |
192 | 184 |
|
193 | 185 |
|
194 | 186 |
} |
195 | 187 |
|
188 |
/** |
|
189 |
* @param dto |
|
190 |
* @param specimenDeleteConfigurer |
|
191 |
* @param std |
|
192 |
*/ |
|
193 |
protected void deleteSpecimenTypeDesignation(SpecimenTypeDesignationWorkingSetDTO<? extends VersionableEntity> dto, SpecimenTypeDesignation std) { |
|
194 |
|
|
195 |
DerivedUnit du = std.getTypeSpecimen(); |
|
196 |
du.removeSpecimenTypeDesignation(std); |
|
197 |
DerivationEvent derivationEvent = du.getDerivedFrom(); |
|
198 |
derivationEvent.removeDerivative(du); |
|
199 |
repo.getNameService().deleteTypeDesignation(dto.getTypifiedName(), std); |
|
200 |
repo.getOccurrenceService().delete(du, specimenDeleteConfigurer); |
|
201 |
// if(derivationEvent.getDerivatives().size() == 0){ |
|
202 |
// getRepo().getEventBaseService().delete(derivationEvent); |
|
203 |
// } |
|
204 |
} |
|
205 |
|
|
196 | 206 |
/** |
197 | 207 |
* @param session |
198 | 208 |
* @param fieldUnit |
... | ... | |
258 | 268 |
* {@inheritDoc} |
259 | 269 |
*/ |
260 | 270 |
@Override |
261 |
public void delete(SpecimenTypeDesignationWorkingSetDTO bean) { |
|
262 |
for(stdDTOs : bean.getSpecimenTypeDesignationDTOs()){ |
|
263 |
|
|
264 |
} |
|
271 |
@Transactional(readOnly=false) |
|
272 |
public void delete(SpecimenTypeDesignationWorkingSetDTO bean, boolean deleteFieldUnit) { |
|
273 |
|
|
274 |
@SuppressWarnings("unchecked") |
|
275 |
List<SpecimenTypeDesignationDTO> specimenTypeDesignationDTOs = bean.getSpecimenTypeDesignationDTOs(); |
|
276 |
for(SpecimenTypeDesignationDTO stdDTO : specimenTypeDesignationDTOs){ |
|
277 |
SpecimenTypeDesignation std = stdDTO.asSpecimenTypeDesignation(); |
|
278 |
deleteSpecimenTypeDesignation(bean, std); |
|
279 |
if(bean.getOwner() instanceof Registration){ |
|
280 |
((Registration)bean.getOwner()).getTypeDesignations().remove(std); |
|
281 |
} |
|
282 |
} |
|
265 | 283 |
|
284 |
if(deleteFieldUnit){ |
|
285 |
FieldUnit fu = bean.getFieldUnit(); |
|
286 |
// delete the fieldunit and all derivatives |
|
287 |
DeleteResult result = repo.getOccurrenceService().delete(fu.getUuid(), specimenDeleteConfigurer); |
|
288 |
String msg = result.toString(); |
|
289 |
} |
|
266 | 290 |
} |
267 | 291 |
|
268 | 292 |
} |
Also available in: Unified diff
delete of SpecimenTypeDesignationWorkingSet implemented