use of com.thinkbiganalytics.policy.rest.model.FieldValidationRule in project kylo by Teradata.
the class TestValidationTransformation method testRangeValidator.
@Test
@Ignore
public void testRangeValidator() {
Integer min = 10;
Integer max = 20;
RangeValidator validator = new RangeValidator(min, max);
FieldValidationRule uiModel = ValidatorAnnotationTransformer.instance().toUIModel(validator);
RangeValidator convertedValidator = fromUI(uiModel, RangeValidator.class);
Assert.assertEquals(min, convertedValidator.getMin());
Assert.assertEquals(max, convertedValidator.getMin());
}
use of com.thinkbiganalytics.policy.rest.model.FieldValidationRule in project kylo by Teradata.
the class TestValidationTransformation method testEmailValidator.
@Test
public void testEmailValidator() {
EmailValidator validator = EmailValidator.instance();
FieldValidationRule uiModel = ValidatorAnnotationTransformer.instance().toUIModel(validator);
EmailValidator convertedValidator = fromUI(uiModel, EmailValidator.class);
Assert.assertEquals(validator, convertedValidator);
}
use of com.thinkbiganalytics.policy.rest.model.FieldValidationRule in project kylo by Teradata.
the class TestValidationTransformation method testTimestampValidator.
@Test
public void testTimestampValidator() {
TimestampValidator validator = new TimestampValidator(false);
FieldValidationRule uiModel = ValidatorAnnotationTransformer.instance().toUIModel(validator);
TimestampValidator convertedValidator = fromUI(uiModel, TimestampValidator.class);
Assert.assertEquals(validator.isAllowNull(), convertedValidator.isAllowNull());
}
use of com.thinkbiganalytics.policy.rest.model.FieldValidationRule in project kylo by Teradata.
the class AvailablePolicies method discoverValidationRules.
public static List<FieldValidationRule> discoverValidationRules() {
List<FieldValidationRule> rules = new ArrayList<>();
Set<Class<?>> validators = ReflectionPolicyAnnotationDiscoverer.getTypesAnnotatedWith(Validator.class);
for (Class c : validators) {
Validator validator = (Validator) c.getAnnotation(Validator.class);
List<FieldRuleProperty> properties = ValidatorAnnotationTransformer.instance().getUiProperties(c);
rules.add(new FieldValidationRuleBuilder(validator.name()).description(validator.description()).addProperties(properties).objectClassType(c).build());
}
return rules;
}
use of com.thinkbiganalytics.policy.rest.model.FieldValidationRule in project kylo by Teradata.
the class FieldPoliciesJsonTransformer method augmentPartitionColumnValidation.
public void augmentPartitionColumnValidation() {
log.info("Augmenting partition column validation");
for (com.thinkbiganalytics.policy.rest.model.FieldPolicy uiFieldPolicy : uiFieldPolicies) {
if (uiFieldPolicy.isPartitionColumn()) {
log.info("Found a partition column: " + uiFieldPolicy.getFieldName());
boolean augmentRule = true;
List<FieldValidationRule> currentValidationRules = uiFieldPolicy.getValidation();
if (currentValidationRules != null) {
log.info("There are validation rules already set for " + uiFieldPolicy.getFieldName());
for (FieldValidationRule fieldValidationRule : currentValidationRules) {
if (fieldValidationRule.getObjectClassType().equals("com.thinkbiganalytics.policy.validation.NotNullValidator") || (fieldValidationRule.getObjectShortClassType().equals("NotNullValidator"))) {
log.info("NotNull validation rule already set for " + uiFieldPolicy.getFieldName());
augmentRule = false;
}
}
}
if (augmentRule) {
log.info("Augmenting the field " + uiFieldPolicy.getFieldName() + " with NotNull validation rule");
if (currentValidationRules == null) {
currentValidationRules = new ArrayList<>();
}
FieldValidationRule fvRule = new FieldValidationRule();
fvRule.setName("Partition Column Not Null");
fvRule.setObjectClassType("com.thinkbiganalytics.policy.validation.NotNullValidator");
fvRule.setObjectShortClassType("NotNullValidator");
List<FieldRuleProperty> fieldRulePropertyList = new ArrayList<>();
FieldRuleProperty fieldRuleProperty1 = new FieldRuleProperty();
fieldRuleProperty1.setName("EMPTY_STRING");
fieldRuleProperty1.setDisplayName(null);
fieldRuleProperty1.setValue("false");
fieldRuleProperty1.setPlaceholder(null);
fieldRuleProperty1.setType(null);
fieldRuleProperty1.setHint(null);
fieldRuleProperty1.setObjectProperty("allowEmptyString");
fieldRuleProperty1.setRequired(false);
fieldRuleProperty1.setGroup(null);
fieldRuleProperty1.setLayout(null);
fieldRuleProperty1.setHidden(false);
fieldRuleProperty1.setPattern(null);
fieldRuleProperty1.setPatternInvalidMessage(null);
FieldRuleProperty fieldRuleProperty2 = new FieldRuleProperty();
fieldRuleProperty2.setName("TRIM_STRING");
fieldRuleProperty2.setDisplayName(null);
fieldRuleProperty2.setValue("true");
fieldRuleProperty2.setPlaceholder(null);
fieldRuleProperty2.setType(null);
fieldRuleProperty2.setHint(null);
fieldRuleProperty2.setObjectProperty("trimString");
fieldRuleProperty2.setRequired(false);
fieldRuleProperty2.setGroup(null);
fieldRuleProperty2.setLayout(null);
fieldRuleProperty2.setHidden(false);
fieldRuleProperty2.setPattern(null);
fieldRuleProperty2.setPatternInvalidMessage(null);
fieldRulePropertyList.add(fieldRuleProperty1);
fieldRulePropertyList.add(fieldRuleProperty2);
fvRule.setProperties(fieldRulePropertyList);
currentValidationRules.add(fvRule);
log.info("Added rule for NotNull validation on " + uiFieldPolicy.getFieldName());
uiFieldPolicy.setValidation(currentValidationRules);
}
}
}
}
Aggregations