From dfb8a9aab672251eeb50c65bd289cf3006a5755c Mon Sep 17 00:00:00 2001 From: yevhenii-moroziuk Date: Thu, 12 Dec 2024 16:55:31 +0200 Subject: [PATCH 1/6] HCK-9128: Handle indexes without name --- forward_engineering/helpers/indexHelper.js | 6 ++--- .../entity_level/entityLevelConfig.json | 22 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/forward_engineering/helpers/indexHelper.js b/forward_engineering/helpers/indexHelper.js index 382ad1e..82ffcc7 100644 --- a/forward_engineering/helpers/indexHelper.js +++ b/forward_engineering/helpers/indexHelper.js @@ -61,7 +61,7 @@ module.exports = app => { }; const createIndex = (terminator, tableName, index, isParentActivated = true) => { - if (_.isEmpty(index.keys)) { + if (_.isEmpty(index.keys) || !index.name) { return ''; } @@ -132,7 +132,7 @@ module.exports = app => { }; const createFullTextIndex = (terminator, tableName, index, isParentActivated) => { - if (_.isEmpty(index.keys)) { + if (_.isEmpty(index.keys) || !index.keyIndex) { return ''; } const catalog = getFulltextCatalog(index); @@ -206,7 +206,7 @@ module.exports = app => { }; const createSpatialIndex = (terminator, tableName, index) => { - if (!index.column) { + if (!index.column || !index.name) { return ''; } const options = getSpatialOptions(index); diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index 2778106..2d9fb10 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -2,9 +2,9 @@ * Copyright © 2016-2020 by IntegrIT S.A. dba Hackolade. All rights reserved. * * The copyright to the computer software herein is the property of IntegrIT S.A. -* The software may be used and/or copied only with the written permission of -* IntegrIT S.A. or in accordance with the terms and conditions stipulated in -* the agreement/contract under which the software has been supplied. +* The software may be used and/or copied only with the written permission of +* IntegrIT S.A. or in accordance with the terms and conditions stipulated in +* the agreement/contract under which the software has been supplied. In order to define custom properties for any object's properties pane, you may copy/paste from the following, making sure that you maintain a proper JSON format. @@ -69,8 +69,8 @@ making sure that you maintain a proper JSON format. ] }, // “groupInput” can have the following states - 0 items, 1 item, and many items. -// “blockInput” has only 2 states - 0 items or 1 item. -// This gives us an easy way to represent it as an object and not as an array internally which is beneficial for processing +// “blockInput” has only 2 states - 0 items or 1 item. +// This gives us an easy way to represent it as an object and not as an array internally which is beneficial for processing // and forward-engineering in particular. { "propertyName": "Block", @@ -98,7 +98,7 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "keyList", "propertyType": "fieldList", "template": "orderedList" - }, + }, { "propertyName": "List with attribute", "propertyKeyword": "keyListOrder", @@ -666,7 +666,10 @@ making sure that you maintain a proper JSON format. "propertyName": "Name", "propertyKeyword": "indxName", "propertyTooltip": "", - "propertyType": "text" + "propertyType": "text", + "validation": { + "required": true + } }, { "propertyName": "Activated", @@ -809,7 +812,10 @@ making sure that you maintain a proper JSON format. "propertyName": "Name", "propertyKeyword": "indxName", "propertyTooltip": "", - "propertyType": "text" + "propertyType": "text", + "validation": { + "required": true + } }, { "propertyName": "Activated", From 8534455c51b0705166d720884fb6e0b2f501a377 Mon Sep 17 00:00:00 2001 From: yevhenii-moroziuk Date: Fri, 13 Dec 2024 21:05:59 +0200 Subject: [PATCH 2/6] HCK-9128: Handle indexes without indxKey --- forward_engineering/configs/templates.js | 2 +- forward_engineering/helpers/indexHelper.js | 16 +++--- .../entity_level/entityLevelConfig.json | 51 ++++++++++++++++++- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/forward_engineering/configs/templates.js b/forward_engineering/configs/templates.js index 82a11e7..a4fa707 100644 --- a/forward_engineering/configs/templates.js +++ b/forward_engineering/configs/templates.js @@ -15,7 +15,7 @@ module.exports = { index: 'CREATE${unique}${clustered}${columnstore} INDEX ${name}\n' + - '\tON ${table} ( ${keys} )${include}${expression}${relational_index_option}${terminator}\n', + '\tON ${table}${keys}${include}${expression}${relational_index_option}${terminator}\n', fullTextIndex: 'CREATE FULLTEXT INDEX ON ${table} (\n\t${keys}\n)\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n', diff --git a/forward_engineering/helpers/indexHelper.js b/forward_engineering/helpers/indexHelper.js index 82ffcc7..e907447 100644 --- a/forward_engineering/helpers/indexHelper.js +++ b/forward_engineering/helpers/indexHelper.js @@ -61,7 +61,9 @@ module.exports = app => { }; const createIndex = (terminator, tableName, index, isParentActivated = true) => { - if (_.isEmpty(index.keys) || !index.name) { + const isInvalidColumnStore = index.type !== 'columnstore' || (index.type === 'columnstore' && index.clustered); + + if ((_.isEmpty(index.keys) && isInvalidColumnStore) || !index.name) { return ''; } @@ -81,16 +83,18 @@ module.exports = app => { ? commentIfDeactivated(dividedKeys.deactivatedItems.join(', '), { isActivated: false }, true) : ''; + const keys = isParentActivated + ? dividedKeys.activatedItems.join(', ') + commentedKeys + : dividedKeys.activatedItems.join(', ') + + (dividedKeys.activatedItems.length ? ', ' : '') + + dividedKeys.deactivatedItems.join(', '); + return assignTemplates(templates.index, { name: index.name, unique: index.unique ? ' UNIQUE' : '', clustered: index.clustered ? ' CLUSTERED' : '', table: getTableName(tableName, index.schemaName), - keys: isParentActivated - ? dividedKeys.activatedItems.join(', ') + commentedKeys - : dividedKeys.activatedItems.join(', ') + - (dividedKeys.activatedItems.length ? ', ' : '') + - dividedKeys.deactivatedItems.join(', '), + keys: dividedKeys.activatedItems.length || commentedKeys.length ? ` ( ${keys} )` : '', columnstore: index.type === 'columnstore' ? ' COLUMNSTORE' : '', relational_index_option: relationalIndexOption.length ? '\n\tWITH (\n\t\t' + relationalIndexOption.join(',\n\t\t') + '\n\t)' diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index 2d9fb10..a9776d1 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -863,16 +863,55 @@ making sure that you maintain a proper JSON format. "propertyType": "fieldList", "template": "orderedList", "attributeList": ["ascending", "descending"], + "validation": { + "required": true, + "minLength": 1 + }, "dependency": { - "type": "or", + "key": "indxType", + "value": "Index" + } + }, + { + "propertyName": "Keys", + "propertyKeyword": "indxKey", + "propertyType": "fieldList", + "template": "orderedList", + "attributeList": ["ascending", "descending"], + "dependency": { + "type": "and", "values": [ { "key": "indxType", - "value": "Index" + "value": "Columnstore" }, + { + "key": "clusteredIndx", + "value": false + } + ] + }, + "validation": { + "required": true, + "minLength": 1 + } + }, + { + "propertyName": "Keys", + "propertyKeyword": "indxKey", + "propertyType": "fieldList", + "template": "orderedList", + "attributeList": ["ascending", "descending"], + "dependency": { + "type": "and", + "values": [ { "key": "indxType", "value": "Columnstore" + }, + { + "key": "clusteredIndx", + "value": true } ] } @@ -889,6 +928,10 @@ making sure that you maintain a proper JSON format. }, "templateOptions": { "maxFields": 1 + }, + "validation": { + "required": true, + "minLength": 1 } }, { @@ -1345,6 +1388,10 @@ making sure that you maintain a proper JSON format. "dependency": { "key": "indxType", "value": "FullText" + }, + "validation": { + "required": true, + "minLength": 1 } }, { From 3c6f304babfb4f0e57bc507948281f49df076bae Mon Sep 17 00:00:00 2001 From: yevhenii-moroziuk Date: Sun, 15 Dec 2024 19:18:48 +0200 Subject: [PATCH 3/6] HCK-9128: Handle indexes without indxKey --- forward_engineering/configs/templates.js | 3 +- forward_engineering/helpers/indexHelper.js | 44 ++++++++++--------- .../entity_level/entityLevelConfig.json | 17 ++++--- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/forward_engineering/configs/templates.js b/forward_engineering/configs/templates.js index a4fa707..0e30c4b 100644 --- a/forward_engineering/configs/templates.js +++ b/forward_engineering/configs/templates.js @@ -17,8 +17,7 @@ module.exports = { 'CREATE${unique}${clustered}${columnstore} INDEX ${name}\n' + '\tON ${table}${keys}${include}${expression}${relational_index_option}${terminator}\n', - fullTextIndex: - 'CREATE FULLTEXT INDEX ON ${table} (\n\t${keys}\n)\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n', + fullTextIndex: 'CREATE FULLTEXT INDEX ON ${table}\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n', spatialIndex: 'CREATE SPATIAL INDEX ${name} ON ${table} (${column})${using}\n${options}${terminator}\n', diff --git a/forward_engineering/helpers/indexHelper.js b/forward_engineering/helpers/indexHelper.js index e907447..c533235 100644 --- a/forward_engineering/helpers/indexHelper.js +++ b/forward_engineering/helpers/indexHelper.js @@ -61,7 +61,7 @@ module.exports = app => { }; const createIndex = (terminator, tableName, index, isParentActivated = true) => { - const isInvalidColumnStore = index.type !== 'columnstore' || (index.type === 'columnstore' && index.clustered); + const isInvalidColumnStore = index.type !== 'columnstore' || (index.type === 'columnstore' && !index.clustered); if ((_.isEmpty(index.keys) && isInvalidColumnStore) || !index.name) { return ''; @@ -136,33 +136,35 @@ module.exports = app => { }; const createFullTextIndex = (terminator, tableName, index, isParentActivated) => { - if (_.isEmpty(index.keys) || !index.keyIndex) { + if (!index.keyIndex) { return ''; } const catalog = getFulltextCatalog(index); const options = getFullTextOptions(index); - return assignTemplates(templates.fullTextIndex, { - table: getTableName(tableName, index.schemaName), - keys: index.keys - .map(key => { - let column = `[${key.name}]`; + const keys = index.keys + .map(key => { + let column = `[${key.name}]`; - if (key.columnType) { - column += ` TYPE COLUMN ${key.columnType}`; - } + if (key.columnType) { + column += ` TYPE COLUMN ${key.columnType}`; + } - if (key.languageTerm) { - column += ` LANGUAGE ${key.languageTerm}`; - } + if (key.languageTerm) { + column += ` LANGUAGE ${key.languageTerm}`; + } - if (key.statisticalSemantics) { - column += ` STATISTICAL_SEMANTICS`; - } + if (key.statisticalSemantics) { + column += ` STATISTICAL_SEMANTICS`; + } - return isParentActivated ? commentIfDeactivated(column, key) : column; - }) - .join(',\n\t'), + return isParentActivated ? commentIfDeactivated(column, key) : column; + }) + .join(',\n\t'); + + return assignTemplates(templates.fullTextIndex, { + table: getTableName(tableName, index.schemaName), + keys: keys ? ` (\n\t${keys}\n)\n` : '', indexName: index.keyIndex, catalog: catalog ? `ON ${catalog}\n` : '', options: options ? `WITH (\n\t${options}\n)` : '', @@ -230,9 +232,9 @@ module.exports = app => { return createSpatialIndex(terminator, tableName, index); } else if (index.type === 'fulltext') { return createFullTextIndex(terminator, tableName, index); - } else { - return createIndex(terminator, tableName, index, isParentActivated); } + + return createIndex(terminator, tableName, index, isParentActivated); }; const createMemoryOptimizedClusteredIndex = indexData => { diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index a9776d1..f3465ce 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -886,8 +886,13 @@ making sure that you maintain a proper JSON format. "value": "Columnstore" }, { - "key": "clusteredIndx", - "value": false + "type": "not", + "values": [ + { + "key": "clusteredIndx", + "value": true + } + ] } ] }, @@ -1388,10 +1393,6 @@ making sure that you maintain a proper JSON format. "dependency": { "key": "indxType", "value": "FullText" - }, - "validation": { - "required": true, - "minLength": 1 } }, { @@ -1423,11 +1424,13 @@ making sure that you maintain a proper JSON format. { "propertyName": "Key index", "propertyKeyword": "indxFullTextKeyIndex", - "requiredProperty": true, "propertyType": "text", "dependency": { "key": "indxType", "value": "FullText" + }, + "validation": { + "required": true } }, { From 61330521d1a4cf31170808e1df51eec57f1475a4 Mon Sep 17 00:00:00 2001 From: yevhenii-moroziuk Date: Sun, 15 Dec 2024 19:26:53 +0200 Subject: [PATCH 4/6] HCK-9128: Make name optional for full-text index --- .../entity_level/entityLevelConfig.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index f3465ce..1da363e 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -815,6 +815,25 @@ making sure that you maintain a proper JSON format. "propertyType": "text", "validation": { "required": true + }, + "dependency": { + "type": "not", + "values": [ + { + "key": "indxType", + "value": "FullText" + } + ] + } + }, + { + "propertyName": "Name", + "propertyKeyword": "indxName", + "propertyTooltip": "", + "propertyType": "text", + "dependency": { + "key": "indxType", + "value": "FullText" } }, { From 639447f58bf50ea0a6428a3da08ab73f52c5c02d Mon Sep 17 00:00:00 2001 From: yevhenii-moroziuk Date: Mon, 16 Dec 2024 12:26:44 +0200 Subject: [PATCH 5/6] HCK-9128: fix FE --- forward_engineering/configs/templates.js | 3 +- forward_engineering/helpers/indexHelper.js | 2 +- .../entity_level/entityLevelConfig.json | 28 +++++++++---------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/forward_engineering/configs/templates.js b/forward_engineering/configs/templates.js index 0e30c4b..d728e96 100644 --- a/forward_engineering/configs/templates.js +++ b/forward_engineering/configs/templates.js @@ -17,7 +17,8 @@ module.exports = { 'CREATE${unique}${clustered}${columnstore} INDEX ${name}\n' + '\tON ${table}${keys}${include}${expression}${relational_index_option}${terminator}\n', - fullTextIndex: 'CREATE FULLTEXT INDEX ON ${table}\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n', + fullTextIndex: + 'CREATE FULLTEXT INDEX ON ${table}${keys}\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n', spatialIndex: 'CREATE SPATIAL INDEX ${name} ON ${table} (${column})${using}\n${options}${terminator}\n', diff --git a/forward_engineering/helpers/indexHelper.js b/forward_engineering/helpers/indexHelper.js index c533235..4c3f046 100644 --- a/forward_engineering/helpers/indexHelper.js +++ b/forward_engineering/helpers/indexHelper.js @@ -164,7 +164,7 @@ module.exports = app => { return assignTemplates(templates.fullTextIndex, { table: getTableName(tableName, index.schemaName), - keys: keys ? ` (\n\t${keys}\n)\n` : '', + keys: keys ? ` (\n\t${keys}\n)` : '', indexName: index.keyIndex, catalog: catalog ? `ON ${catalog}\n` : '', options: options ? `WITH (\n\t${options}\n)` : '', diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index 1da363e..2a4b050 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -927,15 +927,24 @@ making sure that you maintain a proper JSON format. "template": "orderedList", "attributeList": ["ascending", "descending"], "dependency": { - "type": "and", + "type": "or", "values": [ { "key": "indxType", - "value": "Columnstore" + "value": "FullText" }, { - "key": "clusteredIndx", - "value": true + "type": "and", + "values": [ + { + "key": "indxType", + "value": "Columnstore" + }, + { + "key": "clusteredIndx", + "value": true + } + ] } ] } @@ -1403,17 +1412,6 @@ making sure that you maintain a proper JSON format. ] } }, - { - "propertyName": "Keys", - "propertyKeyword": "indxKey", - "propertyType": "fieldList", - "template": "orderedList", - "attributeList": [], - "dependency": { - "key": "indxType", - "value": "FullText" - } - }, { "propertyName": "Keys properties", "propertyKeyword": "indxFullTextKeysProperties", From d3a44e22e54fbc5c3935111404e196eede24b481 Mon Sep 17 00:00:00 2001 From: yevhenii-moroziuk Date: Mon, 16 Dec 2024 17:37:08 +0200 Subject: [PATCH 6/6] HCK-9128: simplify the statement --- forward_engineering/helpers/indexHelper.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/forward_engineering/helpers/indexHelper.js b/forward_engineering/helpers/indexHelper.js index 4c3f046..57de340 100644 --- a/forward_engineering/helpers/indexHelper.js +++ b/forward_engineering/helpers/indexHelper.js @@ -83,11 +83,14 @@ module.exports = app => { ? commentIfDeactivated(dividedKeys.deactivatedItems.join(', '), { isActivated: false }, true) : ''; - const keys = isParentActivated - ? dividedKeys.activatedItems.join(', ') + commentedKeys - : dividedKeys.activatedItems.join(', ') + - (dividedKeys.activatedItems.length ? ', ' : '') + - dividedKeys.deactivatedItems.join(', '); + const activatedKeys = dividedKeys.activatedItems.join(', '); + const deactivatedKeys = dividedKeys.deactivatedItems.join(', '); + + let keys = activatedKeys + commentedKeys; + + if (!isParentActivated) { + keys = activatedKeys + (activatedKeys && deactivatedKeys ? ', ' : '') + deactivatedKeys; + } return assignTemplates(templates.index, { name: index.name,