Skip to content

Commit

Permalink
Merge pull request #1056 from MetadataConsulting/loinc-config-excel-l…
Browse files Browse the repository at this point in the history
…oader-optimization-attempt

Merge branch 'develop' of https://github.com/MetadataConsulting/ModelCataloguePlugin into loinc-config-excel-loader-optimization-attempt
  • Loading branch information
davidmilward authored Dec 21, 2017
2 parents e1a1638 + 337cc92 commit 75f4944
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ class DataImportController {
protected void loadConfigSpreadsheet(Workbook wb, String modelName, InputStream xmlConfigStream, Long id, Long userId) {
auditService.betterMute {
try {
// ConfigExcelLoader loader = new ConfigExcelLoader(modelName, xmlConfigStream)
ConfigStatelessExcelLoader loader = new ConfigStatelessExcelLoader(modelName, xmlConfigStream)
ConfigExcelLoader loader = new ConfigExcelLoader(modelName, xmlConfigStream)
// ConfigStatelessExcelLoader loader = new ConfigStatelessExcelLoader(modelName, xmlConfigStream)
loader.buildModel(wb)
finalizeAsset(id, (DataModel) (DataModel.findByName(modelName)), userId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class ConfigStatelessExcelLoader extends ExcelLoader {
} else {
println(msg)
}
println(msg + obj?.toString() ?: '')
}
Boolean equalsIgnoreCase(String s1, String s2) {
return s1 ? s1.equalsIgnoreCase(s2) : s1 == s2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,76 @@ class ConfigStatelessExcelLoaderSpec extends AbstractIntegrationSpec {
String loincDataModelName = 'LOINC'
String goshDataModelName = 'GOSH'
String lpdcDataModelName = 'WinPath'
String lpdcRareDataModelName = 'RareDisease'
String loincHeadersMapXml = 'loinc_headers_map.xml'
String goshHeadersMapXml = 'gosh_headers_map.xml'
String lpdcHeadersMapXml = 'lpdc_headers_map.xml'
String RareDiseaseldpcXml = 'RareDiseaseldpc.xml'
String lpdcDataFile = 'TFC-TLC_LPDC_With Dups.xlsx'
String RareDiseaseldpc = 'RareDiseaseldpc.xlsx'
String testDataModelName = 'TEST_MODEL'
String testLoincData = 'loinc.xlsx'
String testGoshData = 'GOSH_lab_test_codes100.xlsx'
String[] loincDataFiles = ['1loinc.xlsx', '2loinc.xlsx', '3loinc.xlsx', '4loinc.xlsx', '5loinc.xlsx', '6loinc.xlsx', '7loinc.xlsx', '8loinc.xlsx']
String[] goshDataFiles = ['GOSH lab test codes 1.xlsx', 'GOSH lab test codes 2.xlsx', 'GOSH lab test codes 3.xlsx', 'GOSH lab test codes 4.xlsx', 'GOSH lab test codes 5.xlsx']
@Shared String lpdcResourcePath = (new File('test/integration/resources/org/modelcatalogue/integration/excel/')).getAbsolutePath()
@Shared String loincResourcePath = (new File('test/integration/resources/org/modelcatalogue/integration/excel/loinc/')).getAbsolutePath()
@Shared String goshResourcePath = (new File('test/integration/resources/org/modelcatalogue/integration/excel/goshTestCodes/')).getAbsolutePath()
ConfigStatelessExcelLoader excelLoader
// CatalogueBuilder catalogueBuilder
def dataModelService, elementService
AuditService auditService
DataClassService dataClassService
GrailsApplication grailsApplication
@Rule TemporaryFolder temporaryFolder = new TemporaryFolder()

def loincData() {
for (String loincDataXlsx in loincDataFiles) {
excelLoader = new ConfigStatelessExcelLoader(loincDataModelName, new FileInputStream(loincResourcePath + '/' + loincHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(loincResourcePath + '/' + loincDataXlsx)))
excelLoader = null
}
}
def goshData() {
for (String goshDataXlsx in goshDataFiles) {
excelLoader = new ConfigStatelessExcelLoader(goshDataModelName, new FileInputStream(goshResourcePath + '/' + goshHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(goshResourcePath + '/' + goshDataXlsx)))
excelLoader = null
}
}
def lpdcData() {
excelLoader = new ConfigStatelessExcelLoader(lpdcDataModelName, new FileInputStream(lpdcResourcePath + '/' + lpdcHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(lpdcResourcePath + '/' + lpdcDataFile)))
excelLoader = null
}
def rareDisease() {
excelLoader = new ConfigStatelessExcelLoader(lpdcRareDataModelName, new FileInputStream(lpdcResourcePath + '/' + RareDiseaseldpcXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(lpdcResourcePath + '/' + RareDiseaseldpc)))
excelLoader = null
}
def testData() {
excelLoader = new ConfigStatelessExcelLoader(testDataModelName, new FileInputStream(loincResourcePath + '/' + loincHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(loincResourcePath + '/' + testLoincData)))
}
def setup() {
// XMLUnit.ignoreWhitespace = true
// XMLUnit.ignoreComments = true
// XMLUnit.ignoreAttributeOrder = true
// catalogueBuilder = new DefaultCatalogueBuilder(dataModelService, elementService)
// excelLoader = new ConfigStatelessExcelLoader(dataModelName, new FileInputStream(resourcePath + '/' + headersMapXml))
}

def "test default catalogue builder imports generic nt dataset"(){

when: "I load the Excel file"
// excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(resourcePath + '/' + dataXlsx)))
// testData()
auditService.betterMute {
for (String loincDataXlsx in loincDataFiles) {
excelLoader = new ConfigStatelessExcelLoader(loincDataModelName, new FileInputStream(loincResourcePath + '/' + loincHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(loincResourcePath + '/' + loincDataXlsx)))
excelLoader = null
}
for (String goshDataXlsx in goshDataFiles) {
excelLoader = new ConfigStatelessExcelLoader(goshDataModelName, new FileInputStream(goshResourcePath + '/' + goshHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(goshResourcePath + '/' + goshDataXlsx)))
excelLoader = null
}
excelLoader = new ConfigStatelessExcelLoader(lpdcDataModelName, new FileInputStream(lpdcResourcePath + '/' + lpdcHeadersMapXml))
excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(lpdcResourcePath + '/' + lpdcDataFile)))
excelLoader = null
// excelLoader.buildModelFromStandardWorkbookSheet(null, WorkbookFactory.create(new FileInputStream(resourcePath + '/' + dataXlsx)))
// loincData()
// goshData()
// lpdcData()
// rareDisease()
testData()
}
then: "new model is created"

// DataModel.findByName(lpdcDataModelName)
// DataModel.findByName(loincDataModelName)
DataModel.findByName(goshDataModelName)
// DataModel.findByName(goshDataModelName)
// DataModel.findByName(lpdcRareDataModelName)
DataModel.findByName(testDataModelName)
}
}
Binary file not shown.

0 comments on commit 75f4944

Please sign in to comment.