Example #1
0
 public override string GenerateSelectStarQuery(TableOrView tableOrView, int top)
 {
     return String.Format(
         "SELECT t.* FROM {1} AS t {0}",
         GenerateTopExpression(top),
         GetResolvedTableName(tableOrView.DatabaseName, tableOrView.SchemaName, tableOrView.ObjectName));
 }
        public JobInstance ScheduleAsJob(TableOrView source, string path, FileFormatDescription format, string queueName, string comments)
        {
            var job = GetInitializedJobInstance(queueName, comments);

            var et = new ExportTable();

            et.Source = source;

            // TODO: change this to support different compression formats
            path = Path.Combine(path, String.Format("{0}_{1}_{2}{3}.gz", Context.UserName, job.JobID, source.ObjectName, format.DefaultExtension));

            var destination = FileFormatFactory.CreateFile(format);
            destination.Uri = new Uri(String.Format("file:///{0}", path));
            destination.FileMode = DataFileMode.Write;
            destination.Compression = CompressionMethod.GZip;

            // special initialization in case of a text file
            if (destination is TextDataFile)
            {
                var tf = (TextDataFile)destination;
                tf.Encoding = Encoding.ASCII;
                tf.Culture = System.Globalization.CultureInfo.InvariantCulture;
                tf.GenerateIdentityColumn = false;
                tf.ColumnNamesInFirstLine = true;
            }

            et.Destination = destination;

            job.Parameters["Parameters"].SetValue(et);

            return job;
        }
Example #3
0
        /// <summary>
        /// Creates a new index object and initializes its parent object.
        /// </summary>
        /// <param name="tableOrView"></param>
        public Index(TableOrView tableOrView)
            : base(tableOrView.Dataset)
        {
            InitializeMembers();

            this.tableOrView = tableOrView;
        }
Example #4
0
        /// <summary>
        /// Copies member variables
        /// </summary>
        /// <param name="old"></param>
        private void CopyMembers(TableOrView old)
        {
            this.ObjectType = old.ObjectType;

            this.columns    = new LazyProperty <ConcurrentDictionary <string, Column> >(LoadColumns);
            this.indexes    = new LazyProperty <ConcurrentDictionary <string, Index> >(LoadIndexes);
            this.statistics = new LazyProperty <TableStatistics>(LoadStatistics);
        }
Example #5
0
        /// <summary>
        /// Creates a new index object and initializes its parent object.
        /// </summary>
        /// <param name="tableOrView"></param>
        public Index(TableOrView tableOrView)
            : base(tableOrView.Dataset)
        {
            InitializeMembers(new StreamingContext());

            this.tableOrView = tableOrView;

            this.SchemaName = tableOrView.SchemaName;
            this.DatabaseName = tableOrView.DatabaseName;
        }
Example #6
0
        /// <summary>
        /// Creates a new index object and initializes its parent object.
        /// </summary>
        /// <param name="tableOrView"></param>
        public Index(TableOrView tableOrView)
            : base(tableOrView.Dataset)
        {
            InitializeMembers(new StreamingContext());

            this.tableOrView = tableOrView;

            this.SchemaName   = tableOrView.SchemaName;
            this.DatabaseName = tableOrView.DatabaseName;
        }
Example #7
0
        private void InitializeMembers(StreamingContext context)
        {
            this.ObjectType = DatabaseObjectType.Index;

            this.tableOrView  = null;
            this.indexId      = -1;
            this.isPrimaryKey = false;
            this.isClustered  = false;
            this.isUnique     = false;

            this.columns = new Lazy <ConcurrentDictionary <string, IndexColumn> >(this.LoadIndexColumns, true);
        }
Example #8
0
        private void CopyMembers(Index old)
        {
            this.ObjectType = old.ObjectType;

            this.tableOrView  = old.tableOrView;
            this.indexId      = old.indexId;
            this.isPrimaryKey = old.isPrimaryKey;
            this.isClustered  = old.isClustered;
            this.isUnique     = old.isUnique;

            this.columns = new Lazy <ConcurrentDictionary <string, IndexColumn> >(this.LoadIndexColumns, true);
        }
Example #9
0
        public JobInstance ScheduleAsJob(Federation federation, TableOrView[] sources, string path, FileFormatDescription format, string queueName, string comments)
        {
            var job = GetInitializedJobInstance(queueName, comments);

            var settings = new ExportTablesJobSettings(job.JobDefinition.Settings);

            path = path ?? settings.OutputDirectory;
            path = Path.Combine(path, String.Format("{0}_{1}{2}", Context.UserName, job.JobID, Jhu.Graywulf.IO.Constants.FileExtensionZip));

            var destinations = new DataFileBase[sources.Length];
            for (int i = 0; i < sources.Length; i++)
            {
                var ff = FileFormatFactory.Create(federation.FileFormatFactory);

                var destination = ff.CreateFile(format);
                destination.Uri = Util.UriConverter.FromFilePath(String.Format("{0}{1}", sources[i].ObjectName, format.DefaultExtension));

                // special initialization in case of a text file
                // TODO: move this somewhere else, maybe web?
                if (destination is TextDataFileBase)
                {
                    var tf = (TextDataFileBase)destination;
                    tf.Encoding = Encoding.ASCII;
                    tf.Culture = System.Globalization.CultureInfo.InvariantCulture;
                    tf.GenerateIdentityColumn = false;
                    tf.ColumnNamesInFirstLine = true;
                }

                destinations[i] = destination;
            }

            var et = new ExportTables()
            {
                Sources = sources,
                Destinations = destinations,
                Archival = DataFileArchival.Zip,
                Uri = Util.UriConverter.FromFilePath(path),
                FileFormatFactoryType = federation.FileFormatFactory,
                StreamFactoryType = federation.StreamFactory,
            };

            job.Parameters["Parameters"].Value = et;

            return job;
        }
Example #10
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="old"></param>
 public TableOrView(TableOrView old)
     : base(old)
 {
     CopyMembers(old);
 }
Example #11
0
 internal abstract TableStatistics LoadTableStatistics(TableOrView tableOrView);
Example #12
0
        protected void DropTableOrView(TableOrView tableOrView)
        {
            // TODO: move this to schema eventually
            string sql = @"
            IF (OBJECT_ID('[{0}].[{1}].[{2}]') IS NOT NULL)
            BEGIN
            DROP {3} [{0}].[{1}].[{2}]
            END";

            sql = String.Format(
                sql,
                !String.IsNullOrWhiteSpace(tableOrView.DatabaseName) ? tableOrView.DatabaseName : tableOrView.Dataset.DatabaseName,
                tableOrView.SchemaName,
                tableOrView.ObjectName,
                tableOrView.GetType().Name);

            ExecuteCommandNonQuery(sql, tableOrView.Dataset.ConnectionString);
        }
Example #13
0
        /// <summary>
        /// Copies member variables
        /// </summary>
        /// <param name="old"></param>
        private void CopyMembers(TableOrView old)
        {
            this.ObjectType = old.ObjectType;

            this.columns = new LazyProperty<ConcurrentDictionary<string, Column>>(LoadColumns);
            this.indexes = new LazyProperty<ConcurrentDictionary<string, Index>>(LoadIndexes);
            this.statistics = new LazyProperty<TableStatistics>(LoadStatistics);
        }
 // ----
 /// <summary>
 /// 
 /// </summary>
 /// <param name="linkedServerName"></param>
 /// <param name="databaseName"></param>
 /// <param name="schemaName"></param>
 /// <param name="tableName"></param>
 /// <param name="top"></param>
 /// <returns></returns>
 /// <remarks>This is used by the web interface's 'peek' function</remarks>
 public abstract string GenerateSelectStarQuery(TableOrView tableOrView, int top);
Example #15
0
 private void InitializeMembers(StreamingContext context)
 {
     //this.databaseInstanceName = String.Empty;
     //this.schemaName = null;
     //this.datasetName = null;
     //this.databaseName = null;
     //this.tableName = null;
     this.source = null;
     this.destination = null;
 }
Example #16
0
        private void InitializeMembers(StreamingContext context)
        {
            this.ObjectType = DatabaseObjectType.Index;

            this.tableOrView = null;
            this.indexId = -1;
            this.isPrimaryKey = false;
            this.isClustered = false;
            this.isUnique = false;

            this.columns = new Lazy<ConcurrentDictionary<string, IndexColumn>>(this.LoadIndexColumns, true);
        }
Example #17
0
        private void CopyMembers(Index old)
        {
            this.ObjectType = old.ObjectType;

            this.tableOrView = old.tableOrView;
            this.indexId = old.indexId;
            this.isPrimaryKey = old.isPrimaryKey;
            this.isClustered = old.isClustered;
            this.isUnique = old.isUnique;

            this.columns = new Lazy<ConcurrentDictionary<string, IndexColumn>>(this.LoadIndexColumns, true);
        }
 public override string GenerateSelectStarQuery(TableOrView tableOrView, int top)
 {
     var sql = "SELECT {0} * FROM {1}";
     return String.Format(sql, GenerateTopExpression(top), tableOrView.GetFullyResolvedName());
 }
Example #19
0
 public override string GenerateSelectStarQuery(TableOrView tableOrView, int top)
 {
     string sql = "SELECT t.* FROM {1} AS t {0}";
     return String.Format(sql, GenerateTopExpression(top), QuoteDatabaseObjectName(tableOrView));
 }
Example #20
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="old"></param>
 public TableOrView(TableOrView old)
     : base(old)
 {
     CopyMembers(old);
 }