incorp review comments
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ALTER TABLE m_group MODIFY name VARCHAR(100) NOT NULL;
|
||||
+7
-3
@@ -45,9 +45,13 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class GroupsApiResource {
|
||||
|
||||
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "name", "externalId",
|
||||
"clientMembers", "allowedClients", "allowedOffices", "allowedParentGroups", "groupLevel", "allowedStaffs", "childGroups"));
|
||||
|
||||
/*
|
||||
* GROUP_DATA_PARAMETERS is used by ToApiJsonSerializer<E>, make sure E's properties and E_PARAMETERS are in same
|
||||
*/
|
||||
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "externalId", "officeId",
|
||||
"officeName", "staffId", "staffName", "parentId", "parentName", "hierarchy", "groupSummaryData", "groupLevelData",
|
||||
"clientMembers", "allowedClients", "allowedOffices", "allowedParentGroups", "allowedStaffs", "childGroups"));
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final GroupReadPlatformService groupReadPlatformService;
|
||||
private final ToApiJsonSerializer<GroupData> toApiJsonSerializer;
|
||||
|
||||
+8
-17
@@ -23,12 +23,11 @@ public class GroupData {
|
||||
private final String officeName;
|
||||
private final Long staffId;
|
||||
private final String staffName;
|
||||
private final Long groupLevel;
|
||||
private final Long parentId;
|
||||
private final String parentName;
|
||||
private final String hierarchy;
|
||||
@SuppressWarnings("unused")
|
||||
private final GroupSummaryData groupSummaryData;
|
||||
private final GroupSummary groupSummaryData;
|
||||
@SuppressWarnings("unused")
|
||||
private final GroupLevelData groupLevelData;
|
||||
private final Collection<ClientLookup> clientMembers;
|
||||
@@ -37,21 +36,19 @@ public class GroupData {
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<OfficeData> allowedOffices;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<GroupLookupData> allowedParentGroups;
|
||||
private final Collection<GroupLookup> allowedParentGroups;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<StaffData> allowedStaffs;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<GroupLookupData> childGroups;
|
||||
private final Collection<GroupLookup> childGroups;
|
||||
|
||||
public GroupData(final Long id, final Long officeId, final String officeName, final String name, final String externalId,
|
||||
final Long groupLevel, final Long parentId, final String parentName, final Long staffId, final String staffName,
|
||||
final String hierarchy) {
|
||||
final Long parentId, final String parentName, final Long staffId, final String staffName, final String hierarchy) {
|
||||
this.id = id;
|
||||
this.officeId = officeId;
|
||||
this.officeName = officeName;
|
||||
this.name = name;
|
||||
this.externalId = externalId;
|
||||
this.groupLevel = groupLevel;
|
||||
this.parentId = parentId;
|
||||
this.parentName = parentName;
|
||||
this.staffId = staffId;
|
||||
@@ -68,15 +65,14 @@ public class GroupData {
|
||||
}
|
||||
|
||||
public GroupData(final GroupData group, final Collection<ClientLookup> clientMembers, final Collection<ClientLookup> allowedClients,
|
||||
final Collection<OfficeData> allowedOffices, final Collection<GroupLookupData> allowedParentGroups,
|
||||
final GroupLevelData groupLevelData, final Collection<StaffData> allowedStaffs, final Collection<GroupLookupData> childGroups,
|
||||
final GroupSummaryData groupSummaryData) {
|
||||
final Collection<OfficeData> allowedOffices, final Collection<GroupLookup> allowedParentGroups,
|
||||
final GroupLevelData groupLevelData, final Collection<StaffData> allowedStaffs, final Collection<GroupLookup> childGroups,
|
||||
final GroupSummary groupSummaryData) {
|
||||
this.id = group.getId();
|
||||
this.officeId = group.getOfficeId();
|
||||
this.officeName = group.getOfficeName();
|
||||
this.name = group.getName();
|
||||
this.externalId = group.getExternalId();
|
||||
this.groupLevel = group.getGroupLevel();
|
||||
this.parentId = group.getParentId();
|
||||
this.parentName = group.getParentName();
|
||||
this.staffId = group.getStaffId();
|
||||
@@ -94,7 +90,7 @@ public class GroupData {
|
||||
}
|
||||
|
||||
public GroupData(final Long officeId, final Collection<ClientLookup> allowedClients, final Collection<OfficeData> allowedOffices,
|
||||
final Collection<GroupLookupData> allowedParentGroups, final GroupLevelData groupLevelData,
|
||||
final Collection<GroupLookup> allowedParentGroups, final GroupLevelData groupLevelData,
|
||||
final Collection<StaffData> allowedStaffs) {
|
||||
this.id = null;
|
||||
this.officeId = officeId;
|
||||
@@ -102,7 +98,6 @@ public class GroupData {
|
||||
this.name = null;
|
||||
this.externalId = null;
|
||||
this.clientMembers = null;
|
||||
this.groupLevel = null;
|
||||
this.parentId = null;
|
||||
this.parentName = null;
|
||||
this.staffId = null;
|
||||
@@ -137,10 +132,6 @@ public class GroupData {
|
||||
return this.officeName;
|
||||
}
|
||||
|
||||
public Long getGroupLevel() {
|
||||
return this.groupLevel;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,12 +8,12 @@ package org.mifosplatform.portfolio.group.data;
|
||||
/**
|
||||
* Immutable data object representing groups.
|
||||
*/
|
||||
public class GroupLookupData {
|
||||
public class GroupLookup {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
|
||||
public GroupLookupData(final Long id, final String name) {
|
||||
public GroupLookup(final Long id, final String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
+2
-2
@@ -9,14 +9,14 @@ import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.organisation.monetary.data.MoneyData;
|
||||
|
||||
public class GroupSummaryData {
|
||||
public class GroupSummary {
|
||||
|
||||
private final Long totalActiveClients;
|
||||
private final Long totalChildGroups;
|
||||
private final Collection<MoneyData> totalLoanPortfolio;
|
||||
private final Collection<MoneyData> totalSavings;
|
||||
|
||||
public GroupSummaryData(final Long totalActiveClients, final Long totalChildGroups, final Collection<MoneyData> totalLoanPortfolio,
|
||||
public GroupSummary(final Long totalActiveClients, final Long totalChildGroups, final Collection<MoneyData> totalLoanPortfolio,
|
||||
final Collection<MoneyData> totalSavings) {
|
||||
this.totalActiveClients = totalActiveClients;
|
||||
this.totalChildGroups = totalChildGroups;
|
||||
+13
-4
@@ -80,6 +80,13 @@ public final class GroupCommandFromApiJsonDeserializer extends AbstractFromApiJs
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("group");
|
||||
|
||||
/*
|
||||
* Name is a mandatory field and not exceeding length 100 character
|
||||
*/
|
||||
final String nameParameterName = "name";
|
||||
final String name = this.fromApiJsonHelper.extractStringNamed(nameParameterName, element);
|
||||
baseDataValidator.reset().parameter(nameParameterName).value(name).notNull().notExceedingLengthOf(100);
|
||||
|
||||
final String externalIdParameterName = "externalId";
|
||||
if (this.fromApiJsonHelper.parameterExists(externalIdParameterName, element)) {
|
||||
@@ -87,11 +94,13 @@ public final class GroupCommandFromApiJsonDeserializer extends AbstractFromApiJs
|
||||
baseDataValidator.reset().parameter(externalIdParameterName).value(externalId).ignoreIfNull().notExceedingLengthOf(100);
|
||||
}
|
||||
|
||||
/*
|
||||
* OfficeId is mandatory field
|
||||
*/
|
||||
final String officeIdParameterName = "officeId";
|
||||
if (this.fromApiJsonHelper.parameterExists(officeIdParameterName, element)) {
|
||||
final Long officeId = this.fromApiJsonHelper.extractLongNamed(officeIdParameterName, element);
|
||||
baseDataValidator.reset().parameter(officeIdParameterName).value(officeId).notNull().integerGreaterThanZero();
|
||||
}
|
||||
final Long officeId = this.fromApiJsonHelper.extractLongNamed(officeIdParameterName, element);
|
||||
baseDataValidator.reset().parameter(officeIdParameterName).value(officeId).notNull().integerGreaterThanZero();
|
||||
|
||||
|
||||
final String parentIdParameterName = "parentId";
|
||||
if (this.fromApiJsonHelper.parameterExists(parentIdParameterName, element)) {
|
||||
|
||||
+5
-3
@@ -14,7 +14,7 @@ import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLevelData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLookupData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLookup;
|
||||
|
||||
public interface GroupReadPlatformService {
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface GroupReadPlatformService {
|
||||
|
||||
Collection<GroupAccountSummaryData> retrieveGroupLoanAccountsByLoanOfficerId(Long groupId, Long loanOfficerId);
|
||||
|
||||
Collection<GroupLookupData> retrieveAllGroupsbyOfficeIdAndLevelId(Long officeId, Long levelId);
|
||||
Collection<GroupLookup> retrieveAllGroupsbyOfficeIdAndLevelId(Long officeId, Long levelId);
|
||||
|
||||
GroupLevelData retrieveGroupLevelDetails(Long levelId);
|
||||
|
||||
@@ -38,7 +38,7 @@ public interface GroupReadPlatformService {
|
||||
|
||||
GroupData retrieveGroupDetails(Long groupId, boolean template);
|
||||
|
||||
Collection<GroupLookupData> retrieveChildGroupsbyGroupId(Long groupId);
|
||||
Collection<GroupLookup> retrieveChildGroupsbyGroupId(Long groupId);
|
||||
|
||||
Long retrieveTotalNoOfChildGroups(Long groupId);
|
||||
|
||||
@@ -49,4 +49,6 @@ public interface GroupReadPlatformService {
|
||||
GroupData retrieveNewChildGroupDetails(Long officeId, Long levelId, Long parentGroupId);
|
||||
|
||||
StaffData retrieveStaffsbyId(Long staffId);
|
||||
|
||||
Long getLevelIdByGroupId(final Long groupId);
|
||||
}
|
||||
|
||||
+27
-19
@@ -28,8 +28,8 @@ import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLevelData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLookupData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupSummaryData;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLookup;
|
||||
import org.mifosplatform.portfolio.group.data.GroupSummary;
|
||||
import org.mifosplatform.portfolio.group.domain.Group;
|
||||
import org.mifosplatform.portfolio.group.domain.GroupRepository;
|
||||
import org.mifosplatform.portfolio.group.exception.GroupLevelNotFoundException;
|
||||
@@ -93,7 +93,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GroupLookupData> retrieveAllGroupsbyOfficeIdAndLevelId(final Long officeId, final Long levelId) {
|
||||
public Collection<GroupLookup> retrieveAllGroupsbyOfficeIdAndLevelId(final Long officeId, final Long levelId) {
|
||||
|
||||
this.context.authenticatedUser();
|
||||
final GroupLookupMapper rm = new GroupLookupMapper();
|
||||
@@ -101,7 +101,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { officeId, levelId });
|
||||
}
|
||||
|
||||
private GroupLookupData retrieveGroupbyId(final Long parentGroupId) {
|
||||
private GroupLookup retrieveGroupbyId(final Long parentGroupId) {
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
final GroupLookupMapper rm = new GroupLookupMapper();
|
||||
@@ -114,7 +114,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GroupLookupData> retrieveChildGroupsbyGroupId(final Long groupId) {
|
||||
public Collection<GroupLookup> retrieveChildGroupsbyGroupId(final Long groupId) {
|
||||
|
||||
this.context.authenticatedUser();
|
||||
final GroupLookupMapper rm = new GroupLookupMapper();
|
||||
@@ -155,10 +155,10 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
|
||||
final List<OfficeData> allowedOffices = new ArrayList<OfficeData>(this.officeReadPlatformService.retrieveAllOfficesForDropdown());
|
||||
|
||||
List<GroupLookupData> allowedParentGroups = null;
|
||||
List<GroupLookup> allowedParentGroups = null;
|
||||
|
||||
if (groupLevelData.getParentLevelId() != null) {
|
||||
allowedParentGroups = new ArrayList<GroupLookupData>(retrieveAllGroupsbyOfficeIdAndLevelId(officeId,
|
||||
allowedParentGroups = new ArrayList<GroupLookup>(retrieveAllGroupsbyOfficeIdAndLevelId(officeId,
|
||||
groupLevelData.getParentLevelId()));
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
final List<OfficeData> allowedOffices = new ArrayList<OfficeData>();
|
||||
allowedOffices.add(this.officeReadPlatformService.retrieveOffice(officeId));
|
||||
|
||||
final List<GroupLookupData> allowedParentGroups = new ArrayList<GroupLookupData>();
|
||||
final List<GroupLookup> allowedParentGroups = new ArrayList<GroupLookup>();
|
||||
allowedParentGroups.add(retrieveGroupbyId(parentGroupId));
|
||||
|
||||
final List<StaffData> allowedStaffs = new ArrayList<StaffData>();
|
||||
@@ -206,17 +206,17 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
final Collection<ClientLookup> clientMembers = retrieveClientMembers(groupId);
|
||||
Collection<ClientLookup> availableClients = null;
|
||||
Collection<OfficeData> allowedOffices = null;
|
||||
Collection<GroupLookupData> allowedParentGroups = null;
|
||||
final GroupLevelData groupLevelData = retrieveGroupLevelDetails(group.getGroupLevel());
|
||||
Collection<GroupLookup> allowedParentGroups = null;
|
||||
final GroupLevelData groupLevelData = retrieveGroupLevelDetails(getLevelIdByGroupId(groupId));
|
||||
;
|
||||
Collection<StaffData> allowedStaffs = null;
|
||||
final Collection<GroupLookupData> childGroups = retrieveChildGroupsbyGroupId(groupId);
|
||||
final Collection<GroupLookup> childGroups = retrieveChildGroupsbyGroupId(groupId);
|
||||
|
||||
final Long totalActiveClients = retrieveTotalClients(group.getHierarchy());
|
||||
final Long totalChildGroups = retrieveTotalNoOfChildGroups(groupId);
|
||||
final Collection<MoneyData> totalLoanPortfolio = retrieveGroupLoanPortfolio(group.getHierarchy());
|
||||
|
||||
final GroupSummaryData groupSummaryData = new GroupSummaryData(totalActiveClients, totalChildGroups, totalLoanPortfolio, null);
|
||||
final GroupSummary groupSummaryData = new GroupSummary(totalActiveClients, totalChildGroups, totalLoanPortfolio, null);
|
||||
|
||||
group = new GroupData(group, clientMembers, availableClients, allowedOffices, allowedParentGroups, groupLevelData, allowedStaffs,
|
||||
childGroups, groupSummaryData);
|
||||
@@ -265,6 +265,15 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLevelIdByGroupId(final Long groupId){
|
||||
|
||||
this.context.authenticatedUser();
|
||||
final String sqlTotalClients = "SELECT g.level_Id as levelId FROM m_group g WHERE g.id = ?";
|
||||
return this.jdbcTemplate.queryForLong(sqlTotalClients, new Object[] { groupId });
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long retrieveTotalClients(final String hierarchy) {
|
||||
|
||||
@@ -323,7 +332,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
private static final class GroupDataMapper implements RowMapper<GroupData> {
|
||||
|
||||
public String groupSchema() {
|
||||
return "g.office_id as officeId, g.level_id as groupLevel , g.parent_id as parentId , o.name as officeName,"
|
||||
return "g.office_id as officeId, g.parent_id as parentId , o.name as officeName,"
|
||||
+ " g.id as id, g.external_id as externalId, g.name as name , s.display_name as staffName , pg.name as"
|
||||
+ " parentName , g.staff_id as staffId , g.hierarchy as hierarchy from m_group g join m_office o on o.id = g.office_id left join "
|
||||
+ "m_staff s on s.id = g.staff_id left join m_group pg on pg.id = g.parent_id";
|
||||
@@ -337,32 +346,31 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long officeId = rs.getLong("officeId");
|
||||
final String officeName = rs.getString("officeName");
|
||||
final Long groupLevel = rs.getLong("groupLevel");
|
||||
final Long parentId = JdbcSupport.getLong(rs, "parentId");
|
||||
final Long parentId = rs.getLong("parentId");
|
||||
final String parentName = rs.getString("parentName");
|
||||
final Long staffId = JdbcSupport.getLong(rs, "staffId");
|
||||
final String staffName = rs.getString("staffName");
|
||||
final String hierarchy = rs.getString("hierarchy");
|
||||
|
||||
return new GroupData(id, officeId, officeName, name, externalId, groupLevel, parentId, parentName, staffId, staffName,
|
||||
return new GroupData(id, officeId, officeName, name, externalId, parentId, parentName, staffId, staffName,
|
||||
hierarchy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final class GroupLookupMapper implements RowMapper<GroupLookupData> {
|
||||
private static final class GroupLookupMapper implements RowMapper<GroupLookup> {
|
||||
|
||||
public String groupLookupSchema() {
|
||||
return "g.id as id, g.name as name ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupLookupData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
public GroupLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = rs.getLong("id");
|
||||
final String name = rs.getString("name");
|
||||
|
||||
return new GroupLookupData(id, name);
|
||||
return new GroupLookup(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user