Skip to content

Commit

Permalink
PI-2673 - move variables back to generators
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj committed Jan 10, 2025
1 parent 4c02d53 commit de1c44e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import uk.gov.justice.digital.hmpps.audit.repository.BusinessInteractionReposito
import uk.gov.justice.digital.hmpps.data.generator.*
import uk.gov.justice.digital.hmpps.data.generator.LimitedAccessGenerator.generateExclusion
import uk.gov.justice.digital.hmpps.data.generator.LimitedAccessGenerator.generateRestriction
import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator.NSI_FUZZY_SEARCH
import uk.gov.justice.digital.hmpps.entity.Exclusion
import uk.gov.justice.digital.hmpps.entity.Restriction
import uk.gov.justice.digital.hmpps.integrations.delius.audit.BusinessInteractionCode
Expand Down Expand Up @@ -281,7 +282,7 @@ class DataLoader(

personRepository.save(PersonGenerator.FUZZY_SEARCH)
entityManagerDataLoader.loadData()
nsiManagerRepository.save(NsiGenerator.generateManager(entityManagerDataLoader.nsiFuzzySearch!!))
nsiManagerRepository.save(NsiGenerator.generateManager(NSI_FUZZY_SEARCH!!))

auditUserRepository.save(UserGenerator.LIMITED_ACCESS_USER)
personRepository.saveAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import jakarta.persistence.PersistenceContext
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional
import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator
import uk.gov.justice.digital.hmpps.integrations.delius.referral.entity.Nsi
import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator.NSI_FUZZY_SEARCH

@Component
class EntityManagerDataLoader {

@PersistenceContext
private lateinit var entityManager: EntityManager

var nsiFuzzySearch: Nsi? = null

@Transactional
fun loadData() {
nsiFuzzySearch = entityManager.merge(NsiGenerator.FUZZY_SEARCH)
NSI_FUZZY_SEARCH = entityManager.merge(NsiGenerator.FUZZY_SEARCH)
entityManager.merge(NsiGenerator.TERMINATED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ object NsiGenerator {
eventId = 97
)

var NSI_FUZZY_SEARCH: Nsi? = null

var TERMINATED = generate(
TYPES.values.first(),
eventId = SentenceGenerator.EVENT_WITH_NSI.id,
Expand Down

0 comments on commit de1c44e

Please sign in to comment.