use of io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException in project furms by unity-idm.
the class ProjectAllocationComponent method createConfirmDialog.
private Dialog createConfirmDialog(String projectAllocationId, String projectAllocationName) {
FurmsDialog furmsDialog = new FurmsDialog(getTranslation("view.community-admin.project-allocation.dialog.text", projectAllocationName));
furmsDialog.addConfirmButtonClickListener(event -> {
try {
service.delete(communityId, projectAllocationId);
loadGridContent();
} catch (RemovalOfConsumedProjectAllocationIsFirbiddenException e) {
showErrorNotification(getTranslation("project.allocation.removing.message"));
} catch (Exception e) {
showErrorNotification(getTranslation("base.error.message"));
}
});
return furmsDialog;
}
use of io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException in project furms by unity-idm.
the class ProjectAllocationServiceImpl method delete.
@Override
@Transactional
@FurmsAuthorize(capability = COMMUNITY_WRITE, resourceType = COMMUNITY, id = "communityId")
public void delete(String communityId, String id) {
validator.validateDelete(communityId, id);
ProjectAllocationResolved projectAllocationResolved = projectAllocationRepository.findByIdWithRelatedObjects(id).get();
if (projectAllocationResolved.consumed.compareTo(BigDecimal.ZERO) > 0) {
throw new RemovalOfConsumedProjectAllocationIsFirbiddenException(id);
}
projectAllocationInstallationService.createDeallocation(projectAllocationResolved);
ProjectAllocation projectAllocation = projectAllocationRepository.findById(id).get();
publisher.publishEvent(new ProjectAllocationRemovedEvent(projectAllocation));
LOG.info("ProjectAllocation with given ID: {} was deleted", id);
}
Aggregations