Search in sources :

Example 1 with PreconditionRule

use of com.thinkbiganalytics.policy.rest.model.PreconditionRule in project kylo by Teradata.

the class PreconditionPolicyTransformer method getPreconditionPolicies.

public List<Precondition> getPreconditionPolicies() {
    List<Precondition> policies = new ArrayList<>();
    if (preconditionRules != null) {
        for (PreconditionRule rule : preconditionRules) {
            try {
                Precondition policy = PreconditionAnnotationTransformer.instance().fromUiModel(rule);
                policies.add(policy);
            } catch (PolicyTransformException e) {
                throw new RuntimeException(e);
            }
        }
    }
    return policies;
}
Also used : Precondition(com.thinkbiganalytics.policy.precondition.Precondition) ArrayList(java.util.ArrayList) PolicyTransformException(com.thinkbiganalytics.policy.PolicyTransformException) PreconditionRule(com.thinkbiganalytics.policy.rest.model.PreconditionRule)

Example 2 with PreconditionRule

use of com.thinkbiganalytics.policy.rest.model.PreconditionRule in project kylo by Teradata.

the class PreconditionPolicyTransformer method getPreconditionObligationGroups.

public List<ObligationGroup> getPreconditionObligationGroups() {
    List<ObligationGroup> policies = new ArrayList<>();
    if (preconditionRules != null) {
        for (PreconditionRule rule : preconditionRules) {
            try {
                Precondition policy = PreconditionAnnotationTransformer.instance().fromUiModel(rule);
                policies.addAll(Lists.newArrayList(policy.buildPreconditionObligations()));
            } catch (PolicyTransformException e) {
                throw new RuntimeException(e);
            }
        }
    }
    return policies;
}
Also used : Precondition(com.thinkbiganalytics.policy.precondition.Precondition) ArrayList(java.util.ArrayList) PolicyTransformException(com.thinkbiganalytics.policy.PolicyTransformException) ObligationGroup(com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup) PreconditionRule(com.thinkbiganalytics.policy.rest.model.PreconditionRule)

Example 3 with PreconditionRule

use of com.thinkbiganalytics.policy.rest.model.PreconditionRule in project kylo by Teradata.

the class PreconditionAnnotationTransformer method buildUiModel.

@Override
public PreconditionRule buildUiModel(PreconditionPolicy annotation, Precondition policy, List<FieldRuleProperty> properties) {
    String desc = annotation.description();
    String shortDesc = annotation.shortDescription();
    if (StringUtils.isBlank(desc) && StringUtils.isNotBlank(shortDesc)) {
        desc = shortDesc;
    }
    if (StringUtils.isBlank(shortDesc) && StringUtils.isNotBlank(desc)) {
        shortDesc = desc;
    }
    PreconditionRule rule = new PreconditionRuleBuilder(annotation.name()).objectClassType(policy.getClass()).description(desc).shortDescription(shortDesc).addProperties(properties).build();
    return rule;
}
Also used : PreconditionRuleBuilder(com.thinkbiganalytics.policy.rest.model.PreconditionRuleBuilder) PreconditionRule(com.thinkbiganalytics.policy.rest.model.PreconditionRule)

Example 4 with PreconditionRule

use of com.thinkbiganalytics.policy.rest.model.PreconditionRule in project kylo by Teradata.

the class TestPreconditionPolicyTransform method testFeedExecutedSinceFeed.

@Test
public void testFeedExecutedSinceFeed() throws IOException {
    String dependentUponFeed = "category.feed";
    String currentFeed = "currentCategory.currentFeeda";
    FeedExecutedSinceFeeds feedExecutedSinceFeed = new FeedExecutedSinceFeeds(currentFeed, dependentUponFeed);
    PreconditionRule uiModel = PreconditionAnnotationTransformer.instance().toUIModel(feedExecutedSinceFeed);
    List<LabelValue> values = new ArrayList<>();
    values.add(new LabelValue("Label1", "Value1"));
    values.add(new LabelValue("Label2", "Value2"));
    uiModel.getProperty("Dependent Feeds").setValues(values);
    FeedExecutedSinceFeeds convertedPolicy = fromUI(uiModel, FeedExecutedSinceFeeds.class);
    Assert.assertEquals(currentFeed, convertedPolicy.getSinceCategoryAndFeedName());
    Assert.assertEquals(dependentUponFeed, convertedPolicy.getCategoryAndFeeds());
    Set<ObligationGroup> preconditionGroups = convertedPolicy.buildPreconditionObligations();
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue) ArrayList(java.util.ArrayList) PreconditionRule(com.thinkbiganalytics.policy.rest.model.PreconditionRule) ObligationGroup(com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup) Test(org.junit.Test)

Example 5 with PreconditionRule

use of com.thinkbiganalytics.policy.rest.model.PreconditionRule in project kylo by Teradata.

the class TestPreconditionPolicyTransform method testUiCreation.

@Test
public void testUiCreation() {
    List<PreconditionRule> rules = AvailablePolicies.discoverPreconditions();
    PreconditionRule rule = Iterables.tryFind(rules, new Predicate<PreconditionRule>() {

        @Override
        public boolean apply(PreconditionRule rule) {
            return rule.getName().equalsIgnoreCase(PreconditionPolicyConstants.FEED_EXECUTED_SINCE_FEEDS_NAME);
        }
    }).orNull();
    rule.getProperty("Since Feed").setValue("currentCategory.currentFeed");
    rule.getProperty("Dependent Feeds").setValue("category.feed");
    FeedExecutedSinceFeeds convertedPolicy = fromUI(rule, FeedExecutedSinceFeeds.class);
    Assert.assertEquals("currentCategory.currentFeed", convertedPolicy.getSinceCategoryAndFeedName());
    Assert.assertEquals("category.feed", convertedPolicy.getCategoryAndFeeds());
}
Also used : PreconditionRule(com.thinkbiganalytics.policy.rest.model.PreconditionRule) Predicate(com.google.common.base.Predicate) Test(org.junit.Test)

Aggregations

PreconditionRule (com.thinkbiganalytics.policy.rest.model.PreconditionRule)6 ArrayList (java.util.ArrayList)4 PolicyTransformException (com.thinkbiganalytics.policy.PolicyTransformException)2 Precondition (com.thinkbiganalytics.policy.precondition.Precondition)2 LabelValue (com.thinkbiganalytics.rest.model.LabelValue)2 Test (org.junit.Test)2 Predicate (com.google.common.base.Predicate)1 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1 HadoopAuthorizationService (com.thinkbiganalytics.datalake.authorization.service.HadoopAuthorizationService)1 CreateFeedBuilder (com.thinkbiganalytics.feedmgr.nifi.CreateFeedBuilder)1 PropertyExpressionResolver (com.thinkbiganalytics.feedmgr.nifi.PropertyExpressionResolver)1 TemplateConnectionUtil (com.thinkbiganalytics.feedmgr.nifi.TemplateConnectionUtil)1 NifiFlowCache (com.thinkbiganalytics.feedmgr.nifi.cache.NifiFlowCache)1 DeployResponseEntityVersion (com.thinkbiganalytics.feedmgr.rest.model.DeployResponseEntityVersion)1 DraftEntityVersion (com.thinkbiganalytics.feedmgr.rest.model.DraftEntityVersion)1 EntityVersion (com.thinkbiganalytics.feedmgr.rest.model.EntityVersion)1 EntityVersionDifference (com.thinkbiganalytics.feedmgr.rest.model.EntityVersionDifference)1 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)1