Add processingResult to Audit
This commit is contained in:
@@ -19,7 +19,12 @@ VALUES
|
||||
('loan_transaction_strategy_id',1,'mifos-standard-strategy','Mifos style'),
|
||||
('loan_transaction_strategy_id',2,'heavensfamily-strategy','Heavensfamily'),
|
||||
('loan_transaction_strategy_id',3,'creocore-strategy','Creocore'),
|
||||
('loan_transaction_strategy_id',4,'rbi-india-strategy','RBI (India)');
|
||||
('loan_transaction_strategy_id',4,'rbi-india-strategy','RBI (India)'),
|
||||
('processing_result_enum', '0', 'invalid', 'Invalid'),
|
||||
('processing_result_enum', '1', 'processed', 'Processed'),
|
||||
('processing_result_enum', '2', 'awaiting.approval', 'Awaiting Approval'),
|
||||
('processing_result_enum', '3', 'rejected', 'Rejected');
|
||||
|
||||
|
||||
|
||||
INSERT INTO `m_currency`
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '0', 'invalid', 'Invalid');
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '1', 'processed', 'Processed');
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '2', 'awaiting.approval', 'Awaiting Approval');
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '3', 'rejected', 'Rejected');
|
||||
@@ -73,14 +73,15 @@ public class AuditApiResource {
|
||||
@QueryParam("makerDateTimeTo") final String makerDateTimeTo,
|
||||
@QueryParam("checkerId") final Long checkerId,
|
||||
@QueryParam("checkerDateTimeFrom") final String checkerDateTimeFrom,
|
||||
@QueryParam("checkerDateTimeTo") final String checkerDateTimeTo) {
|
||||
@QueryParam("checkerDateTimeTo") final String checkerDateTimeTo,
|
||||
@QueryParam("processingResult") final Integer processingResult) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(
|
||||
resourceNameForPermissions);
|
||||
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName,
|
||||
resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo);
|
||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
|
||||
.process(uriInfo.getQueryParameters());
|
||||
@@ -137,7 +138,7 @@ public class AuditApiResource {
|
||||
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 String checkerDateTimeTo, final Integer processingResult) {
|
||||
|
||||
String extraCriteria = "";
|
||||
|
||||
@@ -176,6 +177,10 @@ public class AuditApiResource {
|
||||
+ ApiParameterHelper.sqlEncodeString(checkerDateTimeTo);
|
||||
}
|
||||
|
||||
if (processingResult != null) {
|
||||
extraCriteria += " and aud.processing_result_enum = " + processingResult;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
extraCriteria = extraCriteria.substring(4);
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package org.mifosplatform.audit.api;
|
||||
|
||||
/**
|
||||
* Immutable data object for application user data.
|
||||
*/
|
||||
public class ProcessingResultLookup {
|
||||
|
||||
private final Long id;
|
||||
private final String processingResult;
|
||||
|
||||
public ProcessingResultLookup(final Long id, final String processingResult) {
|
||||
this.id = id;
|
||||
this.processingResult = processingResult;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getProcessingResult() {
|
||||
return this.processingResult;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,8 @@ public final class AuditData {
|
||||
@SuppressWarnings("unused")
|
||||
private final DateTime checkedOnDate;
|
||||
@SuppressWarnings("unused")
|
||||
private final String processingResult;
|
||||
@SuppressWarnings("unused")
|
||||
private final String commandAsJson;
|
||||
|
||||
public AuditData(final Long id, final String actionName,
|
||||
@@ -40,7 +42,7 @@ public final class AuditData {
|
||||
final String subResource, final Long subResourceId,
|
||||
final String maker, final DateTime madeOnDate,
|
||||
final String checker, final DateTime checkedOnDate,
|
||||
final String commandAsJson) {
|
||||
final String processingResult, final String commandAsJson) {
|
||||
|
||||
this.id = id;
|
||||
this.actionName = actionName;
|
||||
@@ -55,5 +57,6 @@ public final class AuditData {
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate;
|
||||
this.commandAsJson = commandAsJson;
|
||||
this.processingResult = processingResult;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.mifosplatform.audit.data;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.audit.api.ProcessingResultLookup;
|
||||
import org.mifosplatform.useradministration.data.AppUserLookup;
|
||||
|
||||
/**
|
||||
@@ -10,16 +11,21 @@ import org.mifosplatform.useradministration.data.AppUserLookup;
|
||||
*/
|
||||
public final class AuditSearchData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<AppUserLookup> appUsers;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<String> actionNames;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<String> entityNames;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<AppUserLookup> appUsers;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<String> actionNames;
|
||||
@SuppressWarnings("unused")
|
||||
private final List<String> entityNames;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<ProcessingResultLookup> processingResults;
|
||||
|
||||
public AuditSearchData(final Collection<AppUserLookup> appUsers, final List<String> apiOperations, final List<String> resources) {
|
||||
this.appUsers = appUsers;
|
||||
this.actionNames = apiOperations;
|
||||
this.entityNames = resources;
|
||||
}
|
||||
public AuditSearchData(final Collection<AppUserLookup> appUsers,
|
||||
final List<String> apiOperations, final List<String> resources,
|
||||
final Collection<ProcessingResultLookup> processingResults) {
|
||||
this.appUsers = appUsers;
|
||||
this.actionNames = apiOperations;
|
||||
this.entityNames = resources;
|
||||
this.processingResults = processingResults;
|
||||
}
|
||||
}
|
||||
+32
-4
@@ -7,6 +7,7 @@ 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.infrastructure.core.domain.JdbcSupport;
|
||||
@@ -49,11 +50,12 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
|
||||
return " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName, aud.api_operation as apiOperation, "
|
||||
+ " aud.api_resource as resource, aud.resource_id as resourceId, aud.api_subresource as subResource, aud.subresource_id as subResourceId,"
|
||||
+ " mk.username as maker, aud.made_on_date as madeOnDate, ck.username as checker, aud.checked_on_date as checkedOnDate"
|
||||
+ " mk.username as maker, aud.made_on_date as madeOnDate, ck.username as checker, aud.checked_on_date as checkedOnDate, ev.enum_message_property as processingResult "
|
||||
+ commandAsJsonString
|
||||
+ " from m_portfolio_command_source aud "
|
||||
+ " left join m_appuser mk on mk.id = aud.maker_id"
|
||||
+ " left join m_appuser ck on ck.id = aud.checker_id";
|
||||
+ " left join m_appuser ck on ck.id = aud.checker_id"
|
||||
+ " left join r_enum_value ev on ev.enum_name = 'processing_result_enum' and ev.enum_id = aud.processing_result_enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +77,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
final String checker = rs.getString("checker");
|
||||
final DateTime checkedOnDate = JdbcSupport.getDateTime(rs,
|
||||
"checkedOnDate");
|
||||
final String processingResult = rs.getString("processingResult");
|
||||
String commandAsJson;
|
||||
// commandAsJson might not be on the select list of columns
|
||||
try {
|
||||
@@ -84,7 +87,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
}
|
||||
return new AuditData(id, actionName, entityName, apiOperation,
|
||||
resource, resourceId, subResource, subResourceId, maker,
|
||||
madeOnDate, checker, checkedOnDate, commandAsJson);
|
||||
madeOnDate, checker, checkedOnDate, processingResult,
|
||||
commandAsJson);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +132,12 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
List<String> entityNames = this.jdbcTemplate.query(mapper2.schema(),
|
||||
mapper2, new Object[] {});
|
||||
|
||||
return new AuditSearchData(appUsers, actionNames, entityNames);
|
||||
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
Collection<ProcessingResultLookup> processingResults = this.jdbcTemplate
|
||||
.query(mapper3.schema(), mapper3, new Object[] {});
|
||||
|
||||
return new AuditSearchData(appUsers, actionNames, entityNames,
|
||||
processingResults);
|
||||
}
|
||||
|
||||
private static final class ActionNamesMapper implements RowMapper<String> {
|
||||
@@ -164,4 +173,23 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
+ " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ProcessingResultsMapper implements
|
||||
RowMapper<ProcessingResultLookup> {
|
||||
|
||||
@Override
|
||||
public ProcessingResultLookup mapRow(final ResultSet rs,
|
||||
@SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
Long id = JdbcSupport.getLong(rs, "id");
|
||||
String processingResult = rs.getString("processingResult");
|
||||
|
||||
return new ProcessingResultLookup(id, processingResult);
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return " select enum_id as id, enum_message_property as processingResult from r_enum_value where enum_name = 'processing_result_enum' "
|
||||
+ " order by enum_id";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,8 @@ public class CommandSource extends AbstractPersistable<Long> {
|
||||
@Column(name = "checked_on_date", nullable = false)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date checkedOnDate;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "processing_result_enum", nullable = false)
|
||||
private Integer processingResult;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user