Add visibility rules checkup on dataset finalize checkup

This commit is contained in:
George Kalampokis 2021-06-01 12:30:01 +03:00
parent 5483847754
commit be311f238b
1 changed files with 10 additions and 1 deletions

View File

@ -673,9 +673,18 @@ public class DatasetManager {
datasetProfileValidators.add(node.getNodeValue()); datasetProfileValidators.add(node.getNodeValue());
} }
JSONObject obj = new JSONObject(dataset.getProperties()); JSONObject obj = new JSONObject(dataset.getProperties());
VisibilityRuleService visibilityRuleService = this.apiContext.getUtilitiesService().getVisibilityRuleService();
visibilityRuleService.setProperties(obj.toMap());
dataset.setProfile(profile);
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), dataset);
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
for (String validator : datasetProfileValidators) { for (String validator : datasetProfileValidators) {
if (obj.getString(validator) == null || obj.getString(validator).trim().isEmpty()) { if ((obj.getString(validator) == null || obj.getString(validator).trim().isEmpty()) && visibilityRuleService.isElementVisible(validator)) {
throw new Exception("Field value of " + validator + " must be filled."); throw new Exception("Field value of " + validator + " must be filled.");
} }
} }