Search in sources :

Example 11 with OptionalParameter

use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.

the class GroupFormView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    GroupFormModel groupFormModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> genericGroupService.findBy(communityId, new GenericGroupId(id)))).flatMap(Function.identity()).map(x -> new GroupFormModel(x.id, x.communityId, x.name, x.description)).orElseGet(() -> new GroupFormModel(communityId));
    String trans = parameter == null ? "view.site-admin.policy-documents.form.parameter.new" : "view.site-admin.policy-documents.form.parameter.update";
    breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
    binder.setBean(groupFormModel);
    if (groupFormModel.id.id == null)
        addCreateButtons();
    else {
        addUpdateButtons();
        workflowComboBox.setReadOnly(true);
    }
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) DuplicatedNameValidationError(io.imunity.furms.api.validation.exceptions.DuplicatedNameValidationError) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) TextArea(com.vaadin.flow.component.textfield.TextArea) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) Binder(com.vaadin.flow.data.binder.Binder) Div(com.vaadin.flow.component.html.Div) PageTitle(io.imunity.furms.ui.components.PageTitle) ComboBox(com.vaadin.flow.component.combobox.ComboBox) BeforeEvent(com.vaadin.flow.router.BeforeEvent) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) FurmsFormLayout(io.imunity.furms.ui.components.FurmsFormLayout) Function(java.util.function.Function) Route(com.vaadin.flow.router.Route) GenericGroupService(io.imunity.furms.api.generic_groups.GenericGroupService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) BeanValidationBinder(com.vaadin.flow.data.binder.BeanValidationBinder) Key(com.vaadin.flow.component.Key) UI(com.vaadin.flow.component.UI) PolicyWorkflow(io.imunity.furms.domain.policy_documents.PolicyWorkflow) CommunityAdminMenu(io.imunity.furms.ui.views.community.CommunityAdminMenu) TextField(com.vaadin.flow.component.textfield.TextField) EAGER(com.vaadin.flow.data.value.ValueChangeMode.EAGER) FormButtons(io.imunity.furms.ui.components.FormButtons) ButtonVariant(com.vaadin.flow.component.button.ButtonVariant) Optional.ofNullable(java.util.Optional.ofNullable) GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) OptionalParameter(com.vaadin.flow.router.OptionalParameter) Objects(java.util.Objects) Button(com.vaadin.flow.component.button.Button) MAX_NAME_LENGTH(java.util.prefs.Preferences.MAX_NAME_LENGTH) Optional(java.util.Optional) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId)

Example 12 with OptionalParameter

use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.

the class CommunityAllocationsDetailsView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    Optional<CommunityAllocation> communityAllocation = ofNullable(parameter).flatMap(id -> handleExceptions(() -> communityAllocationService.findById(id))).flatMap(Function.identity());
    if (communityAllocation.isPresent()) {
        getContent().removeAll();
        breadCrumbParameter = new BreadCrumbParameter(parameter, communityAllocation.get().name, getTranslation("view.fenix-admin.community.resource-allocations.details.page.bread-crumb"));
        ResourceAllocationChart resourceAllocationChart = new ResourceAllocationChart(chartPowerService.getChartDataForCommunityAlloc(communityAllocation.get().communityId, communityAllocation.get().id), jsonExporter.getJsonForCommunityAllocation(communityAllocation.get().communityId, communityAllocation.get().id), csvExporter.getCsvForCommunityAllocation(communityAllocation.get().communityId, communityAllocation.get().id), true);
        getContent().add(resourceAllocationChart);
    }
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) Optional.ofNullable(java.util.Optional.ofNullable) CommunityAllocation(io.imunity.furms.domain.community_allocation.CommunityAllocation) ResourceUsageJSONExporter(io.imunity.furms.api.export.ResourceUsageJSONExporter) CommunityAllocationService(io.imunity.furms.api.community_allocation.CommunityAllocationService) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) Route(com.vaadin.flow.router.Route) OptionalParameter(com.vaadin.flow.router.OptionalParameter) FenixAdminMenu(io.imunity.furms.ui.views.fenix.menu.FenixAdminMenu) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Optional(java.util.Optional) ResourceUsageCSVExporter(io.imunity.furms.api.export.ResourceUsageCSVExporter) ChartPowerService(io.imunity.furms.ui.charts.ChartPowerService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) CommunityAllocation(io.imunity.furms.domain.community_allocation.CommunityAllocation)

Example 13 with OptionalParameter

use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.

the class ResourceAllocationsDetailsView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    Optional<ProjectAllocation> projectAllocation = ofNullable(parameter).flatMap(id -> handleExceptions(() -> projectAllocationService.findByProjectIdAndId(projectId, id))).flatMap(Function.identity());
    if (projectAllocation.isPresent()) {
        getContent().removeAll();
        breadCrumbParameter = new BreadCrumbParameter(parameter, projectAllocation.get().name, getTranslation("view.project-admin.resource-allocations.details.page.bread-crumb"));
        ToggleButton toggle = new ToggleButton("Show per-user breakdown");
        toggle.addValueChangeListener(evt -> {
            getContent().removeAll();
            if (evt.getValue())
                getContent().add(toggle, getResourceAllocationChartWithUsersUsage(projectAllocation.get()));
            else
                getContent().add(toggle, getBasicResourceAllocationChart(projectAllocation.get()));
        });
        getContent().add(toggle, getBasicResourceAllocationChart(projectAllocation.get()));
    }
}
Also used : ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ToggleButton(com.vaadin.componentfactory.ToggleButton) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) Optional.ofNullable(java.util.Optional.ofNullable) ResourceUsageJSONExporter(io.imunity.furms.api.export.ResourceUsageJSONExporter) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) Route(com.vaadin.flow.router.Route) OptionalParameter(com.vaadin.flow.router.OptionalParameter) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Optional(java.util.Optional) ResourceUsageCSVExporter(io.imunity.furms.api.export.ResourceUsageCSVExporter) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) ChartPowerService(io.imunity.furms.ui.charts.ChartPowerService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ToggleButton(com.vaadin.componentfactory.ToggleButton) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation)

Example 14 with OptionalParameter

use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.

the class ResourceTypeFormView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    ResourceTypeViewModel serviceViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> resourceTypeService.findById(id, getCurrentResourceId()))).flatMap(Function.identity()).map(ResourceTypeViewModelMapper::map).orElseGet(() -> new ResourceTypeViewModel(getCurrentResourceId()));
    String trans = parameter == null ? "view.site-admin.resource-types.form.parameter.new" : "view.site-admin.resource-types.form.parameter.update";
    breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
    resourceTypeFormComponent.setFormPools(serviceViewModel);
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) Binder(com.vaadin.flow.data.binder.Binder) NotificationUtils(io.imunity.furms.ui.utils.NotificationUtils) PageTitle(io.imunity.furms.ui.components.PageTitle) Function(java.util.function.Function) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Route(com.vaadin.flow.router.Route) 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) UI(com.vaadin.flow.component.UI) SiteAdminMenu(io.imunity.furms.ui.views.site.SiteAdminMenu) 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) ResourceType(io.imunity.furms.domain.resource_types.ResourceType) InfraServiceService(io.imunity.furms.api.services.InfraServiceService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) OptionalParameter(com.vaadin.flow.router.OptionalParameter) Button(com.vaadin.flow.component.button.Button) Optional(java.util.Optional) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter)

Example 15 with OptionalParameter

use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.

the class InfraServiceFormView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    InfraServiceViewModel serviceViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> infraServiceService.findById(id, getCurrentResourceId()))).flatMap(Function.identity()).map(InfraServiceViewModelMapper::map).orElseGet(() -> new InfraServiceViewModel(getCurrentResourceId()));
    String trans = parameter == null ? "view.site-admin.service.form.parameter.new" : "view.site-admin.service.form.parameter.update";
    breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
    serviceFormComponent.setFormPools(serviceViewModel);
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) PolicyId(io.imunity.furms.domain.policy_documents.PolicyId) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) Binder(com.vaadin.flow.data.binder.Binder) NotificationUtils(io.imunity.furms.ui.utils.NotificationUtils) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) Route(com.vaadin.flow.router.Route) InfraService(io.imunity.furms.domain.services.InfraService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) OptionalException(io.imunity.furms.ui.utils.OptionalException) Map(java.util.Map) BeanValidationBinder(com.vaadin.flow.data.binder.BeanValidationBinder) Key(com.vaadin.flow.component.Key) UI(com.vaadin.flow.component.UI) SiteAdminMenu(io.imunity.furms.ui.views.site.SiteAdminMenu) 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) PolicyDto(io.imunity.furms.ui.views.site.PolicyDto) InfraServiceService(io.imunity.furms.api.services.InfraServiceService) Collectors(java.util.stream.Collectors) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) OptionalParameter(com.vaadin.flow.router.OptionalParameter) Button(com.vaadin.flow.component.button.Button) Optional(java.util.Optional) PolicyDocumentService(io.imunity.furms.api.policy_documents.PolicyDocumentService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter)

Aggregations

BeforeEvent (com.vaadin.flow.router.BeforeEvent)16 OptionalParameter (com.vaadin.flow.router.OptionalParameter)16 Route (com.vaadin.flow.router.Route)16 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)14 PageTitle (io.imunity.furms.ui.components.PageTitle)14 BreadCrumbParameter (io.imunity.furms.ui.components.layout.BreadCrumbParameter)14 VaadinExceptionHandler.handleExceptions (io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions)14 Optional (java.util.Optional)14 Optional.ofNullable (java.util.Optional.ofNullable)14 Function (java.util.function.Function)13 UI (com.vaadin.flow.component.UI)11 Button (com.vaadin.flow.component.button.Button)11 Key (com.vaadin.flow.component.Key)10 ButtonVariant (com.vaadin.flow.component.button.ButtonVariant)10 BeanValidationBinder (com.vaadin.flow.data.binder.BeanValidationBinder)10 Binder (com.vaadin.flow.data.binder.Binder)10 FormButtons (io.imunity.furms.ui.components.FormButtons)10 ResourceGetter.getCurrentResourceId (io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId)8 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)6 DuplicatedNameValidationError (io.imunity.furms.api.validation.exceptions.DuplicatedNameValidationError)5