public virtual DcColumn CreateColumn(DcSchemaKind schemaType, string name, DcTable input, DcTable output, bool isKey) { Debug.Assert(!String.IsNullOrEmpty(name), "Wrong use: column name cannot be null or empty."); // TODO: Check constraints: 1. only one super-column can exist 2. no loops can appear DcSchemaKind inSchemaType = input.Schema.GetSchemaKind(); DcSchemaKind outSchemaType = output.Schema.GetSchemaKind(); DcColumn column; // // We create a column according to its table type // if (schemaType == DcSchemaKind.Dc) // Column belongs to a normal table { column = new Column(name, input, output, isKey, false); } else if (schemaType == DcSchemaKind.Csv) // Column belongs to a CSV table { column = new ColumnCsv(name, input, output, isKey, false); } else { throw new NotImplementedException("This schema type is not implemented."); } /* OLD - here we create a column according to import-export status * if (inSchemaType == DcSchemaKind.Dc || outSchemaType == DcSchemaKind.Dc) // Intra-mashup or import/export columns * { * column = new Column(name, input, output, isKey, false); * } * else if (inSchemaType == DcSchemaKind.Csv && outSchemaType == DcSchemaKind.Csv) // Intra-csv columns * { * column = new ColumnCsv(name, input, output, isKey, false); * } * else if (inSchemaType == DcSchemaKind.Oledb && outSchemaType == DcSchemaKind.Oledb) // Intra-oledb columns * { * throw new NotImplementedException("This schema type is not implemented."); * } * else if (inSchemaType == DcSchemaKind.Rel && outSchemaType == DcSchemaKind.Rel) // Intra-rel columns * { * column = new ColumnRel(name, input, output, isKey, false); * } * else * { * throw new NotImplementedException("This schema type is not implemented."); * } */ _columns.Add(column); NotifyAdd(column); return(column); }
public virtual DcTable CreateTable(DcSchemaKind schemaType, string name, DcTable parent) { DcSchema schema = parent.Schema; //DcSchemaKind schemaType = schema.GetSchemaKind(); DcTable table; Column column; string colName; if (parent is DcSchema) { colName = "Top"; } else { colName = "Super"; } if (schemaType == DcSchemaKind.Dc) { table = new Table(name, this); column = new Column(colName, table, parent, true, true); } else if (schemaType == DcSchemaKind.Csv) { table = new TableCsv(name, this); column = new ColumnCsv(colName, table, parent, true, true); } else if (schemaType == DcSchemaKind.Oledb) { table = new TableRel(name, this); column = new ColumnRel(colName, table, parent, true, true); } else if (schemaType == DcSchemaKind.Rel) { table = new TableRel(name, this); column = new ColumnRel(colName, table, parent, true, true); } else { throw new NotImplementedException("This schema type is not implemented."); } _tables.Add(table); NotifyAdd(table); _columns.Add(column); NotifyAdd(column); return(table); }