private Task ExtractExtensionsAsync(ICollection <ExtensionMetadata> output, SqlExtractionTask task,
                                            CancellationToken token)
        {
            var query = CreateQuery(mapping.Extension, task, mapping.ExtensionName, mapping.ExtensionText);

            return(ExecuteQueryAsync(output, query, ParseExtension, token));
        }
        private Task ExtractAssembliesAsync(ICollection <AssemblyMetadata> output, SqlExtractionTask task,
                                            CancellationToken token)
        {
            var query = CreateQuery(mapping.Assembly, task, mapping.AssemblyName, mapping.AssemblyVersion);

            return(ExecuteQueryAsync(output, query, ParseAssembly, token));
        }
예제 #3
0
        public void ExtractAssemblies(MetadataSet output, SqlExtractionTask task)
        {
            var assemblies = new List <AssemblyMetadata>();

            ExtractAssemblies(assemblies, task);
            output.Assemblies.AddRange(assemblies);
        }
예제 #4
0
        public void ExtractExtensions(MetadataSet output, SqlExtractionTask task)
        {
            var extensions = new List <ExtensionMetadata>();

            ExtractExtensions(extensions, task);
            output.Extensions.AddRange(extensions);
        }
예제 #5
0
        public void ExtractTypes(MetadataSet output, SqlExtractionTask task)
        {
            var types = new List <TypeMetadata>();

            ExtractTypes(types, task);
            output.Types.AddRange(types);
        }
        public static void DemandSchemas(ConnectionInfo connectionInfo, params string[] schemas)
        {
            var driver = TestSqlDriver.Create(connectionInfo);

            using (var connection = driver.CreateConnection()) {
                connection.Open();

                var extractionTask   = new SqlExtractionTask(driver.CoreServerInfo.DatabaseName);
                var extractionResult = driver.Extract(connection, new[] { extractionTask });
                var catalog          = extractionResult.Catalogs.Single();
                var existingSchemas  = catalog.Schemas.Select(s => s.Name);
                var schemasToCreate  = schemas.Except(existingSchemas, StringComparer.OrdinalIgnoreCase);

                // Oracle does not support creating schemas, user should be created instead.
                if (connectionInfo.Provider == WellKnown.Provider.Oracle)
                {
                    CreateUsers(connection, schemasToCreate);
                }
                else
                {
                    CreateSchemas(connection, catalog, schemasToCreate);
                }

                connection.Close();
            }
        }
        public async Task ExtractTypesAsync(MetadataSet output, SqlExtractionTask task, CancellationToken token = default)
        {
            var types = new List <TypeMetadata>();

            await ExtractTypesAsync(types, task, token).ConfigureAwait(false);

            output.Types.AddRange(types);
        }
        public async Task ExtractExtensionsAsync(MetadataSet output, SqlExtractionTask task,
                                                 CancellationToken token = default)
        {
            var extensions = new List <ExtensionMetadata>();

            await ExtractExtensionsAsync(extensions, task, token).ConfigureAwait(false);

            output.Extensions.AddRange(extensions);
        }
        public async Task ExtractAssembliesAsync(MetadataSet output, SqlExtractionTask task,
                                                 CancellationToken token = default)
        {
            var assemblies = new List <AssemblyMetadata>();

            await ExtractAssembliesAsync(assemblies, task, token).ConfigureAwait(false);

            output.Assemblies.AddRange(assemblies);
        }
예제 #10
0
        private static bool ShouldSkipMetadataExtraction(MetadataMapping mapping, SqlWorkerResult result,
                                                         SqlExtractionTask task)
        {
            if (result.Schema == null)
            {
                return(false);
            }

            var tables = GetSchemaTables(result, task);

            return(tables[mapping.Assembly] == null && tables[mapping.Type] == null && tables[mapping.Extension] == null);
        }
예제 #11
0
        // Constructors

        public MetadataWriter(StorageDriver driver, MetadataMapping mapping, SqlExtractionTask task, IProviderExecutor executor)
        {
            ArgumentValidator.EnsureArgumentNotNull(driver, "driver");
            ArgumentValidator.EnsureArgumentNotNull(mapping, "mapping");
            ArgumentValidator.EnsureArgumentNotNull(task, "task");
            ArgumentValidator.EnsureArgumentNotNull(executor, "executor");

            this.driver   = driver;
            this.mapping  = mapping;
            this.task     = task;
            this.executor = executor;
        }
예제 #12
0
        private SqlSelect CreateQuery(string tableName, SqlExtractionTask task, params string[] columnNames)
        {
            var catalog = new Catalog(task.Catalog);
            var schema  = catalog.CreateSchema(task.Schema);
            var table   = schema.CreateTable(tableName);

            foreach (var column in columnNames)
            {
                table.CreateColumn(column);
            }
            var tableRef   = SqlDml.TableRef(table);
            var select     = SqlDml.Select(tableRef);
            var columnRefs = columnNames
                             .Select((c, i) => SqlDml.ColumnRef(tableRef.Columns[i], c));

            foreach (var columnRef in columnRefs)
            {
                select.Columns.Add(columnRef);
            }
            return(select);
        }
        // Constructors

        public MultischemaMappingResolver(DomainConfiguration configuration, NodeConfiguration nodeConfiguration,
                                          DefaultSchemaInfo defaultSchemaInfo)
        {
            schemaMapping = nodeConfiguration.SchemaMapping;
            defaultSchema = configuration.DefaultSchema;

            extractionTasks = configuration.MappingRules
                              .Select(r => r.Schema)
                              .Where(s => !string.IsNullOrEmpty(s))
                              .Concat(Enumerable.Repeat(configuration.DefaultSchema, 1))
                              .Distinct()
                              .Select(s => new SqlExtractionTask(defaultSchemaInfo.Database, schemaMapping.Apply(s)))
                              .ToList();

            reversedSchemaMapping = new NameMappingCollection();
            foreach (var mapping in schemaMapping)
            {
                reversedSchemaMapping.Add(mapping.Value, mapping.Key);
            }

            metadataTask = new SqlExtractionTask(defaultSchemaInfo.Database, schemaMapping.Apply(defaultSchema));
        }
예제 #14
0
        private void ExtractExtensions(ICollection <ExtensionMetadata> output, SqlExtractionTask task)
        {
            var query = CreateQuery(mapping.Extension, task, mapping.ExtensionName, mapping.ExtensionText);

            ExecuteQuery(output, query, ParseExtension);
        }
예제 #15
0
        private void ExtractTypes(ICollection <TypeMetadata> output, SqlExtractionTask task)
        {
            var query = CreateQuery(mapping.Type, task, mapping.TypeId, mapping.TypeName);

            ExecuteQuery(output, query, ParseType);
        }
예제 #16
0
        private void ExtractAssemblies(ICollection <AssemblyMetadata> output, SqlExtractionTask task)
        {
            var query = CreateQuery(mapping.Assembly, task, mapping.AssemblyName, mapping.AssemblyVersion);

            ExecuteQuery(output, query, ParseAssembly);
        }
예제 #17
0
        // Constructors

        public SimpleMappingResolver(DefaultSchemaInfo defaultSchemaInfo)
        {
            extractionTask = new SqlExtractionTask(defaultSchemaInfo.Database, defaultSchemaInfo.Schema);
        }
        private Task ExtractTypesAsync(ICollection <TypeMetadata> output, SqlExtractionTask task, CancellationToken token)
        {
            var query = CreateQuery(mapping.Type, task, mapping.TypeId, mapping.TypeName);

            return(ExecuteQueryAsync(output, query, ParseType, token));
        }
예제 #19
0
        private static PairedNodeCollection <Schema, Table> GetSchemaTables(SqlWorkerResult result, SqlExtractionTask task)
        {
            var catalog = GetCatalog(result, task.Catalog);
            var schema  = GetSchema(catalog, task.Schema);

            return(schema.Tables);
        }