use of org.springframework.web.bind.annotation.PathVariable in project metasfresh-webui-api by metasfresh.
the class BoardRestController method getNewCardsViewLayout.
@GetMapping("/{boardId}/newCardsView/layout")
public JSONNewCardsViewLayout getNewCardsViewLayout(@PathVariable("boardId") final int boardId) {
userSession.assertLoggedIn();
final BoardDescriptor boardDescriptor = boardsRepo.getBoardDescriptor(boardId);
final ViewLayout documentsViewLayout = viewsRepo.getViewLayout(boardDescriptor.getDocumentWindowId(), JSONViewDataType.list, ViewProfileId.NULL);
final JSONOptions jsonOpts = newJSONOptions();
final String adLanguage = jsonOpts.getAD_Language();
return JSONNewCardsViewLayout.builder().caption(documentsViewLayout.getCaption(adLanguage)).description(documentsViewLayout.getDescription(adLanguage)).emptyResultHint(documentsViewLayout.getEmptyResultHint(adLanguage)).emptyResultText(documentsViewLayout.getEmptyResultText(adLanguage)).filters(JSONDocumentFilterDescriptor.ofCollection(documentsViewLayout.getFilters(), jsonOpts)).orderBys(boardDescriptor.getCardFields().stream().map(cardField -> JSONBoardCardOrderBy.builder().fieldName(cardField.getFieldName()).caption(cardField.getCaption().translate(adLanguage)).build()).collect(ImmutableList.toImmutableList())).build();
}
use of org.springframework.web.bind.annotation.PathVariable in project irida by phac-nml.
the class AnnouncementsController method getUserAnnouncementInfoTable.
/**
* Get user read status for current announcement
* @param announcementID {@link Long} identifier for the {@link Announcement}
* @param params {@link DataTablesParams} parameters for current DataTable
* @return {@link DataTablesResponse} containing the list of users.
*/
@RequestMapping(value = "/{announcementID}/details/ajax/list", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_ADMIN')")
@ResponseBody
public DataTablesResponse getUserAnnouncementInfoTable(@PathVariable Long announcementID, @DataTablesRequest final DataTablesParams params) {
final Announcement currentAnnouncement = announcementService.read(announcementID);
final Page<User> page = userService.search(UserSpecification.searchUser(params.getSearchValue()), new PageRequest(params.getCurrentPage(), params.getLength(), params.getSort()));
final List<DataTablesResponseModel> announcementUsers = page.getContent().stream().map(user -> new DTAnnouncementUser(user, userHasRead(user, currentAnnouncement))).collect(Collectors.toList());
return new DataTablesResponse(params, page, announcementUsers);
}
use of org.springframework.web.bind.annotation.PathVariable in project goci by EBISPOT.
the class AssociationController method addSnpInteraction.
@RequestMapping(value = "/studies/{studyId}/associations/add_interaction", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String addSnpInteraction(@ModelAttribute("form") @Valid SnpAssociationInteractionForm snpAssociationInteractionForm, BindingResult bindingResult, @PathVariable Long studyId, Model model, @RequestParam(required = true) String measurementType, HttpServletRequest request) throws EnsemblMappingException {
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
model.addAttribute("measurementType", measurementType);
// Binding vs Validator issue. File: messages.properties
if (bindingResult.hasErrors()) {
model.addAttribute("form", snpAssociationInteractionForm);
return "add_snp_interaction_association";
}
// Check for errors in form that would prevent saving an association
List<AssociationValidationView> colErrors = associationOperationsService.checkSnpAssociationInteractionFormErrorsForView(snpAssociationInteractionForm, measurementType);
if (!colErrors.isEmpty()) {
model.addAttribute("errors", colErrors);
model.addAttribute("form", snpAssociationInteractionForm);
model.addAttribute("criticalErrorsFound", true);
return "add_snp_interaction_association";
} else {
// Create an association object from details in returned form
Association newAssociation = snpInteractionAssociationService.createAssociation(snpAssociationInteractionForm);
// Save and validate form
String eRelease = ensemblRestTemplateService.getRelease();
Collection<AssociationValidationView> errors = associationOperationsService.saveAssociationCreatedFromForm(study, newAssociation, currentUserDetailsService.getUserFromRequest(request), eRelease);
// Determine if we have any errors rather than warnings
long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
if (errorCount > 0) {
model.addAttribute("errors", errors);
model.addAttribute("form", snpAssociationInteractionForm);
model.addAttribute("criticalErrorsFound", true);
return "add_snp_interaction_association";
} else {
return "redirect:/associations/" + newAssociation.getId();
}
}
}
use of org.springframework.web.bind.annotation.PathVariable in project goci by EBISPOT.
the class AssociationController method addStandardSnps.
// Add new standard association/snp information to a study
@RequestMapping(value = "/studies/{studyId}/associations/add_standard", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String addStandardSnps(@ModelAttribute("form") @Valid SnpAssociationStandardMultiForm snpAssociationStandardMultiForm, BindingResult bindingResult, @PathVariable Long studyId, Model model, @RequestParam(required = true) String measurementType, HttpServletRequest request) throws EnsemblMappingException {
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
model.addAttribute("measurementType", measurementType);
// Binding vs Validator issue. File: messages.properties
if (bindingResult.hasErrors()) {
model.addAttribute("form", snpAssociationStandardMultiForm);
return "add_standard_snp_association";
}
// Check for errors in form that would prevent saving an association
List<AssociationValidationView> rowErrors = associationOperationsService.checkSnpAssociationFormErrors(snpAssociationStandardMultiForm, measurementType);
if (!rowErrors.isEmpty()) {
model.addAttribute("errors", rowErrors);
model.addAttribute("form", snpAssociationStandardMultiForm);
model.addAttribute("criticalErrorsFound", true);
return "add_standard_snp_association";
} else {
// Create an association object from details in returned form
Association newAssociation = singleSnpMultiSnpAssociationService.createAssociation(snpAssociationStandardMultiForm);
// Save and validate form
String eRelease = ensemblRestTemplateService.getRelease();
Collection<AssociationValidationView> errors = associationOperationsService.saveAssociationCreatedFromForm(study, newAssociation, currentUserDetailsService.getUserFromRequest(request), eRelease);
// Determine if we have any errors rather than warnings
long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
if (errorCount > 0) {
model.addAttribute("errors", errors);
model.addAttribute("form", snpAssociationStandardMultiForm);
model.addAttribute("criticalErrorsFound", true);
return "add_standard_snp_association";
} else {
return "redirect:/associations/" + newAssociation.getId();
}
}
}
use of org.springframework.web.bind.annotation.PathVariable in project resilience4j by resilience4j.
the class CircuitBreakerEventsEndpoint method getEventsStreamFilteredByCircuitBreakerNameAndEventType.
@RequestMapping(value = "stream/events/{circuitBreakerName}/{eventType}", produces = MEDIA_TYPE_TEXT_EVENT_STREAM)
public SseEmitter getEventsStreamFilteredByCircuitBreakerNameAndEventType(@PathVariable("circuitBreakerName") String circuitBreakerName, @PathVariable("eventType") String eventType) {
CircuitBreaker circuitBreaker = circuitBreakerRegistry.getAllCircuitBreakers().find(cb -> cb.getName().equals(circuitBreakerName)).getOrElseThrow(() -> new IllegalArgumentException(String.format("circuit breaker with name %s not found", circuitBreakerName)));
Flux<CircuitBreakerEvent> eventStream = toFlux(circuitBreaker.getEventPublisher()).filter(event -> event.getEventType() == CircuitBreakerEvent.Type.valueOf(eventType.toUpperCase()));
return CircuitBreakerEventEmitter.createSseEmitter(eventStream);
}
Aggregations