wip mifosx-97 refactor audit/makerchecker for re-use
This commit is contained in:
@@ -39,10 +39,10 @@ import org.springframework.stereotype.Component;
|
||||
public class AuditApiResource {
|
||||
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(
|
||||
Arrays.asList("id", "apiOperation", "resource", "resourceId",
|
||||
"maker", "madeOnDate", "checker", "checkedOnDate",
|
||||
"commandAsJson"));
|
||||
|
||||
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;
|
||||
|
||||
+2
@@ -18,4 +18,6 @@ public interface AuditReadPlatformService {
|
||||
|
||||
AuditSearchData retrieveSearchTemplate();
|
||||
|
||||
Collection<AuditData> retrieveAllEntriesToBeChecked();
|
||||
|
||||
}
|
||||
+15
-1
@@ -46,7 +46,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
}
|
||||
|
||||
private static final class AuditMapper implements RowMapper<AuditData> {
|
||||
|
||||
//TODO - jpw need to break this down, also data scope etc.
|
||||
public String schema(boolean includeJson) {
|
||||
|
||||
String commandAsJsonString = "";
|
||||
@@ -161,6 +161,20 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
processingResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AuditData> retrieveAllEntriesToBeChecked() {
|
||||
context.authenticatedUser();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
|
||||
final String sql = "select " + rm.schema(false)
|
||||
+ " where aud.checker_id is null and aud.processing_result_enum = 2 order by aud.id";
|
||||
//+ " where mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.entity_name ASC, mc.action_name ASC";
|
||||
logger.info("sql: " + sql);
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
private static final class ActionNamesMapper implements RowMapper<String> {
|
||||
|
||||
@Override
|
||||
|
||||
+13
-7
@@ -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.CommandSourceData;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
@@ -41,23 +42,28 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class CommandsApiResource {
|
||||
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "taskName", "madeOnDate"));
|
||||
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"));
|
||||
private final String resourceNameForPermissions = "MAKERCHECKER";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final PortfolioCommandsReadPlatformService readPlatformService;
|
||||
private final AuditReadPlatformService readPlatformService;
|
||||
private final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer;
|
||||
private final DefaultToApiJsonSerializer<AuditData> toApiJsonSerializerAudit;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
public CommandsApiResource(final PlatformSecurityContext context, final PortfolioCommandsReadPlatformService readPlatformService,
|
||||
final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer,
|
||||
public CommandsApiResource(final PlatformSecurityContext context, final AuditReadPlatformService readPlatformService,
|
||||
final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer, final DefaultToApiJsonSerializer<AuditData> toApiJsonSerializerAudit,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioCommandSourceWritePlatformService writePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.toApiJsonSerializerAudit = toApiJsonSerializerAudit;
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@@ -68,10 +74,10 @@ public class CommandsApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Collection<CommandSourceData> entries = this.readPlatformService.retrieveAllEntriesToBeChecked();
|
||||
final Collection<AuditData> entries = this.readPlatformService.retrieveAllEntriesToBeChecked();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
|
||||
return this.toApiJsonSerializerAudit.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
|
||||
-2
@@ -11,8 +11,6 @@ import org.mifosplatform.commands.data.CommandSourceData;
|
||||
|
||||
public interface PortfolioCommandsReadPlatformService {
|
||||
|
||||
Collection<CommandSourceData> retrieveAllEntriesToBeChecked();
|
||||
|
||||
CommandSourceData retrieveById(Long id);
|
||||
|
||||
Collection<CommandSourceData> retrieveUnprocessChangesByEntityNameAndId(String entityName, Long entityId);
|
||||
|
||||
-10
@@ -53,16 +53,6 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CommandSourceData> retrieveAllEntriesToBeChecked() {
|
||||
context.authenticatedUser();
|
||||
|
||||
final CommandSourceMapper rm = new CommandSourceMapper();
|
||||
final String sql = "select " + rm.schema()
|
||||
+ " where mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.entity_name ASC, mc.action_name ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSourceData retrieveById(final Long id) {
|
||||
|
||||
Reference in New Issue
Block a user