Skip to content

ministryofjustice/hmpps-digital-prison-reporting-mi

Repository files navigation

hmpps-digital-prison-reporting-mi

repo standards badge CircleCI Docker Repository on Quay API docs

This project is generated from ministryofjustice/hmpps-template-kotlin

Requires Java 17 or above

CODEOWNER

Overview

Provides a front end for Management Information Visualisation and Presentation

Local Development

This project uses gradle which is bundled with the repository and also makes use of

  • micronaut - for compile time dependency injection
  • lombok - to reduce boilerplate when creating data classes
  • jacoco - for test coverage reports

Running Locally against Dev

  1. Add implementation("com.h2database:h2:2.1.214") to build.gradle
  2. Change the existing datasource config in the application.yml file to the following:
  jpa:
    database-platform: org.hibernate.dialect.H2Dialect
    hibernate:
      ddl-auto: create-drop
  datasource:
    url: jdbc:h2:mem:datamart;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS domain\;
    username: sa
    password: sa
    driver-class-name: org.h2.Driver
  1. Add the following two environment variables on intellij run configuration HMPPS_AUTH_URL https://sign-in-dev.hmpps.service.justice.gov.uk/auth

    AUTHORISED_ROLES ROLE_PRISONS_REPORTING_USER
  2. Optional: Change the org.springframework.security level to DEBUG in logback-spring.xml
  3. Run main from DigitalPrisonReportingMi

Testing

Note - test coverage reports are enabled by default and after running the tests the report will be written to build/reports/jacoco/test/html

Unit Tests

The unit tests use JUnit5 and Mockito where appropriate. Use the following to run the tests.

    ./gradlew clean test

Contributing

Please adhere to the following guidelines when making contributions to the project.

Documentation

  • Keep all code commentary and documentation up to date

Branch Naming

  • Use a JIRA ticket number where available
  • Otherwise a short descriptive name is acceptable

Commit Messages

  • Prefix any commit messages with the JIRA ticket number where available
  • Otherwise use the prefix NOJIRA

Pull Requests

  • Reference or link any relevant JIRA tickets in the pull request notes
  • At least one approval is required before a PR can be merged

Deployment

The app is deployed to the namespace: hmpps-digital-prison-reporting-mi-<env>.

Config for the dev environment can be found here: https://github.com/ministryofjustice/cloud-platform-environments/tree/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-digital-prison-reporting-mi-dev

Additionally, the RedShift credentials need to be manually deployed to each environment. The file redshift-jdbc-secret.yaml should be updated with the base64 encoded values and applied to the environment.

NB: Please do not commit these changes to redshift-jdbc-secret.yaml.

Example of base64 encoding a secret value:

echo -n 'placeholder' | base64

Example of applying the secret to an environment:

kubectl -n hmpps-digital-prison-reporting-mi-dev apply -f redshift-jdbc-secret.yaml

Deploying new data product definition files

The data product definition files are in digital-prison-reporting-data-product-definitions directory which is a git submodule. In order to deploy new files from this repository to the reporting mi application you would need to pull the latest changes from the submodule's main branch. Then create symlinks from the new json files in the submodule to the main resources directory.
And finally these new files would need to be added to the Dockerfile.

  • cd digital-prison-reporting-data-product-definitions
  • git checkout main
  • git pull
  • cd ../src/main/resources
  • ln -s ../../../digital-prison-reporting-data-product-definitions/prisons/orphanage/external-movements.json
  • The last step is to add the file to Dockerfile by adding this line to Dockerfile below line 21: ADD ./digital-prison-reporting-data-product-definitions/prisons/orphanage/external-movements.json .
  • And finally add this file location to the env variable DPR_LIB_DEFINITION_LOCATIONS by appending the file name to the comma separated list of files here: ENV DPR_LIB_DEFINITION_LOCATIONS=
  • So for example for a new file called external movements assuming you already had dpd001-court-hospital-movements.json you would have: ENV DPR_LIB_DEFINITION_LOCATIONS=/external-movements.json,/dpd001-court-hospital-movements.json
  • Following the above steps the same can be done for any file.
  • If an existing file has changed then a new deployment of the reporting mi application will pick up these changes as this happens through the circleci pipeline.

About

HMPPS Digital Prisons Reporting MI API

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published