Skip to content

Commit

Permalink
Feature toggle the Legacy Process Licence service
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4728

As part of ongoing work to migrate the legacy import logic into this repo, we are adding a trigger to enable us to start using this new logic - #1453

However, some of the logic needs to be turned off behind a feature flag so the other logic can go live.

This import process was initially designed to be kicked off by the existing import service. This change will remove the route and controller for this older idea.
  • Loading branch information
jonathangoulding committed Oct 29, 2024
1 parent 8e4b0d6 commit 9a96b3d
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions app/services/import/legacy/process-licence.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
*/

const DetermineSupplementaryBillingFlagsService = require('../determine-supplementary-billing-flags.service.js')
const FeatureFlags = require('../../../../config/feature-flags.config.js')
const LicenceStructureValidator = require('../../../validators/import/licence-structure.validator.js')
const PersistImportService = require('../persist-import.service.js')
const ProcessLicenceReturnLogsService = require('../../jobs/return-logs/process-licence-return-logs.service.js')
const TransformAddressesService = require('./transform-addresses.service.js')
const TransformLicenceDocumentService = require('./transform-licence-document.service.js')
const TransformLicenceDocumentRolesService = require('./transform-licence-document-roles.service.js')
const TransformCompaniesService = require('./transform-companies.service.js')
const TransformCompanyAddressesService = require('./transform-company-addresses.service.js')
const TransformContactsService = require('./transform-contacts.service.js')
const TransformLicenceDocumentRolesService = require('./transform-licence-document-roles.service.js')
const TransformLicenceDocumentService = require('./transform-licence-document.service.js')
const TransformLicenceService = require('./transform-licence.service.js')
const TransformLicenceVersionPurposeConditionsService = require('./transform-licence-version-purpose-conditions.service.js')
const TransformLicenceVersionPurposesService = require('./transform-licence-version-purposes.service.js')
Expand Down Expand Up @@ -43,30 +44,32 @@ async function go (licenceRef) {
await ProcessLicenceReturnLogsService.go(wrlsLicenceId)
}

// Pass the transformed licence through each transformation step, building the licence as we go
await TransformLicenceVersionsService.go(regionCode, naldLicenceId, transformedLicence)
await TransformLicenceVersionPurposesService.go(regionCode, naldLicenceId, transformedLicence)
await TransformLicenceVersionPurposeConditionsService.go(regionCode, naldLicenceId, transformedLicence)
if (FeatureFlags.enableSystemImportLegacyLicence) {
// Pass the transformed licence through each transformation step, building the licence as we go
await TransformLicenceVersionsService.go(regionCode, naldLicenceId, transformedLicence)
await TransformLicenceVersionPurposesService.go(regionCode, naldLicenceId, transformedLicence)
await TransformLicenceVersionPurposeConditionsService.go(regionCode, naldLicenceId, transformedLicence)

// Document
await TransformLicenceDocumentService.go(regionCode, naldLicenceId, transformedLicence)
await TransformLicenceDocumentRolesService.go(regionCode, naldLicenceId, transformedLicence, licenceRef)
// Document
await TransformLicenceDocumentService.go(regionCode, naldLicenceId, transformedLicence)
await TransformLicenceDocumentRolesService.go(regionCode, naldLicenceId, transformedLicence, licenceRef)

// Transform the company data
const { transformedCompanies } = await TransformCompaniesService.go(regionCode, naldLicenceId)
// Transform the company data
const { transformedCompanies } = await TransformCompaniesService.go(regionCode, naldLicenceId)

// Pass the transformed companies through each transformation step, building the company as we go
await TransformContactsService.go(regionCode, naldLicenceId, transformedCompanies)
await TransformAddressesService.go(regionCode, naldLicenceId, transformedCompanies)
await TransformCompanyAddressesService.go(regionCode, naldLicenceId, transformedCompanies)
// Pass the transformed companies through each transformation step, building the company as we go
await TransformContactsService.go(regionCode, naldLicenceId, transformedCompanies)
await TransformAddressesService.go(regionCode, naldLicenceId, transformedCompanies)
await TransformCompanyAddressesService.go(regionCode, naldLicenceId, transformedCompanies)

// Ensure the built licence has all the valid child records we require
LicenceStructureValidator.go(transformedLicence)
// Ensure the built licence has all the valid child records we require
LicenceStructureValidator.go(transformedLicence)

// Either insert or update the licence in WRLS
const licenceId = await PersistImportService.go(transformedLicence, transformedCompanies)
// Either insert or update the licence in WRLS
const licenceId = await PersistImportService.go(transformedLicence, transformedCompanies)

calculateAndLogTimeTaken(startTime, 'Legacy licence import complete', { licenceId, licenceRef })
calculateAndLogTimeTaken(startTime, 'Legacy licence import complete', { licenceId, licenceRef })
}
} catch (error) {
global.GlobalNotifier.omfg('Legacy licence import errored', { licenceRef }, error)
}
Expand Down

0 comments on commit 9a96b3d

Please sign in to comment.