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