Ejemplo n.º 1
0
  /**
   * Remove an association between a challenge and a challenge referral.
   *
   * @param id challenge id
   * @param challengeReferralId challenge referral id
   * @return ServiceResponse with appropriate status
   * @throws ObjectNotFoundException If one of the objects were not found
   */
  @RequestMapping(value = "/{id}/challengeReferral", method = RequestMethod.DELETE)
  public @ResponseBody ServiceResponse removeChallengeReferralFromChallenge(
      @PathVariable final UUID id, @RequestBody @NotNull final UUID challengeReferralId)
      throws ObjectNotFoundException {

    final Challenge challenge = service.get(id);
    final ChallengeReferral referral = challengeReferralService.get(challengeReferralId);

    service.removeChallengeReferralFromChallenge(referral, challenge);
    return new ServiceResponse(true);
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "/search", method = RequestMethod.GET)
  @DynamicPermissionChecking
  public @ResponseBody List<ChallengeTO> getChallengesForPerson(
      @PathVariable final UUID personId, @RequestParam("query") final String query)
      throws Exception {

    try {
      return challengeService.search(query, personService.get(personId), false);
    } catch (Exception e) {
      LOGGER.error("ERROR : search() : {}", e.getMessage(), e);
      throw e;
    }
  }
Ejemplo n.º 3
0
  /**
   * Get all {@link ChallengeReferralTO} associated with the specified {@link ChallengeTO}.
   *
   * @param id challenge id
   * @param status {@link ObjectStatus}
   * @param start Optional start (0-based)
   * @param limit Optional row limit
   * @param sort Optional sort column
   * @param sortDirection Optional sort direction
   * @return All {@link ChallengeReferralTO} associated with the specified {@link ChallengeTO}.
   * @throws ObjectNotFoundException If the specified challenge could not be found.
   */
  @RequestMapping(value = "/{id}/challengeReferral", method = RequestMethod.GET)
  @PreAuthorize(Permission.SECURITY_REFERENCE_READ)
  public @ResponseBody PagedResponse<ChallengeReferralTO> getChallengeReferralsForChallenge(
      @PathVariable final UUID id,
      final @RequestParam(required = false) ObjectStatus status,
      final @RequestParam(required = false) Integer start,
      final @RequestParam(required = false) Integer limit,
      final @RequestParam(required = false) String sort,
      final @RequestParam(required = false) String sortDirection)
      throws ObjectNotFoundException {

    final Challenge challenge = service.get(id);

    final PagingWrapper<ChallengeReferral> data =
        challengeReferralService.getAllForChallenge(
            challenge,
            SortingAndPaging.createForSingleSortWithPaging(
                status, start, limit, sort, sortDirection, null));

    return new PagedResponse<ChallengeReferralTO>(
        true, data.getResults(), challengeReferralTOFactory.asTOSet(data.getRows()));
  }