fixed mifosx-268 one to many datatable update and deletes fail maker checker approve... plus minor other changes

This commit is contained in:
John Woodlock
2013-03-21 22:20:32 +00:00
parent d24dc10818
commit ea9e24a270
14 changed files with 102 additions and 72 deletions
@@ -291,6 +291,7 @@ CREATE TABLE `m_portfolio_command_source` (
`loan_id` bigint(20) DEFAULT NULL, `loan_id` bigint(20) DEFAULT NULL,
`api_get_url` varchar(100) NOT NULL, `api_get_url` varchar(100) NOT NULL,
`resource_id` bigint(20) DEFAULT NULL, `resource_id` bigint(20) DEFAULT NULL,
`subresource_id` bigint(20) DEFAULT NULL,
`command_as_json` text NOT NULL, `command_as_json` text NOT NULL,
`maker_id` bigint(20) NOT NULL, `maker_id` bigint(20) NOT NULL,
`made_on_date` datetime NOT NULL, `made_on_date` datetime NOT NULL,
@@ -0,0 +1,7 @@
/*
Datatables defined as one to many need a subresource_id for maker-checker approval
*/
ALTER TABLE m_portfolio_command_source
ADD COLUMN `subresource_id` BIGINT(20) NULL AFTER `resource_id` ;
@@ -21,6 +21,8 @@ public final class AuditData {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Long resourceId; private final Long resourceId;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Long subresourceId;
@SuppressWarnings("unused")
private final String maker; private final String maker;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final DateTime madeOnDate; private final DateTime madeOnDate;
@@ -33,7 +35,7 @@ public final class AuditData {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final String commandAsJson; private final String commandAsJson;
public AuditData(final Long id, final String actionName, final String entityName, final Long resourceId, final String maker, public AuditData(final Long id, final String actionName, final String entityName, final Long resourceId, final Long subresourceId, final String maker,
final DateTime madeOnDate, final String checker, final DateTime checkedOnDate, final String processingResult, final DateTime madeOnDate, final String checker, final DateTime checkedOnDate, final String processingResult,
final String commandAsJson) { final String commandAsJson) {
@@ -41,6 +43,7 @@ public final class AuditData {
this.actionName = actionName; this.actionName = actionName;
this.entityName = entityName; this.entityName = entityName;
this.resourceId = resourceId; this.resourceId = resourceId;
this.subresourceId = subresourceId;
this.maker = maker; this.maker = maker;
this.madeOnDate = madeOnDate; this.madeOnDate = madeOnDate;
this.checker = checker; this.checker = checker;
@@ -50,7 +50,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
String commandAsJsonString = ""; String commandAsJsonString = "";
if (includeJson) commandAsJsonString = ", aud.command_as_json as commandAsJson "; if (includeJson) commandAsJsonString = ", aud.command_as_json as commandAsJson ";
return " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName," + " aud.resource_id as resourceId," return " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName," + " aud.resource_id as resourceId, aud.subresource_id as subresourceId,"
+ " mk.username as maker, aud.made_on_date as madeOnDate, " + " 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 " + "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" + commandAsJsonString + " from m_portfolio_command_source aud " + " left join m_appuser mk on mk.id = aud.maker_id"
@@ -65,6 +65,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
final String actionName = rs.getString("actionName"); final String actionName = rs.getString("actionName");
final String entityName = rs.getString("entityName"); final String entityName = rs.getString("entityName");
final Long resourceId = JdbcSupport.getLong(rs, "resourceId"); final Long resourceId = JdbcSupport.getLong(rs, "resourceId");
final Long subresourceId = JdbcSupport.getLong(rs, "subresourceId");
final String maker = rs.getString("maker"); final String maker = rs.getString("maker");
final DateTime madeOnDate = JdbcSupport.getDateTime(rs, "madeOnDate"); final DateTime madeOnDate = JdbcSupport.getDateTime(rs, "madeOnDate");
final String checker = rs.getString("checker"); final String checker = rs.getString("checker");
@@ -77,7 +78,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
} catch (SQLException e) { } catch (SQLException e) {
commandAsJson = null; commandAsJson = null;
} }
return new AuditData(id, actionName, entityName, resourceId, maker, madeOnDate, checker, checkedOnDate, processingResult, return new AuditData(id, actionName, entityName, resourceId, subresourceId, maker, madeOnDate, checker, checkedOnDate, processingResult,
commandAsJson); commandAsJson);
} }
} }
@@ -53,6 +53,9 @@ public class CommandSource extends AbstractPersistable<Long> {
@Column(name = "resource_id") @Column(name = "resource_id")
private Long resourceId; private Long resourceId;
@Column(name = "subresource_id")
private Long subresourceId;
@Column(name = "command_as_json", length = 1000) @Column(name = "command_as_json", length = 1000)
private String commandAsJson; private String commandAsJson;
@@ -81,7 +84,7 @@ public class CommandSource extends AbstractPersistable<Long> {
private Integer processingResult; private Integer processingResult;
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) { public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) {
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.json(), maker, DateTime.now()); return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(), command.json(), maker, DateTime.now());
} }
protected CommandSource() { protected CommandSource() {
@@ -90,13 +93,14 @@ public class CommandSource extends AbstractPersistable<Long> {
private CommandSource( private CommandSource(
final String actionName, final String entityName, final String href, final String actionName, final String entityName, final String href,
final Long resourceId, final Long resourceId, final Long subresourceId,
final String commandSerializedAsJson, final AppUser maker, final String commandSerializedAsJson, final AppUser maker,
final DateTime madeOnDateTime) { final DateTime madeOnDateTime) {
this.actionName = actionName; this.actionName = actionName;
this.entityName = entityName; this.entityName = entityName;
this.resourceGetUrl = href; this.resourceGetUrl = href;
this.resourceId = resourceId; this.resourceId = resourceId;
this.subresourceId = subresourceId;
this.commandAsJson = commandSerializedAsJson; this.commandAsJson = commandSerializedAsJson;
this.maker = maker; this.maker = maker;
this.madeOnDate = madeOnDateTime.toDate(); this.madeOnDate = madeOnDateTime.toDate();
@@ -113,6 +117,10 @@ public class CommandSource extends AbstractPersistable<Long> {
this.resourceId = resourceId; this.resourceId = resourceId;
} }
public void updateSubresourceId(final Long subresourceId) {
this.subresourceId = subresourceId;
}
public void updateJsonTo(final String json) { public void updateJsonTo(final String json) {
this.commandAsJson = json; this.commandAsJson = json;
} }
@@ -121,6 +129,10 @@ public class CommandSource extends AbstractPersistable<Long> {
return this.resourceId; return this.resourceId;
} }
public Long subresourceId() {
return this.subresourceId;
}
public boolean hasJson() { public boolean hasJson() {
return StringUtils.isNotBlank(this.commandAsJson); return StringUtils.isNotBlank(this.commandAsJson);
} }
@@ -145,6 +157,10 @@ public class CommandSource extends AbstractPersistable<Long> {
return this.resourceId; return this.resourceId;
} }
public Long getSubresourceId() {
return this.subresourceId;
}
public void markAsAwaitingApproval() { public void markAsAwaitingApproval() {
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue(); this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue();
} }
@@ -17,6 +17,7 @@ public class CommandWrapper {
private final String entityName; private final String entityName;
private final String taskPermissionName; private final String taskPermissionName;
private final Long entityId; private final Long entityId;
private final Long subentityId;
private final String href; private final String href;
private final String json; private final String json;
private final Long apptableId; private final Long apptableId;
@@ -26,16 +27,16 @@ public class CommandWrapper {
private final String supportedEntityType; private final String supportedEntityType;
private final Long supportedEntityId; private final Long supportedEntityId;
public static CommandWrapper wrap(final String actionName, final String enityName, final Long resourceId) { public static CommandWrapper wrap(final String actionName, final String entityName, final Long resourceId, final Long subresourceId) {
return new CommandWrapper(null, actionName, enityName, resourceId, null); return new CommandWrapper(null, actionName, entityName, resourceId, subresourceId, null);
} }
public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String enityName, public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String entityName,
final Long resourceId, final String resourceGetUrl) { final Long resourceId, final Long subresourceId, final String resourceGetUrl) {
return new CommandWrapper(commandId, actionName, enityName, resourceId, resourceGetUrl); return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl);
} }
private CommandWrapper(final Long commandId, final String actionName, final String enityName, final Long resourceId, private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId, final Long subresourceId,
final String resourceGetUrl) { final String resourceGetUrl) {
this.commandId = commandId; this.commandId = commandId;
this.officeId = null; this.officeId = null;
@@ -43,10 +44,10 @@ public class CommandWrapper {
this.clientId = null; this.clientId = null;
this.loanId = null; this.loanId = null;
this.actionName = actionName; this.actionName = actionName;
this.entityName = enityName; this.entityName = entityName;
this.taskPermissionName = actionName + "_" + entityName; this.taskPermissionName = actionName + "_" + entityName;
this.entityId = resourceId; this.entityId = resourceId;
this.datatableId = null; this.subentityId = subresourceId;
this.codeId = null; this.codeId = null;
this.supportedEntityType = null; this.supportedEntityType = null;
this.supportedEntityId = null; this.supportedEntityId = null;
@@ -54,15 +55,19 @@ public class CommandWrapper {
this.json = null; this.json = null;
this.transactionId = null; this.transactionId = null;
if (this.href.contains("datatables")) { /* TODO - jpw taking this out later*/
if (this.href.startsWith("/datatables/")) {
this.apptableId = resourceId; this.apptableId = resourceId;
this.datatableId = subresourceId;
} else { } else {
this.apptableId = null; this.apptableId = null;
this.datatableId = null;
} }
} }
public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final String actionName, public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final String actionName,
final String entityName, final Long entityId, final Long apptableId, final Long datatableId, final Long codeId, final String entityName, final Long entityId, final Long subentityId, final Long apptableId, final Long datatableId, final Long codeId,
final String supportedEntityType, final Long supportedEntityId, final String href, final String json, final String transactionId) { final String supportedEntityType, final Long supportedEntityId, final String href, final String json, final String transactionId) {
this.commandId = null; this.commandId = null;
this.officeId = officeId; this.officeId = officeId;
@@ -73,6 +78,7 @@ public class CommandWrapper {
this.entityName = entityName; this.entityName = entityName;
this.taskPermissionName = actionName + "_" + entityName; this.taskPermissionName = actionName + "_" + entityName;
this.entityId = entityId; this.entityId = entityId;
this.subentityId = subentityId;
this.apptableId = apptableId; this.apptableId = apptableId;
this.datatableId = datatableId; this.datatableId = datatableId;
this.codeId = codeId; this.codeId = codeId;
@@ -99,6 +105,10 @@ public class CommandWrapper {
return this.entityId; return this.entityId;
} }
public Long subresourceId() {
return this.subentityId;
}
public String taskPermissionName() { public String taskPermissionName() {
return this.actionName + "_" + this.entityName; return this.actionName + "_" + this.entityName;
} }
@@ -135,6 +145,10 @@ public class CommandWrapper {
return this.entityId; return this.entityId;
} }
public Long getSubentityId() {
return this.subentityId;
}
public Long getGroupId() { public Long getGroupId() {
return this.groupId; return this.groupId;
} }
@@ -354,7 +368,7 @@ public class CommandWrapper {
} }
public boolean isDatatableResource() { public boolean isDatatableResource() {
return this.apptableId != null; return this.href.startsWith("/datatables/");
} }
public boolean isDeleteOneToOne() { public boolean isDeleteOneToOne() {
@@ -16,6 +16,7 @@ public class CommandWrapperBuilder {
private String actionName; private String actionName;
private String entityName; private String entityName;
private Long entityId; private Long entityId;
private Long subentityId;
private String href; private String href;
private String json = "{}"; private String json = "{}";
private Long apptableId; private Long apptableId;
@@ -26,7 +27,7 @@ public class CommandWrapperBuilder {
private Long supportedEntityId; private Long supportedEntityId;
public CommandWrapper build() { public CommandWrapper build() {
return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.actionName, this.entityName, this.entityId, return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.actionName, this.entityName, this.entityId, this.subentityId,
this.apptableId, this.datatableId, this.codeId, this.supportedEntityType, this.supportedEntityId, this.href, this.json, this.apptableId, this.datatableId, this.codeId, this.supportedEntityType, this.supportedEntityId, this.href, this.json,
this.transactionId); this.transactionId);
} }
@@ -327,44 +328,40 @@ public class CommandWrapperBuilder {
} }
public CommandWrapperBuilder createDatatable(final String datatable, final Long apptableId, final Long datatableId) { public CommandWrapperBuilder createDatatable(final String datatable, final Long apptableId, final Long datatableId) {
this.apptableId = apptableId;
this.datatableId = datatableId;
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = datatable; commonDatatableSettings(datatable, apptableId, datatableId);
if (datatableId == null) {
this.href = "/datatables/" + datatable + "/" + apptableId;
} else {
this.href = "/datatables/" + datatable + "/" + apptableId + "/" + datatableId;
}
return this; return this;
} }
public CommandWrapperBuilder updateDatatable(final String datatable, final Long apptableId, final Long datatableId) { public CommandWrapperBuilder updateDatatable(final String datatable, final Long apptableId, final Long datatableId) {
this.apptableId = apptableId;
this.datatableId = datatableId;
this.actionName = "UPDATE"; this.actionName = "UPDATE";
this.entityName = datatable; commonDatatableSettings(datatable, apptableId, datatableId);
if (datatableId == null) {
this.href = "/datatables/" + datatable + "/" + apptableId;
} else {
this.href = "/datatables/" + datatable + "/" + apptableId + "/" + datatableId;
}
return this; return this;
} }
public CommandWrapperBuilder deleteDatatable(final String datatable, final Long apptableId, final Long datatableId) { public CommandWrapperBuilder deleteDatatable(final String datatable, final Long apptableId, final Long datatableId) {
this.actionName = "DELETE";
commonDatatableSettings(datatable, apptableId, datatableId);
return this;
}
private void commonDatatableSettings(final String datatable, final Long apptableId, final Long datatableId) {
//TODO - remove apptableId and datatableId later JPW
this.apptableId = apptableId; this.apptableId = apptableId;
this.datatableId = datatableId; this.datatableId = datatableId;
this.actionName = "DELETE";
this.entityName = datatable; this.entityName = datatable;
this.entityId = apptableId;
this.subentityId = datatableId;
if (datatableId == null) { if (datatableId == null) {
this.href = "/datatables/" + datatable + "/" + apptableId; this.href = "/datatables/" + datatable + "/" + apptableId;
} else { } else {
this.href = "/datatables/" + datatable + "/" + apptableId + "/" + datatableId; this.href = "/datatables/" + datatable + "/" + apptableId + "/" + datatableId;
} }
return this;
} }
public CommandWrapperBuilder createLoanCharge(final Long loanId) { public CommandWrapperBuilder createLoanCharge(final Long loanId) {
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = "LOANCHARGE"; this.entityName = "LOANCHARGE";
@@ -57,7 +57,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
try { try {
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json);
final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(), final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(),
wrapper.getEntityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getApptableId(), wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getApptableId(),
wrapper.getDatatableId(), wrapper.getCodeId(), wrapper.getSupportedEntityType(), wrapper.getSupportedEntityId(), wrapper.getTransactionId()); wrapper.getDatatableId(), wrapper.getCodeId(), wrapper.getSupportedEntityType(), wrapper.getSupportedEntityId(), wrapper.getTransactionId());
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker); result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
@@ -74,7 +74,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
} }
final JsonCommand command = JsonCommand.from(jsonToUse, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(), final JsonCommand command = JsonCommand.from(jsonToUse, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(),
entityId, wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getApptableId(), entityId, wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getApptableId(),
wrapper.getDatatableId(), wrapper.getCodeId(), wrapper.getSupportedEntityType(), wrapper.getSupportedEntityId(), wrapper.getTransactionId()); wrapper.getDatatableId(), wrapper.getCodeId(), wrapper.getSupportedEntityType(), wrapper.getSupportedEntityId(), wrapper.getTransactionId());
result = this.processAndLogCommandService.logCommand(wrapper, command); result = this.processAndLogCommandService.logCommand(wrapper, command);
@@ -91,11 +91,11 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode()); context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(commandId, commandSourceInput.getActionName(), final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(commandId, commandSourceInput.getActionName(),
commandSourceInput.getEntityName(), commandSourceInput.resourceId(), commandSourceInput.getResourceGetUrl()); commandSourceInput.getEntityName(), commandSourceInput.resourceId(), commandSourceInput.subresourceId(), commandSourceInput.getResourceGetUrl());
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(commandSourceInput.json()); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(commandSourceInput.json());
final JsonCommand command = JsonCommand.fromExistingCommand(commandId, commandSourceInput.json(), parsedCommand, final JsonCommand command = JsonCommand.fromExistingCommand(commandId, commandSourceInput.json(), parsedCommand,
this.fromApiJsonHelper, commandSourceInput.getEntityName(), commandSourceInput.resourceId()); this.fromApiJsonHelper, commandSourceInput.getEntityName(), commandSourceInput.resourceId(), commandSourceInput.subresourceId());
final boolean makerCheckerApproval = true; final boolean makerCheckerApproval = true;
return this.processAndLogCommandService.processAndLogCommand(wrapper, command, makerCheckerApproval); return this.processAndLogCommandService.processAndLogCommand(wrapper, command, makerCheckerApproval);
@@ -33,6 +33,7 @@ public final class JsonCommand {
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
private final Long commandId; private final Long commandId;
private final Long resourceId; private final Long resourceId;
private final Long subresourceId;
private final Long groupId; private final Long groupId;
private final Long clientId; private final Long clientId;
private final Long loanId; private final Long loanId;
@@ -45,21 +46,21 @@ public final class JsonCommand {
private final String transactionId; private final String transactionId;
public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper,
final String entityName, final Long resourceId, final Long groupId, final Long clientId, final Long loanId, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId, final Long loanId,
final Long apptableId, final Long datatableId, final Long codeId, final String supportedEntityType, final Long apptableId, final Long datatableId, final Long codeId, final String supportedEntityType,
final Long supportedEntityId, final String transactionId) { final Long supportedEntityId, final String transactionId) {
return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, groupId, clientId, loanId, return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, clientId, loanId,
apptableId, datatableId, codeId, supportedEntityType, supportedEntityId, transactionId); apptableId, datatableId, codeId, supportedEntityType, supportedEntityId, transactionId);
} }
public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId) { final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId) {
return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, null, null, null, null, return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, null, null, null, null,
null, null, null, null, null); null, null, null, null, null);
} }
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long groupId, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId,
final Long clientId, final Long loanId, final Long apptableId, final Long datatableId, final Long codeId, final Long clientId, final Long loanId, final Long apptableId, final Long datatableId, final Long codeId,
final String supportedEntityType, final Long supportedEntityId, final String transactionId) { final String supportedEntityType, final Long supportedEntityId, final String transactionId) {
this.commandId = commandId; this.commandId = commandId;
@@ -68,6 +69,7 @@ public final class JsonCommand {
this.fromApiJsonHelper = fromApiJsonHelper; this.fromApiJsonHelper = fromApiJsonHelper;
this.entityName = entityName; this.entityName = entityName;
this.resourceId = resourceId; this.resourceId = resourceId;
this.subresourceId = subresourceId;
this.groupId = groupId; this.groupId = groupId;
this.clientId = clientId; this.clientId = clientId;
this.loanId = loanId; this.loanId = loanId;
@@ -108,6 +110,10 @@ public final class JsonCommand {
return this.resourceId; return this.resourceId;
} }
public Long subentityId() {
return this.subresourceId;
}
public Long getGroupId() { public Long getGroupId() {
return this.groupId; return this.groupId;
} }
@@ -28,16 +28,11 @@ public class CreateDatatableEntryCommandHandler implements NewCommandSourceHandl
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { public CommandProcessingResult processCommand(final JsonCommand command) {
Long appTableId = command.getApptableId(); this.writePlatformService.createNewDatatableEntry(command.entityName(), command.entityId(), command);
if (appTableId == null) {
appTableId = command.entityId();
}
this.writePlatformService.createNewDatatableEntry(command.entityName(), appTableId, command);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(appTableId) // .withEntityId(command.entityId()) //
.build(); .build();
} }
} }
@@ -28,8 +28,8 @@ public class DeleteOneToManyDatatableEntryCommandHandler implements NewCommandSo
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { public CommandProcessingResult processCommand(final JsonCommand command) {
this.writePlatformService.deleteDatatableEntry(command.entityName(), command.getApptableId(), command.getDatatableId()); this.writePlatformService.deleteDatatableEntry(command.entityName(), command.entityId(), command.subentityId());
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getDatatableId()).build(); return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.entityId()).build();
} }
} }
@@ -28,16 +28,11 @@ public class DeleteOneToOneDatatableEntryCommandHandler implements NewCommandSou
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { public CommandProcessingResult processCommand(final JsonCommand command) {
Long appTableId = command.getApptableId(); this.writePlatformService.deleteDatatableEntries(command.entityName(), command.entityId());
if (appTableId == null) {
appTableId = command.entityId();
}
this.writePlatformService.deleteDatatableEntries(command.entityName(), appTableId);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(appTableId) // .withEntityId(command.entityId()) //
.build(); .build();
} }
} }
@@ -31,8 +31,8 @@ public class UpdateOneToManyDatatableEntryCommandHandler implements NewCommandSo
public CommandProcessingResult processCommand(final JsonCommand command) { public CommandProcessingResult processCommand(final JsonCommand command) {
final Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToMany(command.entityName(), final Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToMany(command.entityName(),
command.getApptableId(), command.getDatatableId(), command); command.entityId(), command.subentityId(), command);
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getDatatableId()).with(changes).build(); return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.entityId()).with(changes).build();
} }
} }
@@ -30,17 +30,12 @@ public class UpdateOneToOneDatatableEntryCommandHandler implements NewCommandSou
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { public CommandProcessingResult processCommand(final JsonCommand command) {
Long appTableId = command.getApptableId(); final Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToOne(command.entityName(), command.entityId(),
if (appTableId == null) {
appTableId = command.entityId();
}
final Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToOne(command.entityName(), appTableId,
command); command);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(appTableId) // .withEntityId(command.entityId()) //
.with(changes) // .with(changes) //
.build(); .build();
} }