use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.
the class ProjectFormView method setParameter.
@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
ProjectViewModel projectViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> resolver.resolve(id, UIContext.getCurrent().getZone()))).orElseGet(() -> new ProjectViewModel(ResourceGetter.getCurrentResourceId()));
String trans = parameter == null ? "view.community-admin.project.form.parameter.new" : "view.community-admin.project.form.parameter.update";
breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
projectFormComponent.setFormPools(projectViewModel);
}
use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.
the class ProjectResourceAllocationsDetailsView method setParameter.
@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
Optional<String> projectId = event.getLocation().getQueryParameters().getParameters().getOrDefault("projectId", List.of()).stream().findAny();
Optional<ProjectAllocation> projectAllocation = ofNullable(parameter).filter(id -> projectId.isPresent()).flatMap(id -> handleExceptions(() -> projectAllocationService.findByProjectIdAndId(projectId.get(), id))).flatMap(Function.identity());
if (projectAllocation.isPresent()) {
getContent().removeAll();
breadCrumbParameter = new BreadCrumbParameter(parameter, projectAllocation.get().name, getTranslation("view.user-settings.projects.page.details.bread-crumb"));
ResourceAllocationChart resourceAllocationChart = new ResourceAllocationChart(chartPowerService.getChartDataForProjectAlloc(projectAllocation.get().projectId, projectAllocation.get().id), jsonExporter.getJsonForProjectAllocation(projectAllocation.get().projectId, projectAllocation.get().id), csvExporter.getCsvForProjectAllocation(projectAllocation.get().projectId, projectAllocation.get().id));
getContent().add(resourceAllocationChart);
}
}
use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.
the class SSHKeyFormView method setParameter.
@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
try {
sshKeyService.assertIsEligibleToManageKeys();
} catch (UserWithoutFenixIdValidationError e) {
LOG.debug(e.getMessage(), e);
showErrorNotification(getTranslation("user.without.fenixid.error.message"));
setVisible(false);
return;
} catch (UserWithoutSitesError e) {
LOG.debug(e.getMessage(), e);
showErrorNotification(getTranslation("view.user-settings.ssh-keys.user.without.sites.error.message"));
return;
} catch (AccessDeniedException e) {
LOG.debug(e.getMessage(), e);
showErrorNotification(getTranslation("view.user-settings.ssh-keys.access.denied.error.message"));
setVisible(false);
return;
}
SSHKeyUpdateModel serviceViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> sshKeyService.findById(id))).flatMap(Function.identity()).map(k -> SSHKeyViewModelMapper.mapToUpdate(k, zoneId)).orElseGet(() -> new SSHKeyUpdateModel(authzService.getCurrentUserId()));
String trans = parameter == null ? "view.user-settings.ssh-keys.form.parameter.new" : "view.user-settings.ssh-keys.form.parameter.update";
breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
sshKeyComponent.setFormPools(serviceViewModel);
}
use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.
the class PolicyDocumentFormView method setParameter.
@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
PolicyDocumentFormModel policyDocumentFormModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> policyDocumentService.findById(siteId, new PolicyId(id)))).flatMap(Function.identity()).map(PolicyDocumentFormModelMapper::map).orElseGet(() -> new PolicyDocumentFormModel(siteId));
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(policyDocumentFormModel);
revision.setText(String.valueOf(policyDocumentFormModel.revision));
if (policyDocumentFormModel.id == null)
addCreateButtons();
else {
addUpdateButtons();
workflowComboBox.setReadOnly(true);
}
}
use of com.vaadin.flow.router.OptionalParameter in project furms by unity-idm.
the class ResourceCreditFormView method setParameter.
@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
ResourceCreditViewModel resourceCreditViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> resourceCreditService.findWithAllocationsByIdAndSiteId(id, getCurrentResourceId()))).flatMap(Function.identity()).map(credit -> ResourceCreditViewModelMapper.map(credit, zoneId)).orElseGet(() -> new ResourceCreditViewModel(getCurrentResourceId()));
String trans = parameter == null ? "view.site-admin.resource-credits.form.parameter.new" : "view.site-admin.resource-credits.form.parameter.update";
breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
resourceCreditFormComponent.setFormPools(resourceCreditViewModel, resourceCreditService.hasCommunityAllocations(resourceCreditViewModel.getId(), resourceCreditViewModel.getSiteId()), () -> resourceCreditService.getOccupiedNames(resourceCreditViewModel.getSiteId()));
}
Aggregations