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;
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;
@@ -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;
@@ -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,11 +300,11 @@ public class CommandWrapper {
public String commandName() {
return this.actionName + "_" + this.entityName;
}
public boolean isLoanDisburseDetailResource() {
return this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL");
}
public boolean isUpdateDisbursementDate() {
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
&& this.entityId != null;
@@ -305,5 +314,5 @@ public class CommandWrapper {
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
&& this.entityId == null;
}
}
@@ -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,7 +172,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isLoanDisburseDetailResource()) {
} else if (wrapper.isLoanDisburseDetailResource()) {
if (wrapper.isUpdateDisbursementDate()) {
handler = this.applicationContext.getBean("updateLoanDisbuseDateCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.addAndDeleteDisbursementDetails()) {
@@ -180,10 +180,14 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
}
else {
handler = this.commandHandlerProvider.getHandler(wrapper.entityName(), wrapper.actionName());
} 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());
}
return handler;