imports/vx/server/daemon/recordimporter.js
/**
     * Process the entire row copying cells into results.record.
     */
Process the entire row copying cells into results.record.
Process the entire row copying cells into results . record .
processRow(uploadStats, importSchema, headerArray, row, index, rowIndex, messages,
        fieldIdKey, results, insertArray) {
        results.record.dateModified = new Date()
        results.record.userModified = uploadStats.userId
        let allValid = true
        headerArray.forEach((path, columnIndex) => {
            if (path === "command") {
                return
            }
            const fieldIdVariables = { rowIndex: rowIndex,  path: path }
            const importSchemaPath = RecordImporter.importSchemaPath(path)
            const definition = get(importSchema, importSchemaPath)
            let value = FX.trim.strip(row[columnIndex])
            let valid = true
            if (definition.required) {
                valid = VXApp.validateRequired(value, index, messages, fieldIdKey, fieldIdVariables)
                if (!valid) {
                    allValid = false
                    return
                }
            }
            if (!value) {
                return
            }
            if (definition.guid) {
                value = Util.getGuid()
            }
            if (definition.lookup) {
                value = VXApp.lookupValue(uploadStats, value, definition, index, messages, fieldIdKey, fieldIdVariables)
            }
            if (definition.format) {
                value = definition.format.strip(value)
            }
            if (definition.list) {
                const codeArray = Util.makeCodeArray(definition.list)
                value = VXApp.lookupCode(definition, value, codeArray, index, messages, fieldIdKey, fieldIdVariables)
            }
            if (definition.codeArrayFunction) {
                const codeArray = definition.codeArrayFunction()
                value = VXApp.lookupCode(definition, value, codeArray, index, messages, fieldIdKey, fieldIdVariables)
            }
            if (definition.rule) {
                valid = VXApp.validateRule(value, definition.rule, index, messages, fieldIdKey, fieldIdVariables)
            }
            if (!valid) {
                allValid = false
                return
            }
            const peerGuidPath = RecordImporter.peerGuidPath(importSchema, path)
            if (peerGuidPath) {
                const existingGuid = get(results.record, peerGuidPath)
                if (!existingGuid) {
                    set(results.record, peerGuidPath, Util.getGuid())
                }
            }
            const convertedValue = RecordImporter.convertValue(uploadStats, definition, value)
            set(results.record, path, convertedValue)
        })
        RecordImporter.postProcess(importSchema, results.record)
        if (allValid) {
            insertArray.push(results)
            return
        }
        OLog.debug(`recordimporter.js prepareGeneric *bypassing* index=${index} allValid=${allValid} ` +
                `messages=${OLog.debugString(messages)}`)
        return
    }
processRow ( uploadStats , importSchema , headerArray , row , index , rowIndex , messages , fieldIdKey , results , insertArray ) { results . record . dateModified = new Date ( ) results . record . userModified = uploadStats . userId let allValid = true headerArray . forEach ( ( path , columnIndex ) => { if ( path === "command" ) { return } const fieldIdVariables = { rowIndex : rowIndex , path : path } const importSchemaPath = RecordImporter . importSchemaPath ( path ) const definition = get ( importSchema , importSchemaPath ) let value = FX . trim . strip ( row [ columnIndex ] ) let valid = true if ( definition . required ) { valid = VXApp . validateRequired ( value , index , messages , fieldIdKey , fieldIdVariables ) if ( ! valid ) { allValid = false return } } if ( ! value ) { return } if ( definition . guid ) { value = Util . getGuid ( ) } if ( definition . lookup ) { value = VXApp . lookupValue ( uploadStats , value , definition , index , messages , fieldIdKey , fieldIdVariables ) } if ( definition . format ) { value = definition . format . strip ( value ) } if ( definition . list ) { const codeArray = Util . makeCodeArray ( definition . list ) value = VXApp . lookupCode ( definition , value , codeArray , index , messages , fieldIdKey , fieldIdVariables ) } if ( definition . codeArrayFunction ) { const codeArray = definition . codeArrayFunction ( ) value = VXApp . lookupCode ( definition , value , codeArray , index , messages , fieldIdKey , fieldIdVariables ) } if ( definition . rule ) { valid = VXApp . validateRule ( value , definition . rule , index , messages , fieldIdKey , fieldIdVariables ) } if ( ! valid ) { allValid = false return } const peerGuidPath = RecordImporter . peerGuidPath ( importSchema , path ) if ( peerGuidPath ) { const existingGuid = get ( results . record , peerGuidPath ) if ( ! existingGuid ) { set ( results . record , peerGuidPath , Util . getGuid ( ) ) } } const convertedValue = RecordImporter . convertValue ( uploadStats , definition , value ) set ( results . record , path , convertedValue ) } ) RecordImporter . postProcess ( importSchema , results . record ) if ( allValid ) { insertArray . push ( results ) return } OLog . debug ( ` ${ index } ${ allValid } ` + ` ${ OLog . debugString ( messages ) } ` ) return }
Process the entire row copying cells into results.record.
Process the entire row copying cells into results . record .