-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3346 from AtlasOfLivingAustralia/feature/issue3345
Script to configure services for new forms #3345
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/scripts/releases/4.1/adhoc/configureGrantsAndProcurementFormServices.js
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,42 @@ | ||
load('../../../utils/audit.js'); | ||
const forms = ['Grants and Others Progress Report', 'Procurement Output Report']; | ||
const nhtOutputReportForm = 'NHT Output Report'; | ||
let services = db.service.find(); | ||
while (services.hasNext()) { | ||
let service = services.next(); | ||
let updated = false; | ||
let sectionName = null; | ||
for (let i=0; i<service.outputs.length; i++) { | ||
let output = service.outputs[i]; | ||
|
||
if (output.formName == nhtOutputReportForm) { | ||
sectionName = output.sectionName; | ||
} | ||
} | ||
|
||
if (!sectionName) { | ||
print("No section found for service: "+service.name); | ||
continue; | ||
} | ||
for (let form in forms) { | ||
let found = false; | ||
for (let i=0; i<service.outputs.length; i++) { | ||
let output = service.outputs[i]; | ||
if (output.formName == forms[form]) { | ||
found = true; | ||
} | ||
} | ||
if (!found) { | ||
service.outputs.push({formName:forms[form], sectionName:sectionName}); | ||
updated = true; | ||
} | ||
} | ||
|
||
if (updated) { | ||
print("Updating service forms for service: "+service.name); | ||
db.service.replaceOne({_id:service._id}, service); | ||
audit(service, service.serviceId, 'au.org.ala.ecodata.Service', 'system'); | ||
} | ||
|
||
|
||
} |