Merge branch 'master' into IT_With_Waive_Interest

Merging branch master into this branch to stay current with the codebase before sending pull request
This commit is contained in:
Priti
2013-04-02 17:33:18 +05:30
26 changed files with 838 additions and 312 deletions
@@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.audit.api;
package org.mifosplatform.commands.api;
import java.util.Arrays;
import java.util.Collection;
@@ -21,9 +21,9 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils;
import org.mifosplatform.audit.data.AuditData;
import org.mifosplatform.audit.data.AuditSearchData;
import org.mifosplatform.audit.service.AuditReadPlatformService;
import org.mifosplatform.commands.data.AuditData;
import org.mifosplatform.commands.data.AuditSearchData;
import org.mifosplatform.commands.service.AuditReadPlatformService;
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
@@ -33,10 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Path("/audit")
@Path("/audits")
@Component
@Scope("singleton")
public class AuditApiResource {
public class AuditsApiResource {
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList("id", "actionName", "entityName", "resourceId", "subresourceId",
@@ -52,7 +52,7 @@ public class AuditApiResource {
private final DefaultToApiJsonSerializer<AuditSearchData> toApiJsonSerializerSearchTemplate;
@Autowired
public AuditApiResource(
public AuditsApiResource(
final PlatformSecurityContext context,
final AuditReadPlatformService auditReadPlatformService,
final ApiRequestParameterHelper apiRequestParameterHelper,
@@ -130,10 +130,10 @@ public class AuditApiResource {
.process(uriInfo.getQueryParameters());
final AuditSearchData auditSearchData = this.auditReadPlatformService
.retrieveSearchTemplate();
.retrieveSearchTemplate("audit");
final Set<String> RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE = new HashSet<String>(
Arrays.asList("appUsers", "apiOperations", "resources"));
Arrays.asList("appUsers", "actionNames", "entityNames", "processingResults"));
return this.toApiJsonSerializerSearchTemplate.serialize(settings,
auditSearchData, RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE);
@@ -23,9 +23,10 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils;
import org.mifosplatform.audit.data.AuditData;
import org.mifosplatform.audit.service.AuditReadPlatformService;
import org.mifosplatform.commands.data.AuditData;
import org.mifosplatform.commands.data.AuditSearchData;
import org.mifosplatform.commands.data.CommandSourceData;
import org.mifosplatform.commands.service.AuditReadPlatformService;
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
@@ -37,10 +38,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Path("/commands")
@Path("/makercheckers")
@Component
@Scope("singleton")
public class CommandsApiResource {
public class MakercheckersApiResource {
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList("id", "actionName", "entityName", "resourceId", "subresourceId",
@@ -52,18 +53,21 @@ public class CommandsApiResource {
private final AuditReadPlatformService readPlatformService;
private final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer;
private final DefaultToApiJsonSerializer<AuditData> toApiJsonSerializerAudit;
private final DefaultToApiJsonSerializer<AuditSearchData> toApiJsonSerializerSearchTemplate;
private final ApiRequestParameterHelper apiRequestParameterHelper;
private final PortfolioCommandSourceWritePlatformService writePlatformService;
@Autowired
public CommandsApiResource(final PlatformSecurityContext context, final AuditReadPlatformService readPlatformService,
final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer, final DefaultToApiJsonSerializer<AuditData> toApiJsonSerializerAudit,
public MakercheckersApiResource(final PlatformSecurityContext context, final AuditReadPlatformService readPlatformService,
final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer, final DefaultToApiJsonSerializer<AuditData> toApiJsonSerializerAudit,
final DefaultToApiJsonSerializer<AuditSearchData> toApiJsonSerializerSearchTemplate,
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioCommandSourceWritePlatformService writePlatformService) {
this.context = context;
this.readPlatformService = readPlatformService;
this.toApiJsonSerializer = toApiJsonSerializer;
this.apiRequestParameterHelper = apiRequestParameterHelper;
this.toApiJsonSerializerAudit = toApiJsonSerializerAudit;
this.toApiJsonSerializerSearchTemplate = toApiJsonSerializerSearchTemplate;
this.writePlatformService = writePlatformService;
}
@@ -80,6 +84,28 @@ public class CommandsApiResource {
return this.toApiJsonSerializerAudit.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
}
@GET
@Path("/searchtemplate")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(
resourceNameForPermissions);
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
.process(uriInfo.getQueryParameters());
final AuditSearchData auditSearchData = this.readPlatformService
.retrieveSearchTemplate("makerchecker");
final Set<String> RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE = new HashSet<String>(
Arrays.asList("appUsers", "actionNames", "entityNames"));
return this.toApiJsonSerializerSearchTemplate.serialize(settings,
auditSearchData, RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE);
}
@POST
@Path("{commandId}")
@Consumes({ MediaType.APPLICATION_JSON })
@@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.audit.data;
package org.mifosplatform.commands.data;
import org.joda.time.DateTime;
@@ -3,12 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.audit.data;
package org.mifosplatform.commands.data;
import java.util.Collection;
import java.util.List;
import org.mifosplatform.audit.api.ProcessingResultLookup;
import org.mifosplatform.useradministration.data.AppUserData;
/**
@@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.audit.api;
package org.mifosplatform.commands.data;
/**
* Immutable data object for application user data.
@@ -3,12 +3,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.audit.service;
package org.mifosplatform.commands.service;
import java.util.Collection;
import org.mifosplatform.audit.data.AuditData;
import org.mifosplatform.audit.data.AuditSearchData;
import org.mifosplatform.commands.data.AuditData;
import org.mifosplatform.commands.data.AuditSearchData;
public interface AuditReadPlatformService {
@@ -16,7 +16,7 @@ public interface AuditReadPlatformService {
AuditData retrieveAuditEntry(Long auditId);
AuditSearchData retrieveSearchTemplate();
AuditSearchData retrieveSearchTemplate(String useType);
Collection<AuditData> retrieveAllEntriesToBeChecked();
@@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.audit.service;
package org.mifosplatform.commands.service;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -12,10 +12,11 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.mifosplatform.audit.api.ProcessingResultLookup;
import org.mifosplatform.audit.data.AuditData;
import org.mifosplatform.audit.data.AuditSearchData;
import org.mifosplatform.commands.data.AuditData;
import org.mifosplatform.commands.data.AuditSearchData;
import org.mifosplatform.commands.data.ProcessingResultLookup;
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.useradministration.data.AppUserData;
@@ -141,7 +142,12 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
}
@Override
public AuditSearchData retrieveSearchTemplate() {
public AuditSearchData retrieveSearchTemplate(String useType) {
if (!(useType.equals("audit") || useType.equals("makerchecker"))) {
throw new PlatformDataIntegrityException("error.msg.invalid.auditSearchTemplate.useType",
"Invalid Audit Search Template UseType: " + useType); }
final Collection<AppUserData> appUsers = appUserReadPlatformService
.retrieveSearchTemplate();
@@ -153,10 +159,12 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
List<String> entityNames = this.jdbcTemplate.query(mapper2.schema(),
mapper2, new Object[] {});
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
Collection<ProcessingResultLookup> processingResults = this.jdbcTemplate
.query(mapper3.schema(), mapper3, new Object[] {});
Collection<ProcessingResultLookup> processingResults = null;
if (useType.equals("audit")) {
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
}
return new AuditSearchData(appUsers, actionNames, entityNames,
processingResults);
}
@@ -77,6 +77,19 @@ public class LoanChargesApiResource {
return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
}
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveAllLoanCharges(@PathParam("loanId") final Long loanId, @Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
final Collection<LoanChargeData> loanCharges = this.loanChargeReadPlatformService.retrieveLoanCharges(loanId);
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, loanCharges, RESPONSE_DATA_PARAMETERS);
}
@GET
@Path("template")
@Consumes({ MediaType.APPLICATION_JSON })
@@ -94,10 +107,10 @@ public class LoanChargesApiResource {
}
@GET
@Path("{loanChargeId}")
@Path("{chargeId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("loanChargeId") final Long loanChargeId,
public String retrieveLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId,
@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
@@ -121,10 +134,10 @@ public class LoanChargesApiResource {
}
@PUT
@Path("{loanChargeId}")
@Path("{chargeId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("loanChargeId") final Long loanChargeId,
public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId,
final String apiRequestBodyAsJson) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanCharge(loanId, loanChargeId)
@@ -810,9 +810,12 @@ public class Loan extends AbstractPersistable<Long> {
}
final String clientIdParamName = "clientId";
if (command.isChangeInLongParameterNamed(clientIdParamName, this.client.getId())) {
final Long newValue = command.longValueOfParameterNamed(clientIdParamName);
actualChanges.put(clientIdParamName, newValue);
//FIXME AA : Client is null for group loans. Group loan modifications require group validation.
if (this.client != null) {
if (command.isChangeInLongParameterNamed(clientIdParamName, this.client.getId())) {
final Long newValue = command.longValueOfParameterNamed(clientIdParamName);
actualChanges.put(clientIdParamName, newValue);
}
}
final String productIdParamName = "productId";
@@ -36,7 +36,7 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
/**
* The parameters supported for this command.
*/
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "clientId", "groupId", "productId", "accountNo",
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "clientId", "groupId", "calendarId", "productId", "accountNo",
"externalId", "fundId", "loanOfficerId", "loanPurposeId", "transactionProcessingStrategyId", "principal", "inArrearsTolerance",
"interestRatePerPeriod", "repaymentEvery", "numberOfRepayments", "loanTermFrequency", "loanTermFrequencyType",
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",