Search in sources :

Example 1 with ObligationGroup

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;
}
Also used : Obligation(com.thinkbiganalytics.metadata.rest.model.sla.Obligation) ServiceLevelAgreementCheck(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreementCheck) ArrayList(java.util.ArrayList) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) ObligationGroup(com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup)

Example 2 with ObligationGroup

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;
}
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 ObligationGroup

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;
}
Also used : Obligation(com.thinkbiganalytics.metadata.rest.model.sla.Obligation) ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) PolicyTransformException(com.thinkbiganalytics.policy.PolicyTransformException) ObligationGroup(com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup)

Example 4 with ObligationGroup

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

Aggregations

ObligationGroup (com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup)4 ArrayList (java.util.ArrayList)3 Obligation (com.thinkbiganalytics.metadata.rest.model.sla.Obligation)2 Metric (com.thinkbiganalytics.metadata.sla.api.Metric)2 PolicyTransformException (com.thinkbiganalytics.policy.PolicyTransformException)2 PreconditionRule (com.thinkbiganalytics.policy.rest.model.PreconditionRule)2 ServiceLevelAgreement (com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement)1 ServiceLevelAgreementCheck (com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreementCheck)1 ServiceLevelAgreementActionConfiguration (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration)1 Precondition (com.thinkbiganalytics.policy.precondition.Precondition)1 LabelValue (com.thinkbiganalytics.rest.model.LabelValue)1 Test (org.junit.Test)1