Esempio n. 1
0
        /// <inheritdoc/>
        public string GetDatabaseRuntimeName(LoadStage loadStage, INameDatabasesAndTablesDuringLoads namer = null)
        {
            var baseName = GetDatabaseRuntimeName();

            if (namer == null)
            {
                namer = new FixedStagingDatabaseNamer(baseName);
            }

            return(namer.GetDatabaseName(baseName, loadStage.ToLoadBubble()));
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public string GetRuntimeName(LoadBubble bubble, INameDatabasesAndTablesDuringLoads tableNamingScheme = null)
        {
            // If no naming scheme is specified, the default 'FixedStaging...' prepends the database name and appends '_STAGING'
            if (tableNamingScheme == null)
            {
                tableNamingScheme = new FixedStagingDatabaseNamer(Database);
            }

            string baseName = GetQuerySyntaxHelper().GetRuntimeName(Name);

            return(tableNamingScheme.GetName(baseName, bubble));
        }
        /// <summary>
        /// Constructor for use in tests, if possible use the LoadMetadata constructor instead
        /// </summary>
        /// <param name="liveServer">The live server where the data is held, IMPORTANT: this must contain InitialCatalog parameter</param>
        /// <param name="namer">optionally lets you specify how to pick database names for the temporary bubbles STAGING and RAW</param>
        /// <param name="defaults">optionally specifies the location to get RAW default server from</param>
        /// <param name="overrideRAWServer">optionally specifies an explicit server to use for RAW</param>
        public HICDatabaseConfiguration(DiscoveredServer liveServer, INameDatabasesAndTablesDuringLoads namer = null, IServerDefaults defaults = null, IExternalDatabaseServer overrideRAWServer = null)
        {
            //respects the override of LIVE server
            var liveDatabase = liveServer.GetCurrentDatabase();

            if (liveDatabase == null)
            {
                throw new Exception("Cannot load live without having a unique live named database");
            }

            // Default namer
            if (namer == null)
            {
                if (liveServer.DatabaseType == DatabaseType.PostgreSql)
                {
                    //create the DLE tables on the live database because postgres can't handle cross database references
                    namer = new FixedStagingDatabaseNamer(liveDatabase.GetRuntimeName(), liveDatabase.GetRuntimeName());
                }
                else
                {
                    namer = new FixedStagingDatabaseNamer(liveDatabase.GetRuntimeName());
                }
            }

            //if there are defaults
            if (overrideRAWServer == null && defaults != null)
            {
                overrideRAWServer = defaults.GetDefaultFor(PermissableDefaults.RAWDataLoadServer);//get the raw default if there is one
            }
            DiscoveredServer rawServer;

            //if there was defaults and a raw default server
            if (overrideRAWServer != null)
            {
                rawServer = DataAccessPortal.GetInstance().ExpectServer(overrideRAWServer, DataAccessContext.DataLoad, false); //get the raw server connection
            }
            else
            {
                rawServer = liveServer; //there is no raw override so we will have to use the live server for RAW too.
            }
            //populates the servers -- note that an empty rawServer value passed to this method makes it the localhost
            DeployInfo = new StandardDatabaseHelper(liveServer.GetCurrentDatabase(), namer, rawServer);

            RequiresStagingTableCreation = true;
        }