Search in sources :

Example 1 with CommunityAllocationModelsMapper

use of io.imunity.furms.ui.community.allocations.CommunityAllocationModelsMapper in project furms by unity-idm.

the class CommunityAllocationFormView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    CommunityAllocationViewModel serviceViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> communityAllocationService.findByIdWithRelatedObjects(id))).flatMap(Function.identity()).map(CommunityAllocationModelsMapper::map).orElseGet(() -> {
        String communityId = event.getLocation().getQueryParameters().getParameters().get("communityId").iterator().next();
        return new CommunityAllocationViewModel(communityId, communityService.findById(communityId).get().getName());
    });
    this.communityId = serviceViewModel.getCommunityId();
    String trans = parameter == null ? "view.fenix-admin.resource-credits-allocation.form.parameter.new" : "view.fenix-admin.resource-credits-allocation.form.parameter.update";
    breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
    communityAllocationFormComponent.setModelObject(serviceViewModel, () -> communityAllocationService.getOccupiedNames(communityId));
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) DuplicatedNameValidationError(io.imunity.furms.api.validation.exceptions.DuplicatedNameValidationError) CommunityAllocationViewModel(io.imunity.furms.ui.community.allocations.CommunityAllocationViewModel) CommunityAllocationModelsMapper(io.imunity.furms.ui.community.allocations.CommunityAllocationModelsMapper) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) Binder(com.vaadin.flow.data.binder.Binder) CommunityAllocationService(io.imunity.furms.api.community_allocation.CommunityAllocationService) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) Route(com.vaadin.flow.router.Route) BigDecimal(java.math.BigDecimal) CommunityAllocationComboBoxesModelsResolver(io.imunity.furms.ui.community.allocations.CommunityAllocationComboBoxesModelsResolver) ResourceTypeService(io.imunity.furms.api.resource_types.ResourceTypeService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) OptionalException(io.imunity.furms.ui.utils.OptionalException) BeanValidationBinder(com.vaadin.flow.data.binder.BeanValidationBinder) Key(com.vaadin.flow.component.Key) SiteService(io.imunity.furms.api.sites.SiteService) UI(com.vaadin.flow.component.UI) ResourceCreditService(io.imunity.furms.api.resource_credits.ResourceCreditService) VaadinExceptionHandler.getResultOrException(io.imunity.furms.ui.utils.VaadinExceptionHandler.getResultOrException) FormButtons(io.imunity.furms.ui.components.FormButtons) ButtonVariant(com.vaadin.flow.component.button.ButtonVariant) Optional.ofNullable(java.util.Optional.ofNullable) CommunityAllocation(io.imunity.furms.domain.community_allocation.CommunityAllocation) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) OptionalParameter(com.vaadin.flow.router.OptionalParameter) FenixAdminMenu(io.imunity.furms.ui.views.fenix.menu.FenixAdminMenu) Button(com.vaadin.flow.component.button.Button) CommunityView(io.imunity.furms.ui.views.fenix.communites.CommunityView) Optional(java.util.Optional) CommunityService(io.imunity.furms.api.communites.CommunityService) CommunityAllocationErrors(io.imunity.furms.ui.views.fenix.communites.CommunityAllocationErrors) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) CommunityAllocationViewModel(io.imunity.furms.ui.community.allocations.CommunityAllocationViewModel)

Aggregations

Key (com.vaadin.flow.component.Key)1 UI (com.vaadin.flow.component.UI)1 Button (com.vaadin.flow.component.button.Button)1 ButtonVariant (com.vaadin.flow.component.button.ButtonVariant)1 BeanValidationBinder (com.vaadin.flow.data.binder.BeanValidationBinder)1 Binder (com.vaadin.flow.data.binder.Binder)1 BeforeEvent (com.vaadin.flow.router.BeforeEvent)1 OptionalParameter (com.vaadin.flow.router.OptionalParameter)1 Route (com.vaadin.flow.router.Route)1 CommunityService (io.imunity.furms.api.communites.CommunityService)1 CommunityAllocationService (io.imunity.furms.api.community_allocation.CommunityAllocationService)1 ResourceCreditService (io.imunity.furms.api.resource_credits.ResourceCreditService)1 ResourceTypeService (io.imunity.furms.api.resource_types.ResourceTypeService)1 SiteService (io.imunity.furms.api.sites.SiteService)1 DuplicatedNameValidationError (io.imunity.furms.api.validation.exceptions.DuplicatedNameValidationError)1 CommunityAllocation (io.imunity.furms.domain.community_allocation.CommunityAllocation)1 CommunityAllocationComboBoxesModelsResolver (io.imunity.furms.ui.community.allocations.CommunityAllocationComboBoxesModelsResolver)1 CommunityAllocationModelsMapper (io.imunity.furms.ui.community.allocations.CommunityAllocationModelsMapper)1 CommunityAllocationViewModel (io.imunity.furms.ui.community.allocations.CommunityAllocationViewModel)1 FormButtons (io.imunity.furms.ui.components.FormButtons)1