use of com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException 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.catalog.DataSetNotFoundException in project kylo by Teradata.
the class JcrFeedProvider method ensureFeedSource.
@Override
public FeedSource ensureFeedSource(ID feedId, DataSet.ID dsId) {
JcrFeed feed = (JcrFeed) findById(feedId);
FeedSource source = feed.getSource(dsId);
if (source == null) {
return dataSetProvider.find(dsId).map(ds -> feed.ensureFeedSource((JcrDataSet) ds, false)).orElseThrow(() -> new DataSetNotFoundException(dsId));
} else {
return source;
}
}
use of com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException 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.catalog.DataSet.ID> sourceDataSets = new HashSet<>();
Set<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID> sourceDatasources = new HashSet<>();
Set<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID> destinationDatasources = new HashSet<>();
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());
}
// Collect the IDs of the legacy datasources the feed had referenced
Set<Datasource.ID> previousSourceIds = domainFeed.getSources().stream().filter(fs -> fs.getDatasource().isPresent()).map(fs -> fs.getDatasource().get().getId()).collect(Collectors.toSet());
Set<Datasource.ID> previousDestIds = domainFeed.getDestinations().stream().filter(// Currently will always be true as there are no destination data sets yet.
fs -> fs.getDatasource().isPresent()).map(fs -> fs.getDatasource().get().getId()).collect(Collectors.toSet());
boolean isSampleDataSet = isTreatSourceDataSetsAsSample(feed, template);
// find Definition registration
derivedDatasourceFactory.populateDatasources(feed, template, sourceDatasources, destinationDatasources);
// Replace the older legacy datasource references with the new ones.
previousSourceIds.stream().filter(id -> !sourceDatasources.contains(id)).forEach(id -> feedProvider.removeFeedSource(domainFeedId, id));
sourceDatasources.stream().forEach(sourceId -> feedProvider.ensureFeedSource(domainFeedId, sourceId));
previousDestIds.stream().filter(id -> !destinationDatasources.contains(id)).forEach(id -> feedProvider.removeFeedDestination(domainFeedId, id));
destinationDatasources.stream().forEach(sourceId -> feedProvider.ensureFeedDestination(domainFeedId, sourceId));
// Update data sets
if (feed.getSourceDataSets() != null) {
// Collect the IDs of source data sets the feed had referenced
Set<com.thinkbiganalytics.metadata.api.catalog.DataSet.ID> currentDataSetIds = domainFeed.getSources().stream().map(FeedSource::getDataSet).filter(Optional::isPresent).map(Optional::get).map(com.thinkbiganalytics.metadata.api.catalog.DataSet::getId).collect(Collectors.toSet());
Set<com.thinkbiganalytics.metadata.api.catalog.DataSet.ID> newDataSetIds = new HashSet<>();
feed.getSourceDataSets().forEach(dataSet -> {
com.thinkbiganalytics.metadata.api.catalog.DataSet addedDataSet;
if (dataSet.getId() == null) {
DataSource.ID dataSourceId = dataSourceProvider.resolveId(dataSet.getDataSource().getId());
dataSourceProvider.find(dataSourceId).orElseThrow(() -> new DataSourceNotFoundException(dataSourceId));
addedDataSet = catalogModelTransform.buildDataSet(dataSet, dataSetProvider.build(dataSourceId));
} else {
com.thinkbiganalytics.metadata.api.catalog.DataSet.ID dataSetId = dataSetProvider.resolveId(dataSet.getId());
addedDataSet = dataSetProvider.find(dataSetId).orElseThrow(() -> new DataSetNotFoundException(dataSetId));
}
newDataSetIds.add(addedDataSet.getId());
catalogModelTransform.updateDataSet(dataSet, addedDataSet);
feedProvider.ensureFeedSource(domainFeedId, addedDataSet.getId(), isSampleDataSet);
});
// Remove any data set sources no longer referenced in the updated feed.
currentDataSetIds.stream().filter(id -> !newDataSetIds.contains(id)).forEach(id -> feedProvider.removeFeedSource(domainFeedId, id));
}
}
use of com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException in project kylo by Teradata.
the class JcrFeedProvider method ensureFeedSource.
@Override
public FeedSource ensureFeedSource(ID feedId, DataSet.ID dsId, boolean isSample) {
JcrFeed feed = (JcrFeed) findById(feedId);
FeedSource source = feed.getSource(dsId);
if (source == null) {
return dataSetProvider.find(dsId).map(ds -> feed.ensureFeedSource((JcrDataSet) ds, isSample)).orElseThrow(() -> new DataSetNotFoundException(dsId));
} else {
return source;
}
}
Aggregations