Merge pull request #294 from ashok-conflux/MIFOSX-356

MIFOSX-356: modify api call to unassignStaff from a group
This commit is contained in:
Vishwas Babu A J
2013-05-16 03:50:38 -07:00
7 changed files with 44 additions and 9 deletions
@@ -884,7 +884,7 @@ public class CommandWrapperBuilder {
return this;
}
public CommandWrapperBuilder unassignStaff(final Long groupId) {
public CommandWrapperBuilder unassignGroupStaff(final Long groupId) {
this.actionName = "UNASSIGNSTAFF";
this.entityName = "GROUP";
this.entityId = groupId;
@@ -395,7 +395,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else if (wrapper.isUpdate()) {
handler = applicationContext.getBean("updateGroupCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUnassignStaff()) {
handler = applicationContext.getBean("unassignStaffCommandHandler", NewCommandSourceHandler.class);
handler = applicationContext.getBean("unassignGroupStaffCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDelete()) {
handler = applicationContext.getBean("deleteGroupCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isGroupActivation()) {
@@ -188,7 +188,7 @@ public class GroupsApiResource {
public String unassignLoanOfficer(@PathParam("groupId") final Long groupId, final String apiRequestBodyAsJson) {
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
.unassignStaff(groupId) //
.unassignGroupStaff(groupId) //
.withJson(apiRequestBodyAsJson) //
.build(); //
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
@@ -255,8 +255,12 @@ public class GroupsApiResource {
final CommandWrapper commandRequest = builder.saveGroupCollectionSheet(groupId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result);
}else if (is(commandParam, "unassignStaff")) {
final CommandWrapper commandRequest = builder.unassignGroupStaff(groupId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result);
} else {
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet", "saveCollectionSheet" });
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet", "saveCollectionSheet", "unassignStaff" });
}
}
@@ -14,18 +14,18 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class UnassignStaffCommandHandler implements NewCommandSourceHandler {
public class UnassignGroupStaffCommandHandler implements NewCommandSourceHandler {
private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
public UnassignStaffCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
public UnassignGroupStaffCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.groupWritePlatformService.unassignStaff(command.entityId(), command);
return this.groupWritePlatformService.unassignGroupOrCenterStaff(command.entityId(), command);
}
}
@@ -0,0 +1,31 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.group.handler;
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.portfolio.group.service.GroupingTypesWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class UnassignStaffFromCenterCommandHandler implements NewCommandSourceHandler {
private final GroupingTypesWritePlatformService writePlatformService;
@Autowired
public UnassignStaffFromCenterCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.writePlatformService = groupWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.unassignGroupOrCenterStaff(command.entityId(), command);
}
}
@@ -22,7 +22,7 @@ public interface GroupingTypesWritePlatformService {
CommandProcessingResult deleteGroup(Long groupId);
CommandProcessingResult unassignStaff(Long groupId, JsonCommand command);
CommandProcessingResult unassignGroupOrCenterStaff(Long groupId, JsonCommand command);
CommandProcessingResult associateClientsToGroup(Long groupId, JsonCommand command);
@@ -305,7 +305,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
@Transactional
@Override
public CommandProcessingResult unassignStaff(final Long grouptId, final JsonCommand command) {
public CommandProcessingResult unassignGroupOrCenterStaff(final Long grouptId, final JsonCommand command) {
this.context.authenticatedUser();