MIFOSX-108 minor issues fixes.
This commit is contained in:
@@ -33,6 +33,7 @@ import org.mifosng.platform.client.service.ClientReadPlatformService;
|
|||||||
import org.mifosng.platform.group.service.GroupReadPlatformService;
|
import org.mifosng.platform.group.service.GroupReadPlatformService;
|
||||||
import org.mifosng.platform.group.service.GroupWritePlatformService;
|
import org.mifosng.platform.group.service.GroupWritePlatformService;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -64,6 +65,9 @@ public class GroupsApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApiJsonSerializerService apiJsonSerializerService;
|
private ApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
private static final Set<String> typicalResponseParameters = new HashSet<String>(
|
private static final Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("id", "officeId", "name", "externalId", "clientMembers")
|
Arrays.asList("id", "officeId", "name", "externalId", "clientMembers")
|
||||||
);
|
);
|
||||||
@@ -120,14 +124,12 @@ public class GroupsApiResource {
|
|||||||
responseParameters.add("allowedClients");
|
responseParameters.add("allowedClients");
|
||||||
responseParameters.add("allowedOffices");
|
responseParameters.add("allowedOffices");
|
||||||
|
|
||||||
final String extraCriteria;
|
|
||||||
if (officeId != null){
|
if (officeId != null){
|
||||||
extraCriteria = getGroupExtraCriteria(null, officeId, null, null, null);
|
availableClients = this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(officeId);
|
||||||
} else {
|
} else {
|
||||||
extraCriteria = getGroupExtraCriteria(null, group.getOfficeId(), null, null, null);
|
availableClients = this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(group.getOfficeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
availableClients = this.clientReadPlatformService.retrieveAllIndividualClientsForLookup(extraCriteria);
|
|
||||||
availableClients.removeAll(group.clientMembers());
|
availableClients.removeAll(group.clientMembers());
|
||||||
|
|
||||||
allowedOffices = officeReadPlatformService.retrieveAllOfficesForLookup();
|
allowedOffices = officeReadPlatformService.retrieveAllOfficesForLookup();
|
||||||
@@ -151,11 +153,14 @@ public class GroupsApiResource {
|
|||||||
}
|
}
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
responseParameters.addAll(Arrays.asList("allowedClients", "allowedOffices"));
|
responseParameters.addAll(Arrays.asList("officeId", "allowedClients", "allowedOffices"));
|
||||||
|
|
||||||
final String extraCriteria = getGroupExtraCriteria(null, officeId, null, null, null);
|
GroupData groupData;
|
||||||
|
if (officeId != null){
|
||||||
GroupData groupData = this.groupReadPlatformService.retrieveNewGroupDetails(extraCriteria);
|
groupData = this.groupReadPlatformService.retrieveNewGroupDetails(officeId);
|
||||||
|
} else {
|
||||||
|
groupData = this.groupReadPlatformService.retrieveNewGroupDetails(context.authenticatedUser().getOffice().getId());
|
||||||
|
}
|
||||||
|
|
||||||
return this.apiJsonSerializerService.serializeGroupDataToJson(prettyPrint, responseParameters, groupData);
|
return this.apiJsonSerializerService.serializeGroupDataToJson(prettyPrint, responseParameters, groupData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ public class GroupData {
|
|||||||
this.allowedOffices = allowedOffices;
|
this.allowedOffices = allowedOffices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupData(final Collection<ClientLookup> allowedClients, final Collection<OfficeLookup> allowedOffices) {
|
public GroupData(final Long officeId, final Collection<ClientLookup> allowedClients, final Collection<OfficeLookup> allowedOffices) {
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.officeId = null;
|
this.officeId = officeId;
|
||||||
this.officeName = null;
|
this.officeName = null;
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.externalId = null;
|
this.externalId = null;
|
||||||
|
|||||||
+2
@@ -18,6 +18,8 @@ public interface ClientReadPlatformService {
|
|||||||
|
|
||||||
Collection<ClientLookup> retrieveAllIndividualClientsForLookup(String extraCriteria);
|
Collection<ClientLookup> retrieveAllIndividualClientsForLookup(String extraCriteria);
|
||||||
|
|
||||||
|
Collection<ClientLookup> retrieveAllIndividualClientsForLookupByOfficeId(Long officeId);
|
||||||
|
|
||||||
ClientAccountSummaryCollectionData retrieveClientAccountDetails(Long clientId);
|
ClientAccountSummaryCollectionData retrieveClientAccountDetails(Long clientId);
|
||||||
|
|
||||||
Collection<NoteData> retrieveAllClientNotes(Long clientId);
|
Collection<NoteData> retrieveAllClientNotes(Long clientId);
|
||||||
|
|||||||
+11
@@ -114,6 +114,17 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ClientLookup> retrieveAllIndividualClientsForLookupByOfficeId(Long officeId) {
|
||||||
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
|
ClientLookupMapper rm = new ClientLookupMapper();
|
||||||
|
|
||||||
|
String sql = "select " + rm.clientLookupSchema() + " and c.office_id = " + officeId;
|
||||||
|
|
||||||
|
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientData retrieveNewClientDetails() {
|
public ClientData retrieveNewClientDetails() {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ public interface GroupReadPlatformService {
|
|||||||
|
|
||||||
GroupData retrieveGroup(Long groupId);
|
GroupData retrieveGroup(Long groupId);
|
||||||
|
|
||||||
GroupData retrieveNewGroupDetails(String extraCriteria);
|
GroupData retrieveNewGroupDetails(Long officeId);
|
||||||
|
|
||||||
Collection<ClientLookup> retrieveClientMembers(Long groupId);
|
Collection<ClientLookup> retrieveClientMembers(Long groupId);
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -19,6 +19,7 @@ import org.mifosng.platform.infrastructure.JdbcSupport;
|
|||||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
|
import org.mifosng.platform.user.domain.AppUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
@@ -76,16 +77,14 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupData retrieveNewGroupDetails(String extraCriteria) {
|
public GroupData retrieveNewGroupDetails(final Long officeId) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
|
||||||
|
|
||||||
List<ClientLookup> allowedClients = new ArrayList<ClientLookup>(
|
List<ClientLookup> allowedClients = new ArrayList<ClientLookup>(
|
||||||
this.clientReadPlatformService.retrieveAllIndividualClientsForLookup(extraCriteria));
|
this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(officeId));
|
||||||
|
|
||||||
List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup());
|
List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup());
|
||||||
|
|
||||||
return new GroupData(allowedClients, allowedOffices);
|
return new GroupData(officeId, allowedClients, allowedOffices);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class GroupMapper implements RowMapper<GroupData> {
|
private static final class GroupMapper implements RowMapper<GroupData> {
|
||||||
|
|||||||
Reference in New Issue
Block a user