From f28e26c1e4728171c83162d22860614043f2a4d1 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Wed, 26 Mar 2014 01:21:31 -0700 Subject: [PATCH] cleaning up MIFOSX-1014 --- .../commands/domain/CommandWrapper.java | 22 +++++++++---------- ...CommandSourceWritePlatformServiceImpl.java | 11 +++++----- .../infrastructure/core/api/JsonCommand.java | 14 +++++++----- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java index 4889831ed..eab81a155 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java @@ -37,13 +37,13 @@ public class CommandWrapper { return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl, productId); } - public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String entityName, - final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId, - final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId) { - return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl, productId); + final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId, final Long officeId, + final Long groupId, final Long clientId, final Long loanId, final Long savingsId) { + return new CommandWrapper(commandId, actionName, entityName, resourceId, subresourceId, resourceGetUrl, productId, officeId, + groupId, clientId, loanId, savingsId); } - + private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId) { this.commandId = commandId; @@ -91,10 +91,10 @@ public class CommandWrapper { this.templateId = templateId; } - public CommandWrapper(final Long commandId, final String actionName, final String entityName, - final Long resourceId, final Long subresourceId, final String resourceGetUrl, final Long productId, - final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId) { - + private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId, + final Long subresourceId, final String resourceGetUrl, final Long productId, final Long officeId, final Long groupId, + final Long clientId, final Long loanId, final Long savingsId) { + this.commandId = commandId; this.officeId = officeId; this.groupId = groupId; @@ -114,7 +114,7 @@ public class CommandWrapper { this.transactionId = null; this.productId = productId; } - + public Long commandId() { return this.commandId; } @@ -691,7 +691,7 @@ public class CommandWrapper { public boolean isRejectClientTransfer() { return this.actionName.equalsIgnoreCase("REJECTTRANSFER") && this.entityName.equalsIgnoreCase("CLIENT"); } - + public boolean isUpdateClientSavingsAccount() { return this.actionName.equalsIgnoreCase("UPDATESAVINGSACCOUNT") && this.entityName.equalsIgnoreCase("CLIENT"); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java index 589b627c8..a4cc883bf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java @@ -86,14 +86,15 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(makerCheckerId, commandSourceInput.getActionName(), commandSourceInput.getEntityName(), commandSourceInput.resourceId(), commandSourceInput.subresourceId(), - commandSourceInput.getResourceGetUrl(), commandSourceInput.getProductId(), commandSourceInput.getOfficeId(), - commandSourceInput.getGroupId(), commandSourceInput.getClientId(), commandSourceInput.getLoanId(), commandSourceInput.getSavingsId()); + commandSourceInput.getResourceGetUrl(), commandSourceInput.getProductId(), commandSourceInput.getOfficeId(), + commandSourceInput.getGroupId(), commandSourceInput.getClientId(), commandSourceInput.getLoanId(), + commandSourceInput.getSavingsId()); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(commandSourceInput.json()); final JsonCommand command = JsonCommand.fromExistingCommand(makerCheckerId, commandSourceInput.json(), parsedCommand, this.fromApiJsonHelper, commandSourceInput.getEntityName(), commandSourceInput.resourceId(), - commandSourceInput.subresourceId(), commandSourceInput.getGroupId(), commandSourceInput.getClientId(), commandSourceInput.getLoanId(), - commandSourceInput.getSavingsId(), commandSourceInput.getResourceGetUrl(), commandSourceInput.getProductId()); - + commandSourceInput.subresourceId(), commandSourceInput.getGroupId(), commandSourceInput.getClientId(), + commandSourceInput.getLoanId(), commandSourceInput.getSavingsId(), commandSourceInput.getResourceGetUrl(), + commandSourceInput.getProductId()); final boolean makerCheckerApproval = true; return this.processAndLogCommandService.processAndLogCommand(wrapper, command, makerCheckerApproval); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java index a9fa8baf0..aa45ab37e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java @@ -67,13 +67,18 @@ public final class JsonCommand { null, null, null, null, null, null, url, productId); } + /*** + * Vishwas TODO: If we are recreating this command from the database, all + * properties should be set. Presence of NULL properties means we can expect + * errors! + ***/ public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, - final Long groupId, final Long clientId, final Long loanId, final Long savingsId,final String url, final Long productId) { - return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, clientId, - loanId, savingsId, null, null, null, null, url, productId); + final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String url, final Long productId) { + return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, + clientId, loanId, savingsId, null, null, null, null, url, productId); } - + public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final Long codeId, @@ -97,7 +102,6 @@ public final class JsonCommand { this.url = url; this.productId = productId; } - public String json() { return this.jsonCommand;