asciidoctor-liquibase
Version:
Asciidoctor.js extension to render liquibase changesets as entity relationship diagram
153 lines (149 loc) • 7.46 kB
JavaScript
// *** WARNING: DO NOT MODIFY *** This is a generated JavaScript source code!
//
// Generated by LF-ET 2.2.1 (230826a), https://www.lohrfink.de/lfet
// From decision table
// "/opt/data/github/asciidoctor/asciidoctor-liquibase/lfet/extractor/column.lfet"
// 14.09.2023 14:11
//
// Changes to this code resulting from refactorings can be synchronised
// with LF-ET using the function "Scrapbook Import".
//
// Prolog Decision Table ---->
const { stringify } = require('../utils')
function column (element, currentFile, logger) {
let _step = 1
let _exit = false
let constraintElementCallback = (_element) => { return undefined }
const columnDetails = {}
do {
_exit = true
// $$BasicIndentLevel=2
// Prolog Decision Table <----
// Condition B01/01: step / 1 / Step 1
if (_step === 1) {
// Condition B02/01: definition is based on ... format / yaml / yaml definition
if (currentFile.endsWith('yaml')) {
// Rule R01 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 1 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A01/01: define callback to check existence of constraint element / yaml / yaml based callback
constraintElementCallback = (_element) => { return _element.constraints }
// Action A04/02: extract column name / yaml / extract table on yaml definition
columnDetails.name = element.name
// Action A05/02: extract column type / yaml / extract table on yaml definition
columnDetails.type = element.type
// Action A07/01: next step / + / next step
_step++
_exit = false
// Rule R01 <----
// Condition B02/02: definition is based on ... format / xml / xml definition
} else if (currentFile.endsWith('xml')) {
// Rule R02 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 2 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A01/02: define callback to check existence of constraint element / xml / xml based callback
constraintElementCallback = (_element) => { return (_element.$$ !== undefined && _element.$$[0]['#name'] === 'constraints') ? _element.$$[0].$ : undefined }
// Action A04/01: extract column name / xml / extract on xml definition
columnDetails.name = element.$.name
// Action A05/01: extract column type / xml / extract on xml definition
columnDetails.type = element.$.type
// Action A07/01: next step / + / next step
_step++
_exit = false
// Rule R02 <----
} else {
// Rule R03 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 3 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A06/01: error / X / execute action
logger.error(`column - 20230914.141121 - Format for ${currentFile} is not supported.`)
// Action A07/02: next step / Ex / exit
_exit = true
// Rule R03 <----
}
} else {
// Condition B03/01: exist constraints element / Y / Yes
if (constraintElementCallback(element) !== undefined) {
// Condition B04/01: exists primaryKey information / Y / Yes
if (constraintElementCallback(element).primaryKey !== undefined) {
// Condition B05/01: exists foreignKey information / Y / Yes
if (constraintElementCallback(element).referencedColumnNames !== undefined && constraintElementCallback(element).referencedTableName !== undefined) {
// Rule R04 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 4 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A02/01: extract primary key information's / EXTRACT / extract information from element
columnDetails.primaryKey = constraintElementCallback(element).primaryKey
// Action A03/01: extract foreign key information's / EXTRACT / extract information from element
const _constraintElement = constraintElementCallback(element)
columnDetails.referencedColumn = _constraintElement.referencedColumnNames
columnDetails.referencedTable = _constraintElement.referencedTableName
// Action A07/02: next step / Ex / exit
_exit = true
// Rule R04 <----
} else {
// Rule R05 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 5 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A02/01: extract primary key information's / EXTRACT / extract information from element
columnDetails.primaryKey = constraintElementCallback(element).primaryKey
// Action A07/02: next step / Ex / exit
_exit = true
// Rule R05 <----
}
} else {
// Condition B05/01: exists foreignKey information / Y / Yes
if (constraintElementCallback(element).referencedColumnNames !== undefined && constraintElementCallback(element).referencedTableName !== undefined) {
// Rule R06 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 6 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A02/02: extract primary key information's / FALSE / set information to false
columnDetails.primaryKey = false
// Action A03/01: extract foreign key information's / EXTRACT / extract information from element
const _constraintElement = constraintElementCallback(element)
columnDetails.referencedColumn = _constraintElement.referencedColumnNames
columnDetails.referencedTable = _constraintElement.referencedTableName
// Action A07/02: next step / Ex / exit
_exit = true
// Rule R06 <----
} else {
// Rule R07 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 7 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A02/02: extract primary key information's / FALSE / set information to false
columnDetails.primaryKey = false
// Action A07/02: next step / Ex / exit
_exit = true
// Rule R07 <----
}
}
} else {
// Rule R08 ---->
// Trace ---->
logger.info(`column - 20230914.141121 - 8 / 8 - ${currentFile} - ${stringify(element)} - ${stringify(columnDetails)}`)
// Trace <----
// Action A02/02: extract primary key information's / FALSE / set information to false
columnDetails.primaryKey = false
// Action A07/02: next step / Ex / exit
_exit = true
// Rule R08 <----
}
}
// Epilog Decision Table ---->
} while (_exit === false)
return columnDetails
}
module.exports = {
extract: (element, currentFile, logger) => {
return column(element, currentFile, logger)
}
}
// Epilog Decision Table <----
// End of generated JavaScript source code
// Generated by LF-ET 2.2.1 (230826a), https://www.lohrfink.de/lfet