use of com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup in project kylo by Teradata.
the class ServiceLevelAgreementMetricTransformerHelper method toServiceLevelAgreementGroup.
/**
* Transform the Rest Model back to the form model
*/
public ServiceLevelAgreementGroup toServiceLevelAgreementGroup(ServiceLevelAgreement sla) {
ServiceLevelAgreementGroup slaGroup = new ServiceLevelAgreementGroup();
slaGroup.setId(sla.getId());
slaGroup.setName(sla.getName());
slaGroup.setDescription(sla.getDescription());
slaGroup.setActionErrors(sla.getSlaCheckErrors());
slaGroup.setRuleErrors(sla.getObligationErrors());
for (ObligationGroup group : sla.getGroups()) {
List<Obligation> obligations = group.getObligations();
for (Obligation obligation : obligations) {
List<Metric> metrics = obligation.getMetrics();
for (Metric metric : metrics) {
ServiceLevelAgreementRule rule = ServiceLevelAgreementMetricTransformer.instance().toUIModel(metric);
rule.setCondition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition.valueOf(group.getCondition()));
slaGroup.addServiceLevelAgreementRule(rule);
}
}
}
// transform the Actions if they exist.
if (sla.getSlaChecks() != null) {
List<ServiceLevelAgreementActionUiConfigurationItem> agreementActionUiConfigurationItems = new ArrayList<>();
for (ServiceLevelAgreementCheck check : sla.getSlaChecks()) {
for (ServiceLevelAgreementActionConfiguration actionConfig : check.getActionConfigurations()) {
if (actionConfig != null) {
ServiceLevelAgreementActionUiConfigurationItem uiModel = ServiceLevelAgreementActionConfigTransformer.instance().toUIModel(actionConfig);
agreementActionUiConfigurationItems.add(uiModel);
}
}
}
slaGroup.setActionConfigurations(agreementActionUiConfigurationItems);
}
slaGroup.setCanEdit(sla.isCanEdit());
return slaGroup;
}
use of com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup 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.metadata.rest.model.sla.ObligationGroup in project kylo by Teradata.
the class ServiceLevelAgreementMetricTransformerHelper method getServiceLevelAgreement.
public ServiceLevelAgreement getServiceLevelAgreement(ServiceLevelAgreementGroup serviceLevelAgreement) {
ServiceLevelAgreement transformedSla = new ServiceLevelAgreement();
transformedSla.setId(serviceLevelAgreement.getId());
transformedSla.setName(serviceLevelAgreement.getName());
transformedSla.setDescription(serviceLevelAgreement.getDescription());
for (ServiceLevelAgreementRule rule : serviceLevelAgreement.getRules()) {
try {
ObligationGroup group = new ObligationGroup();
Metric policy = ServiceLevelAgreementMetricTransformer.instance().fromUiModel(rule);
Obligation obligation = new Obligation(policy.getDescription());
obligation.setMetrics(Lists.newArrayList(policy));
group.addObligation(obligation);
group.setCondition(rule.getCondition().name());
transformedSla.addGroup(group);
} catch (PolicyTransformException e) {
throw new RuntimeException(e);
}
}
return transformedSla;
}
use of com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup 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();
}
Aggregations