Merge pull request #665 from ashok-conflux/MIFOSX-783
display parent offices staff for creating a center
This commit is contained in:
+7
-4
@@ -12,6 +12,7 @@ import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
@@ -98,7 +99,8 @@ public class CentersApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("command") final String commandParam,
|
||||
@QueryParam("officeId") final Long officeId) {
|
||||
@QueryParam("officeId") final Long officeId,
|
||||
@DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME);
|
||||
|
||||
@@ -109,7 +111,7 @@ public class CentersApiResource {
|
||||
GroupingTypesApiConstants.CENTER_RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
final CenterData template = this.centerReadPlatformService.retrieveTemplate(officeId);
|
||||
final CenterData template = this.centerReadPlatformService.retrieveTemplate(officeId, staffInSelectedOfficeOnly);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.centerApiJsonSerializer.serialize(settings, template, GroupingTypesApiConstants.CENTER_RESPONSE_DATA_PARAMETERS);
|
||||
@@ -138,7 +140,8 @@ public class CentersApiResource {
|
||||
@Path("{centerId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("centerId") final Long centerId) {
|
||||
public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("centerId") final Long centerId,
|
||||
@DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME);
|
||||
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
@@ -148,7 +151,7 @@ public class CentersApiResource {
|
||||
|
||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
if (template) {
|
||||
final CenterData templateCenter = this.centerReadPlatformService.retrieveTemplate(center.officeId());
|
||||
final CenterData templateCenter = this.centerReadPlatformService.retrieveTemplate(center.officeId(), staffInSelectedOfficeOnly);
|
||||
center = CenterData.withTemplate(templateCenter, center);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
|
||||
public interface CenterReadPlatformService {
|
||||
|
||||
CenterData retrieveTemplate(Long officeId);
|
||||
CenterData retrieveTemplate(Long officeId, boolean staffInSelectedOfficeOnly);
|
||||
|
||||
CenterData retrieveOne(Long centerId);
|
||||
|
||||
|
||||
+10
-2
@@ -239,13 +239,21 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
|
||||
}
|
||||
|
||||
@Override
|
||||
public CenterData retrieveTemplate(final Long officeId) {
|
||||
public CenterData retrieveTemplate(final Long officeId, final boolean staffInSelectedOfficeOnly) {
|
||||
|
||||
final Long officeIdDefaulted = defaultToUsersOfficeIfNull(officeId);
|
||||
|
||||
final Collection<OfficeData> officeOptions = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
|
||||
|
||||
final boolean loanOfficersOnly = false;
|
||||
Collection<StaffData> staffOptions = null;
|
||||
if (staffInSelectedOfficeOnly) {
|
||||
staffOptions = this.staffReadPlatformService.retrieveAllStaffForDropdown(officeIdDefaulted);
|
||||
} else {
|
||||
staffOptions = this.staffReadPlatformService.retrieveAllStaffInOfficeAndItsParentOfficeHierarchy(officeIdDefaulted,
|
||||
loanOfficersOnly);
|
||||
}
|
||||
|
||||
Collection<StaffData> staffOptions = this.staffReadPlatformService.retrieveAllStaffForDropdown(officeIdDefaulted);
|
||||
if (CollectionUtils.isEmpty(staffOptions)) {
|
||||
staffOptions = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user