diff --git a/src/server/models/Conversion.js b/src/server/models/Conversion.js index d9a857467..37ce9c0a2 100644 --- a/src/server/models/Conversion.js +++ b/src/server/models/Conversion.js @@ -7,16 +7,16 @@ const sqlFile = database.sqlFile; class Conversion { /** - * @param {*} sourceName The unit id of the source. - * @param {*} destinationName The unit id of the destination. + * @param {*} sourceId The unit id of the source. + * @param {*} destinationId The unit id of the destination. * @param {*} bidirectional Is this conversion bidirectional? * @param {*} slope The slope of the conversion. * @param {*} intercept The intercept of the conversion. * @param {*} note Comments by the admin or OED inserted. */ - constructor(sourceName, destinationName, bidirectional, slope, intercept, note) { - this.sourceName = sourceName; - this.destinationName = destinationName; + constructor(sourceId, destinationId, bidirectional, slope, intercept, note) { + this.sourceId = sourceId; + this.destinationId = destinationId; this.bidirectional = bidirectional; this.slope = slope; this.intercept = intercept; diff --git a/src/server/routes/conversions.js b/src/server/routes/conversions.js index cd4ac840f..31b548835 100644 --- a/src/server/routes/conversions.js +++ b/src/server/routes/conversions.js @@ -13,7 +13,7 @@ const router = express.Router(); function formatConversionForResponse(item) { return { - sourceName: item.sourceName, destinationName: item.destinationName, bidirectional: item.bidirectional, slope: item.slope, intercept: item.intercept, note: item.note + sourceId: item.sourceId, destinationId: item.destinationId, bidirectional: item.bidirectional, slope: item.slope, intercept: item.intercept, note: item.note }; } @@ -36,14 +36,14 @@ router.get('/', async (req, res) => { router.post('/edit', async (req, res) => { const validConversion = { type: 'object', - required: ['sourceName', 'destinationName', 'bidirectional', 'slope', 'intercept'], + required: ['sourceId', 'destinationId', 'bidirectional', 'slope', 'intercept'], properties: { - sourceName: { + sourceId: { type: 'number', // Do not allow negatives for now minimum: 0 }, - destinationName: { + destinationId: { type: 'number', // Do not allow negatives for now minimum: 0 @@ -73,7 +73,7 @@ router.post('/edit', async (req, res) => { } else { const conn = getConnection(); try { - const updatedConversion = new Conversion(req.body.sourceName, req.body.destinationName, req.body.bidirectional, + const updatedConversion = new Conversion(req.body.sourceId, req.body.destinationId, req.body.bidirectional, req.body.slope, req.body.intercept, req.body.note); await updatedConversion.update(conn); } catch (err) { @@ -90,14 +90,14 @@ router.post('/edit', async (req, res) => { router.post('/addConversion', async (req, res) => { const validConversion = { type: 'object', - required: ['sourceName', 'destinationName', 'bidirectional', 'slope', 'intercept'], + required: ['sourceId', 'destinationId', 'bidirectional', 'slope', 'intercept'], properties: { - sourceName: { + sourceId: { type: 'number', // Do not allow negatives for now minimum: 0 }, - destinationName: { + destinationId: { type: 'number', // Do not allow negatives for now minimum: 0 @@ -128,8 +128,8 @@ router.post('/addConversion', async (req, res) => { try { await conn.tx(async t => { const newConversion = new Conversion( - req.body.sourceName, - req.body.destinationName, + req.body.sourceId, + req.body.destinationId, req.body.bidirectional, req.body.slope, req.body.intercept, @@ -152,14 +152,14 @@ router.post('/delete', async (req, res) => { // Only require a source and destination id const validConversion = { type: 'object', - required: ['sourceName', 'destinationName'], + required: ['sourceId', 'destinationId'], properties: { - sourceName: { + sourceId: { type: 'number', // Do not allow negatives for now minimum: 0 }, - destinationName: { + destinationId: { type: 'number', // Do not allow negatives for now minimum: 0 @@ -177,12 +177,12 @@ router.post('/delete', async (req, res) => { try { // Don't worry about checking if the conversion already exists // Just try to delete it to save the extra database call, since the database will return an error anyway if the row does not exist - await Conversion.delete(req.body.sourceName, req.body.destinationName, conn); + await Conversion.delete(req.body.sourceId, req.body.destinationId, conn); } catch (err) { log.error(`Error while deleting conversion with error(s): ${err}`); failure(res, 500, `Error while deleting conversion with errors(s): ${err}`); } - success(res, `Successfully deleted conversion ${req.body.sourceName} -> ${req.body.destinationName}`); + success(res, `Successfully deleted conversion ${req.body.sourceId} -> ${req.body.destinationId}`); } }); diff --git a/src/server/services/graph/createConversionArrays.js b/src/server/services/graph/createConversionArrays.js index ce1aafd5a..7eddaadb6 100644 --- a/src/server/services/graph/createConversionArrays.js +++ b/src/server/services/graph/createConversionArrays.js @@ -71,10 +71,10 @@ async function createCikArray(graph, conn) { await assignIndex(destinations, conn); for (const source of sources) { for (const destination of destinations) { - const sourceName = source.id; - const destinationName = destination.id; + const sourceId = source.id; + const destinationId = destination.id; // The shortest path from source to destination. - const path = getPath(graph, sourceName, destinationName); + const path = getPath(graph, sourceId, destinationId); // Check if the path exists. // If not, we will do nothing since the array has been initialized with [Nan, Nan, '']. if (path !== null) { diff --git a/src/server/services/graph/createConversionGraph.js b/src/server/services/graph/createConversionGraph.js index f35384a98..995a0d66c 100644 --- a/src/server/services/graph/createConversionGraph.js +++ b/src/server/services/graph/createConversionGraph.js @@ -21,9 +21,9 @@ async function createConversionGraph(conn) { const conversions = await Conversion.getAll(conn); for (let i = 0; i < conversions.length; ++i) { - graph.addLink(conversions[i].sourceName, conversions[i].destinationName); + graph.addLink(conversions[i].sourceId, conversions[i].destinationId); if (conversions[i].bidirectional) { - graph.addLink(conversions[i].destinationName, conversions[i].sourceName); + graph.addLink(conversions[i].destinationId, conversions[i].sourceId); } } @@ -33,16 +33,16 @@ async function createConversionGraph(conn) { /** * Returns the list of units on the shortest path from source to destination. * @param {*} graph The conversion graph. - * @param {*} sourceName The source unit's id. - * @param {*} destinationName The destination unit's id. + * @param {*} sourceId The source unit's id. + * @param {*} destinationId The destination unit's id. * @returns */ -function getPath(graph, sourceName, destinationName) { +function getPath(graph, sourceId, destinationId) { const pathFinder = path.aStar(graph, { oriented: true }); // The path is returned in reversed order so we need to reverse it. - const p = pathFinder.find(sourceName, destinationName).reverse(); + const p = pathFinder.find(sourceId, destinationId).reverse(); if (p.length <= 1) { // Returns null if the path doesn't exist. return null; @@ -52,17 +52,17 @@ function getPath(graph, sourceName, destinationName) { /** * Returns all shortest paths from a unit to others. - * @param {*} sourceName The source unit's id. + * @param {*} sourceId The source unit's id. * @param {*} graph The conversion graph. * @returns */ -function getAllPaths(graph, sourceName) { +function getAllPaths(graph, sourceId) { let paths = []; // Loops through all the unit's ids in the graph. graph.forEachNode(destination => { - const destinationName = destination.id; + const destinationId = destination.id; // The shortest path from source to destination. - const currentPath = getPath(graph, sourceName, destinationName); + const currentPath = getPath(graph, sourceId, destinationId); // Checks if the path exists. if (currentPath !== null) { paths.push(currentPath); diff --git a/src/server/services/graph/handleSuffixUnits.js b/src/server/services/graph/handleSuffixUnits.js index deb79561d..0db9def46 100644 --- a/src/server/services/graph/handleSuffixUnits.js +++ b/src/server/services/graph/handleSuffixUnits.js @@ -9,17 +9,17 @@ const { getAllPaths } = require('./createConversionGraph'); /** * Adds the new unit and conversions to the database and the conversion graph. - * @param {*} sourceName The source unit's id. - * @param {*} destinationName The destination unit's id. + * @param {*} sourceId The source unit's id. + * @param {*} destinationId The destination unit's id. * @param {*} slope The conversion's slope from source to destination. * @param {*} intercept The conversion's intercept from source to destination. * @param {*} unitName The new unit's name. * @param {*} unitIdentifier The new unit's identifier. * @param {*} conn The connection to use. */ -async function addNewUnitAndConversion(sourceName, destinationName, slope, intercept, unitName, unitIdentifier, graph, conn) { - const sourceUnit = await Unit.getById(sourceName, conn); - const destinationUnit = await Unit.getById(destinationName, conn); +async function addNewUnitAndConversion(sourceId, destinationId, slope, intercept, unitName, unitIdentifier, graph, conn) { + const sourceUnit = await Unit.getById(sourceId, conn); + const destinationUnit = await Unit.getById(destinationId, conn); // Add a new units where: name is unitName, identifier is unitIdentifier, type_of_unit is Unit.type.suffix, // displayable and preferredDisplay is the same as destination. // Note a type_of_unit of suffix is different than a unit with a suffix string. @@ -30,13 +30,13 @@ async function addNewUnitAndConversion(sourceName, destinationName, slope, inter await newUnit.insert(conn); // Create the conversion from the prefix unit to this new unit. - const newConversion = new Conversion(sourceName, newUnit.id, false, slope, intercept, + const newConversion = new Conversion(sourceId, newUnit.id, false, slope, intercept, `${sourceUnit.name} → ${newUnit.name} (created by OED for unit with suffix)`); await newConversion.insert(conn); // Add the new node and conversion to the graph. graph.addNode(newUnit.id, newUnit.name); - graph.addLink(sourceName, newUnit.id); + graph.addLink(sourceId, newUnit.id); } /** @@ -49,17 +49,17 @@ async function addNewUnitAndConversion(sourceName, destinationName, slope, inter * @param {*} conn The connection to use. */ async function verifyConversion(expectedSlope, expectedIntercept, source, destination, graph, conn) { - const sourceName = source.id; - const destinationName = destination.id; - const currentConversion = await Conversion.getBySourceDestination(sourceName, destinationName, conn); + const sourceId = source.id; + const destinationId = destination.id; + const currentConversion = await Conversion.getBySourceDestination(sourceId, destinationId, conn); if (!currentConversion) { // The destination suffix unit exists but the conversion doesn't. // Create a new conversion with desired values. - const newConversion = new Conversion(sourceName, destinationName, false, expectedSlope, expectedIntercept, + const newConversion = new Conversion(sourceId, destinationId, false, expectedSlope, expectedIntercept, `${source.name} → ${destination.name} (created by OED for unit with suffix)`); // Insert the new conversion to database and graph. await newConversion.insert(conn); - graph.addLink(sourceName, destinationName); + graph.addLink(sourceId, destinationId); } else if (currentConversion.slope !== expectedSlope || currentConversion.intercept !== expectedIntercept) { // While unlikely, the conversion changed so update currentConversion.slope = expectedSlope; @@ -99,11 +99,11 @@ async function hideSuffixUnit(unit, paths, graph, conn) { /** * Check if the suffix unit's displayable is the same as the destination unit. * @param {*} suffixUnit The suffix unit to check. - * @param {*} destinationName The destination unit's id + * @param {*} destinationId The destination unit's id * @param {*} conn The connection to use. */ -async function verifyUnit(suffixUnit, destinationName, conn) { - const destinationUnit = await Unit.getById(destinationName, conn); +async function verifyUnit(suffixUnit, destinationId, conn) { + const destinationUnit = await Unit.getById(destinationId, conn); if (suffixUnit.displayable !== destinationUnit.displayable) { suffixUnit.displayable = destinationUnit.displayable; await suffixUnit.update(conn); @@ -124,10 +124,10 @@ async function handleSuffixUnits(graph, conn) { const paths = getAllPaths(graph, unit.id); // Analyze each path for (const p of paths) { - const sourceName = p[0].id; - const destinationName = p[p.length - 1].id; + const sourceId = p[0].id; + const destinationId = p[p.length - 1].id; // The destination unit. - const destinationUnit = await Unit.getById(destinationName, conn); + const destinationUnit = await Unit.getById(destinationId, conn); // We don't need to create any new units/conversions if the destination unit has the type of suffix or it's not displayed. if (destinationUnit.typeOfUnit === Unit.unitType.SUFFIX || destinationUnit.displayable === Unit.displayableType.NONE) { continue; @@ -141,10 +141,10 @@ async function handleSuffixUnits(graph, conn) { // See if this unit already exists. Would if this was done before where this path existed. if (neededSuffixUnit === null) { // If not then add the new unit and conversion. - await addNewUnitAndConversion(sourceName, destinationName, slope, intercept, unitName, unitIdentifier, graph, conn); + await addNewUnitAndConversion(sourceId, destinationId, slope, intercept, unitName, unitIdentifier, graph, conn); } else { // If it already exists then check if the unit and conversion are correct. - await verifyUnit(neededSuffixUnit, destinationName, conn); + await verifyUnit(neededSuffixUnit, destinationId, conn); await verifyConversion(slope, intercept, unit, neededSuffixUnit, graph, conn); } } @@ -164,13 +164,13 @@ async function handleSuffixUnits(graph, conn) { */ async function removeAdditionalConversionsAndUnits(suffixUnit, conn) { // Get all conversions from this suffix unit. - const conversions = (await Conversion.getAll(conn)).filter((conversion) => conversion.sourceName === suffixUnit.id); + const conversions = (await Conversion.getAll(conn)).filter((conversion) => conversion.sourceId === suffixUnit.id); conversions.forEach(async (conversion) => { - const destinationUnit = await Unit.getById(conversion.destinationName, conn); + const destinationUnit = await Unit.getById(conversion.destinationId, conn); // The units that OED adds are suffix unit. if (destinationUnit.typeOfUnit === Unit.unitType.SUFFIX) { // Delete the conversion. - await Conversion.delete(conversion.sourceName, conversion.destinationName, conn); + await Conversion.delete(conversion.sourceId, conversion.destinationId, conn); // Hide the destination unit. destinationUnit.displayable = Unit.displayableType.NONE; await destinationUnit.update(conn); diff --git a/src/server/services/graph/pathConversion.js b/src/server/services/graph/pathConversion.js index c0d1002bf..1d73f1bfd 100644 --- a/src/server/services/graph/pathConversion.js +++ b/src/server/services/graph/pathConversion.js @@ -88,9 +88,9 @@ async function pathConversion(path, conn) { let intercept = 0; let suffix = ''; for (let i = 0; i < path.length - 1; ++i) { - const sourceName = path[i].id; - const destinationName = path[i + 1].id; - const [newSlope, newIntercept, newSuffix] = await conversionValues(sourceName, destinationName, conn); + const sourceId = path[i].id; + const destinationId = path[i + 1].id; + const [newSlope, newIntercept, newSuffix] = await conversionValues(sourceId, destinationId, conn); // Updates the path conversion for this new edge. [slope, intercept] = updatedConversion(slope, intercept, newSlope, newIntercept); // Updates the suffix for this new edge. diff --git a/src/server/sql/conversion/insert_new_conversion.sql b/src/server/sql/conversion/insert_new_conversion.sql index 138cf27b4..2203c7f3d 100644 --- a/src/server/sql/conversion/insert_new_conversion.sql +++ b/src/server/sql/conversion/insert_new_conversion.sql @@ -3,4 +3,4 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ INSERT INTO conversions(source_id, destination_id, bidirectional, slope, intercept, note) -VALUES (${sourceName}, ${destinationName}, ${bidirectional}, ${slope}, ${intercept}, ${note}); +VALUES (${sourceId}, ${destinationId}, ${bidirectional}, ${slope}, ${intercept}, ${note}); diff --git a/src/server/sql/conversion/update_conversion.sql b/src/server/sql/conversion/update_conversion.sql index efa0c9354..52a309c05 100644 --- a/src/server/sql/conversion/update_conversion.sql +++ b/src/server/sql/conversion/update_conversion.sql @@ -7,4 +7,4 @@ UPDATE conversions slope = ${slope}, intercept = ${intercept}, note = ${note} - WHERE source_id = ${sourceName} AND destination_id = ${destinationName}; + WHERE source_id = ${sourceId} AND destination_id = ${destinationId}; diff --git a/src/server/test/db/conversionTests.js b/src/server/test/db/conversionTests.js index 12a9d21a0..90e550a9c 100644 --- a/src/server/test/db/conversionTests.js +++ b/src/server/test/db/conversionTests.js @@ -12,8 +12,8 @@ const Unit = require('../../models/Unit'); * @param {*} actual The actual conversion. */ function expectConversionToBeEquivalent(expected, actual) { - expect(actual).to.have.property('sourceName', expected.sourceName); - expect(actual).to.have.property('destinationName', expected.destinationName); + expect(actual).to.have.property('sourceId', expected.sourceId); + expect(actual).to.have.property('destinationId', expected.destinationId); expect(actual).to.have.property('bidirectional', expected.bidirectional); expect(actual).to.have.property('slope', expected.slope); expect(actual).to.have.property('intercept', expected.intercept); @@ -49,7 +49,7 @@ mocha.describe('Conversions', () => { const conversionPreInsert = new Conversion(unitAId, unitBId, true, 1.23, 4.56, 'Note'); await conversionPreInsert.insert(conn); - // Updates the conversion. Note that the sourceName and destinationName can't be changed. + // Updates the conversion. Note that the sourceId and destinationId can't be changed. conversionPreInsert.bidirectional = false; conversionPreInsert.intercept = 3.14; conversionPreInsert.note = 'New note'; diff --git a/src/server/util/insertData.js b/src/server/util/insertData.js index 8b00553a9..c7f62cd60 100644 --- a/src/server/util/insertData.js +++ b/src/server/util/insertData.js @@ -24,20 +24,16 @@ async function insertUnits(unitsToInsert, update = false, conn) { for (let i = 0; i < unitsToInsert.length; ++i) { // Meter key/value pairs for the current meter. const uData = unitsToInsert[i]; - + // Check that needed keys are there. const requiredKeys = ['name', 'unitRepresent', 'typeOfUnit', 'displayable', 'preferredDisplay']; ok = true; requiredKeys.forEach(key => { - if ((key == 'name') && (typeof uData[key] !== 'string')){ - console.log(`********key "${key}" is required but missing so unit number ${i} not processed`); - ok = false; - } - if (((key == 'unitRepresent') || (key == 'typeOfUnit') || (key == 'displayable')) && (typeof uData[key] !== 'string')){ + if (((key == 'name') || (key == 'unitRepresent') || (key == 'typeOfUnit') || (key == 'displayable')) && (typeof uData[key] !== 'string')) { console.log(`********key "${key}" is required but missing so conversion number ${i} not processed`); ok = false; } - if ((key == 'preferredDisplay') && (typeof uData[key] !== 'boolean')){ + if ((key == 'preferredDisplay') && (typeof uData[key] !== 'boolean')) { console.log(`********key "${key}" is required but missing so unit number ${i} not processed`); ok = false; } @@ -62,8 +58,8 @@ async function insertUnits(unitsToInsert, update = false, conn) { dbUnit.note = unitData.note; // Should update even though exists. await dbUnit.update(conn); - // Otherwise do not update. } + // Otherwise do not update. } } )); @@ -80,10 +76,10 @@ async function insertStandardUnits(conn) { name: 'kWh', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.ALL, + displayable: Unit.displayableType.ALL, preferredDisplay: true, note: 'OED created standard unit' }, @@ -91,10 +87,10 @@ async function insertStandardUnits(conn) { name: 'BTU', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: true, note: 'OED created standard unit' }, @@ -102,10 +98,10 @@ async function insertStandardUnits(conn) { name: 'm³ gas', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: false, note: 'OED created standard unit' }, @@ -113,10 +109,10 @@ async function insertStandardUnits(conn) { name: 'kg', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: false, note: 'OED created standard unit' }, @@ -124,10 +120,10 @@ async function insertStandardUnits(conn) { name: 'metric ton', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: false, note: 'OED created standard unit' }, @@ -135,10 +131,10 @@ async function insertStandardUnits(conn) { name: 'gallon', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: true, note: 'OED created standard unit' }, @@ -146,10 +142,10 @@ async function insertStandardUnits(conn) { name: 'liter', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: true, note: 'OED created standard unit' }, @@ -157,10 +153,10 @@ async function insertStandardUnits(conn) { name: 'Fahrenheit', identifier: '', unitRepresent: Unit.unitRepresentType.RAW, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: false, note: 'OED created standard unit' }, @@ -168,10 +164,10 @@ async function insertStandardUnits(conn) { name: 'Celsius', identifier: '', unitRepresent: Unit.unitRepresentType.RAW, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: false, note: 'OED created standard unit' }, @@ -179,10 +175,10 @@ async function insertStandardUnits(conn) { name: 'Electric_Utility', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.METER, + secInRate: 3600, + typeOfUnit: Unit.unitType.METER, suffix: '', - displayable: Unit.displayableType.NONE, + displayable: Unit.displayableType.NONE, preferredDisplay: false, note: 'OED created meter unit' }, @@ -204,20 +200,20 @@ async function insertConversions(conversionsToInsert, conn) { for (let i = 0; i < conversionsToInsert.length; ++i) { // Meter key/value pairs for the current meter. const cData = conversionsToInsert[i]; - + // Check that needed keys are there. const requiredKeys = ['sourceName', 'destinationName', 'bidirectional', 'slope', 'intercept']; ok = true; requiredKeys.forEach(key => { - if (((key == 'sourceName') || (key == 'destinationName')) && (typeof cData[key] !== 'string')){ + if (((key == 'sourceName') || (key == 'destinationName')) && (typeof cData[key] !== 'string')) { console.log(`********key "${key}" is required but missing so conversion number ${i} not processed`); ok = false; } - if ((key == 'bidirectional') && (typeof cData[key] !== 'boolean')){ + if ((key == 'bidirectional') && (typeof cData[key] !== 'boolean')) { console.log(`********key "${key}" is required but missing so conversion number ${i} not processed`); ok = false; } - if (((key == 'slope') || (key == 'intercept')) && (typeof cData[key] !== 'number')){ + if (((key == 'slope') || (key == 'intercept')) && (typeof cData[key] !== 'number')) { console.log(`********key "${key}" is required but missing so conversion number ${i} not processed`); ok = false; }