use of com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSet in project kylo by Teradata.
the class MigrateLegacyDatasourcesUpgradeAction method linkDataSets.
private void linkDataSets(JcrDataSource catDs, Set<? extends JcrFeed> referencingFeeds) {
referencingFeeds.stream().forEach(feed -> {
String title = catDs.getTitle();
feed.getSources().stream().map(JcrFeedSource.class::cast).forEach(source -> {
source.getDatasource().map(JcrDatasource.class::cast).ifPresent(datasource -> {
// for each table. Create a data set from each table name.
if (datasource instanceof JcrDerivedDatasource) {
JcrDerivedDatasource dds = (JcrDerivedDatasource) datasource;
if (dds.getProperty("tba:datasourceType").equals("DatabaseDatasource") && title.equals(dds.getAllProperties().get("Database Connection"))) {
Map<String, Object> allProps = dds.getAllProperties();
if (allProps.containsKey("Table")) {
String tableName = allProps.get("Table").toString();
JcrDataSet dataSet = (JcrDataSet) dataSetProvider.build(catDs.getId()).title(tableName).addOption("dbtable", tableName).build();
feed.removeFeedSource(source);
feedProvider.ensureFeedSource(feed.getId(), dataSet.getId());
} else {
log.warn("No table name found in data source: " + dds);
}
}
// Since we've converted a legacy datasource into a category data source with the same ID,
// there will still be a reference to it in one of the FeedSources as a legacy datasource.
// When we find it then remove that FeedSource.
} else if (datasource.getNode().equals(catDs.getNode())) {
feed.removeFeedSource(source);
}
});
});
});
}
use of com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSet 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.modeshape.catalog.dataset.JcrDataSet 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.modeshape.catalog.dataset.JcrDataSet 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