Click here to Skip to main content
15,897,187 members
Articles / Web Development / HTML

Transformalizing NorthWind

Rate me:
Please Sign up or sign in to vote.
4.95/5 (29 votes)
24 Jul 2014GPL37 min read 57.8K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
namespace Transformalize.Configuration.Builders {

    public class ProcessBuilder : IFieldHolder {

        private readonly ProcessConfigurationElement _process;

        public ProcessBuilder(string name) {
            _process = new ProcessConfigurationElement() { Name = name, Star = name + "Star" };

            _process.Providers.Add(
                new ProviderConfigurationElement {
                    Name = "sqlserver",
                    Type = "System.Data.SqlClient.SqlConnection, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                },
                new ProviderConfigurationElement {
                    Name = "mysql",
                    Type = "MySql.Data.MySqlClient.MySqlConnection, MySql.Data"
                },
                new ProviderConfigurationElement {
                    Name = "file",
                    Type = string.Empty
                },
                new ProviderConfigurationElement {
                    Name = "internal",
                    Type = string.Empty
                }
            );

            _process.SearchTypes.Add(
                new SearchTypeConfigurationElement {
                    Name = "none",
                    MultiValued = false,
                    Store = false,
                    Index = false
                },
                new SearchTypeConfigurationElement {
                    Name = "default",
                    MultiValued = false,
                    Store = true,
                    Index = true
                }
            );

        }

        public ProcessConfigurationElement Process() {
            return _process;
        }

        public ConnectionBuilder Connection(string name) {
            var connection = new ConnectionConfigurationElement() { Name = name };
            _process.Connections.Add(connection);
            return new ConnectionBuilder(this, connection);
        }

        public MapBuilder Map(string name, string sql = "") {
            var map = new MapConfigurationElement { Name = name };
            map.Items.Sql = sql;
            _process.Maps.Add(map);

            return new MapBuilder(this, map);
        }

        public EntityBuilder Entity(string name) {
            var entity = new EntityConfigurationElement() { Name = name };
            _process.Entities.Add(entity);
            return new EntityBuilder(this, entity);
        }

        public RelationshipBuilder Relationship() {
            var relationship = new RelationshipConfigurationElement();
            _process.Relationships.Add(relationship);
            return new RelationshipBuilder(this, relationship);
        }

        public TemplateBuilder Template(string name) {
            var template = new TemplateConfigurationElement { Name = name };
            _process.Templates.Add(template);
            return new TemplateBuilder(this, template);
        }

        public SearchTypeBuilder SearchType(string name) {
            var searchType = new SearchTypeConfigurationElement() { Name = name };
            _process.SearchTypes.Add(searchType);
            return new SearchTypeBuilder(this, searchType);
        }

        public FieldBuilder CalculatedField(string name) {
            var calculatedField = new FieldConfigurationElement() { Name = name };
            _process.CalculatedFields.Add(calculatedField);
            return new FieldBuilder(this, calculatedField);
        }

        public FieldBuilder Field(string name) {
            var calculatedField = new FieldConfigurationElement() { Name = name };
            _process.CalculatedFields.Add(calculatedField);
            return new FieldBuilder(this, calculatedField);
        }

        public ProcessBuilder TemplatePath(string path) {
            _process.Templates.Path = path;
            return this;
        }

        public ProcessBuilder ScriptPath(string path) {
            _process.Scripts.Path = path;
            return this;
        }

        public ScriptBuilder Script(string name) {
            var script = new ScriptConfigurationElement() { Name = name };
            _process.Scripts.Add(script);
            return new ScriptBuilder(this, script);
        }

        public ProcessBuilder Star(string star) {
            _process.Star = star;
            return this;
        }

        public ProcessBuilder TimeZone(string timeZone)
        {
            _process.TimeZone = timeZone;
            return this;
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions