コード例 #1
0
  @GET
  @Path("{productId}")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveSavingProductDetails(
      @PathParam("productId") final Long productId, @Context final UriInfo uriInfo) {

    context.authenticatedUser().validateHasReadPermission(entityType);

    Set<String> typicalResponseParameters =
        new HashSet<String>(
            Arrays.asList(
                "id",
                "createdOn",
                "lastModifedOn",
                "locale",
                "name",
                "description",
                "currencyCode",
                "digitsAfterDecimal",
                "interstRate",
                "minInterestRate",
                "maxInterestRate",
                "savingsDepositAmount",
                "savingProductType",
                "tenureType",
                "tenure",
                "frequency",
                "interestType",
                "interestCalculationMethod",
                "minimumBalanceForWithdrawal",
                "isPartialDepositAllowed",
                "isLockinPeriodAllowed",
                "lockinPeriod",
                "lockinPeriodType",
                "depositEvery"));

    Set<String> responseParameters =
        ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
    if (responseParameters.isEmpty()) {
      responseParameters.addAll(typicalResponseParameters);
    }

    SavingProductData savingProduct =
        this.savingProductReadPlatformService.retrieveSavingProduct(productId);

    boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
    boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
    if (template) {
      savingProduct = handleTemplateRelatedData(responseParameters, savingProduct);
    }

    return this.apiJsonSerializerService.serializeSavingProductDataToJson(
        prettyPrint, responseParameters, savingProduct);
  }
コード例 #2
0
  // 'g.' preffix because of ERROR 1052 (23000): Column 'column_name' in where
  // clause is ambiguous
  // caused by the same name of columns in m_office and m_group tables
  private String getGroupExtraCriteria(final SearchParameters searchCriteria) {

    String extraCriteria = " and g.level_Id = " + GroupTypes.GROUP.getId();

    String sqlSearch = searchCriteria.getSqlSearch();
    if (sqlSearch != null) {
      sqlSearch = sqlSearch.replaceAll(" display_name ", " g.display_name ");
      sqlSearch = sqlSearch.replaceAll("display_name ", "g.display_name ");
      extraCriteria += " and (" + sqlSearch + ")";
    }

    final Long officeId = searchCriteria.getOfficeId();
    if (officeId != null) {
      extraCriteria += " and g.office_id = " + officeId;
    }

    final String externalId = searchCriteria.getExternalId();
    if (externalId != null) {
      extraCriteria += " and g.external_id = " + ApiParameterHelper.sqlEncodeString(externalId);
    }

    final String name = searchCriteria.getName();
    if (name != null) {
      extraCriteria +=
          " and g.display_name like " + ApiParameterHelper.sqlEncodeString("%" + name + "%");
    }

    final String hierarchy = searchCriteria.getHierarchy();
    if (hierarchy != null) {
      extraCriteria +=
          " and o.hierarchy like " + ApiParameterHelper.sqlEncodeString(hierarchy + "%");
    }

    if (StringUtils.isNotBlank(extraCriteria)) {
      extraCriteria = extraCriteria.substring(4);
    }

    return extraCriteria;
  }
コード例 #3
0
ファイル: GroupsApiResource.java プロジェクト: Bredun/mifosx
  @GET
  @Path("{groupId}")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveOne(
      @Context final UriInfo uriInfo,
      @PathParam("groupId") final Long groupId,
      @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly")
          final boolean staffInSelectedOfficeOnly,
      @QueryParam("roleId") final Long roleId) {

    this.context
        .authenticatedUser()
        .validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME);
    final Set<String> associationParameters =
        ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());

    GroupGeneralData group = this.groupReadPlatformService.retrieveOne(groupId);

    // associations
    Collection<ClientData> membersOfGroup = null;
    Collection<GroupRoleData> groupRoles = null;
    GroupRoleData selectedRole = null;
    Collection<CalendarData> calendars = null;
    CalendarData collectionMeetingCalendar = null;

    if (!associationParameters.isEmpty()) {
      if (associationParameters.contains("all")) {
        associationParameters.addAll(
            Arrays.asList("clientMembers", "groupRoles", "calendars", "collectionMeetingCalendar"));
      }
      if (associationParameters.contains("clientMembers")) {
        membersOfGroup = this.clientReadPlatformService.retrieveClientMembersOfGroup(groupId);
        if (CollectionUtils.isEmpty(membersOfGroup)) {
          membersOfGroup = null;
        }
      }
      if (associationParameters.contains("groupRoles")) {
        groupRoles = this.groupRolesReadPlatformService.retrieveGroupRoles(groupId);
        if (CollectionUtils.isEmpty(groupRoles)) {
          groupRoles = null;
        }
      }
      if (associationParameters.contains("calendars")) {
        final List<Integer> calendarTypeOptions =
            CalendarUtils.createIntegerListFromQueryParameter("all");
        calendars =
            this.calendarReadPlatformService.retrieveParentCalendarsByEntity(
                groupId, CalendarEntityType.GROUPS.getValue(), calendarTypeOptions);
        if (CollectionUtils.isEmpty(calendars)) {
          calendars = null;
        }
      }
      if (associationParameters.contains("collectionMeetingCalendar")) {
        collectionMeetingCalendar =
            this.calendarReadPlatformService.retrieveCollctionCalendarByEntity(
                groupId, CalendarEntityType.GROUPS.getValue());
      }

      group =
          GroupGeneralData.withAssocations(
              group, membersOfGroup, groupRoles, calendars, collectionMeetingCalendar);
    }

    if (roleId != null) {
      selectedRole = this.groupRolesReadPlatformService.retrieveGroupRole(groupId, roleId);
      if (selectedRole != null) {
        group = GroupGeneralData.updateSelectedRole(group, selectedRole);
      }
    }

    final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
    if (template) {
      final GroupGeneralData templateGroup =
          this.groupReadPlatformService.retrieveTemplate(
              group.officeId(), false, staffInSelectedOfficeOnly);
      group = GroupGeneralData.withTemplate(templateGroup, group);
    }

    final ApiRequestJsonSerializationSettings settings =
        this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    return this.groupGeneralApiJsonSerializer.serialize(
        settings, group, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS);
  }