Skip to content

Commit

Permalink
Merge pull request #726 from AtlasOfLivingAustralia/feature/issue2480
Browse files Browse the repository at this point in the history
Feature/issue2480
  • Loading branch information
salomon-j authored Feb 3, 2022
2 parents d51d464 + 2530344 commit e7fcb88
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class ProjectXlsExporter extends ProjectExporter {
List<String> prioritiesProperties = commonProjectProperties + ['data1', 'data2', 'data3']
List<String> whsAndCaseStudyHeaders = commonProjectHeaders + ['Are you aware of, and compliant with, your workplace health and safety legislation and obligations', 'Do you have appropriate policies and procedures in place that are commensurate with your project activities?', 'Are you willing for your project to be used as a case study by the Department?']
List<String> whsAndCaseStudyProperties = commonProjectProperties + ['obligations', 'policies', 'caseStudy']
List<String> projectAssetHeaders = commonProjectHeaders + ["Asset", "Category"]
List<String> projectAssetProperties = commonProjectProperties + ["description", "category"]

List<String> approvalsHeaders = commonProjectHeaders + ['Date / Time Approved', 'Change Order Numbers','Comment','Approved by']
List<String> approvalsProperties = commonProjectProperties + ['approvalDate', 'changeOrderNumber', 'comment','approvedBy']
Expand Down Expand Up @@ -377,7 +379,7 @@ class ProjectXlsExporter extends ProjectExporter {
String[] meriPlanTabs = [
"MERI_Budget","MERI_Outcomes","MERI_Monitoring","MERI_Project Partnerships","MERI_Project Implementation",
"MERI_Key Evaluation Question","MERI_Priorities","MERI_WHS and Case Study",'MERI_Risks and Threats',
"MERI_Attachments", "MERI_Baseline", "MERI_Event", "MERI_Approvals", "RLP_Outcomes", "RLP_Project_Details", "RLP_Key_Threats", "RLP_Services_and_Targets"
"MERI_Attachments", "MERI_Baseline", "MERI_Event", "MERI_Approvals", "MERI_Project Assets", "RLP_Outcomes", "RLP_Project_Details", "RLP_Key_Threats", "RLP_Services_and_Targets"
]
//Add extra info about approval status if any MERI plan information is to be exported.
if (shouldExport(meriPlanTabs)){
Expand All @@ -400,6 +402,7 @@ class ProjectXlsExporter extends ProjectExporter {
exportBaseline(project)
exportEvents(project)
exportApprovals(project)
exportProjectAssets(project)
exportRLPOutcomes(project)
exportRLPProjectDetails(project)
exportRLPKeyThreats(project)
Expand Down Expand Up @@ -751,6 +754,10 @@ class ProjectXlsExporter extends ProjectExporter {
}
}

private void exportProjectAssets(Map project) {
exportList("MERI_Project Assets", project, project?.custom?.details?.assets, projectAssetHeaders, projectAssetProperties)
}

private void exportBlog(Map project) {
exportList("Blog", project, project.blog, blogHeaders, blogProperties)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,30 @@ class ProjectXlsExporterSpec extends Specification implements GrailsUnitTest {

}

void "MERI plan assets can be exported to XLSX"() {
setup:
String sheet = 'MERI_Project Assets'
Map project = project()

when:
projectXlsExporter.export(project)
xlsExporter.save()

then:
outputFile.withInputStream { fileIn ->
Workbook workbook = WorkbookFactory.create(fileIn)
Sheet testSheet = workbook.getSheet(sheet)
testSheet.physicalNumberOfRows == 3

Cell assetCell = testSheet.getRow(0).find { it.stringCellValue == 'Asset' }
Cell categoryCell = testSheet.getRow(0).find { it.stringCellValue == 'Category' }
testSheet.getRow(1).getCell(assetCell.getColumnIndex()).stringCellValue == 'Asset 1'
testSheet.getRow(1).getCell(categoryCell.getColumnIndex()).stringCellValue == 'Category 1'

}

}

void "RLP Merit approvals exported to XSLS"() {
setup:
String sheet = 'MERI_Approvals'
Expand Down Expand Up @@ -833,7 +857,6 @@ class ProjectXlsExporterSpec extends Specification implements GrailsUnitTest {
" }\n" +
" ],\n" +
" \"primaryOutcome\" : {\n" +
" \"primaryOutcome\" : {\n" +
" \"assets\" : [ \n" +
" \"Climate change adaptation\", \n" +
" \"Market traceability\"\n" +
Expand Down Expand Up @@ -920,7 +943,10 @@ class ProjectXlsExporterSpec extends Specification implements GrailsUnitTest {
" \"data\" : 0\n" +
" }\n" +
" ]\n" +
" }\n" +
" },\n" +
" \"assets\":[ \n" +
" { \"description\":\"Asset 1\", \"category\":\"Category 1\" } " +
" ]\n" +
" }\n" +
" },\n" +
" \"dateCreated\" : \"2018-06-14T04:22:13.057Z\",\n" +
Expand Down

0 comments on commit e7fcb88

Please sign in to comment.