diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm
index 3d990ff36..86d319a1e 100644
--- a/api-docs/apiLive.htm
+++ b/api-docs/apiLive.htm
@@ -288,7 +288,7 @@
Create a Center |
List Centers |
|
- Delete a Center |
+ |
|
@@ -296,7 +296,7 @@
|
Retrieve a Center |
Update a Center |
- |
+ Delete a Center |
| Group |
@@ -304,7 +304,7 @@
Create a Group |
List Groups |
|
- Delete a Group |
+ |
|
@@ -312,7 +312,7 @@
|
Retrieve a Group |
Update a Group |
- |
+ Delete a Group |
@@ -2705,12 +2705,33 @@ No Request Body:
Field Descriptions |
+
+ | externalId |
+
+
+ | A place to put an external reference for this center e.g. The ID another system uses. If provided, it must be unique.
+ |
+
| name |
| Name given to the Center. |
+
+ | active |
+
+
+ | Indicates whether this center is to be created as active. If active=true, then activationDate must be provided. If active=false, then the center is created as pending.
+ |
+
+
+ | activationDate |
+
+
+ | The date on which the center became active.
+ |
+
| officeId |
@@ -2724,11 +2745,10 @@ No Request Body:
The staffId of the staff member dealing with this center. The staff member is not specifically the loan officer. |
- | externalId |
+ groupMembers |
- | A place to put an external reference for this center e.g. The ID another system uses. If provided, it must be unique.
- |
+ The array of groupIds to indicate what groups are part of this center. |
@@ -2749,6 +2769,13 @@ GET https://DomainName/mifosng-provider/api/v1/centers/template
{
+ "active": false,
+ "activationDate": [
+ 2013,
+ 4,
+ 18
+ ],
+ "officeId": 1,
"officeOptions": [
{
"id": 1,
@@ -2757,18 +2784,31 @@ GET https://DomainName/mifosng-provider/api/v1/centers/template
},
{
"id": 2,
- "name": "Suboffice",
- "nameDecorated": "....Suboffice"
+ "name": "Branch Office 1",
+ "nameDecorated": "....Branch Office 1"
}
],
"staffOptions": [
{
"id": 1,
- "displayName": "LoanOfficer, HeadOffice"
+ "displayName": "C, Mike"
+ }
+ ],
+ "groupMembersOptions": [
+ {
+ "id": 1,
+ "name": "First Group",
+ "externalId": "000-1A",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".1."
},
{
"id": 2,
- "displayName": "NonLoanOfficer, HeadOffice"
+ "name": "Pending Group",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".2."
}
]
}
@@ -2780,6 +2820,12 @@ GET https://DomainName/mifosng-provider/api/v1/centers/template?officeId=2
{
+ "active": false,
+ "activationDate": [
+ 2013,
+ 4,
+ 18
+ ],
"officeId": 2,
"officeOptions": [
{
@@ -2789,18 +2835,18 @@ GET https://DomainName/mifosng-provider/api/v1/centers/template?officeId=2
},
{
"id": 2,
- "name": "Suboffice",
- "nameDecorated": "....Suboffice"
+ "name": "Branch Office 1",
+ "nameDecorated": "....Branch Office 1"
}
],
"staffOptions": [
{
- "id": 3,
- "displayName": "LoanOfficer, Suboffice"
+ "id": 2,
+ "displayName": "D, Mary"
},
{
- "id": 4,
- "displayName": "NonLoanOfficer, Suboffice"
+ "id": 3,
+ "displayName": "P, Paul"
}
]
}
@@ -2817,7 +2863,7 @@ GET https://DomainName/mifosng-provider/api/v1/centers/template?officeId=2
Mandatory Fields |
- | name, officeId |
+ name, officeId, active, activationDate (if active=true) |
@@ -2826,11 +2872,12 @@ GET https://DomainName/mifosng-provider/api/v1/centers/template?officeId=2
Optional Fields |
- | externalId, staffId |
+ externalId, staffId, groupMembers |
+
Creater a center as pending with no association to groupMembers.
POST https://DomainName/mifosng-provider/api/v1/centers
@@ -2838,15 +2885,43 @@ POST https://DomainName/mifosng-provider/api/v1/centers
POST centers
Content-Type: application/json Request Body:
{
- "name": "apicenter",
- "officeId": 2
+ "name": "First Center (No groups)",
+ "officeId": 1,
+ "active": false
}
{
- "officeId": 2,
- "groupId": 4,
- "resourceId": 4
+ "officeId": 1,
+ "groupId": 8,
+ "resourceId": 8
+}
+
+
+
+
+
Creater a center as active with no association to groupMembers.
+
+POST https://DomainName/mifosng-provider/api/v1/centers
+
+
+POST centers
+Content-Type: application/json Request Body:
+{
+ "name": "centerwithgroup",
+ "officeId": 1,
+ "groupMembers": ["7"],
+ "locale": "en",
+ "dateFormat": "dd MMMM yyyy",
+ "active": true,
+ "activationDate": "01 March 2011"
+}
+
+
+{
+ "officeId": 1,
+ "groupId": 9,
+ "resourceId": 9
}
@@ -2862,20 +2937,20 @@ Content-Type: application/json Request Body:
PUT https://DomainName/mifosng-provider/api/v1/centers/{centerId}
-PUT centers/4
+PUT centers/8
Content-Type: application/json
Request Body:
{
- "name": "apicenter(updated)"
+ "name": "First Center (No groups)",
}
{
- "officeId": 4,
- "groupId": 2,
- "resourceId": 4,
+ "officeId": 8,
+ "groupId": 8,
+ "resourceId": 8,
"changes": {
- "name": "apicenter(updated)"
+ "name": "First Center (No groups) - modified"
}
}
@@ -2886,13 +2961,14 @@ Request Body:
Delete a Center
+
A center can be delete if it is in pending state and has nothing associated with it - groups, loans, savings etc
POST https://DomainName/mifosng-provider/api/v1/centers/{centerId}
-DELETE centers/1
+DELETE centers/8
{
@@ -2903,7 +2979,74 @@ DELETE centers/1
-
+
+
+
+
Retrieve a Center
+
Example Requests:
+
centers/1
+
+
centers/1?associations=groupMembers
+
+
+
Retrieve an existing center with no groups information.
+
+GET https://DomainName/mifosng-provider/api/v1/centers/8
+
+
+{
+ "id": 8,
+ "status": {
+ "id": 100,
+ "code": "groupingStatusType.pending",
+ "value": "Pending"
+ },
+ "active": false,
+ "name": "First Center (No groups)",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".8."
+}
+
+
+
+
Retrieve an existing center with no groups information.
+
+GET https://DomainName/mifosng-provider/api/v1/centers/9?associations=groupMembers
+
+
+{
+ "id": 9,
+ "status": {
+ "id": 300,
+ "code": "groupingStatusType.active",
+ "value": "Active"
+ },
+ "active": true,
+ "activationDate": [
+ 2011,
+ 3,
+ 1
+ ],
+ "name": "centerwithgroup",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".9.",
+ "groupMembers": [
+ {
+ "id": 7,
+ "name": "Othergroup",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".7."
+ }
+ ]
+}
+
+
+
+
+
List Centers
@@ -2917,49 +3060,40 @@ GET https://DomainName/mifosng-provider/api/v1/centers
[
{
- "id": 1,
- "name": "Center 001",
- "externalId": "001",
+ "id": 8,
+ "status": {
+ "id": 100,
+ "code": "groupingStatusType.pending",
+ "value": "Pending"
+ },
+ "active": false,
+ "name": "First Center (No groups)",
"officeId": 1,
"officeName": "Head Office",
- "hierarchy": ".1."
+ "hierarchy": ".8."
},
{
- "id": 3,
- "name": "Suboffice Center",
- "externalId": "002",
- "officeId": 2,
- "officeName": "Suboffice",
- "hierarchy": ".3."
+ "id": 9,
+ "status": {
+ "id": 300,
+ "code": "groupingStatusType.active",
+ "value": "Active"
+ },
+ "active": true,
+ "activationDate": [
+ 2011,
+ 3,
+ 1
+ ],
+ "name": "centerwithgroup",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".9."
}
]
-
-
-
-
-
Retrieve a Center
-
Example Requests:
-
centers/1
-
-
-
-GET https://DomainName/mifosng-provider/api/v1/centers/1
-
-
-{
- "id": 1,
- "name": "Center 001",
- "externalId": "001",
- "officeId": 1,
- "officeName": "Head Office",
- "hierarchy": ".1."
-}
-
-
-
@@ -2980,18 +3114,6 @@ GET https://DomainName/mifosng-provider/api/v1/centers/1
| Name given to the Group. |
-
- | officeId |
-
-
- | The officeId of the office/branch this group is administrated through. |
-
-
- | staffId |
-
-
- | The staffId of the staff member dealing with this group. The staff member is not specifically the loan officer. |
-
| externalId |
@@ -2999,11 +3121,37 @@ GET https://DomainName/mifosng-provider/api/v1/centers/1
A place to put an external reference for this group e.g. The ID another system uses. If provided, it must be unique.
|
+
+ | officeId |
+
+
+ | The officeId of the office/branch this group is administrated through. |
+
+
+ | active |
+
+
+ | Indicates whether this group is to be created as active. If active=true, then activationDate must be provided. If active=false, then the group is created as pending.
+ |
+
+
+ | activationDate |
+
+
+ | The date on which the group became active.
+ |
+
+
+ | staffId |
+
+
+ | The staffId of the staff member dealing with this group. The staff member is not specifically the loan officer. The staff member must be assigned to the same office as this group. |
+
| clientMembers |
- | The individual client members that make up the group. |
+ The individual client members that make up the group. The clients must be assigned to the same office as this group. |
@@ -3014,13 +3162,16 @@ GET https://DomainName/mifosng-provider/api/v1/centers/1
Retrieve Group Template
Example Requests:
-
groups/template?centerId=1
+
groups/template
groups/template?officeId=2
-
groups/template
+
groups/template?centerId=1
+
+
+
Template to create a standard group
GET https://DomainName/mifosng-provider/api/v1/groups/template
@@ -3035,24 +3186,26 @@ GET https://DomainName/mifosng-provider/api/v1/groups/template
},
{
"id": 2,
- "name": "Suboffice",
- "nameDecorated": "....Suboffice"
+ "name": "Branch Office 1",
+ "nameDecorated": "....Branch Office 1"
}
],
"staffOptions": [
{
"id": 1,
- "displayName": "LoanOfficer, HeadOffice"
+ "displayName": "C, Mike"
+ }
+ ],
+ "clientOptions": [
+ {
+ "id": 1,
+ "displayName": "Petra Yton",
+ "officeId": 1,
+ "officeName": "Head Office"
},
{
"id": 2,
- "displayName": "NonLoanOfficer, HeadOffice"
- }
- ],
- "clientOptions": [
- {
- "id": 1,
- "displayName": "Test one",
+ "displayName": "Small shop business",
"officeId": 1,
"officeName": "Head Office"
}
@@ -3061,6 +3214,7 @@ GET https://DomainName/mifosng-provider/api/v1/groups/template
+
Template to create a standard group with specific office known. This will return only staffOptions and clientMembersOptions relevant for the chosen office.
GET https://DomainName/mifosng-provider/api/v1/groups/template?officeId=2
@@ -3075,75 +3229,30 @@ GET https://DomainName/mifosng-provider/api/v1/groups/template?officeId=2
},
{
"id": 2,
- "name": "Suboffice",
- "nameDecorated": "....Suboffice"
+ "name": "Branch Office 1",
+ "nameDecorated": "....Branch Office 1"
}
],
"staffOptions": [
{
- "id": 3,
- "displayName": "LoanOfficer, Suboffice"
+ "id": 2,
+ "displayName": "D, Mary"
},
{
- "id": 4,
- "displayName": "NonLoanOfficer, Suboffice"
+ "id": 3,
+ "displayName": "P, Paul"
}
]
}
+
Template to create a group for an existing center. As an existing center will be assigned to an office, this will return only staffOptions and clientMembersOptions relevant for the chosen center/office.
GET https://DomainName/mifosng-provider/api/v1/groups/template?centerId=1
-{
- "officeId": 1,
- "centerId": 1,
- "centerName": "Center 001",
- "centerOptions": [
- {
- "id": 1,
- "name": "Center 001",
- "externalId": "001",
- "officeId": 1,
- "officeName": "Head Office",
- "hierarchy": ".1."
- }
- ],
- "officeOptions": [
- {
- "id": 1,
- "name": "Head Office",
- "nameDecorated": "Head Office",
- "externalId": "1",
- "openingDate": [
- 2009,
- 1,
- 1
- ],
- "hierarchy": "."
- }
- ],
- "staffOptions": [
- {
- "id": 1,
- "displayName": "LoanOfficer, HeadOffice"
- },
- {
- "id": 2,
- "displayName": "NonLoanOfficer, HeadOffice"
- }
- ],
- "clientOptions": [
- {
- "id": 1,
- "displayName": "Test one",
- "officeId": 1,
- "officeName": "Head Office"
- }
- ]
-}
+
@@ -3157,7 +3266,7 @@ GET https://DomainName/mifosng-provider/api/v1/groups/template?centerId=1
Mandatory Fields |
- | name,officeId |
+ name, officeId, active, activationDate (if active=true) |
@@ -3178,25 +3287,150 @@ POST https://DomainName/mifosng-provider/api/v1/groups
POST groups
Content-Type: application/json Request Body:
{
-"officeId":"1",
-"name":"TA Group"
+ "officeId":"1",
+ "name":"Pending Group",
+ "active": false
+}
+
+
+{
+ "officeId": 1,
+ "groupId": 2,
+ "resourceId": 2
}
POST groups
Content-Type: application/json Request Body:
{
-"officeId":"1",
-"name":"TA Group"
-"externalId": "000-1A",
-"clientMembers": ["1"]
+ "officeId":"1",
+ "name":"First Group",
+ "externalId": "000-1A",
+ "clientMembers": ["1"],
+ "dateFormat": "dd MMMM yyyy",
+ "locale": "en",
+ "active": true,
+ "activationDate": "04 March 2009"
}
{
- "officeId": 2,
- "groupId": 5,
- "resourceId": 5
+ "officeId": 1,
+ "groupId": 1,
+ "resourceId": 1
+}
+
+
+
+
+
+
+
+
Retrieve a Group
+
Example Requests:
+
groups/1
+
+
groups/1?associations=clientMembers
+
+
+
Group with no clientMembers information requested.
+
+GET https://DomainName/mifosng-provider/api/v1/groups/1
+
+
+{
+ "id": 1,
+ "name": "First Group",
+ "externalId": "000-1A",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".1."
+}
+
+
+
+
Group with clientMembers.
+
+GET https://DomainName/mifosng-provider/api/v1/groups/1?associations=clientMembers
+
+
+{
+ "id": 1,
+ "name": "First Group",
+ "externalId": "000-1A",
+ "officeId": 1,
+ "officeName": "Head Office",
+ "hierarchy": ".1.",
+ "clientMembers": [
+ {
+ "id": 1,
+ "accountNo": "000000001",
+ "externalId": "786YYH7",
+ "activationDate": [
+ 2009,
+ 3,
+ 4
+ ],
+ "firstname": "Petra",
+ "lastname": "Yton",
+ "displayName": "Petra Yton",
+ "officeId": 1,
+ "officeName": "Head Office"
+ }
+ ]
+}
+
+
+
+
+
+
+
+
Update a Group
+
+
+
+PUT https://DomainName/mifosng-provider/api/v1/groups/{groupid}
+
+
+PUT groups/1
+Content-Type: application/json
+Request Body:
+{
+ "name": "First Group (changed)"
+}
+
+
+{
+ "officeId": 1,
+ "groupId": 1,
+ "resourceId": 1,
+ "changes": {
+ "name": "First Group (changed)"
+ }
+}
+
+
+
+
+
+
+
+
Delete a Group
+
A group can be deleted if it is in pending state and has nothing associated with it - groups, loans, savings etc
+
+
+
+POST https://DomainName/mifosng-provider/api/v1/groups/{groupid}
+
+
+DELETE groups/2
+
+
+{
+ "officeId": 1,
+ "groupId": 2,
+ "resourceId": 2
}
@@ -3216,164 +3450,24 @@ GET https://DomainName/mifosng-provider/api/v1/groups
[
{
- "id": 10,
- "name": "GroupU(Suboffice)",
- "officeId": 2,
- "officeName": "Suboffice",
- "centerId": 4,
- "centerName": "apicenter(updated)",
- "hierarchy": ""
- },
- {
- "id": 8,
- "name": "AnothergroupUI",
+ "id": 1,
+ "name": "First Group (changed)",
+ "externalId": "000-1A",
"officeId": 1,
"officeName": "Head Office",
- "centerId": 1,
- "centerName": "Center 001",
- "hierarchy": ""
- },
- {
- "id": 7,
- "name": "NewGroupUI",
- "externalId": "0011",
- "officeId": 1,
- "officeName": "Head Office",
- "centerId": 1,
- "centerName": "Center 001",
- "staffId": 1,
- "staffName": "LoanOfficer, HeadOffice",
- "hierarchy": ""
- },
- {
- "id": 9,
- "name": "GroupUCenter",
- "officeId": 1,
- "officeName": "Head Office",
- "centerId": 1,
- "centerName": "Center 001",
- "staffId": 1,
- "staffName": "LoanOfficer, HeadOffice",
- "hierarchy": ""
+ "hierarchy": ".1."
},
{
"id": 2,
- "name": "Group 001-A",
+ "name": "Pending Group",
"officeId": 1,
"officeName": "Head Office",
- "centerId": 1,
- "centerName": "Center 001",
- "hierarchy": ""
- },
- {
- "id": 11,
- "name": "Test(no parents)",
- "officeId": 1,
- "officeName": "Head Office",
- "hierarchy": ".11."
- },
- {
- "id": 12,
- "name": "SubofficeGroup(no parents)",
- "officeId": 2,
- "officeName": "Suboffice",
- "hierarchy": ".12."
+ "hierarchy": ".2."
}
]
-
-
-
-
-
Retrieve a Group
-
Example Requests:
-
groups/12
-
-
-
-GET https://DomainName/mifosng-provider/api/v1/groups/12
-
-
-{
- "id": 12,
- "name": "SubofficeGroup(no parents)",
- "officeId": 2,
- "officeName": "Suboffice",
- "hierarchy": ".12.",
- "clientMembers": [
- {
- "id": 2,
- "accountNo": "000000002",
- "firstname": "Another",
- "lastname": "client",
- "displayName": "Another client",
- "officeId": 2,
- "officeName": "Suboffice",
- "joinedDate": [
- 2012,
- 4,
- 14
- ]
- }
- ]
-}
-
-
-
-
-
-
-
-
Update a Group
-
-
-
-PUT https://DomainName/mifosng-provider/api/v1/groups/{groupid}
-
-
-PUT groups/5
-Content-Type: application/json
-Request Body:
-{
- "name": "apigroup(changed)"
-}
-
-
-{
- "officeId": 5,
- "groupId": 2,
- "resourceId": 5,
- "changes": {
- "name": "apigroup(changed)"
- }
-}
-
-
-
-
-
-
-
-
Delete a Group
-
-
-
-POST https://DomainName/mifosng-provider/api/v1/groups/{groupid}
-
-
-DELETE groups/5
-
-
-{
- "officeId": 5,
- "groupId": 2,
- "resourceId": 5
-}
-
-
-
@@ -13069,7 +13163,7 @@ GET https://DomainName/api/v1/search?query=000000111
Create a Center |
List Centers |
|
- Delete a Center |
+ |
|
@@ -13077,7 +13171,7 @@ GET https://DomainName/api/v1/search?query=000000111
|
Retrieve a Center |
Update a Center |
- |
+ Delete a Center |
| Group |
@@ -13085,7 +13179,7 @@ GET https://DomainName/api/v1/search?query=000000111
Create a Group |
List Groups |
|
- Delete a Group |
+ |
|
@@ -13093,7 +13187,7 @@ GET https://DomainName/api/v1/search?query=000000111
|
Retrieve a Group |
Update a Group |
- |
+ Delete a Group |
diff --git a/mifosng-db/migrations/core_db/V22__alter-group-for-consistency-add-permissions.sql b/mifosng-db/migrations/core_db/V22__alter-group-for-consistency-add-permissions.sql
new file mode 100644
index 000000000..fc24a41d7
--- /dev/null
+++ b/mifosng-db/migrations/core_db/V22__alter-group-for-consistency-add-permissions.sql
@@ -0,0 +1,19 @@
+INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'ACTIVATE_CENTER', 'CENTER', 'ACTIVATE', 1);
+INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'ACTIVATE_CENTER_CHECKER', 'CENTER', 'ACTIVATE', 0);
+
+INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'ACTIVATE_GROUP', 'GROUP', 'ACTIVATE', 1);
+INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'ACTIVATE_GROUP_CHECKER', 'GROUP', 'ACTIVATE', 0);
+
+
+ALTER TABLE `m_group` DROP FOREIGN KEY `FK_m_group_level`;
+ALTER TABLE `m_group`
+CHANGE COLUMN `external_id` `external_id` VARCHAR(100) NULL DEFAULT NULL AFTER `id`,
+CHANGE COLUMN `status_enum` `status_enum` INT(5) NOT NULL DEFAULT '300' AFTER `external_id`,
+CHANGE COLUMN `name` `display_name` VARCHAR(100) NOT NULL AFTER `level_id`,
+CHANGE COLUMN `level_Id` `level_id` INT(11) NOT NULL,
+ADD CONSTRAINT `FK_m_group_level` FOREIGN KEY (`level_id`) REFERENCES `m_group_level` (`id`);
+
+
+ALTER TABLE `m_group`
+DROP COLUMN `is_deleted`,
+ADD COLUMN `activation_date` DATE NULL DEFAULT NULL AFTER `status_enum` ;
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java
index 2bb32b986..b815b1448 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/AuditReadPlatformServiceImpl.java
@@ -32,281 +32,234 @@ import org.springframework.stereotype.Service;
@Service
public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
- private final static Logger logger = LoggerFactory
- .getLogger(AuditReadPlatformServiceImpl.class);
- private final JdbcTemplate jdbcTemplate;
- private final PlatformSecurityContext context;
- private final AppUserReadPlatformService appUserReadPlatformService;
+ private final static Logger logger = LoggerFactory.getLogger(AuditReadPlatformServiceImpl.class);
+ private final JdbcTemplate jdbcTemplate;
+ private final PlatformSecurityContext context;
+ private final AppUserReadPlatformService appUserReadPlatformService;
- @Autowired
- public AuditReadPlatformServiceImpl(final PlatformSecurityContext context,
- final TenantAwareRoutingDataSource dataSource,
- final AppUserReadPlatformService appUserReadPlatformService) {
- this.context = context;
- this.jdbcTemplate = new JdbcTemplate(dataSource);
- this.appUserReadPlatformService = appUserReadPlatformService;
- }
+ @Autowired
+ public AuditReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
+ final AppUserReadPlatformService appUserReadPlatformService) {
+ this.context = context;
+ this.jdbcTemplate = new JdbcTemplate(dataSource);
+ this.appUserReadPlatformService = appUserReadPlatformService;
+ }
- private static final class AuditMapper implements RowMapper {
+ private static final class AuditMapper implements RowMapper {
- public String schema(boolean includeJson, String hierarchy) {
+ public String schema(final boolean includeJson, final String hierarchy) {
- String commandAsJsonString = "";
- if (includeJson)
- commandAsJsonString = ", aud.command_as_json as commandAsJson ";
+ String commandAsJsonString = "";
+ if (includeJson) commandAsJsonString = ", aud.command_as_json as commandAsJson ";
- String partSql = " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName,"
- + " aud.resource_id as resourceId, aud.subresource_id as subresourceId,"
- + " mk.username as maker, aud.made_on_date as madeOnDate, "
- + "ck.username as checker, aud.checked_on_date as checkedOnDate, ev.enum_message_property as processingResult "
- + commandAsJsonString
- + ", "
- + " o.name as officeName, gl.level_name as groupLevelName, g.name as groupName, c.display_name as clientName, "
- + " l.account_no as loanAccountNo, s.account_no as savingsAccountNo "
- + " from m_portfolio_command_source aud "
- + " left join m_appuser mk on mk.id = aud.maker_id"
- + " left join m_appuser ck on ck.id = aud.checker_id"
- + " left join m_office o on o.id = aud.office_id"
- + " left join m_group g on g.id = aud.group_id"
- + " left join m_group_level gl on gl.id = g.level_id"
- + " left join m_client c on c.id = aud.client_id"
- + " left join m_loan l on l.id = aud.loan_id"
- + " left join m_savings_account s on s.id = aud.savings_account_id"
- + " left join r_enum_value ev on ev.enum_name = 'processing_result_enum' and ev.enum_id = aud.processing_result_enum";
+ String partSql = " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName,"
+ + " aud.resource_id as resourceId, aud.subresource_id as subresourceId,"
+ + " mk.username as maker, aud.made_on_date as madeOnDate, "
+ + "ck.username as checker, aud.checked_on_date as checkedOnDate, ev.enum_message_property as processingResult "
+ + commandAsJsonString + ", "
+ + " o.name as officeName, gl.level_name as groupLevelName, g.display_name as groupName, c.display_name as clientName, "
+ + " l.account_no as loanAccountNo, s.account_no as savingsAccountNo " + " from m_portfolio_command_source aud "
+ + " left join m_appuser mk on mk.id = aud.maker_id" + " left join m_appuser ck on ck.id = aud.checker_id"
+ + " left join m_office o on o.id = aud.office_id" + " left join m_group g on g.id = aud.group_id"
+ + " left join m_group_level gl on gl.id = g.level_id" + " left join m_client c on c.id = aud.client_id"
+ + " left join m_loan l on l.id = aud.loan_id" + " left join m_savings_account s on s.id = aud.savings_account_id"
+ + " left join r_enum_value ev on ev.enum_name = 'processing_result_enum' and ev.enum_id = aud.processing_result_enum";
- // data scoping: head office (hierarchy = ".") can see all audit
- // entries
- if (!(hierarchy.equals("."))) {
- partSql += " join m_office o2 on o2.id = aud.office_id and o2.hierarchy like '"
- + hierarchy + "%' ";
- }
+ // data scoping: head office (hierarchy = ".") can see all audit
+ // entries
+ if (!(hierarchy.equals("."))) {
+ partSql += " join m_office o2 on o2.id = aud.office_id and o2.hierarchy like '" + hierarchy + "%' ";
+ }
- return partSql;
- }
+ return partSql;
+ }
- @Override
- public AuditData mapRow(final ResultSet rs,
- @SuppressWarnings("unused") final int rowNum)
- throws SQLException {
+ @Override
+ public AuditData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
- final Long id = rs.getLong("id");
- final String actionName = rs.getString("actionName");
- final String entityName = rs.getString("entityName");
- final Long resourceId = JdbcSupport.getLong(rs, "resourceId");
- final Long subresourceId = JdbcSupport.getLong(rs, "subresourceId");
- final String maker = rs.getString("maker");
- final DateTime madeOnDate = JdbcSupport.getDateTime(rs,
- "madeOnDate");
- final String checker = rs.getString("checker");
- final DateTime checkedOnDate = JdbcSupport.getDateTime(rs,
- "checkedOnDate");
- final String processingResult = rs.getString("processingResult");
- String commandAsJson;
- // commandAsJson might not be on the select list of columns
- try {
- commandAsJson = rs.getString("commandAsJson");
- } catch (SQLException e) {
- commandAsJson = null;
- }
+ final Long id = rs.getLong("id");
+ final String actionName = rs.getString("actionName");
+ final String entityName = rs.getString("entityName");
+ final Long resourceId = JdbcSupport.getLong(rs, "resourceId");
+ final Long subresourceId = JdbcSupport.getLong(rs, "subresourceId");
+ final String maker = rs.getString("maker");
+ final DateTime madeOnDate = JdbcSupport.getDateTime(rs, "madeOnDate");
+ final String checker = rs.getString("checker");
+ final DateTime checkedOnDate = JdbcSupport.getDateTime(rs, "checkedOnDate");
+ final String processingResult = rs.getString("processingResult");
+ String commandAsJson;
+ // commandAsJson might not be on the select list of columns
+ try {
+ commandAsJson = rs.getString("commandAsJson");
+ } catch (SQLException e) {
+ commandAsJson = null;
+ }
- String officeName = rs.getString("officeName");
- String groupLevelName = rs.getString("groupLevelName");
- String groupName = rs.getString("groupName");
- String clientName = rs.getString("clientName");
- String loanAccountNo = rs.getString("loanAccountNo");
- String savingsAccountNo = rs.getString("savingsAccountNo");
+ String officeName = rs.getString("officeName");
+ String groupLevelName = rs.getString("groupLevelName");
+ String groupName = rs.getString("groupName");
+ String clientName = rs.getString("clientName");
+ String loanAccountNo = rs.getString("loanAccountNo");
+ String savingsAccountNo = rs.getString("savingsAccountNo");
- return new AuditData(id, actionName, entityName, resourceId,
- subresourceId, maker, madeOnDate, checker, checkedOnDate,
- processingResult, commandAsJson, officeName,
- groupLevelName, groupName, clientName, loanAccountNo,
- savingsAccountNo);
- }
- }
+ return new AuditData(id, actionName, entityName, resourceId, subresourceId, maker, madeOnDate, checker, checkedOnDate,
+ processingResult, commandAsJson, officeName, groupLevelName, groupName, clientName, loanAccountNo, savingsAccountNo);
+ }
+ }
- @Override
- public Collection retrieveAuditEntries(String extraCriteria,
- boolean includeJson) {
+ @Override
+ public Collection retrieveAuditEntries(final String extraCriteria, final boolean includeJson) {
- String updatedExtraCriteria = "";
- if (StringUtils.isNotBlank(extraCriteria))
- updatedExtraCriteria = " where (" + extraCriteria + ")";
+ String updatedExtraCriteria = "";
+ if (StringUtils.isNotBlank(extraCriteria)) updatedExtraCriteria = " where (" + extraCriteria + ")";
- updatedExtraCriteria += " order by aud.id DESC";
- return retrieveEntries("audit", updatedExtraCriteria, includeJson);
- }
+ updatedExtraCriteria += " order by aud.id DESC";
+ return retrieveEntries("audit", updatedExtraCriteria, includeJson);
+ }
- @Override
- public Collection retrieveAllEntriesToBeChecked(
- String extraCriteria, boolean includeJson) {
+ @Override
+ public Collection retrieveAllEntriesToBeChecked(final String extraCriteria, final boolean includeJson) {
- String updatedExtraCriteria = "";
- if (StringUtils.isNotBlank(extraCriteria))
- updatedExtraCriteria = " where (" + extraCriteria + ")"
- + " and aud.processing_result_enum = 2";
- else
- updatedExtraCriteria = " where aud.processing_result_enum = 2";
+ String updatedExtraCriteria = "";
+ if (StringUtils.isNotBlank(extraCriteria))
+ updatedExtraCriteria = " where (" + extraCriteria + ")" + " and aud.processing_result_enum = 2";
+ else
+ updatedExtraCriteria = " where aud.processing_result_enum = 2";
- updatedExtraCriteria += " order by aud.id";
+ updatedExtraCriteria += " order by aud.id";
- return retrieveEntries("makerchecker", updatedExtraCriteria,
- includeJson);
- }
+ return retrieveEntries("makerchecker", updatedExtraCriteria, includeJson);
+ }
- public Collection retrieveEntries(String useType,
- String extraCriteria, boolean includeJson) {
+ public Collection retrieveEntries(final String useType, final String extraCriteria, final boolean includeJson) {
- if (!(useType.equals("audit") || useType.equals("makerchecker"))) {
- throw new PlatformDataIntegrityException(
- "error.msg.invalid.auditSearchTemplate.useType",
- "Invalid Audit Search Template UseType: " + useType);
- }
+ if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
+ "error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
- AppUser currentUser = context.authenticatedUser();
- String hierarchy = currentUser.getOffice().getHierarchy();
+ AppUser currentUser = context.authenticatedUser();
+ String hierarchy = currentUser.getOffice().getHierarchy();
- final AuditMapper rm = new AuditMapper();
- String sql = "select " + rm.schema(includeJson, hierarchy);
+ final AuditMapper rm = new AuditMapper();
+ String sql = "select " + rm.schema(includeJson, hierarchy);
- Boolean isLimitedChecker = false;
- if (useType.equals("makerchecker")) {
- if (currentUser.hasNotPermissionForAnyOf("ALL_FUNCTIONS",
- "CHECKER_SUPER_USER")) {
- isLimitedChecker = true;
- }
- }
+ Boolean isLimitedChecker = false;
+ if (useType.equals("makerchecker")) {
+ if (currentUser.hasNotPermissionForAnyOf("ALL_FUNCTIONS", "CHECKER_SUPER_USER")) {
+ isLimitedChecker = true;
+ }
+ }
- if (isLimitedChecker) {
- sql += " join m_permission p on p.action_name = aud.action_name and p.entity_name = aud.entity_name and p.code like '%\\_CHECKER'"
- + " join m_role_permission rp on rp.permission_id = p.id"
- + " join m_role r on r.id = rp.role_id "
- + " join m_appuser_role ur on ur.role_id = r.id and ur.appuser_id = "
- + currentUser.getId();
- }
- sql += extraCriteria;
+ if (isLimitedChecker) {
+ sql += " join m_permission p on p.action_name = aud.action_name and p.entity_name = aud.entity_name and p.code like '%\\_CHECKER'"
+ + " join m_role_permission rp on rp.permission_id = p.id"
+ + " join m_role r on r.id = rp.role_id "
+ + " join m_appuser_role ur on ur.role_id = r.id and ur.appuser_id = " + currentUser.getId();
+ }
+ sql += extraCriteria;
- logger.info("sql: " + sql);
+ logger.info("sql: " + sql);
- return this.jdbcTemplate.query(sql, rm, new Object[] {});
- }
+ return this.jdbcTemplate.query(sql, rm, new Object[] {});
+ }
- @Override
- public AuditData retrieveAuditEntry(Long auditId) {
+ @Override
+ public AuditData retrieveAuditEntry(final Long auditId) {
- AppUser currentUser = context.authenticatedUser();
- String hierarchy = currentUser.getOffice().getHierarchy();
+ AppUser currentUser = context.authenticatedUser();
+ String hierarchy = currentUser.getOffice().getHierarchy();
- final AuditMapper rm = new AuditMapper();
+ final AuditMapper rm = new AuditMapper();
- String sql = "select " + rm.schema(true, hierarchy);
- sql += " where aud.id = " + auditId;
+ String sql = "select " + rm.schema(true, hierarchy);
+ sql += " where aud.id = " + auditId;
- return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {});
- }
+ return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {});
+ }
- @Override
- public AuditSearchData retrieveSearchTemplate(String useType) {
+ @Override
+ public AuditSearchData retrieveSearchTemplate(final String useType) {
- if (!(useType.equals("audit") || useType.equals("makerchecker"))) {
- throw new PlatformDataIntegrityException(
- "error.msg.invalid.auditSearchTemplate.useType",
- "Invalid Audit Search Template UseType: " + useType);
- }
+ if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
+ "error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
- AppUser currentUser = context.authenticatedUser();
+ AppUser currentUser = context.authenticatedUser();
- final Collection appUsers = appUserReadPlatformService
- .retrieveSearchTemplate();
+ final Collection appUsers = appUserReadPlatformService.retrieveSearchTemplate();
- String sql = " SELECT distinct(action_name) as actionName FROM m_permission p ";
- sql += makercheckerCapabilityOnly(useType, currentUser);
- sql += " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
- ActionNamesMapper mapper = new ActionNamesMapper();
- List actionNames = this.jdbcTemplate.query(sql, mapper,
- new Object[] {});
+ String sql = " SELECT distinct(action_name) as actionName FROM m_permission p ";
+ sql += makercheckerCapabilityOnly(useType, currentUser);
+ sql += " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
+ ActionNamesMapper mapper = new ActionNamesMapper();
+ List actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
- sql = " select distinct(entity_name) as entityName from m_permission p ";
- sql += makercheckerCapabilityOnly(useType, currentUser);
- sql += " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
- EntityNamesMapper mapper2 = new EntityNamesMapper();
- List entityNames = this.jdbcTemplate.query(sql, mapper2,
- new Object[] {});
+ sql = " select distinct(entity_name) as entityName from m_permission p ";
+ sql += makercheckerCapabilityOnly(useType, currentUser);
+ sql += " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
+ EntityNamesMapper mapper2 = new EntityNamesMapper();
+ List entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
- Collection processingResults = null;
- if (useType.equals("audit")) {
- ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
- processingResults = this.jdbcTemplate.query(mapper3.schema(),
- mapper3, new Object[] {});
- }
+ Collection processingResults = null;
+ if (useType.equals("audit")) {
+ ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
+ processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
+ }
- return new AuditSearchData(appUsers, actionNames, entityNames,
- processingResults);
- }
+ return new AuditSearchData(appUsers, actionNames, entityNames, processingResults);
+ }
- private String makercheckerCapabilityOnly(String useType,
- AppUser currentUser) {
- String sql = "";
- Boolean isLimitedChecker = false;
- if (useType.equals("makerchecker")) {
- if (currentUser.hasNotPermissionForAnyOf("ALL_FUNCTIONS",
- "CHECKER_SUPER_USER")) {
- isLimitedChecker = true;
- }
- }
+ private String makercheckerCapabilityOnly(final String useType, final AppUser currentUser) {
+ String sql = "";
+ Boolean isLimitedChecker = false;
+ if (useType.equals("makerchecker")) {
+ if (currentUser.hasNotPermissionForAnyOf("ALL_FUNCTIONS", "CHECKER_SUPER_USER")) {
+ isLimitedChecker = true;
+ }
+ }
- if (isLimitedChecker) {
- sql += " join m_role_permission rp on rp.permission_id = p.id"
- + " join m_role r on r.id = rp.role_id "
- + " join m_appuser_role ur on ur.role_id = r.id and ur.appuser_id = "
- + currentUser.getId();
+ if (isLimitedChecker) {
+ sql += " join m_role_permission rp on rp.permission_id = p.id" + " join m_role r on r.id = rp.role_id "
+ + " join m_appuser_role ur on ur.role_id = r.id and ur.appuser_id = " + currentUser.getId();
- }
- sql += " where p.action_name is not null and p.action_name <> 'READ' ";
- if (isLimitedChecker) {
- sql += "and p.code like '%\\_CHECKER'";
- }
- return sql;
- }
+ }
+ sql += " where p.action_name is not null and p.action_name <> 'READ' ";
+ if (isLimitedChecker) {
+ sql += "and p.code like '%\\_CHECKER'";
+ }
+ return sql;
+ }
- private static final class ActionNamesMapper implements RowMapper {
+ private static final class ActionNamesMapper implements RowMapper {
- @Override
- public String mapRow(final ResultSet rs,
- @SuppressWarnings("unused") final int rowNum)
- throws SQLException {
+ @Override
+ public String mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
- return rs.getString("actionName");
- }
+ return rs.getString("actionName");
+ }
- }
+ }
- private static final class EntityNamesMapper implements RowMapper {
+ private static final class EntityNamesMapper implements RowMapper {
- @Override
- public String mapRow(final ResultSet rs,
- @SuppressWarnings("unused") final int rowNum)
- throws SQLException {
- return rs.getString("entityName");
- }
+ @Override
+ public String mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
+ return rs.getString("entityName");
+ }
- }
+ }
- private static final class ProcessingResultsMapper implements
- RowMapper {
+ private static final class ProcessingResultsMapper implements RowMapper {
- @Override
- public ProcessingResultLookup mapRow(final ResultSet rs,
- @SuppressWarnings("unused") final int rowNum)
- throws SQLException {
- Long id = JdbcSupport.getLong(rs, "id");
- String processingResult = rs.getString("processingResult");
+ @Override
+ public ProcessingResultLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
+ Long id = JdbcSupport.getLong(rs, "id");
+ String processingResult = rs.getString("processingResult");
- return new ProcessingResultLookup(id, processingResult);
- }
+ return new ProcessingResultLookup(id, processingResult);
+ }
- public String schema() {
- return " select enum_id as id, enum_message_property as processingResult from r_enum_value where enum_name = 'processing_result_enum' "
- + " order by enum_id";
- }
- }
+ public String schema() {
+ return " select enum_id as id, enum_message_property as processingResult from r_enum_value where enum_name = 'processing_result_enum' "
+ + " order by enum_id";
+ }
+ }
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java
index 7fa322196..bb4cf8f3b 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java
@@ -56,6 +56,10 @@ public final class Client extends AbstractPersistable {
@Column(name = "status_enum", nullable = false)
private Integer status;
+ @Column(name = "activation_date", nullable = true)
+ @Temporal(TemporalType.DATE)
+ private Date activationDate;
+
@Column(name = "firstname", length = 50)
private String firstname;
@@ -72,10 +76,6 @@ public final class Client extends AbstractPersistable {
@Column(name = "display_name", length = 100, nullable = false)
private String displayName;
- @Column(name = "activation_date", nullable = true)
- @Temporal(TemporalType.DATE)
- private Date activationDate;
-
@Column(name = "external_id", length = 100, nullable = true, unique = true)
private String externalId;
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java
index dca9a1ee4..6c183f5fd 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java
@@ -292,8 +292,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
private static final class ParentGroupsMapper implements RowMapper {
public String parentGroupsSchema() {
- return "gp.id As groupId , gp.name As groupName from m_client cl JOIN m_group_client gc ON cl.id = gc.client_id "
- + "JOIN m_group gp ON gp.id = gc.group_id WHERE cl.id = ? AND gp.is_deleted = 0 ";
+ return "gp.id As groupId , gp.display_name As groupName from m_client cl JOIN m_group_client gc ON cl.id = gc.client_id "
+ + "JOIN m_group gp ON gp.id = gc.group_id WHERE cl.id = ?";
}
@Override
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
index 0335b8335..39f68331d 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
@@ -84,18 +84,15 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
final Client client = this.clientRepository.findOneWithNotFoundDetection(clientId);
- final Long officeId = client.getOffice().getId();
-
if (client.isNotPending()) { throw new ClientMustBePendingToBeDeletedException(clientId); }
List relatedNotes = this.noteRepository.findByClientId(clientId);
this.noteRepository.deleteInBatch(relatedNotes);
- // client.delete();
this.clientRepository.delete(client);
return new CommandProcessingResultBuilder() //
- .withOfficeId(officeId) //
+ .withOfficeId(client.officeId()) //
.withClientId(clientId) //
.withEntityId(clientId) //
.build();
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java
index f4c3a4e64..e3efd2b89 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java
@@ -171,7 +171,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
public String collectionSheetSchema() {
- return "SELECT gp.name As groupName, "
+ return "SELECT gp.display_name As groupName, "
+ "gp.id As groupId, "
+ "cl.display_name As clientName, "
+ "sf.id As staffId, "
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java
index 6f003d7be..0ced66ebe 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/CentersApiResource.java
@@ -120,8 +120,8 @@ public class CentersApiResource {
}
if (!associationParameters.isEmpty()) {
- if (associationParameters.contains("groups")) {
- center = CenterData.setGroups(center, this.centerReadPlatformService.retriveAssociatedGroups(centerId));
+ if (associationParameters.contains("groupMembers")) {
+ center = CenterData.setGroups(center, this.centerReadPlatformService.retrieveAssociatedGroups(centerId));
}
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java
index f8593dfcc..c0d6d73fa 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupingTypesApiConstants.java
@@ -22,6 +22,13 @@ public class GroupingTypesApiConstants {
public static final String externalIdParamName = "externalId";
public static final String officeIdParamName = "officeId";
public static final String staffIdParamName = "staffId";
+ public static final String activeParamName = "active";
+ public static final String activationDateParamName = "activationDate";
+ public static final String groupMembersParamName = "groupMembers";
+
+ // group parameters
+ public static final String centerIdParamName = "centerId";
+ public static final String clientMembersParamName = "clientMembers";
// response parameters
public static final String hierarchyParamName = "hierarchy";
@@ -32,7 +39,12 @@ public class GroupingTypesApiConstants {
public static final String clientOptionsParamName = "clientOptions";
public static final Set CENTER_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName,
- dateFormatParamName, nameParamName, externalIdParamName, officeIdParamName, staffIdParamName));
+ dateFormatParamName, idParamName, nameParamName, externalIdParamName, officeIdParamName, staffIdParamName, activeParamName,
+ activationDateParamName, groupMembersParamName));
+
+ public static final Set GROUP_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName, dateFormatParamName,
+ idParamName, nameParamName, externalIdParamName, centerIdParamName, officeIdParamName, staffIdParamName, activeParamName,
+ activationDateParamName, clientMembersParamName));
/**
* These parameters will match the class level parameters of
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java
index c3f6c6eab..17fcf9d69 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java
@@ -124,12 +124,19 @@ public class GroupsApiResource {
public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("groupId") final Long groupId) {
this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME);
+ final Set associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
GroupGeneralData group = this.groupReadPlatformService.retrieveOne(groupId);
- Collection membersOfGroup = this.clientReadPlatformService.retrieveClientMembersOfGroup(groupId);
- if (CollectionUtils.isEmpty(membersOfGroup)) {
- membersOfGroup = null;
+ // associations
+ Collection membersOfGroup = null;
+ if (!associationParameters.isEmpty()) {
+ if (associationParameters.contains("clientMembers")) {
+ membersOfGroup = this.clientReadPlatformService.retrieveClientMembersOfGroup(groupId);
+ if (CollectionUtils.isEmpty(membersOfGroup)) {
+ membersOfGroup = null;
+ }
+ }
}
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommand.java
deleted file mode 100644
index 4dea872a8..000000000
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommand.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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.command;
-
-public class GroupCommand {
-
- private final String externalId;
- private final String name;
- private final Long officeId;
- private final Long staffId;
- private final Long parentId;
- private final String[] clientMembers;
- private final String[] childGroups;
-
- public GroupCommand(final String externalId, final String name, final Long officeId, final Long staffId, final String[] clientMembers,
- final String[] childGroups, final Long parentId) {
- this.officeId = officeId;
- this.staffId = staffId;
- this.parentId = parentId;
- this.externalId = externalId;
- this.name = name;
- this.clientMembers = clientMembers;
- this.childGroups = childGroups;
-
- }
-
- public Long getOfficeId() {
- return this.officeId;
- }
-
- public Long getParentId() {
- return this.parentId;
- }
-
- public Long getStaffId() {
- return this.staffId;
- }
-
- public String getExternalId() {
- return this.externalId;
- }
-
- public String getName() {
- return this.name;
- }
-
- public String[] getClientMembers() {
- return this.clientMembers;
- }
-
- public String[] getChildGroups() {
- return this.childGroups;
- }
-
-}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java
index 26b5731ba..277d8c85b 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/CenterData.java
@@ -7,6 +7,8 @@ package org.mifosplatform.portfolio.group.data;
import java.util.Collection;
+import org.joda.time.LocalDate;
+import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.organisation.office.data.OfficeData;
import org.mifosplatform.organisation.staff.data.StaffData;
@@ -16,8 +18,15 @@ import org.mifosplatform.organisation.staff.data.StaffData;
public class CenterData {
private final Long id;
- private final String name;
private final String externalId;
+
+ private final EnumOptionData status;
+ @SuppressWarnings("unused")
+ private final boolean active;
+ private final LocalDate activationDate;
+
+ private final String name;
+
private final Long officeId;
private final String officeName;
private final Long staffId;
@@ -25,51 +34,70 @@ public class CenterData {
private final String hierarchy;
// associations
- @SuppressWarnings("unused")
- private final Collection groups;
+ private final Collection groupMembers;
// template
private final Collection officeOptions;
private final Collection staffOptions;
+ private final Collection groupMembersOptions;
- public static CenterData template(final Long officeId, final Collection officeOptions,
- final Collection staffOptions) {
- return new CenterData(null, null, null, officeId, null, null, null, null, officeOptions, staffOptions, null);
+ public static CenterData template(final Long officeId, final LocalDate activationDate, final Collection officeOptions,
+ final Collection staffOptions, final Collection groupMembersOptions) {
+ return new CenterData(null, null, null, null, activationDate, officeId, null, null, null, null, null, officeOptions, staffOptions,
+ groupMembersOptions);
}
public static CenterData withTemplate(final CenterData templateCenter, final CenterData center) {
- return new CenterData(center.id, center.name, center.externalId, center.officeId, center.officeName, center.staffId,
- center.staffName, center.hierarchy, templateCenter.officeOptions, templateCenter.staffOptions, null);
+ return new CenterData(center.id, center.name, center.externalId, center.status, center.activationDate, center.officeId,
+ center.officeName, center.staffId, center.staffName, center.hierarchy, center.groupMembers, templateCenter.officeOptions,
+ templateCenter.staffOptions, templateCenter.groupMembersOptions);
}
- public static CenterData instance(final Long id, final String name, final String externalId, final Long officeId,
- final String officeName, final Long staffId, final String staffName, final String hierarchy) {
+ public static CenterData instance(final Long id, final String name, final String externalId, final EnumOptionData status,
+ final LocalDate activationDate, final Long officeId, final String officeName, final Long staffId, final String staffName,
+ final String hierarchy) {
+ final Collection groupMembers = null;
final Collection officeOptions = null;
final Collection staffOptions = null;
+ final Collection groupMembersOptions = null;
- return new CenterData(id, name, externalId, officeId, officeName, staffId, staffName, hierarchy, officeOptions, staffOptions, null);
- }
-
- public static CenterData setGroups(final CenterData centerData, final Collection groups){
- return new CenterData(centerData.id, centerData.name, centerData.externalId, centerData.officeId, centerData.officeName, centerData.staffId, centerData.staffName, centerData.hierarchy, centerData.officeOptions, centerData.staffOptions, groups);
+ return new CenterData(id, name, externalId, status, activationDate, officeId, officeName, staffId, staffName, hierarchy,
+ groupMembers, officeOptions, staffOptions, groupMembersOptions);
}
- private CenterData(final Long id, final String name, final String externalId, final Long officeId, final String officeName,
- final Long staffId, final String staffName, final String hierarchy, final Collection officeOptions,
- final Collection staffOptions, final Collection groups) {
+ public static CenterData setGroups(final CenterData centerData, final Collection groupMembers) {
+ return new CenterData(centerData.id, centerData.name, centerData.externalId, centerData.status, centerData.activationDate,
+ centerData.officeId, centerData.officeName, centerData.staffId, centerData.staffName, centerData.hierarchy, groupMembers,
+ centerData.officeOptions, centerData.staffOptions, centerData.groupMembersOptions);
+ }
+
+ private CenterData(final Long id, final String name, final String externalId, final EnumOptionData status,
+ final LocalDate activationDate, final Long officeId, final String officeName, final Long staffId, final String staffName,
+ final String hierarchy, final Collection groupMembers, final Collection officeOptions,
+ final Collection staffOptions, final Collection groupMembersOptions) {
this.id = id;
this.name = name;
this.externalId = externalId;
+ this.status = status;
+ if (status != null) {
+ this.active = status.getId().equals(300L);
+ } else {
+ this.active = false;
+ }
+ this.activationDate = activationDate;
this.officeId = officeId;
this.officeName = officeName;
this.staffId = staffId;
this.staffName = staffName;
this.hierarchy = hierarchy;
+ this.groupMembers = groupMembers;
+
+ //
this.officeOptions = officeOptions;
this.staffOptions = staffOptions;
- this.groups = groups;
+ this.groupMembersOptions = groupMembersOptions;
}
public Long officeId() {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java
index 4254d73dd..29318afcf 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupGeneralData.java
@@ -76,7 +76,7 @@ public class GroupGeneralData {
}
public static GroupGeneralData instance(final Long id, final String name, final String externalId, final Long officeId,
- final String officeName, final Long parentId, final String parentName, final Long staffId, final String staffName,
+ final String officeName, final Long centerId, final String centerName, final Long staffId, final String staffName,
final String hierarchy) {
final Collection clientMembers = null;
@@ -85,12 +85,12 @@ public class GroupGeneralData {
final Collection staffOptions = null;
final Collection clientOptions = null;
- return new GroupGeneralData(id, name, externalId, officeId, officeName, parentId, parentName, staffId, staffName, hierarchy,
+ return new GroupGeneralData(id, name, externalId, officeId, officeName, centerId, centerName, staffId, staffName, hierarchy,
clientMembers, centerOptions, officeOptions, staffOptions, clientOptions);
}
private GroupGeneralData(final Long id, final String name, final String externalId, final Long officeId, final String officeName,
- final Long parentId, final String parentName, final Long staffId, final String staffName, final String hierarchy,
+ final Long centerId, final String centerName, final Long staffId, final String staffName, final String hierarchy,
final Collection clientMembers, final Collection centerOptions,
final Collection officeOptions, final Collection staffOptions, final Collection clientOptions) {
this.id = id;
@@ -98,8 +98,8 @@ public class GroupGeneralData {
this.externalId = externalId;
this.officeId = officeId;
this.officeName = officeName;
- this.centerId = parentId;
- this.centerName = parentName;
+ this.centerId = centerId;
+ this.centerName = centerName;
this.staffId = staffId;
this.staffName = staffName;
this.hierarchy = hierarchy;
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupLookup.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupLookup.java
deleted file mode 100644
index fc79a3493..000000000
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupLookup.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.data;
-
-/**
- * Immutable data object representing groups.
- */
-@Deprecated
-public class GroupLookup {
-
- private final Long id;
- private final String name;
-
- public GroupLookup(final Long id, final String name) {
- this.id = id;
- this.name = name;
- }
-
- public Long getId() {
- return this.id;
- }
-
- public String getName() {
- return this.name;
- }
-}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java
index 8a4177ffb..b1c84d982 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java
@@ -5,6 +5,7 @@
*/
package org.mifosplatform.portfolio.group.domain;
+import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -19,8 +20,11 @@ import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
import org.apache.commons.lang.StringUtils;
+import org.joda.time.LocalDate;
import org.mifosplatform.organisation.office.domain.Office;
import org.mifosplatform.organisation.staff.domain.Staff;
import org.mifosplatform.portfolio.client.domain.Client;
@@ -28,15 +32,20 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_group")
-public class Group extends AbstractPersistable {
+public final class Group extends AbstractPersistable {
- @OneToMany(fetch = FetchType.EAGER)
- @JoinColumn(name = "parent_id")
- private final List children = new LinkedList();
+ @Column(name = "external_id", length = 100, unique = true)
+ private String externalId;
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "parent_id")
- private Group parent;
+ /**
+ * A value from {@link GroupingTypeStatus}.
+ */
+ @Column(name = "status_enum", nullable = false)
+ private Integer status;
+
+ @Column(name = "activation_date", nullable = true)
+ @Temporal(TemporalType.DATE)
+ private Date activationDate;
@ManyToOne
@JoinColumn(name = "office_id", nullable = false)
@@ -46,21 +55,27 @@ public class Group extends AbstractPersistable {
@JoinColumn(name = "staff_id", nullable = true)
private Staff staff;
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "parent_id")
+ private Group parent;
+
+ /*
+ * TODO - kw - it might be possible to just move this to be a java enum type
+ * rather than 'levels' table.
+ */
@ManyToOne
@JoinColumn(name = "level_id", nullable = false)
private GroupLevel groupLevel;
+ @Column(name = "display_name", length = 100, unique = true)
+ private String name;
+
@Column(name = "hierarchy", length = 100)
private String hierarchy;
- @Column(name = "name", length = 100, unique = true)
- private String name;
-
- @Column(name = "external_id", length = 100, unique = true)
- private String externalId;
-
- @Column(name = "is_deleted", nullable = false)
- private boolean deleted = false;
+ @OneToMany(fetch = FetchType.EAGER)
+ @JoinColumn(name = "parent_id")
+ private final List groupMembers = new LinkedList();
@ManyToMany
@JoinTable(name = "m_group_client", joinColumns = @JoinColumn(name = "group_id"), inverseJoinColumns = @JoinColumn(name = "client_id"))
@@ -73,12 +88,20 @@ public class Group extends AbstractPersistable {
}
public static Group newGroup(final Office office, final Staff staff, final Group parent, final GroupLevel groupLevel,
- final String name, final String externalId, final Set clientMembers, final Set childGroups) {
- return new Group(office, staff, parent, groupLevel, name, externalId, clientMembers, childGroups);
+ final String name, final String externalId, final boolean active, final LocalDate activationDate,
+ final Set clientMembers, final Set groupMembers) {
+
+ GroupingTypeStatus status = GroupingTypeStatus.PENDING;
+ if (active) {
+ status = GroupingTypeStatus.ACTIVE;
+ }
+
+ return new Group(office, staff, parent, groupLevel, name, externalId, status, activationDate, clientMembers, groupMembers);
}
public Group(final Office office, final Staff staff, final Group parent, final GroupLevel groupLevel, final String name,
- final String externalId, final Set clientMembers, final Set childGroups) {
+ final String externalId, final GroupingTypeStatus status, final LocalDate activationDate, final Set clientMembers,
+ final Set groupMembers) {
this.office = office;
this.staff = staff;
this.groupLevel = groupLevel;
@@ -88,6 +111,11 @@ public class Group extends AbstractPersistable {
this.parent.addChild(this);
}
+ this.status = status.getValue();
+ if (activationDate != null) {
+ this.activationDate = activationDate.toDate();
+ }
+
if (StringUtils.isNotBlank(name)) {
this.name = name.trim();
} else {
@@ -101,13 +129,21 @@ public class Group extends AbstractPersistable {
if (clientMembers != null) {
this.clientMembers = clientMembers;
}
- if (childGroups != null) {
- this.children.addAll(childGroups);
+ if (groupMembers != null) {
+ this.groupMembers.addAll(groupMembers);
}
}
+ public boolean isNotPending() {
+ return !isPending();
+ }
+
+ public boolean isPending() {
+ return GroupingTypeStatus.fromInt(this.status).isPending();
+ }
+
private void addChild(final Group group) {
- this.children.add(group);
+ this.groupMembers.add(group);
}
public Long getOfficeId() {
@@ -182,22 +218,6 @@ public class Group extends AbstractPersistable {
return this.clientMembers.contains(client);
}
- /**
- * Delete is a soft delete. Updates flag on group so it wont appear
- * in query/report results.
- *
- * Any fields with unique constraints and prepended with id of record.
- */
- public void delete() {
- this.deleted = true;
- this.externalId = getId() + "_" + this.externalId;
- this.name = getId() + "_" + this.name;
- }
-
- public boolean isDeleted() {
- return this.deleted;
- }
-
public void generateHierarchy() {
if (this.parent != null) {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupLevel.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupLevel.java
index 0f32ab9c7..cb9bae6d0 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupLevel.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupLevel.java
@@ -74,5 +74,4 @@ public class GroupLevel extends AbstractPersistable {
public boolean isIdentifiedByParentId(final Long parentLevelId) {
return this.parentId.equals(parentLevelId);
}
-
-}
+}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTypes.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupTypes.java
similarity index 82%
rename from mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTypes.java
rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupTypes.java
index 9a9d83dca..32bb43a79 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupTypes.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupTypes.java
@@ -1,19 +1,19 @@
-package org.mifosplatform.portfolio.group.data;
+package org.mifosplatform.portfolio.group.domain;
import java.util.HashMap;
import java.util.Map;
public enum GroupTypes {
- CENTER(new Long(1), "groupTypes.center", "center"), //
- GROUP(new Long(2), "groupTypes.group", "group"), //
- INVALID(new Long(99), "lendingStrategy.invalid", "invalid");
+ INVALID(0l, "lendingStrategy.invalid", "invalid"), //
+ CENTER(1l, "groupTypes.center", "center"), //
+ GROUP(2l, "groupTypes.group", "group"); //
private Long id;
private String code;
private String value;
- GroupTypes(final Long id, final String code, final String value) {
+ private GroupTypes(final Long id, final String code, final String value) {
this.id = id;
this.code = code;
this.value = value;
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupingTypeEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupingTypeEnumerations.java
new file mode 100644
index 000000000..b3ef8d8c3
--- /dev/null
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupingTypeEnumerations.java
@@ -0,0 +1,40 @@
+/**
+ * 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.domain;
+
+import org.mifosplatform.infrastructure.core.data.EnumOptionData;
+
+public class GroupingTypeEnumerations {
+
+ public static EnumOptionData status(final Integer statusId) {
+ return status(GroupingTypeStatus.fromInt(statusId));
+ }
+
+ public static EnumOptionData status(final GroupingTypeStatus status) {
+ EnumOptionData optionData = new EnumOptionData(GroupingTypeStatus.INVALID.getValue().longValue(),
+ GroupingTypeStatus.INVALID.getCode(), "Invalid");
+ switch (status) {
+ case INVALID:
+ optionData = new EnumOptionData(GroupingTypeStatus.INVALID.getValue().longValue(), GroupingTypeStatus.INVALID.getCode(),
+ "Invalid");
+ break;
+ case PENDING:
+ optionData = new EnumOptionData(GroupingTypeStatus.PENDING.getValue().longValue(), GroupingTypeStatus.PENDING.getCode(),
+ "Pending");
+ break;
+ case ACTIVE:
+ optionData = new EnumOptionData(GroupingTypeStatus.ACTIVE.getValue().longValue(), GroupingTypeStatus.ACTIVE.getCode(),
+ "Active");
+ break;
+ case CLOSED:
+ optionData = new EnumOptionData(GroupingTypeStatus.CLOSED.getValue().longValue(), GroupingTypeStatus.CLOSED.getCode(),
+ "Closed");
+ break;
+ }
+
+ return optionData;
+ }
+}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupingTypeStatus.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupingTypeStatus.java
new file mode 100644
index 000000000..e0add459d
--- /dev/null
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupingTypeStatus.java
@@ -0,0 +1,66 @@
+/**
+ * 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.domain;
+
+/**
+ * Enum representation of grouping type status states.
+ */
+public enum GroupingTypeStatus {
+
+ INVALID(0, "groupingStatusType.invalid"), //
+ PENDING(100, "groupingStatusType.pending"), //
+ ACTIVE(300, "groupingStatusType.active"), //
+ CLOSED(600, "groupingStatusType.closed");
+
+ private final Integer value;
+ private final String code;
+
+ public static GroupingTypeStatus fromInt(final Integer statusValue) {
+
+ GroupingTypeStatus enumeration = GroupingTypeStatus.INVALID;
+ switch (statusValue) {
+ case 100:
+ enumeration = GroupingTypeStatus.PENDING;
+ break;
+ case 300:
+ enumeration = GroupingTypeStatus.ACTIVE;
+ break;
+ case 600:
+ enumeration = GroupingTypeStatus.CLOSED;
+ break;
+ }
+ return enumeration;
+ }
+
+ private GroupingTypeStatus(final Integer value, final String code) {
+ this.value = value;
+ this.code = code;
+ }
+
+ public boolean hasStateOf(final GroupingTypeStatus state) {
+ return this.value.equals(state.getValue());
+ }
+
+ public Integer getValue() {
+ return this.value;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public boolean isPending() {
+ return this.value.equals(GroupingTypeStatus.PENDING.getValue());
+ }
+
+ public boolean isActive() {
+ return this.value.equals(GroupingTypeStatus.ACTIVE.getValue());
+ }
+
+ public boolean isClosed() {
+ return this.value.equals(GroupingTypeStatus.CLOSED.getValue());
+ }
+}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/exception/GroupMustBePendingToBeDeletedException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/exception/GroupMustBePendingToBeDeletedException.java
new file mode 100644
index 000000000..8eea9b705
--- /dev/null
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/exception/GroupMustBePendingToBeDeletedException.java
@@ -0,0 +1,19 @@
+/**
+ * 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.exception;
+
+import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
+
+/**
+ * A {@link RuntimeException} thrown when attempting to delete groups.
+ */
+public class GroupMustBePendingToBeDeletedException extends AbstractPlatformDomainRuleException {
+
+ public GroupMustBePendingToBeDeletedException(final Long id) {
+ super("error.msg.group.cannot.be.deleted", "Group with identifier " + id + " cannot be deleted as it is not in `Pending` state.",
+ id);
+ }
+}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateCenterCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateCenterCommandHandler.java
index 2ea3d46a1..d2fd280d8 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateCenterCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateCenterCommandHandler.java
@@ -8,7 +8,7 @@ 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.GroupWritePlatformService;
+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;
@@ -16,17 +16,16 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class CreateCenterCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
- private static final Long LEVEL_ID = (long) 1;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public CreateCenterCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public CreateCenterCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
- return this.groupWritePlatformService.createGroup(null , LEVEL_ID , command);
+ return this.groupWritePlatformService.createCenter(command);
}
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateGroupCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateGroupCommandHandler.java
index 6bca12166..d89e68d89 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateGroupCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/CreateGroupCommandHandler.java
@@ -8,8 +8,7 @@ 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.data.GroupTypes;
-import org.mifosplatform.portfolio.group.service.GroupWritePlatformService;
+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;
@@ -17,11 +16,10 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class CreateGroupCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
- private static final Long LEVEL_ID = GroupTypes.GROUP.getId();;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public CreateGroupCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public CreateGroupCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
@@ -30,6 +28,6 @@ public class CreateGroupCommandHandler implements NewCommandSourceHandler {
public CommandProcessingResult processCommand(final JsonCommand command) {
final Long centerId = command.longValueOfParameterNamed("centerId");
- return this.groupWritePlatformService.createGroup(centerId , LEVEL_ID , command);
+ return this.groupWritePlatformService.createGroup(centerId, command);
}
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteCenterCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteCenterCommandHandler.java
index 464a38780..d34ad599f 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteCenterCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteCenterCommandHandler.java
@@ -8,7 +8,7 @@ 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.GroupWritePlatformService;
+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;
@@ -16,10 +16,10 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class DeleteCenterCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public DeleteCenterCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public DeleteCenterCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteGroupCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteGroupCommandHandler.java
index 9099cdd30..88b47db1a 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteGroupCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/DeleteGroupCommandHandler.java
@@ -8,7 +8,7 @@ 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.GroupWritePlatformService;
+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;
@@ -16,10 +16,10 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class DeleteGroupCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public DeleteGroupCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public DeleteGroupCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UnassignStaffCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UnassignStaffCommandHandler.java
index e651a8a1f..5e6179f23 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UnassignStaffCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UnassignStaffCommandHandler.java
@@ -8,7 +8,7 @@ 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.GroupWritePlatformService;
+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;
@@ -16,10 +16,10 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class UnassignStaffCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public UnassignStaffCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public UnassignStaffCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateCenterCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateCenterCommandHandler.java
index 2be7f6574..b2bba7595 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateCenterCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateCenterCommandHandler.java
@@ -8,7 +8,7 @@ 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.GroupWritePlatformService;
+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;
@@ -16,10 +16,10 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class UpdateCenterCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public UpdateCenterCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public UpdateCenterCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
@@ -27,6 +27,6 @@ public class UpdateCenterCommandHandler implements NewCommandSourceHandler {
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
- return this.groupWritePlatformService.updateGroup(command.entityId(), command);
+ return this.groupWritePlatformService.updateCenter(command.entityId(), command);
}
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateGroupCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateGroupCommandHandler.java
index 347101c6e..041b07044 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateGroupCommandHandler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/handler/UpdateGroupCommandHandler.java
@@ -8,7 +8,7 @@ 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.GroupWritePlatformService;
+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;
@@ -16,10 +16,10 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class UpdateGroupCommandHandler implements NewCommandSourceHandler {
- private final GroupWritePlatformService groupWritePlatformService;
+ private final GroupingTypesWritePlatformService groupWritePlatformService;
@Autowired
- public UpdateGroupCommandHandler(final GroupWritePlatformService groupWritePlatformService) {
+ public UpdateGroupCommandHandler(final GroupingTypesWritePlatformService groupWritePlatformService) {
this.groupWritePlatformService = groupWritePlatformService;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupCommandFromApiJsonDeserializer.java
deleted file mode 100644
index ad66c1812..000000000
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/serialization/GroupCommandFromApiJsonDeserializer.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * 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.serialization;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-import org.mifosplatform.infrastructure.core.data.ApiParameterError;
-import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
-import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
-import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
-import org.mifosplatform.infrastructure.core.serialization.AbstractFromApiJsonDeserializer;
-import org.mifosplatform.infrastructure.core.serialization.FromApiJsonDeserializer;
-import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
-import org.mifosplatform.portfolio.client.command.ClientCommand;
-import org.mifosplatform.portfolio.group.command.GroupCommand;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.google.gson.JsonElement;
-import com.google.gson.reflect.TypeToken;
-
-/**
- * Implementation of {@link FromApiJsonDeserializer} for {@link ClientCommand}
- * 's.
- */
-@Component
-public final class GroupCommandFromApiJsonDeserializer extends AbstractFromApiJsonDeserializer {
-
- /**
- * The parameters supported for this command.
- */
- private final Set supportedParameters = new HashSet(Arrays.asList("id", "externalId", "name", "officeId", "staffId",
- "centerId", "clientMembers", "childGroups"));
-
- private final FromJsonHelper fromApiJsonHelper;
-
- @Autowired
- public GroupCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) {
- this.fromApiJsonHelper = fromApiJsonHelper;
- }
-
- @Override
- public GroupCommand commandFromApiJson(final String json) {
-
- if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
-
- final Type typeOfMap = new TypeToken