Search in sources :

Example 26 with Category

use of com.thinkbiganalytics.metadata.api.category.Category in project kylo by Teradata.

the class FeedManagerFeedTest method testLotsOfFeeds.

/**
 * Test querying a large number of feeds
 */
@Test
public void testLotsOfFeeds() {
    // increase to query more .. i.e. 1000
    int numberOfFeeds = 5;
    int numberOfFeedsPerCategory = 20;
    String templateName = "my_template";
    int categories = numberOfFeeds / numberOfFeedsPerCategory;
    // create all the categories
    metadata.commit(() -> {
        for (int i = 1; i <= categories; i++) {
            Category category = feedTestUtil.createCategory("category_" + i);
        }
    }, MetadataAccess.ADMIN);
    metadata.commit(() -> {
        FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
    }, MetadataAccess.ADMIN);
    // create the feeds
    metadata.commit(() -> {
        FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
        Category category = null;
        int categoryNum = 0;
        String categoryName = "category" + categoryNum;
        for (int i = 0; i < numberOfFeeds; i++) {
            if (i % numberOfFeedsPerCategory == 0) {
                categoryNum++;
                categoryName = "category_" + categoryNum;
                category = feedTestUtil.findOrCreateCategory(categoryName);
            }
            Feed feed = feedTestUtil.findOrCreateFeed(category, "feed_" + i, template);
        }
    }, MetadataAccess.ADMIN);
    // now query it
    long time = System.currentTimeMillis();
    Integer size = metadata.read(() -> {
        List<Feed> feeds = feedProvider.findAll();
        return feeds.size();
    }, MetadataAccess.SERVICE);
    long stopTime = System.currentTimeMillis();
    log.info("Time to query {} feeds was {} ms", size, (stopTime - time));
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) Test(org.junit.Test)

Example 27 with Category

use of com.thinkbiganalytics.metadata.api.category.Category in project kylo by Teradata.

the class FeedTestUtil method findOrCreateFeed.

public Feed findOrCreateFeed(String categorySystemName, String feedSystemName, String feedTemplate) {
    Category category = findOrCreateCategory(categorySystemName);
    Feed feed = feedProvider.ensureFeed(category.getId(), feedSystemName);
    feed.setDisplayName(feedSystemName);
    FeedManagerTemplate template = findOrCreateTemplate(feedTemplate);
    feed.setTemplate(template);
    return feedProvider.update(feed);
}
Also used : JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) Category(com.thinkbiganalytics.metadata.api.category.Category) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 28 with Category

use of com.thinkbiganalytics.metadata.api.category.Category in project kylo by Teradata.

the class CheckEntityAccessControlAction method ensureCategoryAccessControl.

private void ensureCategoryAccessControl() {
    List<Category> categories = categoryProvider.findAll();
    if (categories != null) {
        List<SecurityRole> catRoles = this.roleProvider.getEntityRoles(SecurityRole.CATEGORY);
        List<SecurityRole> feedRoles = this.roleProvider.getEntityRoles(SecurityRole.FEED);
        Optional<AllowedActions> allowedActions = this.actionsProvider.getAvailableActions(AllowedActions.CATEGORY);
        categories.stream().forEach(category -> {
            Principal owner = category.getOwner() != null ? category.getOwner() : JcrMetadataAccess.getActiveUser();
            allowedActions.ifPresent(actions -> ((JcrCategory) category).enableAccessControl((JcrAllowedActions) actions, owner, catRoles, feedRoles));
        });
    }
}
Also used : SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Category(com.thinkbiganalytics.metadata.api.category.Category) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Principal(java.security.Principal)

Aggregations

Category (com.thinkbiganalytics.metadata.api.category.Category)28 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)12 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)10 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)7 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)6 JcrCategory (com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)6 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)5 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)5 HadoopSecurityGroup (com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup)5 ArrayList (java.util.ArrayList)5 Collections (java.util.Collections)5 List (java.util.List)5 Optional (java.util.Optional)5 Set (java.util.Set)5 Nonnull (javax.annotation.Nonnull)5 CategoryProvider (com.thinkbiganalytics.metadata.api.category.CategoryProvider)4 DatasourceProvider (com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider)4 FeedAccessControl (com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl)4 AccessController (com.thinkbiganalytics.security.AccessController)4 FeedNameUtil (com.thinkbiganalytics.support.FeedNameUtil)4