Search in sources :

Example 1 with MetadataAccess

use of com.thinkbiganalytics.metadata.api.MetadataAccess 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);
}
Also used : ConnectorProvider(com.thinkbiganalytics.metadata.api.catalog.ConnectorProvider) JcrDataSourceProvider(com.thinkbiganalytics.metadata.modeshape.catalog.datasource.JcrDataSourceProvider) Logger(org.slf4j.Logger) Session(javax.jcr.Session) ConnectorPlugin(com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin) ConnectorAlreadyExistsException(com.thinkbiganalytics.metadata.api.catalog.ConnectorAlreadyExistsException) DataSourceProvider(com.thinkbiganalytics.metadata.api.catalog.DataSourceProvider) ConnectorPluginManager(com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager) PostMetadataConfigAction(com.thinkbiganalytics.metadata.api.PostMetadataConfigAction) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) Configuration(org.springframework.context.annotation.Configuration) JcrDataSetProvider(com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSetProvider) List(java.util.List) DataSetProvider(com.thinkbiganalytics.metadata.api.catalog.DataSetProvider) ConnectorPluginDescriptor(com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor) Connector(com.thinkbiganalytics.metadata.api.catalog.Connector) Workspace(org.modeshape.jcr.api.Workspace) Map(java.util.Map) JcrConnectorProvider(com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnectorProvider) Bean(org.springframework.context.annotation.Bean) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) ConnectorPlugin(com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin) Connector(com.thinkbiganalytics.metadata.api.catalog.Connector) ConnectorPluginDescriptor(com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor)

Aggregations

ConnectorPluginManager (com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager)1 ConnectorPluginDescriptor (com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor)1 ConnectorPlugin (com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin)1 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)1 PostMetadataConfigAction (com.thinkbiganalytics.metadata.api.PostMetadataConfigAction)1 Connector (com.thinkbiganalytics.metadata.api.catalog.Connector)1 ConnectorAlreadyExistsException (com.thinkbiganalytics.metadata.api.catalog.ConnectorAlreadyExistsException)1 ConnectorProvider (com.thinkbiganalytics.metadata.api.catalog.ConnectorProvider)1 DataSetProvider (com.thinkbiganalytics.metadata.api.catalog.DataSetProvider)1 DataSourceProvider (com.thinkbiganalytics.metadata.api.catalog.DataSourceProvider)1 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)1 JcrConnectorProvider (com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnectorProvider)1 JcrDataSetProvider (com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSetProvider)1 JcrDataSourceProvider (com.thinkbiganalytics.metadata.modeshape.catalog.datasource.JcrDataSourceProvider)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Session (javax.jcr.Session)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Workspace (org.modeshape.jcr.api.Workspace)1