Search in sources :

Example 6 with Category

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

the class JcrCategoryAllowedActionsTest method cleanup.

@After
public void cleanup() {
    metadata.commit(() -> {
        Category a = categoryProvider.findBySystemName("testA");
        if (a != null) {
            categoryProvider.deleteById(a.getId());
        }
        Category b = categoryProvider.findBySystemName("testB");
        if (b != null) {
            categoryProvider.deleteById(b.getId());
        }
        Category c = categoryProvider.findBySystemName("testC");
        if (c != null) {
            categoryProvider.deleteById(c.getId());
        }
    }, MetadataAccess.SERVICE);
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) After(org.junit.After)

Example 7 with Category

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

the class JcrCategoryAllowedActionsTest method testSummaryOnlyRead.

@Test
public void testSummaryOnlyRead() {
    Object[] nameDescr = metadata.commit(() -> {
        Category cat = this.categoryProvider.findById(idB);
        cat.getAllowedActions().enable(TEST_USER1, CategoryAccessControl.ACCESS_CATEGORY);
        return new String[] { cat.getSystemName(), cat.getDescription() };
    }, TEST_USER2);
    metadata.read(() -> {
        Category cat = this.categoryProvider.findById(idB);
        assertThat(cat).extracting("systemName", "description").contains(nameDescr);
        assertThat(cat.getUserProperties()).isEmpty();
    }, TEST_USER1);
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) Test(org.junit.Test)

Example 8 with Category

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

the class JcrFeedSlaTest method createFeed.

public JcrFeed.FeedId createFeed(final String categorySystemName, final String feedSystemName) {
    Category category = metadata.commit(() -> {
        JcrCategory cat = (JcrCategory) categoryProvider.ensureCategory(categorySystemName);
        cat.setDescription(categorySystemName + " desc");
        cat.setTitle(categorySystemName);
        categoryProvider.update(cat);
        return cat;
    }, MetadataAccess.ADMIN);
    return metadata.commit(() -> {
        JcrCategory cat = (JcrCategory) categoryProvider.ensureCategory(categorySystemName);
        JcrFeed feed = (JcrFeed) feedProvider.ensureFeed(categorySystemName, feedSystemName, feedSystemName + " desc");
        feed.setTitle(feedSystemName);
        return feed.getId();
    }, MetadataAccess.ADMIN);
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)

Example 9 with Category

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

the class JcrFeedProvider method findByCategoryId.

@Override
public List<? extends Feed> findByCategoryId(Category.ID categoryId) {
    String query = "SELECT e.* from " + EntityUtil.asQueryProperty(JcrFeed.NODE_TYPE) + " as e " + "INNER JOIN [" + CategoryDetails.NODE_TYPE + "] as det on ISCHILDNODE(e, det)" + "INNER JOIN [" + JcrCategory.NODE_TYPE + "] as cat on ISCHILDNODE(det, cat)" + "WHERE cat.[mode:id] = $id";
    Map<String, String> bindParams = new HashMap<>();
    bindParams.put("id", categoryId.toString());
    try {
        QueryResult result = JcrQueryUtil.query(getSession(), query, bindParams);
        // not accessible.  For now filter the result based on the feed summary access.
        return JcrQueryUtil.queryResultStream(result, JcrFeed.class).filter(feed -> feed.getFeedSummary().isPresent()).collect(Collectors.toList());
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Unable to getFeeds for Category ", e);
    }
}
Also used : EntityUtil(com.thinkbiganalytics.metadata.modeshape.common.EntityUtil) Category(com.thinkbiganalytics.metadata.api.category.Category) DatasourceNotFoundException(com.thinkbiganalytics.metadata.api.datasource.DatasourceNotFoundException) ChangeType(com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) QueryResult(javax.jcr.query.QueryResult) FeedChange(com.thinkbiganalytics.metadata.api.event.feed.FeedChange) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) AbstractMetadataCriteria(com.thinkbiganalytics.metadata.modeshape.AbstractMetadataCriteria) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) FeedAccessControl(com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl) JcrDatasource(com.thinkbiganalytics.metadata.modeshape.datasource.JcrDatasource) Map(java.util.Map) FeedPropertyChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent) AccessController(com.thinkbiganalytics.security.AccessController) Pageable(org.springframework.data.domain.Pageable) UserFieldDescriptors(com.thinkbiganalytics.metadata.modeshape.common.UserFieldDescriptors) JcrAllowedEntityActionsProvider(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedEntityActionsProvider) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) PreconditionBuilder(com.thinkbiganalytics.metadata.api.feed.PreconditionBuilder) CategoryNotFoundException(com.thinkbiganalytics.metadata.api.category.CategoryNotFoundException) CategoryDetails(com.thinkbiganalytics.metadata.modeshape.category.CategoryDetails) Session(javax.jcr.Session) FeedOpsAccessControlProvider(com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAccessControlProvider) Set(java.util.Set) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Collectors(java.util.stream.Collectors) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Serializable(java.io.Serializable) SecurityRoleProvider(com.thinkbiganalytics.security.role.SecurityRoleProvider) List(java.util.List) Principal(java.security.Principal) Predicate(com.google.common.base.Predicate) CategoryProvider(com.thinkbiganalytics.metadata.api.category.CategoryProvider) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Optional(java.util.Optional) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) PropertyChange(com.thinkbiganalytics.metadata.api.event.feed.PropertyChange) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) NodeIterator(javax.jcr.NodeIterator) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) HashMap(java.util.HashMap) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) RepositoryException(javax.jcr.RepositoryException) Node(javax.jcr.Node) FeedChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent) FeedSource(com.thinkbiganalytics.metadata.api.feed.FeedSource) Nonnull(javax.annotation.Nonnull) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Datasource(com.thinkbiganalytics.metadata.api.datasource.Datasource) FeedNameUtil(com.thinkbiganalytics.support.FeedNameUtil) DateTime(org.joda.time.DateTime) ServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider) UserFieldDescriptor(com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor) JcrServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementProvider) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) Consumer(java.util.function.Consumer) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) ID(com.thinkbiganalytics.metadata.api.feed.Feed.ID) Condition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) ObligationBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationBuilder) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) DatasourceProvider(com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider) VersionProviderMixin(com.thinkbiganalytics.metadata.modeshape.common.mixin.VersionProviderMixin) Collections(java.util.Collections) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) QueryResult(javax.jcr.query.QueryResult) HashMap(java.util.HashMap) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException)

Example 10 with Category

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

the class JcrCategory method createCategory.

/**
 * Constructs a JcrCategory instance starting with either its base node or a child node, and an
 * optional FeedOpsAccessControlProvider.
 * @param node a tba:category type node or one of its child nodes
 * @param accessPvdr the optional provider
 * @return a new JcrCategory instance wrapping its derived base node
 */
public static JcrCategory createCategory(Node node, Optional<FeedOpsAccessControlProvider> accessPvdr) {
    Node baseNode = node;
    if (JcrUtil.isNodeType(node, CategoryDetails.NODE_TYPE)) {
        baseNode = JcrUtil.getParent(node);
    } else if (!JcrUtil.isNodeType(node, JcrCategory.NODE_TYPE)) {
        throw new IllegalArgumentException("Unexpected node type for category: " + node);
    }
    final Node catNode = baseNode;
    return accessPvdr.map(pvdr -> JcrUtil.createJcrObject(catNode, JcrCategory.class, pvdr)).orElse(JcrUtil.createJcrObject(catNode, JcrCategory.class));
}
Also used : Category(com.thinkbiganalytics.metadata.api.category.Category) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) RepositoryException(javax.jcr.RepositoryException) Node(javax.jcr.Node) Map(java.util.Map) Nonnull(javax.annotation.Nonnull) AccessControlledMixin(com.thinkbiganalytics.metadata.modeshape.security.mixin.AccessControlledMixin) AbstractJcrAuditableSystemEntity(com.thinkbiganalytics.metadata.modeshape.common.AbstractJcrAuditableSystemEntity) JcrPropertyUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil) RoleMembership(com.thinkbiganalytics.metadata.api.security.RoleMembership) FeedOpsAccessControlProvider(com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAccessControlProvider) Set(java.util.Set) UserFieldDescriptor(com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor) Serializable(java.io.Serializable) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrCategoryAllowedActions(com.thinkbiganalytics.metadata.modeshape.category.security.JcrCategoryAllowedActions) List(java.util.List) Principal(java.security.Principal) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Optional(java.util.Optional) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) Collections(java.util.Collections) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) Node(javax.jcr.Node)

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