public void Update(IMetabase metabase, PlanFile plans)
 {
     var updateContext = new UpdateContext {Instructions = this, Metabase = metabase};
     var plan = plans.Plan(ExtractName);
     ExtractName = plan.Name;
     Plan = plan.GetPlan(updateContext);
 }
Exemple #2
0
        protected override void FillIn(PlanPart parent, UpdateContext context)
        {
            ParentTable = parent.Table;
            ParentElementName = parent.ElementName;

            if (String.IsNullOrEmpty(ForeignKey)) ForeignKey = ElementName + Table.PrimaryKey.Name;
        }
Exemple #3
0
 protected override void FillIn(PlanPart parent, UpdateContext context)
 {
     base.FillIn(parent, context);
     ExtractName         = context.Instructions.ExtractName;
     IdsToExtract        = context.Instructions.IdsToExtract;
     DiscriminatorColumn = Table.Columns.FirstOrDefault(x => x.IsNamed(Discriminator))
                           ?? Table.PrimaryKey;
 }
Exemple #4
0
        protected override void FillIn(PlanPart parent, UpdateContext context)
        {
            base.FillIn(parent, context);

            if (String.IsNullOrEmpty(LookupColumn))
            {
                LookupColumn = new[] { "Code", "Name" }
            }
Exemple #5
0
 protected override void FillIn(PlanPart parent, UpdateContext context)
 {
     base.FillIn(parent, context);
     ExtractName = context.Instructions.ExtractName;
     IdsToExtract = context.Instructions.IdsToExtract;
     DiscriminatorColumn = Table.Columns.FirstOrDefault(x => x.IsNamed(Discriminator))
         ?? Table.PrimaryKey;
 }
Exemple #6
0
 protected override void FillIn(PlanPart parent, UpdateContext context)
 {
     if (String.IsNullOrWhiteSpace(ForeignKey))
     {
         ForeignKey = parent.Table.Name + parent.Table.PrimaryKey.Name;
     }
     Ignore(ForeignKey);
     base.FillIn(parent, context);
 }
Exemple #7
0
        protected override void FillIn(PlanPart parent, UpdateContext context)
        {
            ParentTable       = parent.Table;
            ParentElementName = parent.ElementName;

            if (String.IsNullOrEmpty(ForeignKey))
            {
                ForeignKey = ElementName + Table.PrimaryKey.Name;
            }
        }
Exemple #8
0
        public void Update(IMetabase metabase, PlanFile plans)
        {
            var updateContext = new UpdateContext {
                Instructions = this, Metabase = metabase
            };
            var plan = plans.Plan(ExtractName);

            ExtractName = plan.Name;
            Plan        = plan.GetPlan(updateContext);
        }
Exemple #9
0
 public void Update(PlanPart parent, UpdateContext context)
 {
     //Console.WriteLine("Updating {0}", TableName);
     Table   = context.Metabase.Table(TableName);
     Columns = Table.Columns;
     Ignore(Columns.Where(x => x.Insertable() == false).Select(x => x.Name).ToArray());
     Ignore(Table.PrimaryKey);
     FillIn(parent, context);
     foreach (var child in Children)
     {
         child.Update(this, context);
     }
 }
Exemple #10
0
        public PlanPart GetPlan(UpdateContext updateContext)
        {
            var parts = PlanPart.Parse(Segments);

            foreach (var part in parts)
            {
                part.Update(null, updateContext);
            }

            if (parts.Count() > 1)
            {
                Console.WriteLine("Multi-part plans aren't supported (Yet!)");
            }

            return(parts.FirstOrDefault());
        }
Exemple #11
0
        protected override void FillIn(PlanPart parent, UpdateContext context)
        {
            base.FillIn(parent, context);

            if (String.IsNullOrEmpty(LookupColumn))
                LookupColumn = new[] { "Code", "Name"}.FirstOrDefault(x => Columns.Any(y => y.IsNamed(x)));

            if(String.IsNullOrWhiteSpace(LookupColumn))
            {
                throw new Exception("No columns specified for lookup!");
            }

            var lookups = Regex.Split(LookupColumn, @"\s").Select(x => x.Trim()).ToArray();
            var ignored = Columns.Where(x => lookups.All(y => x.IsNamed(y) == false));

            Ignore(ignored.ToArray());
            parent.Ignore(ForeignKey);
        }
Exemple #12
0
        private static IEnumerable <PlanPart> Parse(Segment segment, PlanPart parent)
        {
            var parts = new List <PlanPart>();

            if (parent == default(PlanPart))
            {
                parts.AddRange(RootPlanPart.Parse(segment.Text));
            }
            else
            {
                var text   = segment.Text.Substring(1);
                var prefix = segment.Text[0];

                switch (prefix)
                {
                case '@':
                    parts.AddRange(LookupPart.Parse(text));
                    break;

                case '<':
                    parts.AddRange(HasManyPart.Parse(text));
                    break;

                case '>':
                    parts.AddRange(HasOnePart.Parse(text));
                    break;

                default:
                    Console.Error.WriteLine("Invalid: " + segment.Text);
                    break;
                }
            }

            foreach (var part in parts)
            {
                part.Children = segment.SubSegments.SelectMany(x => Parse(x, part)).ToArray();
            }

            return(parts);
        }
Exemple #13
0
 protected PlanPart()
 {
     Columns  = new ColumnMeta[0];
     Children = new PlanPart[0];
 }
Exemple #14
0
        private static IEnumerable<PlanPart> Parse(Segment segment, PlanPart parent)
        {
            var parts = new List<PlanPart>();

            if (parent == default(PlanPart))
            {
                parts.AddRange(RootPlanPart.Parse(segment.Text));
            }
            else
            {
                var text = segment.Text.Substring(1);
                var prefix = segment.Text[0];

                switch (prefix)
                {
                    case '@':
                        parts.AddRange(LookupPart.Parse(text));
                        break;
                    case '<':
                        parts.AddRange(HasManyPart.Parse(text));
                        break;
                    case '>':
                        parts.AddRange(HasOnePart.Parse(text));
                        break;
                    default:
                        Console.Error.WriteLine("Invalid: " + segment.Text);
                        break;
                }
            }

            foreach (var part in parts)
            {
                part.Children = segment.SubSegments.SelectMany(x => Parse(x, part)).ToArray();
            }

            return parts;
        }
Exemple #15
0
 public void Update(PlanPart parent, UpdateContext context)
 {
     //Console.WriteLine("Updating {0}", TableName);
     Table = context.Metabase.Table(TableName);
     Columns = Table.Columns;
     Ignore(Columns.Where(x => x.Insertable() ==false).Select(x => x.Name).ToArray());
     Ignore(Table.PrimaryKey);
     FillIn(parent, context);
     foreach (var child in Children)
         child.Update(this, context);
 }
Exemple #16
0
 protected override void FillIn(PlanPart parent, UpdateContext context)
 {
     if (String.IsNullOrWhiteSpace(ForeignKey)) ForeignKey = parent.Table.Name + parent.Table.PrimaryKey.Name;
     Ignore(ForeignKey);
     base.FillIn(parent, context);
 }
Exemple #17
0
 protected virtual void FillIn(PlanPart parent, UpdateContext context)
 {
 }
Exemple #18
0
 protected PlanPart()
 {
     Columns = new ColumnMeta[0];
     Children = new PlanPart[0];
 }
Exemple #19
0
 protected virtual void FillIn(PlanPart parent, UpdateContext context)
 {
 }
Exemple #20
0
        protected override void FillIn(PlanPart parent, UpdateContext context)
        {
            base.FillIn(parent, context);

            parent.Ignore(ForeignKey);
        }
Exemple #21
0
        protected override void FillIn(PlanPart parent, UpdateContext context)
        {
            base.FillIn(parent, context);

            parent.Ignore(ForeignKey);
        }