generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab8fe13
commit adfba0a
Showing
36 changed files
with
1,252 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+14.5 KB
projects/approved-premises-and-delius/src/dev/resources/simulations/__files/document.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
projects/approved-premises-and-delius/src/dev/resources/simulations/mappings/alfresco.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"urlPath": "/alfresco/fetch/uuid1" | ||
}, | ||
"response": { | ||
"headers": { | ||
"Content-Type": "application/octet-stream", | ||
"Content-Disposition": "attachment; filename=\"doc1\"; filename*=UTF-8''doc1", | ||
"Custom-Alfresco-Header": "should be ignored" | ||
}, | ||
"status": 200, | ||
"bodyFileName": "document.pdf" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/DocumentController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package uk.gov.justice.digital.hmpps.controller | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.APDocument | ||
import uk.gov.justice.digital.hmpps.service.DocumentService | ||
|
||
@RestController | ||
@Tag(name = "Documents") | ||
@RequestMapping("/document/{crn}") | ||
@PreAuthorize("hasRole('ROLE_APPROVED_PREMISES_STAFF')") | ||
class DocumentController(private val documentService: DocumentService) { | ||
|
||
@GetMapping(value = ["/{id}"]) | ||
@Operation(summary = "Download document content") | ||
fun downloadDocument( | ||
@PathVariable crn: String, | ||
@PathVariable id: String | ||
) = documentService.downloadDocument(crn, id) | ||
|
||
@PreAuthorize("hasRole('ROLE_APPROVED_PREMISES_STAFF')") | ||
@Operation( | ||
summary = "List of documents held in Delius for the probation case", | ||
description = """List of documents available in Delius for the probation | ||
case identified by the CRN provided in the request. Document list | ||
includes summary information on the type and purpose of document held. | ||
Used to support the 'Document List' view of the HMPPS Workforce service | ||
which is used to give detailed information on the case when allocating | ||
to a probation practitioner | ||
""" | ||
) | ||
@GetMapping | ||
fun findDocuments(@PathVariable crn: String): List<APDocument> = | ||
documentService.getDocumentsByCrn(crn) | ||
} |
25 changes: 25 additions & 0 deletions
25
...lius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/alfresco/AlfrescoClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.alfresco | ||
|
||
import feign.RequestInterceptor | ||
import org.springframework.cloud.openfeign.FeignClient | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.core.io.Resource | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import uk.gov.justice.digital.hmpps.security.ServiceContext | ||
|
||
@FeignClient(name = "alfresco", url = "\${integrations.alfresco.url}", configuration = [AlfrescoFeignConfig::class]) | ||
interface AlfrescoClient { | ||
@GetMapping(value = ["/fetch/{id}"]) | ||
fun getDocument(@PathVariable id: String): ResponseEntity<Resource> | ||
} | ||
|
||
class AlfrescoFeignConfig { | ||
@Bean | ||
fun requestInterceptor() = RequestInterceptor { template -> | ||
template.header("X-DocRepository-Remote-User", "N00") | ||
template.header("X-DocRepository-Real-Remote-User", ServiceContext.servicePrincipal()!!.username) | ||
template.header("Content-Type: multipart/form-data") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...in/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.document | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.Document | ||
|
||
interface DocumentRepository : JpaRepository<Document, Long> { | ||
@Query("select d.name from Document d where d.person.crn = :crn and d.alfrescoId = :alfrescoId") | ||
fun findNameByPersonCrnAndAlfrescoId(crn: String, alfrescoId: String): String? | ||
|
||
fun findAllByPersonIdAndSoftDeletedIsFalse(personId: Long): List<Document> | ||
} |
28 changes: 28 additions & 0 deletions
28
...gov/justice/digital/hmpps/integrations/delius/document/entity/ApprovedPremisesReferral.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.document.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
import org.hibernate.annotations.Immutable | ||
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "approved_premises_referral") | ||
class ApprovedPremisesReferral( | ||
@Id | ||
@Column(name = "approved_premises_referral_id") | ||
val id: Long, | ||
|
||
@JoinColumn(name = "event_id", insertable = false, updatable = false) | ||
@ManyToOne | ||
val event: DocEvent, | ||
|
||
@JoinColumn(name = "referral_category_id", insertable = false, updatable = false) | ||
@ManyToOne | ||
val category: ReferenceData | ||
|
||
) |
22 changes: 22 additions & 0 deletions
22
...lin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CaseAllocationDoc.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.document.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
import org.hibernate.annotations.Immutable | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "case_allocation") | ||
class CaseAllocationDoc( | ||
@Id | ||
@Column(name = "case_allocation_id") | ||
val id: Long, | ||
|
||
@JoinColumn(name = "event_id", insertable = false, updatable = false) | ||
@ManyToOne | ||
val event: DocEvent | ||
) |
51 changes: 51 additions & 0 deletions
51
...kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CourtReportDoc.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.document.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
import org.hibernate.annotations.Immutable | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "court_report") | ||
class CourtReportDoc( | ||
@Id | ||
@Column(name = "court_report_id") | ||
val id: Long, | ||
|
||
@JoinColumn(name = "court_appearance_id", insertable = false, updatable = false) | ||
@ManyToOne | ||
val documentCourtAppearance: DocumentCourtAppearance? = null, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "court_report_type_id", updatable = false) | ||
val type: CourtReportType | ||
) | ||
|
||
@Immutable | ||
@Entity | ||
@Table(name = "r_court_report_type") | ||
class CourtReportType( | ||
@Id | ||
@Column(name = "court_report_type_id") | ||
val id: Long, | ||
|
||
val description: String | ||
) | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "court_appearance") | ||
class DocumentCourtAppearance( | ||
|
||
@Id | ||
@Column(name = "court_appearance_id") | ||
val id: Long, | ||
|
||
@JoinColumn(name = "event_id", insertable = false, updatable = false) | ||
@ManyToOne | ||
val event: DocEvent | ||
) |
33 changes: 33 additions & 0 deletions
33
.../uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocAddressAssessment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.document.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
import org.hibernate.annotations.Immutable | ||
|
||
@Entity | ||
@Immutable | ||
class AddressAssessment( | ||
@Id | ||
@Column(name = "address_assessment_id") | ||
var id: Long, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "offender_address_id", insertable = false, updatable = false) | ||
val personAddress: DocPersonAddress? | ||
) | ||
|
||
@Entity | ||
@Table(name = "offender_address") | ||
@Immutable | ||
class DocPersonAddress( | ||
@Id | ||
@Column(name = "offender_address_id") | ||
var id: Long, | ||
val buildingName: String?, | ||
val addressNumber: String?, | ||
val streetName: String? | ||
) |
37 changes: 37 additions & 0 deletions
37
...ain/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocContact.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.document.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.JoinColumn | ||
import jakarta.persistence.ManyToOne | ||
import jakarta.persistence.Table | ||
import org.hibernate.annotations.Immutable | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "contact") | ||
class DocContact( | ||
@Id | ||
@Column(name = "contact_id", updatable = false) | ||
val id: Long = 0, | ||
|
||
@JoinColumn(name = "event_id", insertable = false, updatable = false) | ||
@ManyToOne | ||
val event: DocEvent?, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "contact_type_id", updatable = false) | ||
val type: DocContactType | ||
) | ||
|
||
@Immutable | ||
@Entity | ||
@Table(name = "r_contact_type") | ||
class DocContactType( | ||
@Id | ||
@Column(name = "contact_type_id") | ||
val id: Long, | ||
|
||
val description: String | ||
) |
Oops, something went wrong.