public void Initialize()
 {
     //Type.Root = this.Root;
     //type.Ini
     this.Columns.Root = this.Root;
     this.Columns.Initialize();
 }
Ejemplo n.º 2
0
 protected override ConstraintModel Resolve(OracleDatabase db)
 {
     if (!string.IsNullOrEmpty(this.Name))
     {
         return(db.Constraints[$"{this.Owner}.{this.Name}"]);
     }
     return(null);
 }
Ejemplo n.º 3
0
 public List <object> Parse(OracleDatabase model, Action <string> _log)
 {
     if (_items.Count == 0)
     {
         ModelParser parser = new ModelParser();
         parser.Visit(model, this, _log);
     }
     return(_items);
 }
Ejemplo n.º 4
0
        public static OracleDatabase ReadFile(string filename)
        {
            FileInfo file = new FileInfo(filename);

            using (StreamReader stream = file.OpenText())
            {
                JsonSerializer serializer = new JsonSerializer();
                OracleDatabase db         = (OracleDatabase)serializer.Deserialize(stream, typeof(OracleDatabase));
                db.Initialize();
                return(db);
            }
        }
Ejemplo n.º 5
0
        public void Visit(OracleDatabase model, IOracleModelVisitor visitor, Action <string> _log)
        {
            this._log = _log;
            HashSet <string> _schemas = new HashSet <string>();

            if (!string.IsNullOrEmpty(model.AvailableOwner))
            {
                _schemas = new HashSet <string>(model.AvailableOwner.Split(';').ToList());
            }

            else
            {
                Func <string, bool> fnc = c => !string.IsNullOrWhiteSpace(c) && c.Split('\t', ' ', '\r', '\n').Count() == 1;

                var t = model.Packages.OfType <PackageModel>().Select(c => c.GetOwner()).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Synonyms.OfType <SynonymModel>().Select(c => c.Name).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Synonyms.OfType <SynonymModel>().Select(c => c.ObjectTargetName.Split('.')[0]).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Grants.OfType <GrantModel>().Select(c => c.GetOwner()).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Procedures.OfType <ProcedureModel>().Select(c => c.GetOwner()).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Sequences.OfType <SequenceModel>().Select(c => c.GetOwner()).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Tables.OfType <TableModel>().Select(c => c.GetOwner()).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }

                t = model.Types.OfType <TypeItem>().Select(c => c.GetOwner()).Where(c => fnc(c));
                foreach (string item in t)
                {
                    _schemas.Add(item);
                }
            }


            var schemas = _schemas.Select(c => new SchemaModel()
            {
                Name = c.ToUpper(), Root = model
            });

            this._log(string.Format("--- analyzing {0} schema name(s)", schemas.Count()));
            foreach (var item in schemas)
            {
                visitor.VisitSchema(item);
            }

            this._log(string.Format("--- analyzing {0} grant(s)", model.Grants.OfType <GrantModel>().Count()));
            foreach (GrantModel item in model.Grants)
            {
                visitor.VisitGrant(item);
            }

            this._log(string.Format("--- analyzing {0} package(s)", model.Packages.OfType <PackageModel>().Count()));
            foreach (PackageModel item in model.Packages)
            {
                visitor.VisitPackage(item);
            }

            this._log(string.Format("--- analyzing {0} partition(s)", model.Partitions.OfType <PartitionModel>().Count()));
            foreach (PartitionModel item in model.Partitions)
            {
                visitor.VisitPartition(item);
            }


            this._log(string.Format("--- analyzing {0} procedure(s)", model.Procedures.OfType <ProcedureModel>().Count()));
            foreach (ProcedureModel item in model.Procedures)
            {
                visitor.VisitProcedure(item);
                foreach (ArgumentModel item2 in item.Arguments)
                {
                    visitor.VisitArgument(item2);
                }
            }


            this._log(string.Format("--- analyzing {0} sequences(s)", model.Sequences.OfType <SequenceModel>().Count()));
            foreach (SequenceModel item in model.Sequences)
            {
                visitor.VisitSequence(item);
            }


            this._log(string.Format("--- analyzing {0} synonym(s)", model.Synonyms.OfType <SynonymModel>().Count()));
            foreach (SynonymModel item in model.Synonyms)
            {
                visitor.VisitSynonym(item);
            }


            this._log(string.Format("--- analyzing {0} tables(s)", model.Tables.OfType <TableModel>().Count()));
            foreach (TableModel item in model.Tables)
            {
                visitor.VisitTable(item);
                foreach (ColumnModel item2 in item.Columns)
                {
                    visitor.VisitColumn(item2);
                }

                foreach (PartitionRefModel item2 in item.Partitions)
                {
                    visitor.VisitPartitionRef(item2);
                }
            }

            foreach (ConstraintModel item2 in model.Constraints)
            {
                visitor.VisitConstraint(item2);
                foreach (ConstraintColumnModel item3 in item2.Columns)
                {
                    visitor.VisitConstraintColumn(item3);
                }
            }

            foreach (IndexModel item2 in model.Indexes)
            {
                visitor.VisitIndex(item2);
                foreach (IndexColumnModel item3 in item2.Columns)
                {
                    visitor.VisitIndexColumn(item3);
                }
            }

            foreach (TriggerModel item2 in model.Triggers)
            {
                visitor.VisitTrigger(item2);
            }

            this._log(string.Format("--- analyzing {0} tablespace(s)", model.Tablespaces.OfType <TablespaceModel>().Count()));
            foreach (TablespaceModel item in model.Tablespaces)
            {
                visitor.VisitTablespace(item);
            }


            this._log(string.Format("--- analyzing {0} type(s)", model.Packages.OfType <TypeItem>().Count()));
            foreach (TypeItem item in model.Types)
            {
                visitor.VisitType(item);
            }
        }
Ejemplo n.º 6
0
 protected override IndexModel Resolve(OracleDatabase db)
 {
     return(db.Indexes[$"{this.Owner}.{this.Name}"]);
 }
Ejemplo n.º 7
0
 protected override TableModel Resolve(OracleDatabase db)
 {
     return(db.Tables[$"{this.Owner}.{this.Name}"]);
 }
Ejemplo n.º 8
0
 protected override TablespaceModel Resolve(OracleDatabase db)
 {
     return(db.Tablespaces[this.Name]);
 }
Ejemplo n.º 9
0
 protected abstract T Resolve(OracleDatabase oracleDatabase);
Ejemplo n.º 10
0
 protected override ConstraintModel Resolve(OracleDatabase db)
 {
     return(db.Constraints[$"{this.Owner}.{this.Name}"]);
 }