Skip to content

Commit

Permalink
Merge branch 'main' into issue83-jpa-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin authored Nov 26, 2024
2 parents d49fa7b + 01da39e commit ca9ff29
Show file tree
Hide file tree
Showing 24 changed files with 1,753 additions and 205 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ on:
branches:
- main
push:
branches: [ master ]
branches: [ main ]

jobs:
run-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
java-version: '17'

- name: Run Unit tests and generate report
run: mvn -B clean test jacoco:report --file pom.xml
run: mvn -B clean test jacoco:report --file pom.xml --file README.md --file LICENSE -X -e
env:
PROXY_TO: "https://my.test-server.org/fhir"

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ environment variables
If not set, defaults to
https://smartregister.org/related-entity-location-tag-id

**Monitoring**

[Spring actuator](https://docs.spring.io/spring-boot/reference/actuator/enabling.html)
dependency has been added to provide monitoring for the application and its
components using HTTP endpoints or with JMX. By default, the health endpoint is
exposed over HTTP and JMX. To expose other endpoints e.g. prometheus, one has to
update the application configuration.

### Run project

As documented on the Info Gateway modules
Expand Down Expand Up @@ -396,6 +404,67 @@ Example:
[GET] /LocationHierarchy?_id=<some-location-id>&administrativeLevelMin=2&administrativeLevelMax=4&_count=<page-size>&_page=<page-number>&_sort=<some-sort>
```

##### Inventory Filters

The `LocationHierarchy` endpoint supports filtering by inventory availability,
allowing users to specify whether they want to retrieve only locations that have
associated inventories. This filter can be particularly useful for narrowing
down the results to locations that are actively involved in inventory
management.

The following search parameter is available:

- `filterInventory`: A boolean parameter that specifies whether the response
should be filtered by locations with inventories.
- `filterInventory=true`: Only locations with inventories will be included in
the response.
- `filterInventory=false` (or not set): Locations with or without inventories
will be returned. This effectively disables inventory-based filtering. The
response will include all locations, regardless of their inventory status.
Both locations with and without inventories will be returned.

Example:

```
[GET] /LocationHierarchy?_id=<some-location-id>&filterInventory=true&_count=<page-size>&_page=<page-number>&_sort=<some-sort>
```

##### LastUpdated Filters

The `LocationHierarchy` endpoint supports filtering by the lastUpdated timestamp
of locations. This filter allows users to retrieve locations based on the last
modification date, making it useful for tracking recent updates or syncing data
changes over time.

Behavior based on the lastUpdated parameter:

- `_lastUpdated` Not Defined: The endpoint will include all locations in the
response, regardless of when they were last modified.
- `_lastUpdated` Defined: The response will include only those locations that
were updated on or after the specified timestamp.

Note: This filter only works when in list mode i.e `mode=list` is set as one of
the parameters

Example:

```
[GET] /LocationHierarchy?_id=<some-location-id>&mode=list&_lastUpdated=2024-09-22T15%3A13%3A53.014%2B00%3A00&_count=<page-size>&_page=<page-number>&_sort=<some-sort>
```

##### LocationHierarchy Summary Count

The LocationHierarchy endpoint supports the `_summary=count` parameter. This
allows users to retrieve the total number of matching resources without
returning the resource data. This filter only works when in list mode i.e
`mode=list` is set as one of the parameters.

Example:

```
GET /LocationHierarchy?_id=<some-location-id>&mode=list&_summary=count
```

#### Important Note:

Developers, please update your client applications accordingly to accommodate
Expand Down
12 changes: 6 additions & 6 deletions exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<parent>
<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.8-alpha</version>
<version>2.2.2-alpha</version>
</parent>

<artifactId>exec</artifactId>
<packaging>jar</packaging>

<properties>
<root.basedir>${project.parent.basedir}</root.basedir>
<spring-boot.version>2.7.5</spring-boot.version>
<spring-boot.version>3.3.4</spring-boot.version>
<!-- We do not want to deploy the `exec` uber jar. -->
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
Expand Down Expand Up @@ -46,13 +46,13 @@
<dependency>
<groupId>com.google.fhir.gateway</groupId>
<artifactId>server</artifactId>
<version>0.3.1</version>
<version>${fhir.gateway.version}</version>
</dependency>

<dependency>
<groupId>com.google.fhir.gateway</groupId>
<artifactId>plugins</artifactId>
<version>0.3.1</version>
<version>${fhir.gateway.version}</version>
</dependency>

<!-- For Spring -->
Expand All @@ -70,7 +70,7 @@
<dependency>
<groupId>org.smartregister</groupId>
<artifactId>plugins</artifactId>
<version>2.0.8-alpha</version>
<version>2.2.2-alpha</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -98,7 +98,7 @@
</goals>
<configuration>
<mainClass>org.smartregister.fhir.gateway.MainApp</mainClass>
<!-- We use ZIP layout such that PropertiesLauncher is used and we
<!-- We use ZIP layout such that PropertiesLauncher is used, and we
can add extra jars through `loader.path` property:
https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#appendix.executable-jar.property-launcher
This is useful for when people want to inject other plugins into
Expand Down
28 changes: 14 additions & 14 deletions plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
<parent>
<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.8-alpha</version>
<version>2.2.2-alpha</version>
</parent>

<artifactId>plugins</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.basedir>${project.basedir}</project.basedir>
<hapifhir.version>6.8.3</hapifhir.version>
<hapifhir.version>7.4.3</hapifhir.version>
<fhir.proxy-plugin.version>0.2.0</fhir.proxy-plugin.version>
<sentry.version>7.15.0</sentry.version>
<jakarta-servlet.version>6.0.0</jakarta-servlet.version>
</properties>

<dependencies>

<dependency>
<groupId>com.google.fhir.gateway</groupId>
<artifactId>server</artifactId>
<version>0.3.2</version>
<version>${fhir.gateway.version}</version>
</dependency>
<dependency>
<groupId>com.google.fhir.gateway</groupId>
<artifactId>plugins</artifactId>
<version>0.3.1</version>
<version>${fhir.gateway.version}</version>
</dependency>
<!-- Needed for JEE/Servlet support -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${jakarta-servlet.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
Expand All @@ -51,12 +51,12 @@
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-logback</artifactId>
<version>7.6.0</version>
<version>${sentry.version}</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter</artifactId>
<version>7.6.0</version>
<artifactId>sentry-spring-boot-starter-jakarta</artifactId>
<version>${sentry.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public enum CacheHelper {

Cache<String, String> stringCache;

Cache<String, List<String>> listStringCache;

CacheHelper() {
cache =
Caffeine.newBuilder()
Expand All @@ -42,6 +44,11 @@ public enum CacheHelper {
.expireAfterWrite(getCacheExpiryDurationInSeconds(), TimeUnit.SECONDS)
.maximumSize(DEFAULT_CACHE_SIZE)
.build();
listStringCache =
Caffeine.newBuilder()
.expireAfterWrite(getCacheExpiryDurationInSeconds(), TimeUnit.SECONDS)
.maximumSize(DEFAULT_CACHE_SIZE)
.build();
}

private int getCacheExpiryDurationInSeconds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Constants {
"https://smartregister.org/care-team-tag-id";
public static final String CODE_URL_VALUE_SEPARATOR = "|";
public static final String EMPTY_STRING = "";
public static final String FORWARD_SLASH = "/";
public static final String LOCATION_TAG_URL_ENV = "LOCATION_TAG_URL";
public static final String DEFAULT_LOCATION_TAG_URL =
"https://smartregister.org/location-tag-id";
Expand All @@ -23,6 +24,10 @@ public class Constants {
public static final String IDENTIFIER = "_id";
public static final String MIN_ADMIN_LEVEL = "administrativeLevelMin";
public static final String MAX_ADMIN_LEVEL = "administrativeLevelMax";
public static final String FILTER_INVENTORY = "filterInventory";
public static final String LAST_UPDATED = "_lastUpdated";
public static final String SUMMARY = "_summary";
public static final String COUNT = "count";
public static final int DEFAULT_MAX_ADMIN_LEVEL = 10;
public static final int DEFAULT_MIN_ADMIN_LEVEL = 0;
public static final String PAGINATION_PAGE_SIZE = "_count";
Expand All @@ -38,6 +43,7 @@ public class Constants {
public static final String ROLE_WEB_CLIENT = "WEB_CLIENT";
public static final String MODE = "mode";
public static final String LIST = "list";
public static final String SUBJECT = "subject";
public static final String CORS_ALLOW_HEADERS_KEY = "Access-Control-Allow-Headers";
public static final String CORS_ALLOW_HEADERS_VALUE = "authorization, cache-control";
public static final String CORS_ALLOW_METHODS_KEY = "Access-Control-Allow-Methods";
Expand Down
Loading

0 comments on commit ca9ff29

Please sign in to comment.