diff --git a/DesignerRulesAndTransformations/CustomDesignRules/DataModelerCustomDesignRules.xml b/DesignerRulesAndTransformations/CustomDesignRules/DataModelerCustomDesignRules.xml index 732a445..f93604a 100644 --- a/DesignerRulesAndTransformations/CustomDesignRules/DataModelerCustomDesignRules.xml +++ b/DesignerRulesAndTransformations/CustomDesignRules/DataModelerCustomDesignRules.xml @@ -58,4 +58,9 @@ checkFKColumns(index);]]> + + + \ No newline at end of file diff --git a/DesignerRulesAndTransformations/CustomLibraries/DataModelerCustomLibraries.xml b/DesignerRulesAndTransformations/CustomLibraries/DataModelerCustomLibraries.xml index 1fbdacd..c127a09 100644 --- a/DesignerRulesAndTransformations/CustomLibraries/DataModelerCustomLibraries.xml +++ b/DesignerRulesAndTransformations/CustomLibraries/DataModelerCustomLibraries.xml @@ -86,7 +86,7 @@ var errType; /*============================================================================*/ function versaoBiblioteca() { - var versao = "Versão: 1.0.24.01.2019"; + var versao = "Versão: 1.0.05.02.2019"; var titulo = "TJRS - Biblioteca de scripts"; javax.swing.JOptionPane @@ -688,39 +688,43 @@ function validateTableTablespaceUsage(table) { var result = true; - var model table.getDesignPart(); - - // Get the expected amount of rows + // Gets the reference to the model + model = table.getDesignPart(); + + // Retrieve from physical model the table storage + tableStorage = model.getStorageDesign().getStorageObject(table.getObjectID()); + + // Gets the tablespace assigned to the table + tableTablespace = tableStorage.getTableSpace(); + + // Gets the expected amount of rows tableVolumetry = table.getExpectedVolumes(); - if (tableVolumetry != null) { - //ruleMessage = "Invalid tablespace definition. Using " - // - //if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { - // tableSpaceName = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_SMALL).getName(); - // if (!tableSpaceName.equals(TABLE_TABLESPACE_SMALL)) { - // result = false; - // ruleMessage += tableSpaceName; - // ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL; - // errType = "Error"; - // } - //} else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { - // tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_MEDIUM); - // if (!tableSpaceName.equals(TABLE_TABLESPACE_MEDIUM)) { - // result = false; - // ruleMessage += tableSpaceName; - // ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM; - // errType = "Error"; - // } - //} else if (tableVolumetry >= START_RANGE_LARGE) { - // tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_LARGE); - // if (!tableSpaceName.equals(START_RANGE_LARGE)) { - // result = false; - // ruleMessage += tableSpaceName; - // ruleMessage += " instead of " + START_RANGE_LARGE; - // errType = "Error"; - // } - //} + // Validate tablespace being used by the table based on its volumetry + if (tableVolumetry != null) { + ruleMessage = "Invalid tablespace definition. Using " + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_SMALL)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_MEDIUM)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_LARGE) { + if (!tableTablespace.getName().equals(START_RANGE_LARGE)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + START_RANGE_LARGE; + errType = "Error"; + } + } } return result; diff --git a/DesignerRulesAndTransformations/CustomTransformations/DataModelerCustomTrasnformation.xml b/DesignerRulesAndTransformations/CustomTransformations/DataModelerCustomTrasnformation.xml index c0a7cac..092fc93 100644 --- a/DesignerRulesAndTransformations/CustomTransformations/DataModelerCustomTrasnformation.xml +++ b/DesignerRulesAndTransformations/CustomTransformations/DataModelerCustomTrasnformation.xml @@ -387,7 +387,7 @@ var errType; /*============================================================================*/ function versaoBiblioteca() { - var versao = "Versão: 1.0.24.01.2019"; + var versao = "Versão: 1.0.05.02.2019"; var titulo = "TJRS - Biblioteca de scripts"; javax.swing.JOptionPane @@ -761,7 +761,6 @@ function tableWithOutVolumetry(table) { * Boolean. True if the design rule is satisfied, * otherwise False. */ - function tableWithOutDataCompression(table) { // Stores the result of this custom @@ -808,6 +807,8 @@ function generateSQLConfiguration() { ddlStatementsList.add(new java.lang.String(cfgDDL)); } +/*============================================================================*/ + function getTableVolumetry(pTable) { var table = model.getTableSet().getByName(pTable.getName()); @@ -820,6 +821,8 @@ function getTableVolumetry(pTable) { return retVolumetry; } +/*============================================================================*/ + /** * The goal of this custom transformation script is to adjust * tables' storage parameters according to cient's standards. @@ -853,7 +856,14 @@ function normalizeStorageProperties() { // Lob's Tablespace per table expected rows var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; - var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; // Retrieve and process a set of tables from the Physical Model var tables = model.getStorageDesign().getTableProxySet().toArray(); @@ -868,7 +878,7 @@ function normalizeStorageProperties() { } if (table.getCompressionType() != COMPRESSION_OLTP) { - table.setCompressionType(true); + table.setCompressionType(COMPRESSION_OLTP); table.setDirty(true); } @@ -876,13 +886,13 @@ function normalizeStorageProperties() { // in table's Relational Model section. tableVolumetry = getTableVolumetry(table); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_SMALL); table.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_MEDIUM); table.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_LARGE); table.setTableSpace(tableSpace); } @@ -894,13 +904,13 @@ function normalizeStorageProperties() { for (var x=0; x < tableIndexes.length; x++) { tableIndex = tableIndexes[x]; if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_SMALL); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_MEDIUM); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_LARGE); tableIndex.setTableSpace(tableSpace); } @@ -924,13 +934,13 @@ function normalizeStorageProperties() { tableLobStorage.setOldVersions(LOB_VERSION_RETENTION); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_SMALL); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_MEDIUM); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_LARGE); tableLobStorage.setTableSpace(tableSpace); } @@ -939,6 +949,86 @@ function normalizeStorageProperties() { table.setDirty(true); } } +} + +/*============================================================================*/ + +/** + * This Design rule aims to spot table which + * wrong tablespace assingment, based on table's "Volume Properties", + * "Expected" property. + * + * Parameters + * table: a given table object + * Returns + * Boolean. True if the design rule is satisfied, + * otherwise False. + */ +function validateTableTablespaceUsage(table) { + // Table's Tablespace per expected rows + var TABLE_TABLESPACE_SMALL = "HP_1M_01D"; + var TABLE_TABLESPACE_MEDIUM = "HP_16M_01D"; + var TABLE_TABLESPACE_LARGE = "HP_256M_01D"; + + // Index's Tablespace per table expected rows + var INDEX_TABLESPACE_SMALL = "HP_1M_01X"; + var INDEX_TABLESPACE_MEDIUM = "HP_16M_01X"; + var INDEX_TABLESPACE_LARGE = "HP_256M_01X"; + + // Lob's Tablespace per table expected rows + var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; + var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; + + var result = true; + + // Gets the reference to the model + model = table.getDesignPart(); + + // Retrieve from physical model the table storage + tableStorage = model.getStorageDesign().getStorageObject(table.getObjectID()); + + // Gets the tablespace assigned to the table + tableTablespace = tableStorage.getTableSpace(); + + // Gets the expected amount of rows + tableVolumetry = table.getExpectedVolumes(); + + // Validate tablespace being used by the table based on its volumetry + if (tableVolumetry != null) { + ruleMessage = "Invalid tablespace definition. Using " + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_SMALL)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_MEDIUM)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_LARGE) { + if (!tableTablespace.getName().equals(START_RANGE_LARGE)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + START_RANGE_LARGE; + errType = "Error"; + } + } + } + + return result; }]]> @@ -956,7 +1046,7 @@ var errType; /*============================================================================*/ function versaoBiblioteca() { - var versao = "Versão: 1.0.24.01.2019"; + var versao = "Versão: 1.0.05.02.2019"; var titulo = "TJRS - Biblioteca de scripts"; javax.swing.JOptionPane @@ -1330,7 +1420,6 @@ function tableWithOutVolumetry(table) { * Boolean. True if the design rule is satisfied, * otherwise False. */ - function tableWithOutDataCompression(table) { // Stores the result of this custom @@ -1377,6 +1466,8 @@ function generateSQLConfiguration() { ddlStatementsList.add(new java.lang.String(cfgDDL)); } +/*============================================================================*/ + function getTableVolumetry(pTable) { var table = model.getTableSet().getByName(pTable.getName()); @@ -1389,6 +1480,8 @@ function getTableVolumetry(pTable) { return retVolumetry; } +/*============================================================================*/ + /** * The goal of this custom transformation script is to adjust * tables' storage parameters according to cient's standards. @@ -1422,7 +1515,14 @@ function normalizeStorageProperties() { // Lob's Tablespace per table expected rows var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; - var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; // Retrieve and process a set of tables from the Physical Model var tables = model.getStorageDesign().getTableProxySet().toArray(); @@ -1437,7 +1537,7 @@ function normalizeStorageProperties() { } if (table.getCompressionType() != COMPRESSION_OLTP) { - table.setCompressionType(true); + table.setCompressionType(COMPRESSION_OLTP); table.setDirty(true); } @@ -1445,13 +1545,13 @@ function normalizeStorageProperties() { // in table's Relational Model section. tableVolumetry = getTableVolumetry(table); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_SMALL); table.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_MEDIUM); table.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_LARGE); table.setTableSpace(tableSpace); } @@ -1463,13 +1563,13 @@ function normalizeStorageProperties() { for (var x=0; x < tableIndexes.length; x++) { tableIndex = tableIndexes[x]; if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_SMALL); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_MEDIUM); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_LARGE); tableIndex.setTableSpace(tableSpace); } @@ -1493,13 +1593,13 @@ function normalizeStorageProperties() { tableLobStorage.setOldVersions(LOB_VERSION_RETENTION); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_SMALL); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_MEDIUM); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_LARGE); tableLobStorage.setTableSpace(tableSpace); } @@ -1508,6 +1608,86 @@ function normalizeStorageProperties() { table.setDirty(true); } } +} + +/*============================================================================*/ + +/** + * This Design rule aims to spot table which + * wrong tablespace assingment, based on table's "Volume Properties", + * "Expected" property. + * + * Parameters + * table: a given table object + * Returns + * Boolean. True if the design rule is satisfied, + * otherwise False. + */ +function validateTableTablespaceUsage(table) { + // Table's Tablespace per expected rows + var TABLE_TABLESPACE_SMALL = "HP_1M_01D"; + var TABLE_TABLESPACE_MEDIUM = "HP_16M_01D"; + var TABLE_TABLESPACE_LARGE = "HP_256M_01D"; + + // Index's Tablespace per table expected rows + var INDEX_TABLESPACE_SMALL = "HP_1M_01X"; + var INDEX_TABLESPACE_MEDIUM = "HP_16M_01X"; + var INDEX_TABLESPACE_LARGE = "HP_256M_01X"; + + // Lob's Tablespace per table expected rows + var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; + var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; + + var result = true; + + // Gets the reference to the model + model = table.getDesignPart(); + + // Retrieve from physical model the table storage + tableStorage = model.getStorageDesign().getStorageObject(table.getObjectID()); + + // Gets the tablespace assigned to the table + tableTablespace = tableStorage.getTableSpace(); + + // Gets the expected amount of rows + tableVolumetry = table.getExpectedVolumes(); + + // Validate tablespace being used by the table based on its volumetry + if (tableVolumetry != null) { + ruleMessage = "Invalid tablespace definition. Using " + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_SMALL)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_MEDIUM)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_LARGE) { + if (!tableTablespace.getName().equals(START_RANGE_LARGE)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + START_RANGE_LARGE; + errType = "Error"; + } + } + } + + return result; }]]> @@ -1525,7 +1705,7 @@ var errType; /*============================================================================*/ function versaoBiblioteca() { - var versao = "Versão: 1.0.24.01.2019"; + var versao = "Versão: 1.0.05.02.2019"; var titulo = "TJRS - Biblioteca de scripts"; javax.swing.JOptionPane @@ -1899,7 +2079,6 @@ function tableWithOutVolumetry(table) { * Boolean. True if the design rule is satisfied, * otherwise False. */ - function tableWithOutDataCompression(table) { // Stores the result of this custom @@ -1946,6 +2125,8 @@ function generateSQLConfiguration() { ddlStatementsList.add(new java.lang.String(cfgDDL)); } +/*============================================================================*/ + function getTableVolumetry(pTable) { var table = model.getTableSet().getByName(pTable.getName()); @@ -1958,6 +2139,8 @@ function getTableVolumetry(pTable) { return retVolumetry; } +/*============================================================================*/ + /** * The goal of this custom transformation script is to adjust * tables' storage parameters according to cient's standards. @@ -1991,7 +2174,14 @@ function normalizeStorageProperties() { // Lob's Tablespace per table expected rows var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; - var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; // Retrieve and process a set of tables from the Physical Model var tables = model.getStorageDesign().getTableProxySet().toArray(); @@ -2006,7 +2196,7 @@ function normalizeStorageProperties() { } if (table.getCompressionType() != COMPRESSION_OLTP) { - table.setCompressionType(true); + table.setCompressionType(COMPRESSION_OLTP); table.setDirty(true); } @@ -2014,13 +2204,13 @@ function normalizeStorageProperties() { // in table's Relational Model section. tableVolumetry = getTableVolumetry(table); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_SMALL); table.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_MEDIUM); table.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_LARGE); table.setTableSpace(tableSpace); } @@ -2032,13 +2222,13 @@ function normalizeStorageProperties() { for (var x=0; x < tableIndexes.length; x++) { tableIndex = tableIndexes[x]; if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_SMALL); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_MEDIUM); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_LARGE); tableIndex.setTableSpace(tableSpace); } @@ -2062,13 +2252,13 @@ function normalizeStorageProperties() { tableLobStorage.setOldVersions(LOB_VERSION_RETENTION); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_SMALL); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_MEDIUM); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_LARGE); tableLobStorage.setTableSpace(tableSpace); } @@ -2077,6 +2267,86 @@ function normalizeStorageProperties() { table.setDirty(true); } } +} + +/*============================================================================*/ + +/** + * This Design rule aims to spot table which + * wrong tablespace assingment, based on table's "Volume Properties", + * "Expected" property. + * + * Parameters + * table: a given table object + * Returns + * Boolean. True if the design rule is satisfied, + * otherwise False. + */ +function validateTableTablespaceUsage(table) { + // Table's Tablespace per expected rows + var TABLE_TABLESPACE_SMALL = "HP_1M_01D"; + var TABLE_TABLESPACE_MEDIUM = "HP_16M_01D"; + var TABLE_TABLESPACE_LARGE = "HP_256M_01D"; + + // Index's Tablespace per table expected rows + var INDEX_TABLESPACE_SMALL = "HP_1M_01X"; + var INDEX_TABLESPACE_MEDIUM = "HP_16M_01X"; + var INDEX_TABLESPACE_LARGE = "HP_256M_01X"; + + // Lob's Tablespace per table expected rows + var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; + var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; + + var result = true; + + // Gets the reference to the model + model = table.getDesignPart(); + + // Retrieve from physical model the table storage + tableStorage = model.getStorageDesign().getStorageObject(table.getObjectID()); + + // Gets the tablespace assigned to the table + tableTablespace = tableStorage.getTableSpace(); + + // Gets the expected amount of rows + tableVolumetry = table.getExpectedVolumes(); + + // Validate tablespace being used by the table based on its volumetry + if (tableVolumetry != null) { + ruleMessage = "Invalid tablespace definition. Using " + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_SMALL)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_MEDIUM)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_LARGE) { + if (!tableTablespace.getName().equals(START_RANGE_LARGE)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + START_RANGE_LARGE; + errType = "Error"; + } + } + } + + return result; }]]> @@ -2094,7 +2364,7 @@ var errType; /*============================================================================*/ function versaoBiblioteca() { - var versao = "Versão: 1.0.24.01.2019"; + var versao = "Versão: 1.0.05.02.2019"; var titulo = "TJRS - Biblioteca de scripts"; javax.swing.JOptionPane @@ -2468,7 +2738,6 @@ function tableWithOutVolumetry(table) { * Boolean. True if the design rule is satisfied, * otherwise False. */ - function tableWithOutDataCompression(table) { // Stores the result of this custom @@ -2515,6 +2784,8 @@ function generateSQLConfiguration() { ddlStatementsList.add(new java.lang.String(cfgDDL)); } +/*============================================================================*/ + function getTableVolumetry(pTable) { var table = model.getTableSet().getByName(pTable.getName()); @@ -2527,6 +2798,8 @@ function getTableVolumetry(pTable) { return retVolumetry; } +/*============================================================================*/ + /** * The goal of this custom transformation script is to adjust * tables' storage parameters according to cient's standards. @@ -2560,7 +2833,14 @@ function normalizeStorageProperties() { // Lob's Tablespace per table expected rows var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; - var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; // Retrieve and process a set of tables from the Physical Model var tables = model.getStorageDesign().getTableProxySet().toArray(); @@ -2575,7 +2855,7 @@ function normalizeStorageProperties() { } if (table.getCompressionType() != COMPRESSION_OLTP) { - table.setCompressionType(true); + table.setCompressionType(COMPRESSION_OLTP); table.setDirty(true); } @@ -2583,13 +2863,13 @@ function normalizeStorageProperties() { // in table's Relational Model section. tableVolumetry = getTableVolumetry(table); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_SMALL); table.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_MEDIUM); table.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_LARGE); table.setTableSpace(tableSpace); } @@ -2601,13 +2881,13 @@ function normalizeStorageProperties() { for (var x=0; x < tableIndexes.length; x++) { tableIndex = tableIndexes[x]; if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_SMALL); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_MEDIUM); tableIndex.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(INDEX_TABLESPACE_LARGE); tableIndex.setTableSpace(tableSpace); } @@ -2631,13 +2911,13 @@ function normalizeStorageProperties() { tableLobStorage.setOldVersions(LOB_VERSION_RETENTION); if (tableVolumetry != null) { - if (tableVolumetry >= 0 && tableVolumetry <= 100000) { + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_SMALL); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry >= 100001 && tableVolumetry <= 1000000) { + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_MEDIUM); tableLobStorage.setTableSpace(tableSpace); - } else if (tableVolumetry > 1000000) { + } else if (tableVolumetry >= START_RANGE_LARGE) { tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(LOB_TABLESPACE_LARGE); tableLobStorage.setTableSpace(tableSpace); } @@ -2646,6 +2926,86 @@ function normalizeStorageProperties() { table.setDirty(true); } } +} + +/*============================================================================*/ + +/** + * This Design rule aims to spot table which + * wrong tablespace assingment, based on table's "Volume Properties", + * "Expected" property. + * + * Parameters + * table: a given table object + * Returns + * Boolean. True if the design rule is satisfied, + * otherwise False. + */ +function validateTableTablespaceUsage(table) { + // Table's Tablespace per expected rows + var TABLE_TABLESPACE_SMALL = "HP_1M_01D"; + var TABLE_TABLESPACE_MEDIUM = "HP_16M_01D"; + var TABLE_TABLESPACE_LARGE = "HP_256M_01D"; + + // Index's Tablespace per table expected rows + var INDEX_TABLESPACE_SMALL = "HP_1M_01X"; + var INDEX_TABLESPACE_MEDIUM = "HP_16M_01X"; + var INDEX_TABLESPACE_LARGE = "HP_256M_01X"; + + // Lob's Tablespace per table expected rows + var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L"; + var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L"; + var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L"; + + // Volumetry ranges + var START_RANGE_SMALL = 0; + var END_RANGE_SMALL = 100000; + var START_RANGE_MEDIUM = 100001; + var END_RANGE_MEDIUM = 1000000; + var START_RANGE_LARGE = 1000001; + + var result = true; + + // Gets the reference to the model + model = table.getDesignPart(); + + // Retrieve from physical model the table storage + tableStorage = model.getStorageDesign().getStorageObject(table.getObjectID()); + + // Gets the tablespace assigned to the table + tableTablespace = tableStorage.getTableSpace(); + + // Gets the expected amount of rows + tableVolumetry = table.getExpectedVolumes(); + + // Validate tablespace being used by the table based on its volumetry + if (tableVolumetry != null) { + ruleMessage = "Invalid tablespace definition. Using " + if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_SMALL)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) { + if (!tableTablespace.getName().equals(TABLE_TABLESPACE_MEDIUM)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM; + errType = "Error"; + } + } else if (tableVolumetry >= START_RANGE_LARGE) { + if (!tableTablespace.getName().equals(START_RANGE_LARGE)) { + result = false; + ruleMessage += tableTablespace; + ruleMessage += " instead of " + START_RANGE_LARGE; + errType = "Error"; + } + } + } + + return result; }]]>