MIFOSX-861 #comment fixed issues with group/client creation
This commit is contained in:
committed by
Vishwas Babu A J
parent
31a8a33ce6
commit
45785dff42
+33
-2
@@ -11909,7 +11909,8 @@ GET https://DomainName/api/v1/staff
|
||||
"officeId": 1,
|
||||
"officeName": "Head Office",
|
||||
"isLoanOfficer": true,
|
||||
"externalId": "17H"
|
||||
"externalId": "17H",
|
||||
"isActive": "true"
|
||||
}
|
||||
]
|
||||
</code>
|
||||
@@ -11935,7 +11936,37 @@ GET https://DomainName/api/v1/staff
|
||||
"officeId": 1,
|
||||
"officeName": "Head Office",
|
||||
"isLoanOfficer": true,
|
||||
"externalId": "17H"
|
||||
"externalId": "17H",
|
||||
"isActive": "true"
|
||||
}
|
||||
</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a id="staff_retrieve" name="staff_retrieve" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>Retrieve a Staff by status</h4>
|
||||
<p>Returns the details of a Staff based on status.</p>
|
||||
<p>By <b>default</b> it Returns all the </b>ACTIVE</b> Staff.</p>
|
||||
<p>If status=INACTIVE, then it returns all <b>INACTIVE</b> Staff.</p>
|
||||
<p>and for status=ALL, it Returns both <b>ACTIVE</b> and <b>INACTIVE</b> Staff.</p>
|
||||
<p>Example Requests:</p>
|
||||
<div class=apiClick>staff?status=active</div>
|
||||
</div>
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">GET https://DomainName/api/v1/staff?status={ACTIVE|INACTIVE|ALL}</code>
|
||||
<code class="method-response">
|
||||
{
|
||||
"id": 1,
|
||||
"firstname": "John",
|
||||
"lastname": "Doe",
|
||||
"displayName": "Doe, John",
|
||||
"officeId": 1,
|
||||
"officeName": "Head Office",
|
||||
"isLoanOfficer": true,
|
||||
"externalId": "17H",
|
||||
"isActive": "true"
|
||||
}
|
||||
</code>
|
||||
</div>
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `m_staff`
|
||||
CHANGE COLUMN `is_active` `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `organisational_role_parent_staff_id`;
|
||||
UPDATE `m_staff` SET `is_active`=1;
|
||||
+3
-2
@@ -79,7 +79,8 @@ public class StaffApiResource {
|
||||
public String retrieveStaff(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("officeId") final Long officeId,
|
||||
@DefaultValue("false") @QueryParam("staffInOfficeHierarchy") final boolean staffInOfficeHierarchy,
|
||||
@DefaultValue("false") @QueryParam("loanOfficersOnly") final boolean loanOfficersOnly) {
|
||||
@DefaultValue("false") @QueryParam("loanOfficersOnly") final boolean loanOfficersOnly,
|
||||
@DefaultValue("active") @QueryParam("status") final String status) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
@@ -87,7 +88,7 @@ public class StaffApiResource {
|
||||
if (staffInOfficeHierarchy) {
|
||||
staff = this.readPlatformService.retrieveAllStaffInOfficeAndItsParentOfficeHierarchy(officeId, loanOfficersOnly);
|
||||
} else {
|
||||
staff = this.readPlatformService.retrieveAllStaff(sqlSearch, officeId, loanOfficersOnly);
|
||||
staff = this.readPlatformService.retrieveAllStaff(sqlSearch, officeId, loanOfficersOnly, status);
|
||||
}
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ public class Staff extends AbstractPersistable<Long> {
|
||||
final boolean isLoanOfficer = command.booleanPrimitiveValueOfParameterNamed(isLoanOfficerParamName);
|
||||
|
||||
final String isActiveParamName = "isActive";
|
||||
final boolean isActive = command.booleanPrimitiveValueOfParameterNamed(isActiveParamName);
|
||||
final Boolean isActive = command.booleanObjectValueOfParameterNamed(isActiveParamName);
|
||||
|
||||
return new Staff(staffOffice, firstname, lastname, externalId, mobileNo, isLoanOfficer, isActive);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class Staff extends AbstractPersistable<Long> {
|
||||
this.externalId = StringUtils.defaultIfEmpty(externalId, null);
|
||||
this.mobileNo = StringUtils.defaultIfEmpty(mobileNo, null);
|
||||
this.loanOfficer = isLoanOfficer;
|
||||
this.active = (isActive == null) ? false : isActive;
|
||||
this.active = (isActive == null) ? true : isActive;
|
||||
deriveDisplayName(firstname);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,5 +23,5 @@ public interface StaffReadPlatformService {
|
||||
*/
|
||||
Collection<StaffData> retrieveAllStaffInOfficeAndItsParentOfficeHierarchy(Long officeId, boolean loanOfficersOnly);
|
||||
|
||||
Collection<StaffData> retrieveAllStaff(String sqlSearch, Long officeId, boolean loanOfficersOnly);
|
||||
Collection<StaffData> retrieveAllStaff(String sqlSearch, Long officeId, boolean loanOfficersOnly, String status);
|
||||
}
|
||||
+17
-5
@@ -10,10 +10,12 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.exception.StaffNotFoundException;
|
||||
import org.omg.PortableInterceptor.ACTIVE;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -68,7 +70,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
||||
|
||||
sqlBuilder.append("s.id as id, s.office_id as officeId, ohierarchy.name as officeName,");
|
||||
sqlBuilder.append("s.firstname as firstname, s.lastname as lastname,");
|
||||
sqlBuilder.append("s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId, s.mobile_no as mobileNo ");
|
||||
sqlBuilder.append("s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId, ");
|
||||
sqlBuilder.append("s.mobile_no as mobileNo, s.is_active as isActive ");
|
||||
sqlBuilder.append("from m_office o ");
|
||||
sqlBuilder.append("join m_office ohierarchy on o.hierarchy like concat(ohierarchy.hierarchy, '%') ");
|
||||
sqlBuilder.append("join m_staff s on s.office_id = ohierarchy.id ");
|
||||
@@ -163,8 +166,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<StaffData> retrieveAllStaff(final String sqlSearch, final Long officeId, final boolean loanOfficersOnly) {
|
||||
final String extraCriteria = getStaffCriteria(sqlSearch, officeId, loanOfficersOnly);
|
||||
public Collection<StaffData> retrieveAllStaff(final String sqlSearch, final Long officeId, final boolean loanOfficersOnly, final String status) {
|
||||
final String extraCriteria = getStaffCriteria(sqlSearch, officeId, loanOfficersOnly, status);
|
||||
return retrieveAllStaff(extraCriteria);
|
||||
}
|
||||
|
||||
@@ -179,7 +182,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
private String getStaffCriteria(final String sqlSearch, final Long officeId, final boolean loanOfficersOnly) {
|
||||
private String getStaffCriteria(final String sqlSearch, final Long officeId, final boolean loanOfficersOnly, final String status) {
|
||||
|
||||
final StringBuffer extraCriteria = new StringBuffer(200);
|
||||
|
||||
@@ -192,7 +195,16 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
||||
if (loanOfficersOnly) {
|
||||
extraCriteria.append(" and s.is_loan_officer is true ");
|
||||
}
|
||||
|
||||
// Passing status parameter to get ACTIVE (By Default), INACTIVE or ALL (Both active and Inactive) employees
|
||||
if (status.equalsIgnoreCase("active")) {
|
||||
extraCriteria.append(" and is_active = 1 ");
|
||||
} else if (status.equalsIgnoreCase("inActive")) {
|
||||
extraCriteria.append(" and is_active = 0 ");
|
||||
} else if (status.equalsIgnoreCase("all")) {}
|
||||
else {
|
||||
throw new UnrecognizedQueryParamException("status", status, new Object[] { "all", "active", "inactive" });
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(extraCriteria.toString())) {
|
||||
extraCriteria.delete(0, 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user