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.
Browse files
Browse the repository at this point in the history
* PI-2556 Added LAO endpoints for allocations service * Formatting changes --------- Co-authored-by: probation-integration-bot[bot] <177347787+probation-integration-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8a40c64
commit 91159b9
Showing
11 changed files
with
181 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,9 @@ objectclass: inetOrgPerson | |
cn: JoeBloggs | ||
sn: Bloggs | ||
mail: [email protected] | ||
|
||
dn: cn=MAABT001,cn=JoeBloggs,ou=Users,dc=moj,dc=com | ||
objectclass: NDRoleAssociation | ||
objectclass: alias | ||
cn: MAABT001 | ||
aliasedObjectName: cn=MAABT001,cn=NDRoleAssociation,ou=Users,dc=moj,dc=com |
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
16 changes: 16 additions & 0 deletions
16
...us/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/LimitedAccess.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,16 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.user | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
import uk.gov.justice.digital.hmpps.entity.Exclusion | ||
import uk.gov.justice.digital.hmpps.entity.Restriction | ||
|
||
interface ExclusionRepository : JpaRepository<Exclusion, Long> { | ||
@Query("select e from Exclusion e where e.person.id = :personId and (e.end is null or e.end > current_date)") | ||
fun findByPersonId(personId: Long): List<Exclusion> | ||
} | ||
|
||
interface RestrictionRepository : JpaRepository<Restriction, Long> { | ||
@Query("select r from Restriction r where r.person.id = :personId and (r.end is null or r.end > current_date)") | ||
fun findByPersonId(personId: Long): List<Restriction> | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/UserService.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,32 @@ | ||
package uk.gov.justice.digital.hmpps.service | ||
|
||
import org.springframework.stereotype.Service | ||
import uk.gov.justice.digital.hmpps.api.model.CaseAccessList | ||
import uk.gov.justice.digital.hmpps.api.model.User | ||
import uk.gov.justice.digital.hmpps.exception.NotFoundException | ||
import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository | ||
import uk.gov.justice.digital.hmpps.integrations.delius.user.ExclusionRepository | ||
import uk.gov.justice.digital.hmpps.integrations.delius.user.RestrictionRepository | ||
|
||
@Service | ||
class UserService( | ||
private val personRepository: PersonRepository, | ||
private val exclusionRepository: ExclusionRepository, | ||
private val restrictionRepository: RestrictionRepository | ||
) { | ||
fun getAllAccessLimitations(crn: String, usernamesFilter: List<String>? = null): CaseAccessList { | ||
val person = personRepository.findByCrnAndSoftDeletedFalse(crn) ?: throw NotFoundException("Person", "crn", crn) | ||
return CaseAccessList( | ||
crn = crn, | ||
exclusionMessage = person.exclusionMessage, | ||
restrictionMessage = person.restrictionMessage, | ||
excludedFrom = exclusionRepository.findByPersonId(person.id).map { it.user.username } | ||
.filter { usernamesFilter == null || it in usernamesFilter } | ||
.map { User(it) }, | ||
restrictedTo = restrictionRepository.findByPersonId(person.id).map { it.user.username } | ||
.filter { usernamesFilter == null || it in usernamesFilter } | ||
.map { User(it) }, | ||
) | ||
} | ||
} | ||
|
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