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

    this.context
        .authenticatedUser()
        .validateHasReadPermission(SavingsApiConstants.SAVINGS_PRODUCT_RESOURCE_NAME);

    SavingsProductData savingProductData =
        this.savingProductReadPlatformService.retrieveOne(productId);

    final Collection<ChargeData> charges =
        this.chargeReadPlatformService.retrieveSavingsProductCharges(productId);

    savingProductData = SavingsProductData.withCharges(savingProductData, charges);

    final ApiRequestJsonSerializationSettings settings =
        this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());

    if (savingProductData.hasAccountingEnabled()) {
      final Map<String, Object> accountingMappings =
          this.accountMappingReadPlatformService.fetchAccountMappingDetailsForSavingsProduct(
              productId, savingProductData.accountingRuleTypeId());
      final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings =
          this.accountMappingReadPlatformService
              .fetchPaymentTypeToFundSourceMappingsForSavingsProduct(productId);
      Collection<ChargeToGLAccountMapper> feeToGLAccountMappings =
          this.accountMappingReadPlatformService.fetchFeeToIncomeAccountMappingsForSavingsProduct(
              productId);
      Collection<ChargeToGLAccountMapper> penaltyToGLAccountMappings =
          this.accountMappingReadPlatformService
              .fetchPenaltyToIncomeAccountMappingsForSavingsProduct(productId);
      savingProductData =
          SavingsProductData.withAccountingDetails(
              savingProductData,
              accountingMappings,
              paymentChannelToFundSourceMappings,
              feeToGLAccountMappings,
              penaltyToGLAccountMappings);
    }

    if (settings.isTemplate()) {
      savingProductData = handleTemplateRelatedData(savingProductData);
    }

    return this.toApiJsonSerializer.serialize(
        settings, savingProductData, SavingsApiConstants.SAVINGS_PRODUCT_RESPONSE_DATA_PARAMETERS);
  }