Search in sources :

Example 1 with ServiceLevelAgreementActionConfig

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig in project kylo by Teradata.

the class ServiceLevelAgreementActionConfigTransformer method buildActionConfigurationRegistry.

private synchronized void buildActionConfigurationRegistry() {
    actionConfigurationRegistry = new ArrayList<>();
    List<ServiceLevelAgreementActionUiConfigurationItem> rules = new ArrayList<>();
    Set<Class<?>> items = ReflectionPolicyAnnotationDiscoverer.getTypesAnnotatedWith(ServiceLevelAgreementActionConfig.class);
    for (Class c : items) {
        List<FieldRuleProperty> properties = getUiProperties(c);
        ServiceLevelAgreementActionConfig policy = (ServiceLevelAgreementActionConfig) c.getAnnotation(ServiceLevelAgreementActionConfig.class);
        ServiceLevelAgreementActionUiConfigurationItem configItem = buildUiModel(policy, c, properties);
        rules.add(configItem);
        actionConfigurationRegistry.add(configItem);
    }
}
Also used : ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) ServiceLevelAgreementActionConfig(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)

Example 2 with ServiceLevelAgreementActionConfig

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig in project kylo by Teradata.

the class ServiceLevelAgreementActionConfigTransformer method validateAction.

public List<ServiceLevelAgreementActionValidation> validateAction(String actionConfigurationClassName) {
    List<ServiceLevelAgreementActionValidation> validation = null;
    try {
        Class<? extends ServiceLevelAgreementActionConfiguration> configurationClass = ClassNameChangeRegistry.findClass(actionConfigurationClassName);
        ServiceLevelAgreementActionConfig annotation = (ServiceLevelAgreementActionConfig) configurationClass.getAnnotation(ServiceLevelAgreementActionConfig.class);
        Class<? extends ServiceLevelAgreementAction>[] actions = annotation.actionClasses();
        if (actions != null) {
            List<Class<? extends ServiceLevelAgreementAction>> actionClassList = Lists.newArrayList(actions);
            validation = ServiceLevelAgreementActionUtil.validateActionConfiguration(actionClassList);
        } else {
            validation.add(new ServiceLevelAgreementActionValidation(false, "No Actions are defined for :" + actionConfigurationClassName));
        }
    } catch (ClassNotFoundException e) {
        if (validation != null) {
            validation.add(new ServiceLevelAgreementActionValidation(false, "ImmutableAction Configuration Not Found: " + e.getMessage()));
        }
    }
    return validation;
}
Also used : ServiceLevelAgreementAction(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction) ServiceLevelAgreementActionValidation(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation) ServiceLevelAgreementActionConfig(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)

Example 3 with ServiceLevelAgreementActionConfig

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig in project kylo by Teradata.

the class JcrServiceLevelAgreementCheck method setActionConfigurations.

public void setActionConfigurations(List<? extends ServiceLevelAgreementActionConfiguration> actionConfigurations) {
    try {
        NodeIterator nodes = getNode().getNodes(ACTION_CONFIGURATIONS);
        while (nodes.hasNext()) {
            Node metricNode = (Node) nodes.next();
            metricNode.remove();
        }
        for (ServiceLevelAgreementActionConfiguration actionConfiguration : actionConfigurations) {
            Node node = getNode().addNode(ACTION_CONFIGURATIONS, ACTION_CONFIGURATION_TYPE);
            JcrPropertyUtil.setProperty(node, JcrPropertyConstants.TITLE, actionConfiguration.getClass().getSimpleName());
            ServiceLevelAgreementActionConfig annotation = actionConfiguration.getClass().getAnnotation(ServiceLevelAgreementActionConfig.class);
            String desc = actionConfiguration.getClass().getSimpleName();
            if (annotation != null) {
                desc = annotation.description();
            }
            JcrPropertyUtil.setProperty(node, DESCRIPTION, desc);
            JcrUtil.addGenericJson(node, JcrPropertyConstants.JSON, actionConfiguration);
        }
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve the metric nodes", e);
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) ServiceLevelAgreementActionConfig(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)

Aggregations

ServiceLevelAgreementActionConfig (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)3 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)1 ServiceLevelAgreementAction (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction)1 ServiceLevelAgreementActionConfiguration (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration)1 ServiceLevelAgreementActionValidation (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation)1 FieldRuleProperty (com.thinkbiganalytics.policy.rest.model.FieldRuleProperty)1 ArrayList (java.util.ArrayList)1 Node (javax.jcr.Node)1 NodeIterator (javax.jcr.NodeIterator)1 RepositoryException (javax.jcr.RepositoryException)1