Beispiel #1
0
        public virtual DcSchema CreateSchema(string name, DcSchemaKind schemaType)
        {
            DcSchema schema;

            if (schemaType == DcSchemaKind.Dc)
            {
                schema = new Schema(name, this);
            }
            else if (schemaType == DcSchemaKind.Csv)
            {
                schema = new SchemaCsv(name, this);
            }
            else if (schemaType == DcSchemaKind.Oledb)
            {
                schema = new SchemaOledb(name, this);
            }
            else if (schemaType == DcSchemaKind.Rel)
            {
                throw new NotImplementedException("This schema type is not implemented.");
            }
            else
            {
                throw new NotImplementedException("This schema type is not implemented.");
            }

            _schemas.Add(schema);

            NotifyAdd(schema);

            return(schema);
        }
Beispiel #2
0
        public Schema(string name, DcSpace space)
            : base(name, space)
        {
            _schemaKind = DcSchemaKind.Dc;

            CreateDataTypes(); // Generate all predefined primitive sets as subsets
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public override void FromJson(JObject json, DcSpace ws)
        {
            base.FromJson(json, ws); // Set

            _schemaKind = json["SchemaKind"] != null ? (DcSchemaKind)(int)json["SchemaKind"] : DcSchemaKind.Dc;

            // List of tables
            // Tables are stored in space

            // List of columns
            // Columns cannot be loaded because not all schemas might have been loaded (so it is a problem with import columns)
        }
Beispiel #5
0
        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);
        }