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;
}
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;
}
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;
}
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();
}
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());
}
Aggregations