Merge branch 'master' into develop

This commit is contained in:
Vishwas Babu A J
2015-08-06 14:01:53 -07:00
4 changed files with 35 additions and 26 deletions
@@ -6,7 +6,6 @@
package org.mifosplatform.accounting.journalentry.handler; package org.mifosplatform.accounting.journalentry.handler;
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService; import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
import org.mifosplatform.commands.annotation.CommandType;
import org.mifosplatform.commands.handler.NewCommandSourceHandler; import org.mifosplatform.commands.handler.NewCommandSourceHandler;
import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
@@ -15,7 +14,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@CommandType(entity = "JOURNALENTRY", action = "CREATE")
public class CreateJournalEntryCommandHandler implements NewCommandSourceHandler { public class CreateJournalEntryCommandHandler implements NewCommandSourceHandler {
private final JournalEntryWritePlatformService writePlatformService; private final JournalEntryWritePlatformService writePlatformService;
@@ -6,7 +6,6 @@
package org.mifosplatform.accounting.journalentry.handler; package org.mifosplatform.accounting.journalentry.handler;
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService; import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
import org.mifosplatform.commands.annotation.CommandType;
import org.mifosplatform.commands.handler.NewCommandSourceHandler; import org.mifosplatform.commands.handler.NewCommandSourceHandler;
import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
@@ -15,7 +14,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@CommandType(entity = "JOURNALENTRY", action = "REVERSE")
public class ReverseJournalEntryCommandHandler implements NewCommandSourceHandler { public class ReverseJournalEntryCommandHandler implements NewCommandSourceHandler {
private final JournalEntryWritePlatformService writePlatformService; private final JournalEntryWritePlatformService writePlatformService;
@@ -106,7 +106,7 @@ public class CommandWrapper {
this.transactionId = transactionId; this.transactionId = transactionId;
this.productId = productId; this.productId = productId;
} }
public String getHref() { public String getHref() {
return this.href; return this.href;
} }
@@ -114,11 +114,15 @@ public class CommandWrapper {
public String getJson() { public String getJson() {
return this.json; return this.json;
} }
public boolean isCreate() { public boolean isCreate() {
return this.actionName.equalsIgnoreCase("CREATE"); return this.actionName.equalsIgnoreCase("CREATE");
} }
public boolean isReverse() {
return this.actionName.equalsIgnoreCase("REVERSE");
}
public boolean isCreateDatatable() { public boolean isCreateDatatable() {
return this.actionName.equalsIgnoreCase("CREATE") && this.href.startsWith("/datatables/") && this.entityId == null; return this.actionName.equalsIgnoreCase("CREATE") && this.href.startsWith("/datatables/") && this.entityId == null;
} }
@@ -130,7 +134,7 @@ public class CommandWrapper {
public boolean isUpdateDatatable() { public boolean isUpdateDatatable() {
return this.actionName.equalsIgnoreCase("UPDATE") && this.href.startsWith("/datatables/") && this.entityId == null; return this.actionName.equalsIgnoreCase("UPDATE") && this.href.startsWith("/datatables/") && this.entityId == null;
} }
public boolean isDatatableResource() { public boolean isDatatableResource() {
return this.href.startsWith("/datatables/"); return this.href.startsWith("/datatables/");
} }
@@ -151,11 +155,11 @@ public class CommandWrapper {
public boolean isUpdateMultiple() { public boolean isUpdateMultiple() {
return isDatatableResource() && isUpdateOperation() && this.subentityId != null; return isDatatableResource() && isUpdateOperation() && this.subentityId != null;
} }
public boolean isRegisterDatatable() { public boolean isRegisterDatatable() {
return this.actionName.equalsIgnoreCase("REGISTER") && this.href.startsWith("/datatables/") && this.entityId == null; return this.actionName.equalsIgnoreCase("REGISTER") && this.href.startsWith("/datatables/") && this.entityId == null;
} }
public boolean isNoteResource() { public boolean isNoteResource() {
boolean isnoteResource = false; boolean isnoteResource = false;
if (this.entityName.equalsIgnoreCase("CLIENTNOTE") || this.entityName.equalsIgnoreCase("LOANNOTE") if (this.entityName.equalsIgnoreCase("CLIENTNOTE") || this.entityName.equalsIgnoreCase("LOANNOTE")
@@ -165,25 +169,26 @@ public class CommandWrapper {
} }
return isnoteResource; return isnoteResource;
} }
public boolean isUpdateOfOwnUserDetails(final Long loggedInUserId) { public boolean isUpdateOfOwnUserDetails(final Long loggedInUserId) {
return isUserResource() && isUpdate() && loggedInUserId.equals(this.entityId); return isUserResource() && isUpdate() && loggedInUserId.equals(this.entityId);
} }
public boolean isUpdate() { public boolean isUpdate() {
// permissions resource has special update which involves no resource. // permissions resource has special update which involves no resource.
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource() return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource()
&& isUpdateOperation() || isWorkingDaysResource() && isUpdateOperation() || isPasswordPreferencesResource() && isUpdateOperation() || isWorkingDaysResource() && isUpdateOperation() || isPasswordPreferencesResource()
&& isUpdateOperation() || isUpdateOperation() && this.entityId != null; && isUpdateOperation() || isUpdateOperation() && this.entityId != null;
} }
public boolean isCacheResource() { public boolean isCacheResource() {
return this.entityName.equalsIgnoreCase("CACHE"); return this.entityName.equalsIgnoreCase("CACHE");
} }
public Long getSubentityId() { public Long getSubentityId() {
return this.subentityId; return this.subentityId;
} }
public String getTransactionId() { public String getTransactionId() {
return this.transactionId; return this.transactionId;
} }
@@ -195,7 +200,7 @@ public class CommandWrapper {
public Long getEntityId() { public Long getEntityId() {
return this.entityId; return this.entityId;
} }
public boolean isUpdateOperation() { public boolean isUpdateOperation() {
return this.actionName.equalsIgnoreCase("UPDATE"); return this.actionName.equalsIgnoreCase("UPDATE");
} }
@@ -207,11 +212,15 @@ public class CommandWrapper {
public boolean isDeleteOperation() { public boolean isDeleteOperation() {
return this.actionName.equalsIgnoreCase("DELETE"); return this.actionName.equalsIgnoreCase("DELETE");
} }
public boolean isSurveyResource() { public boolean isSurveyResource() {
return this.href.startsWith("/survey/"); return this.href.startsWith("/survey/");
} }
public boolean isJournalEntryResource() {
return this.entityName.equalsIgnoreCase("JOURNALENTRY");
}
public boolean isRegisterSurvey() { public boolean isRegisterSurvey() {
return this.actionName.equalsIgnoreCase("REGISTER"); return this.actionName.equalsIgnoreCase("REGISTER");
} }
@@ -251,7 +260,7 @@ public class CommandWrapper {
public String taskPermissionName() { public String taskPermissionName() {
return this.actionName + "_" + this.entityName; return this.actionName + "_" + this.entityName;
} }
public String getTaskPermissionName() { public String getTaskPermissionName() {
return this.taskPermissionName; return this.taskPermissionName;
} }
@@ -283,7 +292,7 @@ public class CommandWrapper {
public boolean isUserResource() { public boolean isUserResource() {
return this.entityName.equalsIgnoreCase("USER"); return this.entityName.equalsIgnoreCase("USER");
} }
public boolean isCurrencyResource() { public boolean isCurrencyResource() {
return this.entityName.equalsIgnoreCase("CURRENCY"); return this.entityName.equalsIgnoreCase("CURRENCY");
} }
@@ -291,11 +300,11 @@ public class CommandWrapper {
public String commandName() { public String commandName() {
return this.actionName + "_" + this.entityName; return this.actionName + "_" + this.entityName;
} }
public boolean isLoanDisburseDetailResource() { public boolean isLoanDisburseDetailResource() {
return this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL"); return this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL");
} }
public boolean isUpdateDisbursementDate() { public boolean isUpdateDisbursementDate() {
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL") return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
&& this.entityId != null; && this.entityId != null;
@@ -305,5 +314,5 @@ public class CommandWrapper {
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL") return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
&& this.entityId == null; && this.entityId == null;
} }
} }
@@ -164,7 +164,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else { } else {
throw new UnsupportedCommandException(wrapper.commandName()); throw new UnsupportedCommandException(wrapper.commandName());
} }
} else if (wrapper.isSurveyResource()) { } else if (wrapper.isSurveyResource()) {
if (wrapper.isRegisterSurvey()) { if (wrapper.isRegisterSurvey()) {
handler = this.applicationContext.getBean("registerSurveyCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("registerSurveyCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isFullFilSurvey()) { } else if (wrapper.isFullFilSurvey()) {
@@ -172,7 +172,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else { } else {
throw new UnsupportedCommandException(wrapper.commandName()); throw new UnsupportedCommandException(wrapper.commandName());
} }
} else if (wrapper.isLoanDisburseDetailResource()) { } else if (wrapper.isLoanDisburseDetailResource()) {
if (wrapper.isUpdateDisbursementDate()) { if (wrapper.isUpdateDisbursementDate()) {
handler = this.applicationContext.getBean("updateLoanDisbuseDateCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("updateLoanDisbuseDateCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.addAndDeleteDisbursementDetails()) { } else if (wrapper.addAndDeleteDisbursementDetails()) {
@@ -180,10 +180,14 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else { } else {
throw new UnsupportedCommandException(wrapper.commandName()); throw new UnsupportedCommandException(wrapper.commandName());
} }
} } else if (wrapper.isJournalEntryResource()) {
else { if (wrapper.isCreate()) {
handler = this.applicationContext.getBean("createJournalEntryCommandHandler", NewCommandSourceHandler.class);
handler = this.commandHandlerProvider.getHandler(wrapper.entityName(), wrapper.actionName()); } else if (wrapper.isReverse()) {
handler = this.applicationContext.getBean("reverseJournalEntryCommandHandler", NewCommandSourceHandler.class);
}
} else {
handler = this.commandHandlerProvider.getHandler(wrapper.entityName(), wrapper.actionName());
} }
return handler; return handler;