Search in sources :

Example 1 with FeedSource

use of com.thinkbiganalytics.metadata.rest.model.feed.FeedSource in project kylo by Teradata.

the class FeedsController method ensureDependentDatasources.

private void ensureDependentDatasources(Feed feed, com.thinkbiganalytics.metadata.api.feed.Feed domainFeed) {
    for (FeedSource src : feed.getSources()) {
        Datasource.ID dsId = this.datasetProvider.resolve(src.getId());
        feedProvider.ensureFeedSource(domainFeed.getId(), dsId);
    }
    for (FeedDestination src : feed.getDestinations()) {
        Datasource.ID dsId = this.datasetProvider.resolve(src.getId());
        feedProvider.ensureFeedDestination(domainFeed.getId(), dsId);
    }
}
Also used : Datasource(com.thinkbiganalytics.metadata.api.datasource.Datasource) FeedDestination(com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination) FeedSource(com.thinkbiganalytics.metadata.rest.model.feed.FeedSource)

Example 2 with FeedSource

use of com.thinkbiganalytics.metadata.rest.model.feed.FeedSource in project kylo by Teradata.

the class Model method domainToFeedSource.

/**
 * Transforms the specified domain object to a REST object.
 *
 * @param domain the domain object
 * @return the REST object
 */
public FeedSource domainToFeedSource(@Nonnull final com.thinkbiganalytics.metadata.api.feed.FeedSource domain) {
    FeedSource src = new FeedSource();
    domain.getDatasource().ifPresent(datasource -> src.setDatasource(domainToDs(datasource)));
    domain.getDataSet().ifPresent(dataSet -> src.setDatasource(domainToDs(dataSet)));
    return src;
}
Also used : FeedSource(com.thinkbiganalytics.metadata.rest.model.feed.FeedSource)

Example 3 with FeedSource

use of com.thinkbiganalytics.metadata.rest.model.feed.FeedSource in project kylo by Teradata.

the class Model method domainToFeed.

/**
 * Transforms the specified domain object to a REST object.
 *
 * @param domain     the domain object
 * @param addSources {@code true} to include sources in the REST object, or {@code false} otherwise
 * @return the REST object
 */
public Feed domainToFeed(@Nonnull final com.thinkbiganalytics.metadata.api.feed.Feed domain, final boolean addSources) {
    Feed feed = new Feed();
    feed.setId(domain.getId().toString());
    feed.setSystemName(domain.getName());
    feed.setDisplayName(domain.getDisplayName());
    feed.setDescription(domain.getDescription());
    feed.setState(Feed.State.valueOf(domain.getState().name()));
    feed.setCreatedTime(domain.getCreatedTime());
    feed.setCurrentInitStatus(DOMAIN_TO_INIT_STATUS.apply(domain.getCurrentInitStatus()));
    if (domain.getCategory() != null) {
        feed.setCategory(DOMAIN_TO_FEED_CATEGORY.apply(domain.getCategory()));
    }
    if (addSources) {
        @SuppressWarnings("unchecked") Collection<FeedSource> sources = Collections2.transform(domain.getSources(), this::domainToFeedSource);
        feed.setSources(new HashSet<>(sources));
        @SuppressWarnings("unchecked") Collection<FeedDestination> destinations = Collections2.transform(domain.getDestinations(), this::domainToFeedDestination);
        feed.setDestinations(new HashSet<>(destinations));
    }
    for (Entry<String, Object> entry : domain.getProperties().entrySet()) {
        if (entry.getValue() != null) {
            feed.getProperties().setProperty(entry.getKey(), entry.getValue().toString());
        }
    }
    return feed;
}
Also used : FeedDestination(com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination) FeedSource(com.thinkbiganalytics.metadata.rest.model.feed.FeedSource) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed)

Example 4 with FeedSource

use of com.thinkbiganalytics.metadata.rest.model.feed.FeedSource in project kylo by Teradata.

the class FeedLineageBuilder method build.

private com.thinkbiganalytics.metadata.rest.model.feed.Feed build(Feed domainFeed) {
    com.thinkbiganalytics.metadata.rest.model.feed.Feed feed = restFeeds.containsKey(domainFeed.getId().toString()) ? restFeeds.get(domainFeed.getId().toString()) : model.domainToFeed(domainFeed);
    restFeeds.put(feed.getId(), feed);
    @SuppressWarnings("unchecked") List<? extends com.thinkbiganalytics.metadata.api.feed.FeedSource> sources = domainFeed.getSources();
    Set<FeedSource> feedSources = new HashSet<FeedSource>();
    if (sources != null) {
        boolean containsDerivedDatasource = false;
        for (com.thinkbiganalytics.metadata.api.feed.FeedSource feedSource : sources) {
            FeedSource src = new FeedSource();
            feedSource.getDatasource().ifPresent(datasource -> src.setDatasource(buildDatasource(datasource)));
            // only add datasets if the source is missing or if its not a derived datasource
            if (src.getDatasource() != null && src.getDatasource() instanceof DerivedDatasource) {
                containsDerivedDatasource = true;
            }
            if (!containsDerivedDatasource) {
                feedSource.getDataSet().ifPresent(dataSet -> src.setDatasource(buildDatasource(dataSet)));
            }
            feedSources.add(src);
        }
    }
    feed.setSources(feedSources);
    Set<FeedDestination> feedDestinations = new HashSet<FeedDestination>();
    List<? extends com.thinkbiganalytics.metadata.api.feed.FeedDestination> destinations = domainFeed.getDestinations();
    if (destinations != null) {
        destinations.stream().forEach(feedDestination -> {
            FeedDestination dest = new FeedDestination();
            feedDestination.getDatasource().ifPresent(datasource -> dest.setDatasource(buildDatasource(datasource)));
            feedDestination.getDataSet().ifPresent(dataSet -> dest.setDatasource(buildDatasource(dataSet)));
            feedDestinations.add(dest);
        });
    }
    feed.setDestinations(feedDestinations);
    if (domainFeed.getDependentFeeds() != null) {
        List<Feed> depFeeds = domainFeed.getDependentFeeds();
        depFeeds.stream().forEach(depFeed -> {
            com.thinkbiganalytics.metadata.rest.model.feed.Feed restFeed = restFeeds.get(depFeed.getId().toString());
            if (restFeed == null) {
                com.thinkbiganalytics.metadata.rest.model.feed.Feed depRestFeed = model.domainToFeed(depFeed);
                restFeeds.put(depRestFeed.getId(), depRestFeed);
                feed.getDependentFeeds().add(depRestFeed);
                build(depFeed);
            } else {
                feed.getDependentFeeds().add(restFeed);
            }
        });
    }
    if (domainFeed.getUsedByFeeds() != null) {
        List<Feed> usedByFeeds = domainFeed.getUsedByFeeds();
        usedByFeeds.stream().forEach(usedByFeed -> {
            com.thinkbiganalytics.metadata.rest.model.feed.Feed restFeed = restFeeds.get(usedByFeed.getId().toString());
            if (restFeed == null) {
                com.thinkbiganalytics.metadata.rest.model.feed.Feed usedByRestFeed = model.domainToFeed(usedByFeed);
                restFeeds.put(usedByRestFeed.getId(), usedByRestFeed);
                feed.getUsedByFeeds().add(usedByRestFeed);
                build(usedByFeed);
            } else {
                feed.getUsedByFeeds().add(restFeed);
            }
        });
    }
    return feed;
}
Also used : DerivedDatasource(com.thinkbiganalytics.metadata.rest.model.data.DerivedDatasource) FeedDestination(com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination) FeedSource(com.thinkbiganalytics.metadata.rest.model.feed.FeedSource) HashSet(java.util.HashSet) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Aggregations

FeedSource (com.thinkbiganalytics.metadata.rest.model.feed.FeedSource)4 FeedDestination (com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination)3 Datasource (com.thinkbiganalytics.metadata.api.datasource.Datasource)1 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)1 DerivedDatasource (com.thinkbiganalytics.metadata.rest.model.data.DerivedDatasource)1 Feed (com.thinkbiganalytics.metadata.rest.model.feed.Feed)1 HashSet (java.util.HashSet)1