wip mifosx-97 allow 'id' criteria for audit and makerchecker search + wip mifosx-270 audit/makerchecker api docs
This commit is contained in:
+44
-10
@@ -39,10 +39,12 @@ import org.springframework.stereotype.Component;
|
||||
public class AuditsApiResource {
|
||||
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(
|
||||
Arrays.asList("id", "actionName", "entityName", "resourceId", "subresourceId",
|
||||
"maker", "madeOnDate", "checker", "checkedOnDate", "processingResult",
|
||||
"commandAsJson", "officeName", "groupLevelName", "groupName", "clientName", "loanAccountNo", "savingsAccountNo"));
|
||||
|
||||
Arrays.asList("id", "actionName", "entityName", "resourceId",
|
||||
"subresourceId", "maker", "madeOnDate", "checker",
|
||||
"checkedOnDate", "processingResult", "commandAsJson",
|
||||
"officeName", "groupLevelName", "groupName", "clientName",
|
||||
"loanAccountNo", "savingsAccountNo"));
|
||||
|
||||
private final String resourceNameForPermissions = "AUDIT";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
@@ -79,14 +81,21 @@ public class AuditsApiResource {
|
||||
@QueryParam("checkerId") final Long checkerId,
|
||||
@QueryParam("checkerDateTimeFrom") final String checkerDateTimeFrom,
|
||||
@QueryParam("checkerDateTimeTo") final String checkerDateTimeTo,
|
||||
@QueryParam("processingResult") final Integer processingResult) {
|
||||
@QueryParam("processingResult") final Integer processingResult,
|
||||
@QueryParam("officeId") final Integer officeId,
|
||||
@QueryParam("groupId") final Integer groupId,
|
||||
@QueryParam("clientId") final Integer clientId,
|
||||
@QueryParam("loanid") final Integer loanId,
|
||||
@QueryParam("savingsAccountId") final Integer savingsAccountId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(
|
||||
resourceNameForPermissions);
|
||||
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName,
|
||||
resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult);
|
||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo,
|
||||
processingResult, officeId, groupId, clientId, loanId,
|
||||
savingsAccountId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
|
||||
.process(uriInfo.getQueryParameters());
|
||||
@@ -133,7 +142,8 @@ public class AuditsApiResource {
|
||||
.retrieveSearchTemplate("audit");
|
||||
|
||||
final Set<String> RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE = new HashSet<String>(
|
||||
Arrays.asList("appUsers", "actionNames", "entityNames", "processingResults"));
|
||||
Arrays.asList("appUsers", "actionNames", "entityNames",
|
||||
"processingResults"));
|
||||
|
||||
return this.toApiJsonSerializerSearchTemplate.serialize(settings,
|
||||
auditSearchData, RESPONSE_DATA_PARAMETERS_SEARCH_TEMPLATE);
|
||||
@@ -143,7 +153,10 @@ public class AuditsApiResource {
|
||||
final String entityName, final Long resourceId, final Long makerId,
|
||||
final String makerDateTimeFrom, final String makerDateTimeTo,
|
||||
final Long checkerId, final String checkerDateTimeFrom,
|
||||
final String checkerDateTimeTo, final Integer processingResult) {
|
||||
final String checkerDateTimeTo, final Integer processingResult,
|
||||
final Integer officeId, final Integer groupId,
|
||||
final Integer clientId, final Integer loanId,
|
||||
final Integer savingsAccountId) {
|
||||
|
||||
String extraCriteria = "";
|
||||
|
||||
@@ -183,9 +196,30 @@ public class AuditsApiResource {
|
||||
}
|
||||
|
||||
if (processingResult != null) {
|
||||
extraCriteria += " and aud.processing_result_enum = " + processingResult;
|
||||
extraCriteria += " and aud.processing_result_enum = "
|
||||
+ processingResult;
|
||||
}
|
||||
|
||||
|
||||
if (officeId != null) {
|
||||
extraCriteria += " and aud.office_id = " + officeId;
|
||||
}
|
||||
|
||||
if (groupId != null) {
|
||||
extraCriteria += " and aud.group_id = " + groupId;
|
||||
}
|
||||
|
||||
if (clientId != null) {
|
||||
extraCriteria += " and aud.client_id = " + clientId;
|
||||
}
|
||||
|
||||
if (loanId != null) {
|
||||
extraCriteria += " and aud.loan_id = " + loanId;
|
||||
}
|
||||
|
||||
if (savingsAccountId != null) {
|
||||
extraCriteria += " and aud.savings_account_id = " + savingsAccountId;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
extraCriteria = extraCriteria.substring(4);
|
||||
}
|
||||
|
||||
+39
-9
@@ -87,13 +87,19 @@ public class MakercheckersApiResource {
|
||||
@QueryParam("resourceId") final Long resourceId,
|
||||
@QueryParam("makerId") final Long makerId,
|
||||
@QueryParam("makerDateTimeFrom") final String makerDateTimeFrom,
|
||||
@QueryParam("makerDateTimeTo") final String makerDateTimeTo) {
|
||||
@QueryParam("makerDateTimeTo") final String makerDateTimeTo,
|
||||
@QueryParam("officeId") final Integer officeId,
|
||||
@QueryParam("groupId") final Integer groupId,
|
||||
@QueryParam("clientId") final Integer clientId,
|
||||
@QueryParam("loanid") final Integer loanId,
|
||||
@QueryParam("savingsAccountId") final Integer savingsAccountId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(
|
||||
resourceNameForPermissions);
|
||||
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName,
|
||||
resourceId, makerId, makerDateTimeFrom, makerDateTimeTo);
|
||||
resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
officeId, groupId, clientId, loanId, savingsAccountId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
|
||||
.process(uriInfo.getQueryParameters());
|
||||
@@ -129,16 +135,16 @@ public class MakercheckersApiResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{commandId}")
|
||||
@Path("{auditId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String approveMakerCheckerEntry(
|
||||
@PathParam("commandId") final Long commandId,
|
||||
@PathParam("auditId") final Long auditId,
|
||||
@QueryParam("command") final String commandParam) {
|
||||
|
||||
CommandProcessingResult result = null;
|
||||
if (is(commandParam, "approve")) {
|
||||
result = this.writePlatformService.approveEntry(commandId);
|
||||
result = this.writePlatformService.approveEntry(auditId);
|
||||
} else {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
@@ -152,13 +158,13 @@ public class MakercheckersApiResource {
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{commandId}")
|
||||
@Path("{auditId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteMakerCheckerEntry(
|
||||
@PathParam("commandId") final Long commandId) {
|
||||
@PathParam("auditId") final Long auditId) {
|
||||
|
||||
final Long id = this.writePlatformService.deleteEntry(commandId);
|
||||
final Long id = this.writePlatformService.deleteEntry(auditId);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(CommandProcessingResult
|
||||
.commandOnlyResult(id));
|
||||
@@ -166,7 +172,10 @@ public class MakercheckersApiResource {
|
||||
|
||||
private String getExtraCriteria(final String actionName,
|
||||
final String entityName, final Long resourceId, final Long makerId,
|
||||
final String makerDateTimeFrom, final String makerDateTimeTo) {
|
||||
final String makerDateTimeFrom, final String makerDateTimeTo,
|
||||
final Integer officeId, final Integer groupId,
|
||||
final Integer clientId, final Integer loanId,
|
||||
final Integer savingsAccountId) {
|
||||
|
||||
String extraCriteria = "";
|
||||
|
||||
@@ -194,6 +203,27 @@ public class MakercheckersApiResource {
|
||||
+ ApiParameterHelper.sqlEncodeString(makerDateTimeTo);
|
||||
}
|
||||
|
||||
if (officeId != null) {
|
||||
extraCriteria += " and aud.office_id = " + officeId;
|
||||
}
|
||||
|
||||
if (groupId != null) {
|
||||
extraCriteria += " and aud.group_id = " + groupId;
|
||||
}
|
||||
|
||||
if (clientId != null) {
|
||||
extraCriteria += " and aud.client_id = " + clientId;
|
||||
}
|
||||
|
||||
if (loanId != null) {
|
||||
extraCriteria += " and aud.loan_id = " + loanId;
|
||||
}
|
||||
|
||||
if (savingsAccountId != null) {
|
||||
extraCriteria += " and aud.savings_account_id = "
|
||||
+ savingsAccountId;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
extraCriteria = extraCriteria.substring(4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user