Configure Mandatory Fields - SuperWEB2
It is possible to configure certain fields as "mandatory fields" in SuperWEB2. These fields will be automatically added to all new tables.
By default, users will be able to remove these fields from the table, but you can also activate a rule to prevent this (i.e. it will not be possible to create a table that does not include all the mandatory fields).
Step 1 - Activate the Mandatory Fields Rule
The first step is to activate the mandatory fields rule, by editing <tomcat_home>\webapps\webapi\WEB-INF\data\.repository\RulesEngine.xml in a text editor.
Locate the following section:
XML<rules:RulesPipe name="NewTableRules"> <!-- <rules:rule-name name="MandatoryFieldsRule"/> --> </rules:RulesPipe>
Remove the comments from the rule:
XML<rules:RulesPipe name="NewTableRules"> <rules:rule-name name="MandatoryFieldsRule"/> </rules:RulesPipe>
Save your changes to the file.
Step 2 (Optional) - Configure Mandatory Fields to Be Required in Tables
If you want to prevents users from removing the mandatory fields from the table, then you should also make the following change in <tomcat_home>\webapps\webapi\WEB-INF\data\.repository\RulesEngine.xml:
Locate the following section:
XML<rules:RulesPipe name="CDataOnlineEditRules"> <!-- <rules:rule-name name="OverrideDefaultSummationRule"/> --> <!-- <rules:rule-name name="MandatoryFieldsRule"/> -->
Remove the comments from the MandatoryFieldsRule:
XML<rules:RulesPipe name="CDataOnlineEditRules"> <!-- <rules:rule-name name="OverrideDefaultSummationRule"/> --> <rules:rule-name name="MandatoryFieldsRule"/>
- Save your changes to the file.
Step 3 - Specify the Mandatory Fields
Once you have activated the mandatory field rule(s), you must specify which fields you want to be mandatory, by editing <tomcat_home>\webapps\webapi\WEB-INF\classes\mandatoryfields.json in a text editor.
This file contains a JSON array defining the list of mandatory fields. For example:
[
{
"databases": ["people"],
"mandatoryFields": [
{
"axis": "Row",
"field": "SXV4__PeopleNonMl__People__Occupation_FLD"
},
{
"axis": "Column",
"field": "SXV4__PeopleNonMl__People__Marital status_FLD"
},
{
"axis": "Column",
"field": "Gender",
"factTable": "People"
}
]
},
{
"databases": ["bank"],
"mandatoryFields": [
{
"axis": "Row",
"field": "Customer Open Calendar Date",
"factTable": "Customers",
"valueSet": "C_Cal_Date_2",
"values": [
"1972 Quarter 1",
"2001 Quarter 3",
"2005 Quarter 4"
]
},
{
"axis": "Row",
"field": "SXV4__Retail_Banking__F_Customer__Area_FLD",
"valueSet": "SXV4__Retail_Banking__C_Geography_1",
"values": [
"21510",
"22005"
]
},
{
"axis": "Subject",
"field": "Gender",
"factTable": "Customers",
"values": ["Female"]
},
{
"axis": "Column",
"field": "Marital Status",
"factTable": "Customers"
}
]
}
]
Each mandatory field definition can have the following parameters:
Parameter | Description | Required? |
---|---|---|
axis | The axis to add the field to:
You can have multiple mandatory fields on a single axis; the fields will be nested based on the order they are specified in the mandatory fields file (the first mandatory field listed in the file will be at the outermost nested level). | Yes |
field | The full SXV4 ID of the field. You can obtain the field ID in SuperADMIN. Use the command
CODE
In this example, the ID you need is In some cases you can also specify the field using its display name, but if you do this you must also specify the fact table the field belongs to, using the | Yes |
valueSet | The value set to add to the table. If not specified, then the top level value set will be used. You must use the value set ID, which you can obtain from SuperADMIN using the command | Only for hierarchical fields, where you do not want to use the top level value set. |
values | A list of the field values to add to the table. If you do not specify a list of values then all values for this field or value set will be added. | No |
factTable | The fact table the field belongs to. | Only if using the display names to identify fields. |
When you have finished configuring your mandatory fields file, save your changes and restart Tomcat (or the SuperWEB2 service).