Search in sources :

Example 11 with HadoopSecurityGroup

use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup in project kylo by Teradata.

the class CategoryModelTransform method domainToFeedCategory.

/**
 * Transforms the specified Metadata category into a Feed Manager category.
 *
 * @param domainCategory the Metadata category
 * @param userFields     the user-defined fields
 * @return the Feed Manager category
 */
@Nullable
private FeedCategory domainToFeedCategory(@Nullable final Category domainCategory, @Nonnull final Set<UserFieldDescriptor> userFields, boolean includeFeedDetails) {
    if (domainCategory != null) {
        FeedCategory category = new FeedCategory();
        category.setId(domainCategory.getId().toString());
        if (includeFeedDetails && domainCategory.getFeeds() != null) {
            List<FeedSummary> summaries = feedModelTransform.domainToFeedSummary(domainCategory.getFeeds());
            category.setFeeds(summaries);
            category.setRelatedFeeds(summaries.size());
        }
        category.setIconColor(domainCategory.getIconColor());
        category.setIcon(domainCategory.getIcon());
        category.setName(domainCategory.getDisplayName());
        // in pre-0.8.4 version of Kylo there was no system name stored for domain categories
        category.setSystemName(domainCategory.getSystemName() == null ? domainCategory.getDisplayName() : domainCategory.getSystemName());
        category.setDescription(domainCategory.getDescription());
        category.setAllowIndexing(domainCategory.isAllowIndexing());
        category.setCreateDate(domainCategory.getCreatedTime() != null ? domainCategory.getCreatedTime().toDate() : null);
        category.setUpdateDate(domainCategory.getModifiedTime() != null ? domainCategory.getModifiedTime().toDate() : null);
        // Transform user-defined fields and properties
        category.setUserFields(UserPropertyTransform.toUserFields(categoryProvider.getFeedUserFields(domainCategory.getId()).orElse(Collections.emptySet())));
        category.setUserProperties(UserPropertyTransform.toUserProperties(domainCategory.getUserProperties(), userFields));
        // Convert JCR securitygroup to DTO
        List<com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup> restSecurityGroups = new ArrayList<>();
        if (domainCategory.getSecurityGroups() != null && domainCategory.getSecurityGroups().size() > 0) {
            for (Object group : domainCategory.getSecurityGroups()) {
                HadoopSecurityGroup hadoopSecurityGroup = (HadoopSecurityGroup) group;
                com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup restSecurityGroup = new com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup();
                restSecurityGroup.setDescription(hadoopSecurityGroup.getDescription());
                restSecurityGroup.setId(hadoopSecurityGroup.getGroupId());
                restSecurityGroup.setName(hadoopSecurityGroup.getName());
                restSecurityGroups.add(restSecurityGroup);
            }
        }
        category.setSecurityGroups(restSecurityGroups);
        securityTransform.applyAccessControl(domainCategory, category);
        return category;
    } else {
        return null;
    }
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) ArrayList(java.util.ArrayList) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary) Nullable(javax.annotation.Nullable)

Aggregations

HadoopSecurityGroup (com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup)11 ArrayList (java.util.ArrayList)9 JcrHadoopSecurityGroup (com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)8 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)5 Category (com.thinkbiganalytics.metadata.api.category.Category)4 Nonnull (javax.annotation.Nonnull)4 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)3 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)3 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)3 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)3 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)3 Node (javax.jcr.Node)3 DefaultTag (com.thinkbiganalytics.discovery.model.DefaultTag)2 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)2 UserProperty (com.thinkbiganalytics.feedmgr.rest.model.UserProperty)2 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)2 DateTime (org.joda.time.DateTime)2 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1