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