use of com.thinkbiganalytics.feedmgr.rest.model.FeedCategory in project kylo by Teradata.
the class InMemoryFeedManagerCategoryService method bootstrapCategories.
private void bootstrapCategories() {
List<FeedCategory> feedCategoryList = new ArrayList<>();
feedCategoryList.add(new FeedCategoryBuilder("Employees").description("Employee profile data and records").icon("people").iconColor("#F06292").build());
feedCategoryList.add(new FeedCategoryBuilder("Sales").description("Sales data including opportunities and leads").icon("phone_android").iconColor("#90A4AE").build());
feedCategoryList.add(new FeedCategoryBuilder("Online").description("Web traffic data and reports of online activity").icon("web").iconColor("#66BB6A").build());
feedCategoryList.add(new FeedCategoryBuilder("Payroll").description("Payroll records for employees").icon("attach_money").iconColor("#FFCA28").build());
feedCategoryList.add(new FeedCategoryBuilder("Travel").description("Employee travel records including all expense reports").icon("local_airport").iconColor("#FFF176").build());
feedCategoryList.add(new FeedCategoryBuilder("Data").description("General Data ").icon("cloud").iconColor("#AB47BC").build());
feedCategoryList.add(new FeedCategoryBuilder("Emails").description("All email traffic data archived for the last 5 years").icon("email").iconColor("#FF5252").build());
feedCategoryList.add(new FeedCategoryBuilder("Customers").description("All customer data for various companies").icon("face").iconColor("#FF5252").build());
for (FeedCategory category : feedCategoryList) {
category.setId(UUID.randomUUID().toString());
categories.put(category.getId(), category);
}
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedCategory in project kylo by Teradata.
the class FeedModelTransform method feedToDomain.
/**
* Transforms the specified Feed Manager feed to a Metadata feed.
*
* @param feedMetadata the Feed Manager feed
* @return the Metadata feed
*/
@Nonnull
public Feed feedToDomain(@Nonnull final FeedMetadata feedMetadata) {
// resolve the id
Feed.ID domainId = feedMetadata.getId() != null ? feedProvider.resolveId(feedMetadata.getId()) : null;
Feed domain = domainId != null ? feedProvider.findById(domainId) : null;
FeedCategory restCategoryModel = feedMetadata.getCategory();
Category category = null;
if (restCategoryModel != null && (domain == null || domain.getCategory() == null)) {
category = categoryProvider.findById(categoryProvider.resolveId(restCategoryModel.getId()));
}
if (domain == null) {
// ensure the Category exists
if (category == null) {
final String categoryId = (restCategoryModel != null) ? restCategoryModel.getId() : "(null)";
throw new RuntimeException("Category cannot be found while creating feed " + feedMetadata.getSystemFeedName() + ". Category Id is " + categoryId);
}
domain = feedProvider.ensureFeed(category.getId(), feedMetadata.getSystemFeedName());
domainId = domain.getId();
Feed.State state = Feed.State.valueOf(feedMetadata.getState());
domain.setState(state);
// reassign the domain data back to the ui model....
feedMetadata.setFeedId(domainId.toString());
feedMetadata.setState(state.name());
}
domain.setDisplayName(feedMetadata.getFeedName());
if (feedMetadata.getDescription() == null) {
feedMetadata.setDescription("");
}
domain.setDescription(feedMetadata.getDescription());
domain.setAllowIndexing(feedMetadata.isAllowIndexing());
if (StringUtils.isNotBlank(feedMetadata.getHistoryReindexingStatus())) {
domain.updateHistoryReindexingStatus(new HistoryReindexingStatus(com.thinkbiganalytics.metadata.api.feed.reindex.HistoryReindexingState.valueOf(feedMetadata.getHistoryReindexingStatus())));
}
feedMetadata.setId(domain.getId().toString());
if (StringUtils.isNotBlank(feedMetadata.getState())) {
Feed.State state = Feed.State.valueOf(feedMetadata.getState().toUpperCase());
domain.setState(state);
}
domain.setNifiProcessGroupId(feedMetadata.getNifiProcessGroupId());
// clear out the state as that
RegisteredTemplate template = feedMetadata.getRegisteredTemplate();
prepareForSave(feedMetadata);
feedMetadata.setRegisteredTemplate(template);
if (domain.getTemplate() == null) {
FeedManagerTemplate.ID templateId = templateProvider.resolveId(feedMetadata.getTemplateId());
FeedManagerTemplate domainTemplate = templateProvider.findById(templateId);
domain.setTemplate(domainTemplate);
}
// Set user-defined properties
if (feedMetadata.getUserProperties() != null) {
final Set<UserFieldDescriptor> userFields = getUserFields(category);
domain.setUserProperties(UserPropertyTransform.toMetadataProperties(feedMetadata.getUserProperties()), userFields);
}
// Set the hadoop security groups
final List<HadoopSecurityGroup> securityGroups = new ArrayList<>();
if (feedMetadata.getSecurityGroups() != null) {
for (com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup securityGroup : feedMetadata.getSecurityGroups()) {
JcrHadoopSecurityGroup hadoopSecurityGroup = (JcrHadoopSecurityGroup) hadoopSecurityGroupProvider.ensureSecurityGroup(securityGroup.getName());
hadoopSecurityGroup.setGroupId(securityGroup.getId());
hadoopSecurityGroup.setDescription(securityGroup.getDescription());
securityGroups.add(hadoopSecurityGroup);
}
}
domain.setSecurityGroups(securityGroups);
domain.setVersionName(domain.getVersionName());
if (feedMetadata.getTags() != null) {
domain.setTags(feedMetadata.getTags().stream().map(Tag::getName).collect(Collectors.toSet()));
}
// Create a new feed metadata stripped of any excess data that does
// not need to be serialized and stored in the feed domain entity.
FeedMetadata stripped = stripMetadata(feedMetadata);
domain.setJson(ObjectMapperSerializer.serialize(stripped));
return domain;
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedCategory in project kylo by Teradata.
the class InMemoryFeedManagerFeedService method saveFeed.
public void saveFeed(FeedMetadata feed) {
if (feed.getId() == null || !feeds.containsKey(feed.getId())) {
feed.setId(UUID.randomUUID().toString());
feed.setVersion(new Long(1));
} else {
FeedMetadata previousFeed = feeds.get(feed.getId());
feed.setId(previousFeed.getId());
feed.setVersion(previousFeed.getVersion() + 1L);
}
// match up the related category
String categoryId = feed.getCategory().getId();
FeedCategory category = null;
if (categoryId != null) {
category = categoryProvider.getCategoryById(categoryId);
}
if (category == null) {
final String categoryName = feed.getCategory().getSystemName();
category = categoryProvider.getCategoryBySystemName(categoryName);
feed.setCategory(category);
}
if (category != null) {
category.addRelatedFeed(new FeedSummary(feed));
}
// saveToMetadataStore(feed);
feeds.put(feed.getId(), feed);
FileObjectPersistence.getInstance().writeFeedsToFile(feeds.values());
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedCategory in project kylo by Teradata.
the class InMemoryFeedManagerFeedService method postConstruct.
@PostConstruct
private void postConstruct() {
Collection<FeedMetadata> savedFeeds = FileObjectPersistence.getInstance().getFeedsFromFile();
if (savedFeeds != null) {
Long maxId = 0L;
for (FeedMetadata feed : savedFeeds) {
// update the category mappings
String categoryId = feed.getCategory().getId();
FeedCategory category = categoryProvider.getCategoryById(categoryId);
feed.setCategory(category);
category.addRelatedFeed(new FeedSummary(feed));
// add it to the map
feeds.put(feed.getId(), feed);
}
loadSavedFeedsToMetaClientStore();
}
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedCategory in project kylo by Teradata.
the class InMemoryFeedManagerFeedService method getFeedById.
@Override
public FeedMetadata getFeedById(String id, boolean refreshTargetTableSchema) {
if (feeds != null && !feeds.isEmpty()) {
FeedMetadata feed = feeds.get(id);
if (feed != null) {
// get the latest category data
FeedCategory category = categoryProvider.getCategoryById(feed.getCategory().getId());
feed.setCategory(category);
// set the template to the feed
RegisteredTemplate registeredTemplate = templateProvider.getRegisteredTemplate(feed.getTemplateId());
if (registeredTemplate != null) {
RegisteredTemplate copy = new RegisteredTemplate(registeredTemplate);
copy.getProperties().clear();
feed.setRegisteredTemplate(copy);
feed.setTemplateId(copy.getNifiTemplateId());
}
return feed;
}
}
return null;
}
Aggregations