ds debug
This commit is contained in:
+67
-2
@@ -74,9 +74,34 @@
|
||||
<cfset request.GUEST_USR_ID=3/>
|
||||
|
||||
<!--- global settings --->
|
||||
<cfset request.DS=this.datasource/>
|
||||
|
||||
<cfset this.datasource = "dwh"/>
|
||||
<cfset this.defaultdatasource = this.datasource/>
|
||||
<cfset request.DS = "#this.datasource#">
|
||||
|
||||
<!--- <cfdump var=#GetApplicationSettings()#/> --->
|
||||
|
||||
<!--- <cfif !structKeyExists(GetApplicationSettings().datasources,"#this.datasource#")>
|
||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||
</cfif>
|
||||
|
||||
<!--- неуклюжий выверт для локальной отладки --->
|
||||
<cfif !structKeyExists(this.datasources,"billing-vc")>
|
||||
<cfset this.datasources["billing-vc"]=getDS("billing-vc","ds_billing_vc")/>
|
||||
</cfif>
|
||||
|
||||
<cfif !structKeyExists(this.datasources,"billing-s3")>
|
||||
<cfset this.datasources["billing-s3"]=getDS("billing-s3","ds_billing_s3")/>
|
||||
</cfif> --->
|
||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||
<cfset this.datasources["billing-vc"]=getDS("billing-vc","ds_billing_vc")/>
|
||||
<cfset this.datasources["billing-s3"]=getDS("billing-s3","ds_billing_s3")/>
|
||||
|
||||
<cfdump var=#this.datasources#/>
|
||||
|
||||
|
||||
<cfset request.RECORDS_PER_PAGE=500/>
|
||||
<cfset request.APP_VERSION="0.00.000"/>
|
||||
<cfset request.APP_VERSION="0.00.001"/>
|
||||
<cfset request.STAND=getStand()/>
|
||||
|
||||
<cflock scope="application" type="readonly" timeout=3>
|
||||
@@ -286,6 +311,46 @@
|
||||
</cftry>
|
||||
<cfreturn ""/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction
|
||||
name="getDS"
|
||||
access="private"
|
||||
returntype="struct"
|
||||
output="true"
|
||||
hint="Configure data source from environment variables. Convention: data source name is an environment varialble prefix">
|
||||
|
||||
<cfargument name="dsname" type="string" required="true"/>
|
||||
<cfargument name="prefix" type="string" default=#dsname#/>
|
||||
|
||||
<cfset system = createObject("java", "java.lang.System")/>
|
||||
<cfset var ds={}/>
|
||||
|
||||
<cfloop list="class,connectionString,database,driver,dbdriver,host,port,type,url,username,password,bundleName,bundleVersion,connectionLimit,liveTimeout,validate" item="field"><!--- driver vs dbdriver --->
|
||||
<cfset var value=system.getEnv("#arguments.prefix#_#field#")/>
|
||||
<cfif isDefined("value") AND len(value)>
|
||||
<cfset structInsert(ds,field,value)/>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
<cfif structIsEmpty(ds)>
|
||||
<cfthrow type="application" message="Datasource not configured" detail="Datasource not defined in the environment. Expected prefix is #arguments.prefix#"/>
|
||||
</cfif>
|
||||
|
||||
<!--- test datasource (just to get exception if invalid) --->
|
||||
<cftry>
|
||||
<cfquery name="qTestDs" datasource=#ds#>
|
||||
select 1;
|
||||
</cfquery>
|
||||
|
||||
<cfcatch type="any">
|
||||
<!--- <cfdump var=#ds#/><cfabort/> --->
|
||||
<cfrethrow/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfreturn ds/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
</cfcomponent>
|
||||
Reference in New Issue
Block a user