use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.
the class BaseFeed method addDestination.
public FeedDestination addDestination(Datasource ds) {
FeedDestination dest = new Destination(ds);
this.destinations.add(dest);
return dest;
}
use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.
the class FeedManagerFeedTest method testFeedDatasource.
@Test
public void testFeedDatasource() {
String categorySystemName = "my_category2";
String feedName = "my_feed2";
String templateName = "my_template2";
String description = " my feed description";
setupFeedAndTemplate(categorySystemName, feedName, templateName);
// boolean isDefineTable = true;
// boolean isGetFile = false;
metadata.commit(() -> {
Feed feed = feedTestUtil.findFeed(categorySystemName, feedName);
Set<Datasource.ID> sources = new HashSet<Datasource.ID>();
Set<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID> destinations = new HashSet<>();
// Add Table Dependencies
String uniqueName = FeedNameUtil.fullName(categorySystemName, feedName);
DerivedDatasource srcDatasource = datasourceProvider.ensureDatasource(uniqueName, feed.getDescription(), DerivedDatasource.class);
sources.add(srcDatasource.getId());
DerivedDatasource destDatasource = datasourceProvider.ensureDatasource("destination", feed.getDescription(), DerivedDatasource.class);
destinations.add(destDatasource.getId());
sources.stream().forEach(sourceId -> feedProvider.ensureFeedSource(feed.getId(), sourceId));
destinations.stream().forEach(destinationId -> feedProvider.ensureFeedDestination(feed.getId(), destinationId));
}, MetadataAccess.SERVICE);
// ensure the sources and dest got created
metadata.read(() -> {
Feed feed = feedTestUtil.findFeed(categorySystemName, feedName);
Assert.assertNotNull(feed.getSources());
Assert.assertTrue(feed.getSources().size() == 1, "Feed Sources should be 1");
Assert.assertNotNull(feed.getDestinations());
Assert.assertTrue(feed.getDestinations().size() == 1, "Feed Destinations should be 1");
List<? extends FeedDestination> feedDestinations = feed.getDestinations();
if (feedDestinations != null) {
FeedDestination feedDestination = feedDestinations.get(0);
Datasource ds = feedDestination.getDatasource().get();
Assert.assertTrue(ds instanceof DerivedDatasource, "Datasource was not expected DerivedDatasource");
}
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.
the class JcrFeedProvider method ensureFeedDestination.
@Override
public FeedDestination ensureFeedDestination(ID feedId, DataSet.ID dsId) {
JcrFeed feed = (JcrFeed) findById(feedId);
FeedDestination source = feed.getDestination(dsId);
if (source == null) {
return dataSetProvider.find(dsId).map(ds -> feed.ensureFeedDestination((JcrDataSet) ds)).orElseThrow(() -> new DataSetNotFoundException(dsId));
} else {
return source;
}
}
use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.
the class JcrFeedProvider method ensureFeedDestination.
@Override
public FeedDestination ensureFeedDestination(Feed.ID feedId, com.thinkbiganalytics.metadata.api.datasource.Datasource.ID dsId) {
JcrFeed feed = (JcrFeed) findById(feedId);
FeedDestination source = feed.getDestination(dsId);
if (source == null) {
JcrDatasource datasource = (JcrDatasource) datasourceProvider.getDatasource(dsId);
if (datasource != null) {
JcrFeedDestination jcrDest = feed.ensureFeedDestination(datasource);
// save();
return jcrDest;
} else {
throw new DatasourceNotFoundException(dsId);
}
} else {
return source;
}
}
use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.
the class JcrDatasource method setDestinations.
public void setDestinations(List<FeedDestination> destinations) {
JcrPropertyUtil.setProperty(getNode(), DESTINATION_NAME, null);
for (FeedDestination dest : destinations) {
Node destNode = ((JcrFeedSource) dest).getNode();
addDestinationNode(destNode);
}
}
Aggregations