Search in sources :

Example 1 with LabelValue

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

the class BasePolicyAnnotationTransformer method convertToLabelValue.

private List<LabelValue> convertToLabelValue(String[] values) {
    if (values != null) {
        List<LabelValue> list = new ArrayList<>();
        for (String value : values) {
            LabelValue labelValue = new LabelValue();
            labelValue.setLabel(value);
            labelValue.setValue(value);
            list.add(labelValue);
        }
        return list;
    }
    return null;
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue) ArrayList(java.util.ArrayList)

Example 2 with LabelValue

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

the class ServiceLevelAgreementRestController method getAvailableServiceLevelAgreementTemplateActionClasses.

@GET
@Path("/available-sla-template-actions")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the available SLA actions.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the list of SLA actions used when creating/editing an SLA Email Template.", response = LabelValue.class, responseContainer = "List") })
public Set<LabelValue> getAvailableServiceLevelAgreementTemplateActionClasses() {
    List<ServiceLevelAgreementActionUiConfigurationItem> actionItems = ServiceLevelAgreementActionConfigTransformer.instance().discoverActionConfigurations();
    Set<LabelValue> set = new HashSet<>();
    actionItems.stream().forEach(a -> {
        a.getActionClasses().stream().forEach(c -> {
            LabelValue labelValue = new LabelValue(a.getDisplayName(), c.getName());
            set.add(labelValue);
        });
    });
    return set;
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue) ServiceLevelAgreementActionUiConfigurationItem(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementActionUiConfigurationItem) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with LabelValue

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

the class DefaultFeedManagerFeedService method applyFeedSelectOptions.

@Override
public /**
 * Applies new LableValue array to the FieldProperty.selectableValues {label = Category.Display Feed Name, value=category.system_feed_name}
 */
void applyFeedSelectOptions(List<FieldRuleProperty> properties) {
    if (properties != null && !properties.isEmpty()) {
        List<FeedSummary> feedSummaries = getFeedSummaryData();
        List<LabelValue> feedSelection = new ArrayList<>();
        for (FeedSummary feedSummary : feedSummaries) {
            boolean isDisabled = feedSummary.getState() == Feed.State.DISABLED.name();
            boolean canEditDetails = accessController.isEntityAccessControlled() ? feedSummary.hasAction(FeedAccessControl.EDIT_DETAILS.getSystemName()) : accessController.hasPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
            Map<String, Object> labelValueProperties = new HashMap<>();
            labelValueProperties.put("feed:disabled", isDisabled);
            labelValueProperties.put("feed:editDetails", canEditDetails);
            feedSelection.add(new LabelValue(feedSummary.getCategoryAndFeedDisplayName() + (isDisabled ? " (DISABLED) " : ""), feedSummary.getCategoryAndFeedSystemName(), isDisabled ? "This feed is currently disabled" : "", labelValueProperties));
        }
        feedSelection.sort(Comparator.comparing(LabelValue::getLabel, String.CASE_INSENSITIVE_ORDER));
        for (FieldRuleProperty property : properties) {
            property.setSelectableValues(feedSelection);
            if (property.getValues() == null) {
                // reset the intial values to be an empty arraylist
                property.setValues(new ArrayList<>());
            }
        }
    }
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Example 4 with LabelValue

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

the class BasePolicyAnnotationTransformer method convertToLabelValue.

private LabelValue convertToLabelValue(PropertyLabelValue propertyLabelValue) {
    if (propertyLabelValue != null) {
        LabelValue labelValue = new LabelValue();
        labelValue.setLabel(propertyLabelValue.label());
        labelValue.setValue(propertyLabelValue.value());
        return labelValue;
    }
    return null;
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue)

Example 5 with LabelValue

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

the class InMemoryFeedManagerFeedService method applyFeedSelectOptions.

@Override
public void applyFeedSelectOptions(List<FieldRuleProperty> properties) {
    if (properties != null && !properties.isEmpty()) {
        List<FeedSummary> feedSummaries = getFeedSummaryData();
        List<LabelValue> feedSelection = new ArrayList<>();
        for (FeedSummary feedSummary : feedSummaries) {
            feedSelection.add(new LabelValue(feedSummary.getCategoryAndFeedDisplayName(), feedSummary.getCategoryAndFeedSystemName()));
        }
        for (FieldRuleProperty property : properties) {
            property.setSelectableValues(feedSelection);
            if (property.getValues() == null) {
                // reset the intial values to be an empty arraylist
                property.setValues(new ArrayList<>());
            }
        }
    }
}
Also used : LabelValue(com.thinkbiganalytics.rest.model.LabelValue) ArrayList(java.util.ArrayList) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Aggregations

LabelValue (com.thinkbiganalytics.rest.model.LabelValue)6 ArrayList (java.util.ArrayList)4 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)2 FieldRuleProperty (com.thinkbiganalytics.policy.rest.model.FieldRuleProperty)2 ServiceLevelAgreementActionUiConfigurationItem (com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementActionUiConfigurationItem)1 ObligationGroup (com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup)1 PreconditionRule (com.thinkbiganalytics.policy.rest.model.PreconditionRule)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Test (org.junit.Test)1