use of com.thinkbiganalytics.metadata.api.feed.FeedSource in project kylo by Teradata.
the class DefaultFeedManagerFeedService method assignFeedDatasources.
/**
* Assign the feed sources/destinations
*
* @param feed the feed rest model
* @param domainFeed the domain feed
*/
private void assignFeedDatasources(FeedMetadata feed, Feed domainFeed) {
final Feed.ID domainFeedId = domainFeed.getId();
Set<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID> sources = new HashSet<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID>();
Set<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID> destinations = new HashSet<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID>();
String uniqueName = FeedNameUtil.fullName(feed.getCategory().getSystemName(), feed.getSystemFeedName());
RegisteredTemplate template = feed.getRegisteredTemplate();
if (template == null) {
// fetch it for checks
template = templateRestProvider.getRegisteredTemplate(feed.getTemplateId());
}
// find Definition registration
derivedDatasourceFactory.populateDatasources(feed, template, sources, destinations);
if (domainFeed.getSources() != null) {
Set<Datasource.ID> existingSourceIds = ((List<FeedSource>) domainFeed.getSources()).stream().filter(source -> source.getDatasource() != null).map(source1 -> source1.getDatasource().getId()).collect(Collectors.toSet());
if (!sources.containsAll(existingSourceIds) || (sources.size() != existingSourceIds.size())) {
// remove older sources
// cant do it here for some reason.. need to do it in a separate transaction
feedProvider.removeFeedSources(domainFeedId);
}
}
sources.stream().forEach(sourceId -> feedProvider.ensureFeedSource(domainFeedId, sourceId));
destinations.stream().forEach(sourceId -> feedProvider.ensureFeedDestination(domainFeedId, sourceId));
}
Aggregations