diff --git a/src/main/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporter.groovy b/src/main/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporter.groovy index 8426d129a..f80ccbc40 100644 --- a/src/main/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporter.groovy +++ b/src/main/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporter.groovy @@ -89,6 +89,8 @@ class ProjectXlsExporter extends ProjectExporter { List prioritiesProperties = commonProjectProperties + ['data1', 'data2', 'data3'] List 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 whsAndCaseStudyProperties = commonProjectProperties + ['obligations', 'policies', 'caseStudy'] + List projectAssetHeaders = commonProjectHeaders + ["Asset", "Category"] + List projectAssetProperties = commonProjectProperties + ["description", "category"] List approvalsHeaders = commonProjectHeaders + ['Date / Time Approved', 'Change Order Numbers','Comment','Approved by'] List approvalsProperties = commonProjectProperties + ['approvalDate', 'changeOrderNumber', 'comment','approvedBy'] @@ -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)){ @@ -400,6 +402,7 @@ class ProjectXlsExporter extends ProjectExporter { exportBaseline(project) exportEvents(project) exportApprovals(project) + exportProjectAssets(project) exportRLPOutcomes(project) exportRLPProjectDetails(project) exportRLPKeyThreats(project) @@ -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) } diff --git a/src/test/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporterSpec.groovy b/src/test/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporterSpec.groovy index b8cdff305..cf5444bbf 100644 --- a/src/test/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporterSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/reporting/ProjectXlsExporterSpec.groovy @@ -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' @@ -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" + @@ -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" +