From 244895e07d5570862956ad7ad28ef0f2e671a31e Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Thu, 19 Sep 2013 09:00:54 +0530 Subject: [PATCH] minor fixes while prepping for 1.9.2 release --- .../organisation/office/api/OfficesApiResource.java | 9 ++++++--- .../office/service/OfficeReadPlatformService.java | 2 +- .../service/OfficeReadPlatformServiceImpl.java | 13 +++++++++---- ...ClientWritePlatformServiceJpaRepositoryImpl.java | 3 +++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java index 6e9c6c249..5d58616c3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java @@ -11,12 +11,14 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; @@ -53,7 +55,7 @@ public class OfficesApiResource { private final OfficeReadPlatformService readPlatformService; private final DefaultToApiJsonSerializer toApiJsonSerializer; private final ApiRequestParameterHelper apiRequestParameterHelper; - private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; + private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; @Autowired public OfficesApiResource(final PlatformSecurityContext context, final OfficeReadPlatformService readPlatformService, @@ -69,11 +71,12 @@ public class OfficesApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOffices(@Context final UriInfo uriInfo) { + public String retrieveOffices(@Context final UriInfo uriInfo, + @DefaultValue("false") @QueryParam("includeAllOffices") final boolean onlyManualEntries) { context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions); - final Collection offices = this.readPlatformService.retrieveAllOffices(); + final Collection offices = this.readPlatformService.retrieveAllOffices(onlyManualEntries); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, offices, RESPONSE_DATA_PARAMETERS); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java index faa891020..c59b34f95 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java @@ -12,7 +12,7 @@ import org.mifosplatform.organisation.office.data.OfficeTransactionData; public interface OfficeReadPlatformService { - Collection retrieveAllOffices(); + Collection retrieveAllOffices(boolean includeAllOffices); Collection retrieveAllOfficesForDropdown(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java index c0675c4e4..12820eec7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java @@ -114,8 +114,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits"); Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf"); - CurrencyData currencyData = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf, - currencyDisplaySymbol, currencyNameCode); + CurrencyData currencyData = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf, currencyDisplaySymbol, + currencyNameCode); BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount"); String description = rs.getString("description"); @@ -126,12 +126,17 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } @Override - public Collection retrieveAllOffices() { + public Collection retrieveAllOffices(boolean includeAllOffices) { AppUser currentUser = context.authenticatedUser(); String hierarchy = currentUser.getOffice().getHierarchy(); - String hierarchySearchString = hierarchy + "%"; + String hierarchySearchString = null; + if (includeAllOffices) { + hierarchySearchString = "." + "%"; + } else { + hierarchySearchString = hierarchy + "%"; + } OfficeMapper rm = new OfficeMapper(); String sql = "select " + rm.officeSchema() + "where o.hierarchy like ? order by o.hierarchy"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java index 64adc6dc5..7da023864 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java @@ -344,6 +344,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP if (ClientStatus.fromInt(client.getStatus()).isClosed()) { final String errorMessage = "Client is alread closed."; throw new InvalidClientStateTransitionException("close", "is.already.closed", errorMessage); + } else if (ClientStatus.fromInt(client.getStatus()).isUnderTransfer()) { + final String errorMessage = "Cannot Close a Client under Transfer"; + throw new InvalidClientStateTransitionException("close", "is.under.transfer", errorMessage); } if (client.isNotPending() && client.getActivationLocalDate().isAfter(closureDate)) {