Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add server version, date created and date edited to Practitioner and Organization Resources #1065

Merged
merged 7 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<artifactId>opensrp-server-web</artifactId>
<packaging>war</packaging>
<version>2.9.0-SNAPSHOT</version>
<version>2.9.1-SNAPSHOT</version>
<name>opensrp-server-web</name>
<description>OpenSRP Server Web Application</description>
<url>https://github.com/OpenSRP/opensrp-server-web</url>
Expand All @@ -24,7 +24,7 @@
<redis.jedis.version>3.8.0</redis.jedis.version>
<opensrp.updatePolicy>always</opensrp.updatePolicy>
<nexus-staging-maven-plugin.version>1.5.1</nexus-staging-maven-plugin.version>
<opensrp.core.version>2.13.0-SNAPSHOT</opensrp.core.version>
<opensrp.core.version>2.13.1-SNAPSHOT</opensrp.core.version>
<opensrp.connector.version>2.4.0-SNAPSHOT</opensrp.connector.version>
<opensrp.interface.version>2.0.1-SNAPSHOT</opensrp.interface.version>
<powermock.version>2.0.5</powermock.version>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/opensrp/web/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ public interface Constants {
String DEFAULT_EXCEPTION_HANDLER_MESSAGE = "The server encountered an error processing the request." ;

public static final String RETURN_COUNT= "return_count";

public static final String TOTAL_RECORDS = "total_records";

public static final String PAGE_NUMBER = "pageNumber";

public static final String PAGE_SIZE = "pageSize";

public static final String SERVER_VERSION = "serverVersion";

public static final String ORDER_BY_TYPE = "orderByType";

public static final String ORDER_BY_FIELD_NAME = "orderByFieldName";

public static final String DATETIME_IN_UTC_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";

String LOCATIONS = "locations";

String NULL = "null";
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/org/opensrp/web/rest/OrganizationResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.opensrp.web.Constants.ORDER_BY_FIELD_NAME;
import static org.opensrp.web.Constants.ORDER_BY_TYPE;
import static org.opensrp.web.Constants.PAGE_NUMBER;
import static org.opensrp.web.Constants.PAGE_SIZE;
import static org.opensrp.web.Constants.ORDER_BY_TYPE;
import static org.opensrp.web.Constants.TOTAL_RECORDS;
import static org.opensrp.web.Constants.ORDER_BY_FIELD_NAME;
import static org.opensrp.web.Constants.SERVER_VERSION;

/**
* @author Samuel Githengi created on 09/10/19
Expand Down Expand Up @@ -116,10 +117,17 @@ public List<Organization> getAllOrganizations(@RequestParam(value = "location_id
@RequestParam(value = PAGE_NUMBER, required = false) Integer pageNumber,
@RequestParam(value = PAGE_SIZE, required = false) Integer pageSize,
@RequestParam(value = ORDER_BY_TYPE, required = false) String orderByType,
@RequestParam(value = ORDER_BY_FIELD_NAME, required = false) String orderByFieldName
@RequestParam(value = ORDER_BY_FIELD_NAME, required = false) String orderByFieldName,
@RequestParam(value = SERVER_VERSION, required = false) String serverVersionParam
) {

Long serverVersion = null;
if (serverVersionParam != null) {
serverVersion = Long.parseLong(serverVersionParam);
}

OrganizationSearchBean organizationSearchBean = createOrganizationSearchBeanForPagination(pageNumber, pageSize,
orderByType, orderByFieldName);
orderByType, orderByFieldName, serverVersion);

if (StringUtils.isNotBlank(locationID)) {
return organizationService.selectOrganizationsEncompassLocations(locationID);
Expand Down Expand Up @@ -296,12 +304,14 @@ public ResponseEntity<List<Practitioner>> getOrgPractitioners(@PathVariable("ide

/**
* This API queries list of team assignment from a practitioner identifer
*
* @param practitionerIdentifier
* @return List of Organization
*/
@GetMapping(value = "/by-practitioner/{practitioner-identifier}", produces = { MediaType.APPLICATION_JSON_VALUE })
public List<Organization> getTeamsByPractitionerIdentifier(@PathVariable("practitioner-identifier") String practitionerIdentifier) {
return organizationService.getOrganizationsByPractitionerIdentifier(practitionerIdentifier);
public List<Organization> getTeamsByPractitionerIdentifier(
@PathVariable("practitioner-identifier") String practitionerIdentifier) {
return organizationService.getOrganizationsByPractitionerIdentifier(practitionerIdentifier);
}

@RequestMapping(value = "/assignedLocationsAndPlans", method = RequestMethod.GET, produces = {
Expand Down Expand Up @@ -341,7 +351,7 @@ public ResponseEntity<String> searchOrganization(OrganizationSearchBean organiza
}

private OrganizationSearchBean createOrganizationSearchBeanForPagination(Integer pageNumber, Integer pageSize,
String orderByType, String orderByFieldName) {
String orderByType, String orderByFieldName, Long serverVersion) {
OrganizationSearchBean organizationSearchBean = new OrganizationSearchBean();
OrganizationSearchBean.OrderByType orderByTypeEnum = orderByType != null ?
OrganizationSearchBean.OrderByType.valueOf(orderByType) :
Expand All @@ -353,6 +363,7 @@ private OrganizationSearchBean createOrganizationSearchBeanForPagination(Integer
organizationSearchBean.setPageSize(pageSize);
organizationSearchBean.setOrderByFieldName(fieldName);
organizationSearchBean.setOrderByType(orderByTypeEnum);
organizationSearchBean.setServerVersion(serverVersion);

return organizationSearchBean;
}
Expand Down
Loading