@Autowired
private INameService nameService;
+ @Autowired
+ private IEventBaseService eventService;
+
@Autowired
private ITaxonService taxonService;
}
@Override
- public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache() {
- return dao.getDerivedUnitUuidAndTitleCache();
+ public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern) {
+ return dao.getDerivedUnitUuidAndTitleCache(limit, pattern);
}
@Override
//specimen identifier
FormatKey collectionKey = FormatKey.COLLECTION_CODE;
- String specimenIdentifier = CdmFormatterFactory.format(derivedUnit, new FormatKey[] { FormatKey.COLLECTION_CODE });
+ String specimenIdentifier = CdmFormatterFactory.format(derivedUnit, collectionKey);
if (CdmUtils.isBlank(specimenIdentifier)) {
collectionKey = FormatKey.COLLECTION_NAME;
}
public DeleteResult delete(SpecimenOrObservationBase<?> specimen, SpecimenDeleteConfigurator config) {
specimen = HibernateProxyHelper.deproxy(specimen, SpecimenOrObservationBase.class);
+ DeleteResult deleteResult = isDeletable(specimen.getUuid(), config);
+ if (!deleteResult.isOk()) {
+ return deleteResult;
+ }
+
if (config.isDeleteChildren()) {
Set<DerivationEvent> derivationEvents = specimen.getDerivationEvents();
//clone to avoid concurrent modification
derivativesToDelete.add(unit);
}
for (DerivedUnit unit:derivativesToDelete){
- delete(unit, config);
+ deleteResult.includeResult(delete(unit, config));
}
}
}
- DeleteResult deleteResult = isDeletable(specimen.getUuid(), config);
- if (!deleteResult.isOk()) {
- return deleteResult;
- }
// check related objects
Set<CdmBase> relatedObjects = deleteResult.getRelatedObjects();
specimenOrObservationBase.removeDerivationEvent(derivationEvent);
deleteResult.addUpdatedObject(specimenOrObservationBase);
}
+ // if derivationEvent has no derivates anymore, delete it
+ eventService.delete(derivationEvent);
}
}
else{
FieldUnit fieldUnit = HibernateProxyHelper.deproxy(specimen, FieldUnit.class);
GatheringEvent event = fieldUnit.getGatheringEvent();
fieldUnit.setGatheringEvent(null);
-
+ if (event != null){
+ DeleteResult result = eventService.isDeletable(event.getUuid(), null);
+ if (result.isOk()){
+ eventService.delete(event);
+ }
+ }
}
deleteResult.includeResult(delete(specimen));