コード例 #1
0
 @Override
 @Transactional(readOnly = true, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 public SearchResults<User> getUsersByOrganization(
     String type,
     String organizationUid,
     String parentOrganizationUid,
     Integer offset,
     Integer limit) {
   SearchResults<User> result = new SearchResults<User>();
   result.setSearchResults(
       this.getUserRepository()
           .findUsersByOrganization(
               type.equalsIgnoreCase(
                       CustomProperties.InstitutionType.SCHOOL_DISTRICT.getInstitutionType())
                   ? organizationUid
                   : null,
               type.equalsIgnoreCase(CustomProperties.InstitutionType.SCHOOL.getInstitutionType())
                   ? parentOrganizationUid
                   : null,
               offset,
               limit));
   result.setTotalHitCount(
       this.getUserRepository()
           .getUsersByOrganizationCount(
               type.equalsIgnoreCase(
                       CustomProperties.InstitutionType.SCHOOL_DISTRICT.getInstitutionType())
                   ? organizationUid
                   : null,
               type.equalsIgnoreCase(CustomProperties.InstitutionType.SCHOOL.getInstitutionType())
                   ? parentOrganizationUid
                   : null));
   return result;
 }
コード例 #2
0
 @Override
 @Transactional(readOnly = true, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 public SearchResults<Organization> getOrganizations(
     String type,
     String parentOrganizationUid,
     String stateProvinceId,
     Integer offset,
     Integer limit) {
   SearchResults<Organization> result = new SearchResults<Organization>();
   result.setSearchResults(
       this.getOrganizationRepository()
           .getOrganizations(
               CustomProperties.Table.ORGANIZATION_CATEGORY.getTable() + UNDER_SCORE + type,
               parentOrganizationUid,
               stateProvinceId,
               offset,
               limit,
               false));
   result.setTotalHitCount(
       this.getOrganizationRepository()
           .getOrganizationCount(
               CustomProperties.Table.ORGANIZATION_CATEGORY.getTable() + UNDER_SCORE + type,
               parentOrganizationUid,
               stateProvinceId,
               false));
   return result;
 }
コード例 #3
0
 @Override
 public SearchResults<Organization> listAllOrganizations(
     Integer offset, Integer limit, boolean fetchPremiumOrg) {
   List<Organization> organization =
       this.getOrganizationRepository()
           .getOrganizations(null, null, null, offset, limit, fetchPremiumOrg);
   SearchResults<Organization> result = new SearchResults<Organization>();
   result.setSearchResults(organization);
   result.setTotalHitCount(
       this.getOrganizationRepository().getOrganizationCount(null, null, null, fetchPremiumOrg));
   return result;
 }
コード例 #4
0
 @Override
 public SearchResults<Classpage> getClasspages(
     Integer offset,
     Integer limit,
     Boolean skipPagination,
     User user,
     String title,
     String author,
     String userName) {
   if (userService.isContentAdmin(user)) {
     List<Classpage> classpages =
         this.getCollectionRepository()
             .getClasspages(offset, limit, skipPagination, title, author, userName);
     SearchResults<Classpage> result = new SearchResults<Classpage>();
     result.setSearchResults(classpages);
     result.setTotalHitCount(
         this.getCollectionRepository().getClasspageCount(title, author, userName));
     return result;
   } else {
     throw new UnauthorizedException("user don't have permission ");
   }
 }
コード例 #5
0
  @AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_READ})
  @Transactional(
      readOnly = false,
      propagation = Propagation.REQUIRED,
      rollbackFor = Exception.class)
  @RequestMapping(
      method = RequestMethod.GET,
      value = {"/{id}/item"})
  public ModelAndView getTaskResourceAssociatedItems(
      @PathVariable(ID) String gooruOid,
      @RequestParam(value = SHARING, required = false) String sharing,
      @RequestParam(value = DATA_OBJECT, required = false) String data,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    JSONObject json = requestData(data);
    String[] includeFields = null;
    if (data != null && !data.isEmpty()) {
      includeFields = getValue(FIELDS, json) != null ? getFields(getValue(FIELDS, json)) : null;
    }
    String[] includes =
        (String[])
            ArrayUtils.addAll(
                includeFields == null ? TASK_CREATE_RESOURCE_ASSOC_INCLUDES : includeFields,
                ERROR_INCLUDE);
    includes = (String[]) ArrayUtils.addAll(includes, RESOURCE_INCLUDE_FIELDS);
    includes = (String[]) ArrayUtils.addAll(includes, TASK_INCLUDES);
    List<Resource> taskResourceAssocs =
        this.getTaskService()
            .getTaskResourceAssociatedItems(
                gooruOid,
                Integer.parseInt(
                    json != null && getValue(OFFSET_FIELD, json) != null
                        ? getValue(OFFSET_FIELD, json)
                        : OFFSET.toString()),
                Integer.parseInt(
                    json != null && getValue(LIMIT_FIELD, json) != null
                        ? getValue(LIMIT_FIELD, json)
                        : LIMIT.toString()),
                json != null ? getValue(SKIP_PAGINATION, json) : NO,
                json != null ? getValue(ORDER_BY, json) : DATE,
                sharing);
    String responseJson = null;
    if ((getValue(SKIP_PAGINATION, json) == null
        || (getValue(SKIP_PAGINATION, json) != null
            && getValue(SKIP_PAGINATION, json).equalsIgnoreCase(NO)))) {
      SearchResults<Resource> result = new SearchResults<Resource>();
      result.setSearchResults(taskResourceAssocs);
      result.setTotalHitCount(this.taskRepository.getTaskResourceCount(gooruOid, sharing));
      responseJson =
          serialize(
              result,
              RESPONSE_FORMAT_JSON,
              EXCLUDE_ALL,
              (String[]) ArrayUtils.addAll(RESOURCE_INCLUDE_FIELDS, includes));
    } else {
      responseJson =
          serialize(
              taskResourceAssocs,
              RESPONSE_FORMAT_JSON,
              EXCLUDE_ALL,
              (String[]) ArrayUtils.addAll(RESOURCE_INCLUDE_FIELDS, includes));
    }

    return toModelAndView(responseJson);
  }