From bf6c1b5606549fa51c8efe93c8b2b4029c02997c Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Fri, 3 Aug 2012 15:53:33 +0100 Subject: [PATCH] dont show curreny options by default in json, instead only show when using template resource or when template flag is provided. --- .../platform/api/SavingProductsApiResource.java | 13 +++++++++---- .../ApiDataConversionServiceImpl.java | 2 +- .../src/test/resources/META-INF/context.xml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java index 245f0618c..abd1bea4d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java @@ -70,7 +70,8 @@ public class SavingProductsApiResource { @Produces({MediaType.APPLICATION_JSON}) public String retrieveAllSavingProducts(@Context final UriInfo uriInfo) { - Set typicalResponseParameters = new HashSet(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","interestRate","currencyCode","digitsAfterDecimal")); + Set typicalResponseParameters = new HashSet(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn", + "interestRate","currencyCode","digitsAfterDecimal")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { @@ -89,15 +90,19 @@ public class SavingProductsApiResource { @Produces({MediaType.APPLICATION_JSON}) public String retrieveSavingProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) { - Set typicalResponseParameters = new HashSet(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","interestRate","currencyCode","digitsAfterDecimal")); + Set typicalResponseParameters = new HashSet(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn", + "interestRate","currencyCode","digitsAfterDecimal")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { responseParameters.addAll(typicalResponseParameters); } boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); - //boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); - + boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); + if (template) { + responseParameters.addAll(Arrays.asList("currencyOptions")); + } + SavingProductData savingProduct = this.savingProductReadPlatformService.retrieveSavingProduct(productId); return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, savingProduct); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java index 69902fc5d..90641aad1 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java @@ -1441,7 +1441,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { Set responseParameters, SavingProductData... products) { Set supportedParameters = new HashSet( - Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","interestRate","currencyCode","digitsAfterDecimal")); + Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","interestRate","currencyCode","digitsAfterDecimal", "currencyOptions")); final Set parameterNamesToSkip = new HashSet(); diff --git a/mifosng-provider/src/test/resources/META-INF/context.xml b/mifosng-provider/src/test/resources/META-INF/context.xml index 7c0a42100..d9556190e 100644 --- a/mifosng-provider/src/test/resources/META-INF/context.xml +++ b/mifosng-provider/src/test/resources/META-INF/context.xml @@ -5,7 +5,7 @@ driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/mifosplatform-tenants" username="root" - password="mifos" + password="mysql" validationQuery="select 1" maxActive="10" maxIdle="4"