MIFOSX-97: tidy up of maker checker based on audit work so far.
This commit is contained in:
+1
-2
@@ -48,8 +48,7 @@ public class CommandsApiResource {
|
||||
@Autowired
|
||||
public CommandsApiResource(final PlatformSecurityContext context, final PortfolioCommandsReadPlatformService readPlatformService,
|
||||
final DefaultToApiJsonSerializer<CommandSourceData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService writePlatformService) {
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioCommandSourceWritePlatformService writePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
|
||||
+14
-16
@@ -8,20 +8,26 @@ import org.joda.time.LocalDate;
|
||||
final public class CommandSourceData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Long id;
|
||||
private String apiOperation;
|
||||
private String resource;
|
||||
private final Long resourceId;
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String actionName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String entityName;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long entityId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String entityHref;
|
||||
private String commandJson;
|
||||
@SuppressWarnings("unused")
|
||||
private final LocalDate madeOnDate;
|
||||
|
||||
public CommandSourceData(final Long id, final String apiOperation, final String resource, final Long resourceId,
|
||||
public CommandSourceData(final Long id, final String actionName, final String entityName, final Long entityId, final String entityHref,
|
||||
final String commandJson, final LocalDate madeOnDate) {
|
||||
this.id = id;
|
||||
this.apiOperation = apiOperation;
|
||||
this.resource = resource;
|
||||
this.resourceId = resourceId;
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.entityId = entityId;
|
||||
this.entityHref = entityHref;
|
||||
this.commandJson = commandJson;
|
||||
this.madeOnDate = madeOnDate;
|
||||
}
|
||||
@@ -29,12 +35,4 @@ final public class CommandSourceData {
|
||||
public String json() {
|
||||
return this.commandJson;
|
||||
}
|
||||
|
||||
public boolean isUpdateRolePermissions() {
|
||||
return this.apiOperation.equalsIgnoreCase("UPDATEPERMISSIONS") && this.resourceId != null;
|
||||
}
|
||||
|
||||
public boolean isRoleResource() {
|
||||
return this.resource.equalsIgnoreCase("ROLES");
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -12,7 +12,7 @@ public class CommandWrapperBuilder {
|
||||
private String entityName;
|
||||
private Long entityId;
|
||||
private String href;
|
||||
private String json;
|
||||
private String json = "{}";
|
||||
private Long apptableId;
|
||||
private Long datatableId;
|
||||
|
||||
@@ -217,18 +217,24 @@ public class CommandWrapperBuilder {
|
||||
public CommandWrapperBuilder createClient() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "CLIENT";
|
||||
this.href = "/clients/template";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateClient() {
|
||||
public CommandWrapperBuilder updateClient(final Long clientId) {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CLIENT";
|
||||
this.entityId = clientId;
|
||||
this.href = "/clients/" + clientId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteClient() {
|
||||
public CommandWrapperBuilder deleteClient(final Long clientId) {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "CLIENT";
|
||||
this.entityId = clientId;
|
||||
this.href = "/clients/" + clientId;
|
||||
this.json = "{}";
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ public interface PortfolioCommandsReadPlatformService {
|
||||
|
||||
CommandSourceData retrieveById(Long id);
|
||||
|
||||
Collection<CommandSourceData> retrieveUnprocessChangesByResourceId(String apiResource, Long clientId);
|
||||
Collection<CommandSourceData> retrieveUnprocessChangesByEntityNameAndId(String entityName, Long entityId);
|
||||
}
|
||||
+7
-7
@@ -29,7 +29,7 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
private static final class CommandSourceMapper implements RowMapper<CommandSourceData> {
|
||||
|
||||
public String schema() {
|
||||
return " mc.id as id, mc.action_name as taskOperation, mc.entity_name as taskEntity, mc.resource_id as entityId,"
|
||||
return " mc.id as id, mc.action_name as actionName, mc.entity_name as entityName, mc.resource_id as entityId, mc.api_get_url as getHref, "
|
||||
+ "mc.command_as_json as taskJson, mc.made_on_date as madeOnDate from m_portfolio_command_source mc ";
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
public CommandSourceData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = rs.getLong("id");
|
||||
final String taskOperation = rs.getString("taskOperation");
|
||||
final String taskEntity = rs.getString("taskEntity");
|
||||
final String actionName = rs.getString("actionName");
|
||||
final String entityName = rs.getString("entityName");
|
||||
final Long entityId = JdbcSupport.getLong(rs, "entityId");
|
||||
final String taskJson = rs.getString("taskJson");
|
||||
|
||||
final String getHref = rs.getString("getHref");
|
||||
final LocalDate madeOnDate = JdbcSupport.getLocalDate(rs, "madeOnDate");
|
||||
|
||||
return new CommandSourceData(id, taskOperation, taskEntity, entityId, taskJson, madeOnDate);
|
||||
return new CommandSourceData(id, actionName, entityName, entityId, getHref, taskJson, madeOnDate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CommandSourceData> retrieveUnprocessChangesByResourceId(final String apiResource, final Long resourceId) {
|
||||
public Collection<CommandSourceData> retrieveUnprocessChangesByEntityNameAndId(final String entityName, final Long entityId) {
|
||||
|
||||
final CommandSourceMapper rm = new CommandSourceMapper();
|
||||
final String sql = "select "
|
||||
+ rm.schema()
|
||||
+ " where mc.entity_name like ? and mc.resource_id = ? and mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.action_name ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { apiResource, resourceId });
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { entityName, entityId });
|
||||
}
|
||||
}
|
||||
+13
-8
@@ -182,8 +182,8 @@ public class ClientsApiResource {
|
||||
private Collection<ClientData> retrieveAllUnprocessedDataChanges(final Long clientId) {
|
||||
Collection<ClientData> dataChanges = new ArrayList<ClientData>();
|
||||
|
||||
Collection<CommandSourceData> unprocessedChanges = this.commandSourceReadPlatformService.retrieveUnprocessChangesByResourceId(
|
||||
"clients", clientId);
|
||||
Collection<CommandSourceData> unprocessedChanges = this.commandSourceReadPlatformService.retrieveUnprocessChangesByEntityNameAndId(
|
||||
"CLIENT", clientId);
|
||||
for (CommandSourceData commandSourceData : unprocessedChanges) {
|
||||
ClientData change = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(clientId,
|
||||
commandSourceData.json());
|
||||
@@ -220,8 +220,10 @@ public class ClientsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createClient(final String apiRequestBodyAsJson) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createClient().withUrl("/clients").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
.createClient() //
|
||||
.withJson(apiRequestBodyAsJson) //
|
||||
.build(); //
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
@@ -234,8 +236,10 @@ public class ClientsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateClient(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClient().withUrl("/clients").withEntityId(clientId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
.updateClient(clientId) //
|
||||
.withJson(apiRequestBodyAsJson) //
|
||||
.build(); //
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
@@ -248,8 +252,9 @@ public class ClientsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteClient(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClient().withUrl("/clients").withEntityId(clientId)
|
||||
.withJson("{}").build();
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||
.deleteClient(clientId) //
|
||||
.build(); //
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user