Search in sources :

Example 1 with RemovalOfConsumedProjectAllocationIsFirbiddenException

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;
}
Also used : RemovalOfConsumedProjectAllocationIsFirbiddenException(io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException) RemovalOfConsumedProjectAllocationIsFirbiddenException(io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog)

Example 2 with RemovalOfConsumedProjectAllocationIsFirbiddenException

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);
}
Also used : RemovalOfConsumedProjectAllocationIsFirbiddenException(io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) ProjectAllocationRemovedEvent(io.imunity.furms.domain.project_allocation.ProjectAllocationRemovedEvent) ProjectAllocationResolved(io.imunity.furms.domain.project_allocation.ProjectAllocationResolved) FurmsAuthorize(io.imunity.furms.core.config.security.method.FurmsAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

RemovalOfConsumedProjectAllocationIsFirbiddenException (io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException)2 FurmsAuthorize (io.imunity.furms.core.config.security.method.FurmsAuthorize)1 ProjectAllocation (io.imunity.furms.domain.project_allocation.ProjectAllocation)1 ProjectAllocationRemovedEvent (io.imunity.furms.domain.project_allocation.ProjectAllocationRemovedEvent)1 ProjectAllocationResolved (io.imunity.furms.domain.project_allocation.ProjectAllocationResolved)1 FurmsDialog (io.imunity.furms.ui.components.FurmsDialog)1 Transactional (org.springframework.transaction.annotation.Transactional)1