Skip to content

Commit a41cee1

Browse files
HCK-14977: Custom scripts - regular model (#71)
* HCK-14977: Custom scripts - regular model * fix * fix * fix * fix * backward compatibility * remove
1 parent bf001db commit a41cee1

7 files changed

Lines changed: 418 additions & 26 deletions

File tree

forward_engineering/ddlProvider.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = (baseProvider, options, app) => {
5656
const additionalOptions = getAdditionalOptions(options.additionalOptions);
5757

5858
return dropStatementProxy({ commentIfDeactivated })(additionalOptions.applyDropStatements, {
59-
hydrateDatabase(containerData) {
59+
hydrateSchema(containerData) {
6060
return {
6161
databaseName: containerData.name,
6262
isActivated: containerData.isActivated,
@@ -72,6 +72,11 @@ module.exports = (baseProvider, options, app) => {
7272
};
7373
},
7474

75+
// Keep it because it was used to hydrate `dbData` for the API
76+
hydrateDatabase(containerData) {
77+
return this.hydrateSchema(containerData);
78+
},
79+
7580
hydrateTable({ tableData, entityData, jsonSchema }) {
7681
const detailsTab = entityData[0];
7782
const tableIndexes = entityData[2].Indxs;
@@ -162,7 +167,7 @@ module.exports = (baseProvider, options, app) => {
162167
};
163168
},
164169

165-
createDatabase({
170+
createSchema({
166171
databaseName,
167172
isActivated = true,
168173
db_account,
@@ -620,7 +625,7 @@ module.exports = (baseProvider, options, app) => {
620625
* @param {Array<HydrateDropContainerData>} containerData
621626
* @return {DropContainerData}
622627
*/
623-
hydrateDropDatabase(containerData) {
628+
hydrateDropSchema(containerData) {
624629
return {
625630
databaseName: containerData[0]?.name || '',
626631
};
@@ -631,7 +636,7 @@ module.exports = (baseProvider, options, app) => {
631636
* @param {ContainerCompModeData} compModeData
632637
* @return {ModifyContainerData}
633638
*/
634-
hydrateAlterDatabase({ containerData, compModeData }) {
639+
hydrateAlterSchema({ containerData, compModeData }) {
635640
const data = containerData[0] || {};
636641

637642
const isDbAccountModified = compModeData.new.db_account !== compModeData.old.db_account;
@@ -890,15 +895,15 @@ module.exports = (baseProvider, options, app) => {
890895
* @param {DropContainerData} dropDbData
891896
* @return {string}
892897
*/
893-
dropDatabase(dropDbData) {
898+
dropSchema(dropDbData) {
894899
return assignTemplates(templates.dropDatabase, dropDbData);
895900
},
896901

897902
/**
898903
* @param {ModifyContainerData} alterDbData
899904
* @return {string}
900905
*/
901-
alterDatabase(alterDbData) {
906+
alterSchema(alterDbData) {
902907
const databaseOptions = getDatabaseOptions(alterDbData);
903908

904909
return assignTemplates(templates.modifyDatabase, {
@@ -1120,5 +1125,13 @@ module.exports = (baseProvider, options, app) => {
11201125
this.createView(alterData, dbData, true),
11211126
].join('\n\n');
11221127
},
1128+
1129+
commentStatement(statement) {
1130+
return commentIfDeactivated(statement, { isActivated: false });
1131+
},
1132+
1133+
prepareName(name) {
1134+
return getTableName(name);
1135+
},
11231136
});
11241137
};

forward_engineering/helpers/dropStatementProxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const dropStatementProxy =
55

66
return {
77
...ddlProvider,
8-
...['dropDatabase', 'dropTable', 'dropColumn', 'dropIndex', 'dropCheckConstraint', 'dropView'].reduce(
8+
...['dropSchema', 'dropTable', 'dropColumn', 'dropIndex', 'dropCheckConstraint', 'dropView'].reduce(
99
(result, method) => {
1010
return {
1111
...result,

localization/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,10 @@
174174
"MODAL_WINDOW___OPTIONS_DISPLAY_ERD_V_ENTITY_BOX_CONTENT": "Display of table box content",
175175
"MODAL_WINDOW___OPTIONS_DISPLAY_ERD_V_FIELDS": "Columns",
176176
"MODAL_WINDOW___OPTIONS_DISPLAY_REQUIRED_ATTRIBUTES": "Required columns",
177-
"MODAL_WINDOW___OPTIONS_DISPLAY_NULLABLE_ATTRIBUTES": "Nullable columns"
177+
"MODAL_WINDOW___OPTIONS_DISPLAY_NULLABLE_ATTRIBUTES": "Nullable columns",
178+
179+
"CUSTOM_SCRIPT_CONTAINER_VAR_NAME": "Database name",
180+
"CUSTOM_SCRIPT_CONTAINER_VAR": "databaseName",
181+
"CUSTOM_SCRIPT_ENTITY_VAR_NAME": "Table name",
182+
"CUSTOM_SCRIPT_ENTITY_VAR": "tableName"
178183
}

properties_pane/container_level/containerLevelConfig.json

Lines changed: 128 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Copyright © 2016-2019 by IntegrIT S.A. dba Hackolade. All rights reserved.
33
*
44
* The copyright to the computer software herein is the property of IntegrIT S.A.
5-
* The software may be used and/or copied only with the written permission of
6-
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
7-
* the agreement/contract under which the software has been supplied.
5+
* The software may be used and/or copied only with the written permission of
6+
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
7+
* the agreement/contract under which the software has been supplied.
88

99

1010
In order to define custom properties for any object's properties pane, you may copy/paste from the following,
@@ -71,8 +71,8 @@ making sure that you maintain a proper JSON format.
7171
]
7272
},
7373
// “groupInput” can have the following states - 0 items, 1 item, and many items.
74-
// “blockInput” has only 2 states - 0 items or 1 item.
75-
// This gives us an easy way to represent it as an object and not as an array internally which is beneficial for processing
74+
// “blockInput” has only 2 states - 0 items or 1 item.
75+
// This gives us an easy way to represent it as an object and not as an array internally which is beneficial for processing
7676
// and forward-engineering in particular.
7777
{
7878
"propertyName": "Block",
@@ -100,7 +100,7 @@ making sure that you maintain a proper JSON format.
100100
"propertyKeyword": "keyList",
101101
"propertyType": "fieldList",
102102
"template": "orderedList"
103-
},
103+
},
104104
{
105105
"propertyName": "List with attribute",
106106
"propertyKeyword": "keyListOrder",
@@ -179,6 +179,128 @@ making sure that you maintain a proper JSON format.
179179
"propertyType": "text",
180180
"propertyTooltip": "A database can contain only one default journal table. However, any table in a particular database can use a journal table in a different database. By default the journal tebale is created in the new database if none is specified."
181181
},
182+
{
183+
"propertyName": "Custom scripts",
184+
"propertyType": "block",
185+
"propertyKeyword": "customScripts",
186+
"propertyTooltip": "",
187+
"structure": [
188+
{
189+
"propertyName": "Before CREATE DATABASE",
190+
"propertyKeyword": "beforeCreateContainer",
191+
"propertyType": "block",
192+
"propertyTooltip": "",
193+
"structure": [
194+
{
195+
"propertyName": "Script",
196+
"propertyKeyword": "script",
197+
"propertyType": "details",
198+
"markdown": false,
199+
"template": "codeEditor",
200+
"templateOptions": {
201+
"editorDialect": "sql",
202+
"customScriptVariables": true
203+
}
204+
}
205+
]
206+
},
207+
{
208+
"propertyName": "After CREATE DATABASE",
209+
"propertyKeyword": "afterCreateContainer",
210+
"propertyType": "block",
211+
"propertyTooltip": "",
212+
"structure": [
213+
{
214+
"propertyName": "Script",
215+
"propertyKeyword": "script",
216+
"propertyType": "details",
217+
"markdown": false,
218+
"template": "codeEditor",
219+
"templateOptions": {
220+
"editorDialect": "sql",
221+
"customScriptVariables": true
222+
}
223+
}
224+
]
225+
},
226+
{
227+
"propertyName": "Before each CREATE TABLE",
228+
"propertyKeyword": "beforeCreateEntity",
229+
"propertyType": "block",
230+
"propertyTooltip": "",
231+
"structure": [
232+
{
233+
"propertyName": "Script",
234+
"propertyKeyword": "script",
235+
"propertyType": "details",
236+
"markdown": false,
237+
"template": "codeEditor",
238+
"templateOptions": {
239+
"editorDialect": "sql",
240+
"customScriptVariables": true
241+
}
242+
}
243+
]
244+
},
245+
{
246+
"propertyName": "After each CREATE TABLE",
247+
"propertyKeyword": "afterCreateEntity",
248+
"propertyType": "block",
249+
"propertyTooltip": "",
250+
"structure": [
251+
{
252+
"propertyName": "Script",
253+
"propertyKeyword": "script",
254+
"propertyType": "details",
255+
"markdown": false,
256+
"template": "codeEditor",
257+
"templateOptions": {
258+
"editorDialect": "sql",
259+
"customScriptVariables": true
260+
}
261+
}
262+
]
263+
},
264+
{
265+
"propertyName": "Before each CREATE VIEW",
266+
"propertyKeyword": "beforeCreateView",
267+
"propertyType": "block",
268+
"propertyTooltip": "",
269+
"structure": [
270+
{
271+
"propertyName": "Script",
272+
"propertyKeyword": "script",
273+
"propertyType": "details",
274+
"markdown": false,
275+
"template": "codeEditor",
276+
"templateOptions": {
277+
"editorDialect": "sql",
278+
"customScriptVariables": true
279+
}
280+
}
281+
]
282+
},
283+
{
284+
"propertyName": "After each CREATE VIEW",
285+
"propertyKeyword": "afterCreateView",
286+
"propertyType": "block",
287+
"propertyTooltip": "",
288+
"structure": [
289+
{
290+
"propertyName": "Script",
291+
"propertyKeyword": "script",
292+
"propertyType": "details",
293+
"markdown": false,
294+
"template": "codeEditor",
295+
"templateOptions": {
296+
"editorDialect": "sql",
297+
"customScriptVariables": true
298+
}
299+
}
300+
]
301+
}
302+
]
303+
},
182304
{
183305
"propertyName": "Comments",
184306
"propertyKeyword": "description",

properties_pane/entity_level/entityLevelConfig.json

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Copyright © 2016-2019 by IntegrIT S.A. dba Hackolade. All rights reserved.
33
*
44
* The copyright to the computer software herein is the property of IntegrIT S.A.
5-
* The software may be used and/or copied only with the written permission of
6-
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
7-
* the agreement/contract under which the software has been supplied.
5+
* The software may be used and/or copied only with the written permission of
6+
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
7+
* the agreement/contract under which the software has been supplied.
88

99
In order to define custom properties for any object's properties pane, you may copy/paste from the following,
1010
making sure that you maintain a proper JSON format.
@@ -70,8 +70,8 @@ making sure that you maintain a proper JSON format.
7070
]
7171
},
7272
// “groupInput” can have the following states - 0 items, 1 item, and many items.
73-
// “blockInput” has only 2 states - 0 items or 1 item.
74-
// This gives us an easy way to represent it as an object and not as an array internally which is beneficial for processing
73+
// “blockInput” has only 2 states - 0 items or 1 item.
74+
// This gives us an easy way to represent it as an object and not as an array internally which is beneficial for processing
7575
// and forward-engineering in particular.
7676
{
7777
"propertyName": "Block",
@@ -99,7 +99,7 @@ making sure that you maintain a proper JSON format.
9999
"propertyKeyword": "keyList",
100100
"propertyType": "fieldList",
101101
"template": "orderedList"
102-
},
102+
},
103103
{
104104
"propertyName": "List with attribute",
105105
"propertyKeyword": "keyListOrder",
@@ -645,6 +645,52 @@ making sure that you maintain a proper JSON format.
645645
"template": "textarea",
646646
"markdown": false
647647
},
648+
{
649+
"propertyName": "Custom scripts",
650+
"propertyType": "block",
651+
"propertyKeyword": "customScripts",
652+
"propertyTooltip": "",
653+
"structure": [
654+
{
655+
"propertyName": "Before CREATE TABLE",
656+
"propertyKeyword": "beforeCreateEntity",
657+
"propertyType": "block",
658+
"propertyTooltip": "",
659+
"structure": [
660+
{
661+
"propertyName": "Script",
662+
"propertyKeyword": "script",
663+
"propertyType": "details",
664+
"markdown": false,
665+
"template": "codeEditor",
666+
"templateOptions": {
667+
"editorDialect": "sql",
668+
"customScriptVariables": true
669+
}
670+
}
671+
]
672+
},
673+
{
674+
"propertyName": "After CREATE TABLE",
675+
"propertyKeyword": "afterCreateEntity",
676+
"propertyType": "block",
677+
"propertyTooltip": "",
678+
"structure": [
679+
{
680+
"propertyName": "Script",
681+
"propertyKeyword": "script",
682+
"propertyType": "details",
683+
"markdown": false,
684+
"template": "codeEditor",
685+
"templateOptions": {
686+
"editorDialect": "sql",
687+
"customScriptVariables": true
688+
}
689+
}
690+
]
691+
}
692+
]
693+
},
648694
{
649695
"propertyName": "Remarks",
650696
"propertyKeyword": "comments",

0 commit comments

Comments
 (0)