From bddfa98c4ab94daea6c02d699d7477a7a0c0d3ae Mon Sep 17 00:00:00 2001 From: Nayan Ambali Date: Sun, 24 Feb 2013 23:48:48 +0530 Subject: [PATCH] added Staff details to GET /groups api --- .../portfolio/group/data/GroupData.java | 45 ++++++++++++++++--- .../service/GroupReadPlatformServiceImpl.java | 13 ++++-- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java index 7ad51703d..66fed724f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java @@ -21,7 +21,11 @@ public class GroupData { private final String externalId; private final Long officeId; private final String officeName; + private final Long staffId; + private final String staffName; private final Long groupLevel; + private final Long parentId; + private final String parentName; @SuppressWarnings("unused") private final GroupLevelData groupLevelData; private final Collection clientMembers; @@ -36,13 +40,18 @@ public class GroupData { @SuppressWarnings("unused") private final Collection childGroups; - public GroupData(final Long id, final Long officeId, final String officeName, final String name, final String externalId , final Long groupLevel ) { + 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) { this.id = id; this.officeId = officeId; this.officeName = officeName; this.name = name; this.externalId = externalId; - this.groupLevel =groupLevel; + this.groupLevel = groupLevel; + this.parentId = parentId; + this.parentName = parentName; + this.staffId = staffId; + this.staffName = staffName; this.groupLevelData = null; this.clientMembers = null; this.allowedClients = null; @@ -54,13 +63,17 @@ public class GroupData { public GroupData(final GroupData group, final Collection clientMembers, final Collection allowedClients, final Collection allowedOffices, final Collection allowedParentGroups, - final GroupLevelData groupLevelData , final Collection allowedStaffs , final Collection childGroups) { + final GroupLevelData groupLevelData, final Collection allowedStaffs, final Collection childGroups) { 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(); + this.staffName = group.getStaffName(); this.groupLevelData = groupLevelData; this.clientMembers = clientMembers; @@ -72,14 +85,19 @@ public class GroupData { } public GroupData(final Long officeId, final Collection allowedClients, final Collection allowedOffices, - final Collection allowedParentGroups, final GroupLevelData groupLevelData , final Collection allowedStaffs ) { + final Collection allowedParentGroups, final GroupLevelData groupLevelData, + final Collection allowedStaffs) { this.id = null; this.officeId = officeId; this.officeName = null; this.name = null; this.externalId = null; this.clientMembers = null; - this.groupLevel =null; + this.groupLevel = null; + this.parentId = null; + this.parentName = null; + this.staffId = null; + this.staffName = null; this.groupLevelData = groupLevelData; this.allowedClients = allowedClients; this.allowedOffices = allowedOffices; @@ -107,11 +125,26 @@ public class GroupData { public String getOfficeName() { return officeName; } - + public Long getGroupLevel() { return this.groupLevel; } + public Long getParentId() { + return this.parentId; + } + + public Long getStaffId() { + return this.staffId; + } + + public String getStaffName() { + return this.staffName; + } + + public String getParentName() { + return this.parentName; + } public Collection clientMembers() { return this.clientMembers; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java index d42037fbb..f09c7f88d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java @@ -221,8 +221,10 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService { private static final class GroupDataMapper implements RowMapper { public String groupSchema() { - return "g.office_id as officeId, g.level_id as groupLevel , o.name as officeName, g.id as id, g.external_id as externalId, " - + "g.name as name from m_group g join m_office o on o.id = g.office_id"; + return "g.office_id as officeId, g.level_id as groupLevel , 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 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"; } @Override @@ -234,7 +236,12 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService { Long officeId = rs.getLong("officeId"); String officeName = rs.getString("officeName"); Long groupLevel = rs.getLong("groupLevel"); - return new GroupData(id, officeId, officeName, name, externalId, groupLevel); + Long parentId = rs.getLong("parentId"); + String parentName = rs.getString("parentName"); + Long staffId = rs.getLong("staffId"); + String staffName = rs.getString("staffName"); + + return new GroupData(id, officeId, officeName, name, externalId, groupLevel, parentId, parentName, staffId, staffName); } }