Search in sources :

Example 11 with FieldRuleProperty

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;
}
Also used : FieldValidationRule(com.thinkbiganalytics.policy.rest.model.FieldValidationRule) FieldValidationRuleBuilder(com.thinkbiganalytics.policy.rest.model.FieldValidationRuleBuilder) ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) Validator(com.thinkbiganalytics.policy.validation.Validator)

Example 12 with FieldRuleProperty

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);
            }
        }
    }
}
Also used : FieldValidationRule(com.thinkbiganalytics.policy.rest.model.FieldValidationRule) ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty)

Example 13 with FieldRuleProperty

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;
}
Also used : ServiceLevelAgreementMetric(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementMetric) ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty)

Example 14 with FieldRuleProperty

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<>());
            }
        }
    }
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue) ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Aggregations

FieldRuleProperty (com.thinkbiganalytics.policy.rest.model.FieldRuleProperty)14 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)3 AnnotatedFieldProperty (com.thinkbiganalytics.annotations.AnnotatedFieldProperty)2 AnnotationFieldNameResolver (com.thinkbiganalytics.annotations.AnnotationFieldNameResolver)2 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)2 FieldRulePropertyBuilder (com.thinkbiganalytics.policy.rest.model.FieldRulePropertyBuilder)2 FieldValidationRule (com.thinkbiganalytics.policy.rest.model.FieldValidationRule)2 LabelValue (com.thinkbiganalytics.rest.model.LabelValue)2 Field (java.lang.reflect.Field)2 List (java.util.List)2 SchemaParserDescriptor (com.thinkbiganalytics.discovery.model.SchemaParserDescriptor)1 ServiceLevelAgreementActionConfig (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)1 ServiceLevelAgreementMetric (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementMetric)1 FieldStandardizationRule (com.thinkbiganalytics.policy.rest.model.FieldStandardizationRule)1 FieldStandardizationRuleBuilder (com.thinkbiganalytics.policy.rest.model.FieldStandardizationRuleBuilder)1 FieldValidationRuleBuilder (com.thinkbiganalytics.policy.rest.model.FieldValidationRuleBuilder)1 Standardizer (com.thinkbiganalytics.policy.standardization.Standardizer)1 Validator (com.thinkbiganalytics.policy.validation.Validator)1 Annotation (java.lang.annotation.Annotation)1