Skip to content

Commit f25685a

Browse files
author
Anderson Bestteti Santos
committed
Beginning of validateTableTablespaceUsage() design rule implementatio.
1 parent 2682585 commit f25685a

1 file changed

Lines changed: 81 additions & 3 deletions

File tree

DesignerRulesAndTransformations/CustomLibraries/DataModelerCustomLibraries.xml

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ return true
7272
end]]>
7373
</script>
7474
</lib>
75-
<lib id="79C2ED6C-9A18-434F-F0FE-838F87B60814" name="TJRS lib" engine="Oracle Nashorn" methods="versaoBiblioteca,indexWithInvalidName,FKWithOutIndex,createIndexOnFK,normalizeIndexName,tableWithOutPK,tableWithOutVolumetry,tableWithOutDataCompression,generateSQLConfiguration,normalizeStorageProperties" >
75+
<lib id="79C2ED6C-9A18-434F-F0FE-838F87B60814" name="TJRS lib" engine="Oracle Nashorn" methods="versaoBiblioteca,indexWithInvalidName,FKWithOutIndex,createIndexOnFK,normalizeIndexName,tableWithOutPK,tableWithOutVolumetry,tableWithOutDataCompression,generateSQLConfiguration,normalizeStorageProperties,validateTableTablespaceUsage" >
7676
<script>
7777
<![CDATA[// Variable used to return custom message
7878
var ruleMessage;
@@ -460,7 +460,6 @@ function tableWithOutVolumetry(table) {
460460
* Boolean. True if the design rule is satisfied,
461461
* otherwise False.
462462
*/
463-
464463
function tableWithOutDataCompression(table) {
465464
466465
// Stores the result of this custom
@@ -507,6 +506,8 @@ function generateSQLConfiguration() {
507506
ddlStatementsList.add(new java.lang.String(cfgDDL));
508507
}
509508
509+
/*============================================================================*/
510+
510511
function getTableVolumetry(pTable) {
511512
512513
var table = model.getTableSet().getByName(pTable.getName());
@@ -519,6 +520,8 @@ function getTableVolumetry(pTable) {
519520
return retVolumetry;
520521
}
521522
523+
/*============================================================================*/
524+
522525
/**
523526
* The goal of this custom transformation script is to adjust
524527
* tables' storage parameters according to cient's standards.
@@ -645,7 +648,82 @@ function normalizeStorageProperties() {
645648
table.setDirty(true);
646649
}
647650
}
648-
}]]>
651+
}
652+
653+
/*============================================================================*/
654+
655+
/**
656+
* This Design rule aims to spot table which
657+
* wrong tablespace assingment, based on table's "Volume Properties",
658+
* "Expected" property.
659+
*
660+
* Parameters
661+
* table: a given table object
662+
* Returns
663+
* Boolean. True if the design rule is satisfied,
664+
* otherwise False.
665+
*/
666+
function validateTableTablespaceUsage(table) {
667+
// Table's Tablespace per expected rows
668+
var TABLE_TABLESPACE_SMALL = "HP_1M_01D";
669+
var TABLE_TABLESPACE_MEDIUM = "HP_16M_01D";
670+
var TABLE_TABLESPACE_LARGE = "HP_256M_01D";
671+
672+
// Index's Tablespace per table expected rows
673+
var INDEX_TABLESPACE_SMALL = "HP_1M_01X";
674+
var INDEX_TABLESPACE_MEDIUM = "HP_16M_01X";
675+
var INDEX_TABLESPACE_LARGE = "HP_256M_01X";
676+
677+
// Lob's Tablespace per table expected rows
678+
var LOB_TABLESPACE_SMALL = "OA_1M_32K_01L";
679+
var LOB_TABLESPACE_MEDIUM = "OA_16M_32K_01L";
680+
var LOB_TABLESPACE_LARGE = "OA_256M_32K_01L";
681+
682+
// Volumetry ranges
683+
var START_RANGE_SMALL = 0;
684+
var END_RANGE_SMALL = 100000;
685+
var START_RANGE_MEDIUM = 100001;
686+
var END_RANGE_MEDIUM = 1000000;
687+
var START_RANGE_LARGE = 1000000;
688+
689+
var result = true;
690+
691+
// Get the expected amount of rows
692+
tableVolumetry = table.getExpectedVolumes();
693+
if (tableVolumetry != null) {
694+
695+
ruleMessage = "Invalid tablespace definition. Using "
696+
697+
if (tableVolumetry >= START_RANGE_SMALL && tableVolumetry <= END_RANGE_SMALL) {
698+
tableSpaceName = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_SMALL).getName();
699+
if (!tableSpaceName.equals(TABLE_TABLESPACE_SMALL)) {
700+
result = false;
701+
ruleMessage += tableSpaceName;
702+
ruleMessage += " instead of " + TABLE_TABLESPACE_SMALL;
703+
errType = "Error";
704+
}
705+
} else if (tableVolumetry >= START_RANGE_MEDIUM && tableVolumetry <= END_RANGE_MEDIUM) {
706+
tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_MEDIUM);
707+
if (!tableSpaceName.equals(TABLE_TABLESPACE_MEDIUM)) {
708+
result = false;
709+
ruleMessage += tableSpaceName;
710+
ruleMessage += " instead of " + TABLE_TABLESPACE_MEDIUM;
711+
errType = "Error";
712+
}
713+
} else if (tableVolumetry > START_RANGE_LARGE) {
714+
tableSpace = model.getStorageDesign().getTableSpaceSet().getByName(TABLE_TABLESPACE_LARGE);
715+
if (!tableSpaceName.equals(START_RANGE_LARGE)) {
716+
result = false;
717+
ruleMessage += tableSpaceName;
718+
ruleMessage += " instead of " + START_RANGE_LARGE;
719+
errType = "Error";
720+
}
721+
}
722+
}
723+
724+
return result;
725+
}
726+
]]>
649727
</script>
650728
</lib>
651729
</custom_libraries>

0 commit comments

Comments
 (0)