use of com.thinkbiganalytics.metadata.api.catalog.ConnectorProvider in project kylo by Teradata.
the class CatalogMetadataConfig method doPluginSyncAction.
private void doPluginSyncAction(ConnectorPluginManager pluginMgr, MetadataAccess metadata) {
metadata.commit(() -> {
List<ConnectorPlugin> plugins = pluginMgr.getPlugins();
Map<String, Connector> connectorMap = connectorProvider().findAll(true).stream().collect(Collectors.toMap(Connector::getPluginId, c -> c));
for (ConnectorPlugin plugin : plugins) {
Connector connector = connectorMap.get(plugin.getId());
ConnectorPluginDescriptor descr = plugin.getDescriptor();
if (connector != null) {
connectorMap.get(plugin.getId()).setActive(true);
connectorMap.remove(plugin.getId());
} else {
String title = descr.getTitle();
connector = connectorProvider().create(plugin.getId(), title);
}
connector.setIconColor(descr.getColor());
connector.setIcon(descr.getIcon());
if (StringUtils.isNotBlank(descr.getFormat())) {
connector.getSparkParameters().setFormat(descr.getFormat());
}
}
// least one data source, or removed if they don't.
for (Connector connector : connectorMap.values()) {
if (connector.getDataSources().isEmpty()) {
connectorProvider().deleteById(connector.getId());
} else {
connector.setActive(false);
}
}
}, MetadataAccess.SERVICE);
}
Aggregations