From 9947563078ba3274f34ce2c464964cb5bab5c88d Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Thu, 6 Aug 2015 13:32:16 -0700 Subject: [PATCH] fix for MIFOSX-2131 --- .../CreateJournalEntryCommandHandler.java | 2 - .../ReverseJournalEntryCommandHandler.java | 2 - .../commands/domain/CommandWrapper.java | 37 ++++++++++++------- .../SynchronousCommandProcessingService.java | 13 +++++-- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/CreateJournalEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/CreateJournalEntryCommandHandler.java index fe86a4237..a6644fbac 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/CreateJournalEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/CreateJournalEntryCommandHandler.java @@ -6,7 +6,6 @@ package org.mifosplatform.accounting.journalentry.handler; import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService; -import org.mifosplatform.commands.annotation.CommandType; import org.mifosplatform.commands.handler.NewCommandSourceHandler; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -15,7 +14,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service -@CommandType(entity = "JOURNALENTRY", action = "CREATE") public class CreateJournalEntryCommandHandler implements NewCommandSourceHandler { private final JournalEntryWritePlatformService writePlatformService; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/ReverseJournalEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/ReverseJournalEntryCommandHandler.java index 64bf2630a..971da60dd 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/ReverseJournalEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/handler/ReverseJournalEntryCommandHandler.java @@ -6,7 +6,6 @@ package org.mifosplatform.accounting.journalentry.handler; import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService; -import org.mifosplatform.commands.annotation.CommandType; import org.mifosplatform.commands.handler.NewCommandSourceHandler; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -15,7 +14,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service -@CommandType(entity = "JOURNALENTRY", action = "REVERSE") public class ReverseJournalEntryCommandHandler implements NewCommandSourceHandler { private final JournalEntryWritePlatformService writePlatformService; 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 1ff8fcd4f..f90b3cae5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java @@ -106,7 +106,7 @@ public class CommandWrapper { this.transactionId = transactionId; this.productId = productId; } - + public String getHref() { return this.href; } @@ -114,11 +114,15 @@ public class CommandWrapper { public String getJson() { return this.json; } - + public boolean isCreate() { return this.actionName.equalsIgnoreCase("CREATE"); } + public boolean isReverse() { + return this.actionName.equalsIgnoreCase("REVERSE"); + } + public boolean isCreateDatatable() { return this.actionName.equalsIgnoreCase("CREATE") && this.href.startsWith("/datatables/") && this.entityId == null; } @@ -130,7 +134,7 @@ public class CommandWrapper { public boolean isUpdateDatatable() { return this.actionName.equalsIgnoreCase("UPDATE") && this.href.startsWith("/datatables/") && this.entityId == null; } - + public boolean isDatatableResource() { return this.href.startsWith("/datatables/"); } @@ -151,11 +155,11 @@ public class CommandWrapper { public boolean isUpdateMultiple() { return isDatatableResource() && isUpdateOperation() && this.subentityId != null; } - + public boolean isRegisterDatatable() { return this.actionName.equalsIgnoreCase("REGISTER") && this.href.startsWith("/datatables/") && this.entityId == null; } - + public boolean isNoteResource() { boolean isnoteResource = false; if (this.entityName.equalsIgnoreCase("CLIENTNOTE") || this.entityName.equalsIgnoreCase("LOANNOTE") @@ -165,25 +169,26 @@ public class CommandWrapper { } return isnoteResource; } - + public boolean isUpdateOfOwnUserDetails(final Long loggedInUserId) { return isUserResource() && isUpdate() && loggedInUserId.equals(this.entityId); } - + public boolean isUpdate() { // permissions resource has special update which involves no resource. return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource() && isUpdateOperation() || isWorkingDaysResource() && isUpdateOperation() || isPasswordPreferencesResource() && isUpdateOperation() || isUpdateOperation() && this.entityId != null; } - + public boolean isCacheResource() { return this.entityName.equalsIgnoreCase("CACHE"); } - + public Long getSubentityId() { return this.subentityId; } + public String getTransactionId() { return this.transactionId; } @@ -195,7 +200,7 @@ public class CommandWrapper { public Long getEntityId() { return this.entityId; } - + public boolean isUpdateOperation() { return this.actionName.equalsIgnoreCase("UPDATE"); } @@ -207,11 +212,15 @@ public class CommandWrapper { public boolean isDeleteOperation() { return this.actionName.equalsIgnoreCase("DELETE"); } - + public boolean isSurveyResource() { return this.href.startsWith("/survey/"); } + public boolean isJournalEntryResource() { + return this.entityName.equalsIgnoreCase("JOURNALENTRY"); + } + public boolean isRegisterSurvey() { return this.actionName.equalsIgnoreCase("REGISTER"); } @@ -251,7 +260,7 @@ public class CommandWrapper { public String taskPermissionName() { return this.actionName + "_" + this.entityName; } - + public String getTaskPermissionName() { return this.taskPermissionName; } @@ -283,7 +292,7 @@ public class CommandWrapper { public boolean isUserResource() { return this.entityName.equalsIgnoreCase("USER"); } - + public boolean isCurrencyResource() { return this.entityName.equalsIgnoreCase("CURRENCY"); } @@ -291,5 +300,5 @@ public class CommandWrapper { public String commandName() { return this.actionName + "_" + this.entityName; } - + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java index cf48825fb..3867045d2 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java @@ -164,7 +164,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer } else { throw new UnsupportedCommandException(wrapper.commandName()); } - } else if (wrapper.isSurveyResource()) { + } else if (wrapper.isSurveyResource()) { if (wrapper.isRegisterSurvey()) { handler = this.applicationContext.getBean("registerSurveyCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isFullFilSurvey()) { @@ -172,10 +172,15 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer } else { throw new UnsupportedCommandException(wrapper.commandName()); } - } - else { + } else if (wrapper.isJournalEntryResource()) { + if (wrapper.isCreate()) { + handler = this.applicationContext.getBean("createJournalEntryCommandHandler", NewCommandSourceHandler.class); + } else if (wrapper.isReverse()) { + handler = this.applicationContext.getBean("reverseJournalEntryCommandHandler", NewCommandSourceHandler.class); + } + } else { - handler = this.commandHandlerProvider.getHandler(wrapper.entityName(), wrapper.actionName()); + handler = this.commandHandlerProvider.getHandler(wrapper.entityName(), wrapper.actionName()); } return handler;