MIFOSX-356: modify api call to unassignStaff from a group
This commit is contained in:
+1
-1
@@ -884,7 +884,7 @@ public class CommandWrapperBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandWrapperBuilder unassignStaff(final Long groupId) {
|
public CommandWrapperBuilder unassignGroupStaff(final Long groupId) {
|
||||||
this.actionName = "UNASSIGNSTAFF";
|
this.actionName = "UNASSIGNSTAFF";
|
||||||
this.entityName = "GROUP";
|
this.entityName = "GROUP";
|
||||||
this.entityId = groupId;
|
this.entityId = groupId;
|
||||||
|
|||||||
+1
-1
@@ -395,7 +395,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
} else if (wrapper.isUpdate()) {
|
} else if (wrapper.isUpdate()) {
|
||||||
handler = applicationContext.getBean("updateGroupCommandHandler", NewCommandSourceHandler.class);
|
handler = applicationContext.getBean("updateGroupCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isUnassignStaff()) {
|
} else if (wrapper.isUnassignStaff()) {
|
||||||
handler = applicationContext.getBean("unassignStaffCommandHandler", NewCommandSourceHandler.class);
|
handler = applicationContext.getBean("unassignGroupStaffCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isDelete()) {
|
} else if (wrapper.isDelete()) {
|
||||||
handler = applicationContext.getBean("deleteGroupCommandHandler", NewCommandSourceHandler.class);
|
handler = applicationContext.getBean("deleteGroupCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isGroupActivation()) {
|
} else if (wrapper.isGroupActivation()) {
|
||||||
|
|||||||
+6
-2
@@ -188,7 +188,7 @@ public class GroupsApiResource {
|
|||||||
public String unassignLoanOfficer(@PathParam("groupId") final Long groupId, final String apiRequestBodyAsJson) {
|
public String unassignLoanOfficer(@PathParam("groupId") final Long groupId, final String apiRequestBodyAsJson) {
|
||||||
|
|
||||||
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||||
.unassignStaff(groupId) //
|
.unassignGroupStaff(groupId) //
|
||||||
.withJson(apiRequestBodyAsJson) //
|
.withJson(apiRequestBodyAsJson) //
|
||||||
.build(); //
|
.build(); //
|
||||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
@@ -255,8 +255,12 @@ public class GroupsApiResource {
|
|||||||
final CommandWrapper commandRequest = builder.saveGroupCollectionSheet(groupId).build();
|
final CommandWrapper commandRequest = builder.saveGroupCollectionSheet(groupId).build();
|
||||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
return this.toApiJsonSerializer.serialize(result);
|
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 {
|
} else {
|
||||||
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet", "saveCollectionSheet" });
|
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet", "saveCollectionSheet", "unassignStaff" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -14,18 +14,18 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UnassignStaffCommandHandler implements NewCommandSourceHandler {
|
public class UnassignGroupStaffCommandHandler implements NewCommandSourceHandler {
|
||||||
|
|
||||||
private final GroupingTypesWritePlatformService groupWritePlatformService;
|
private final GroupingTypesWritePlatformService groupWritePlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UnassignStaffCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
|
public UnassignGroupStaffCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
|
||||||
this.groupWritePlatformService = groupWritePlatformService;
|
this.groupWritePlatformService = groupWritePlatformService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||||
return this.groupWritePlatformService.unassignStaff(command.entityId(), command);
|
return this.groupWritePlatformService.unassignGroupOrCenterStaff(command.entityId(), command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+31
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -22,7 +22,7 @@ public interface GroupingTypesWritePlatformService {
|
|||||||
|
|
||||||
CommandProcessingResult deleteGroup(Long groupId);
|
CommandProcessingResult deleteGroup(Long groupId);
|
||||||
|
|
||||||
CommandProcessingResult unassignStaff(Long groupId, JsonCommand command);
|
CommandProcessingResult unassignGroupOrCenterStaff(Long groupId, JsonCommand command);
|
||||||
|
|
||||||
CommandProcessingResult associateClientsToGroup(Long groupId, JsonCommand command);
|
CommandProcessingResult associateClientsToGroup(Long groupId, JsonCommand command);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -305,7 +305,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult unassignStaff(final Long grouptId, final JsonCommand command) {
|
public CommandProcessingResult unassignGroupOrCenterStaff(final Long grouptId, final JsonCommand command) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user