use of com.thinkbiganalytics.policy.rest.model.FieldRuleProperty 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.FieldRuleProperty 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);
}
}
}
}
use of com.thinkbiganalytics.policy.rest.model.FieldRuleProperty in project kylo by Teradata.
the class ServiceLevelAgreementMetricTransformer method discoverSlaMetrics.
public List<ServiceLevelAgreementRule> discoverSlaMetrics() {
List<ServiceLevelAgreementRule> rules = new ArrayList<>();
Set<Class<?>> metrics = ReflectionPolicyAnnotationDiscoverer.getTypesAnnotatedWith(ServiceLevelAgreementMetric.class);
for (Class c : metrics) {
List<FieldRuleProperty> properties = getUiProperties(c);
ServiceLevelAgreementMetric policy = (ServiceLevelAgreementMetric) c.getAnnotation(ServiceLevelAgreementMetric.class);
rules.add(buildUiModel(policy, c, properties));
}
return rules;
}
use of com.thinkbiganalytics.policy.rest.model.FieldRuleProperty in project kylo by Teradata.
the class InMemoryFeedManagerFeedService method applyFeedSelectOptions.
@Override
public void applyFeedSelectOptions(List<FieldRuleProperty> properties) {
if (properties != null && !properties.isEmpty()) {
List<FeedSummary> feedSummaries = getFeedSummaryData();
List<LabelValue> feedSelection = new ArrayList<>();
for (FeedSummary feedSummary : feedSummaries) {
feedSelection.add(new LabelValue(feedSummary.getCategoryAndFeedDisplayName(), feedSummary.getCategoryAndFeedSystemName()));
}
for (FieldRuleProperty property : properties) {
property.setSelectableValues(feedSelection);
if (property.getValues() == null) {
// reset the intial values to be an empty arraylist
property.setValues(new ArrayList<>());
}
}
}
}
Aggregations