// Constructors public MultidatabaseMappingResolver(DomainConfiguration configuration, NodeConfiguration nodeConfiguration) { databaseMapping = new NameMappingCollection(); foreach (var database in configuration.Databases) { if (!string.IsNullOrEmpty(database.RealName)) { databaseMapping.Add(database.Name, database.RealName); } } foreach (var item in nodeConfiguration.DatabaseMapping) { databaseMapping.Add(item.Key, item.Value); } schemaMapping = nodeConfiguration.SchemaMapping; defaultDatabase = configuration.DefaultDatabase; defaultSchema = configuration.DefaultSchema; var extractionTasksQuery = from db in GetDatabases(configuration) from schema in GetSchemasForDatabase(configuration, db) select new SqlExtractionTask(databaseMapping.Apply(db), schemaMapping.Apply(schema)); extractionTasks = extractionTasksQuery.ToList(); reversedDatabaseMapping = new NameMappingCollection(); foreach (var mapping in databaseMapping) { reversedDatabaseMapping.Add(mapping.Value, mapping.Key); } reversedSchemaMapping = new NameMappingCollection(); foreach (var mapping in schemaMapping) { reversedSchemaMapping.Add(mapping.Value, mapping.Key); } var metadataSchema = schemaMapping.Apply(defaultSchema); metadataTasks = extractionTasks.Where(t => t.Schema == metadataSchema).ToList(); }
// 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)); }