public override string GetNodeName(string mappingDatabase, string mappingSchema, string mappingName) { if (string.IsNullOrEmpty(mappingSchema)) { mappingSchema = defaultSchema; } return(FormatNodeName(schemaMapping.Apply(mappingSchema), mappingName)); }
// 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(); }
public override MappingResolveResult Resolve(SchemaExtractionResult model, string nodeName) { var names = nodeName.Split(NameElementSeparator); var schema = (model.IsShared) ? model.Catalogs.Single().Schemas[reversedSchemaMapping.Apply(names[0])] : model.Catalogs.Single().Schemas[names[0]]; var name = names[1]; if (schema == null) { throw new InvalidOperationException(string.Format(Strings.ExUnableToResolveSchemaForNodeXPleaseVerifyThatThisSchemaExists, nodeName)); } return(new MappingResolveResult(schema, name)); }
public override string GetNodeName(string mappingDatabase, string mappingSchema, string mappingName) { // The only reason this method accepts empty database or schema is HintGenerator. // It needs resolving mapping information from previous upgrade // which could be performed in different multidatabase/multischema mode. // If such case occurs we simply use current domain defaults as mapping information. if (string.IsNullOrEmpty(mappingDatabase)) { mappingDatabase = defaultDatabase; } if (string.IsNullOrEmpty(mappingSchema)) { mappingSchema = defaultSchema; } return(FormatNodeName( databaseMapping.Apply(mappingDatabase), schemaMapping.Apply(mappingSchema), mappingName)); }
// 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)); }