Skip to content

Commit

Permalink
Merge branch 'p720'
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/lib/cdn.cfc
  • Loading branch information
justincarter committed Mar 23, 2017
2 parents ad2be86 + 3882737 commit b416b7a
Show file tree
Hide file tree
Showing 31 changed files with 486 additions and 238 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Download the latest community build or get a "ready-to-go" express version for a
- [FarCry Dev Support Forum](http://discourse.farcrycore.org/)
- [Google+ Community](https://plus.google.com/communities/107650642291146266954)
- [FarCry Documentation WIKI](https://farcry.jira.com/wiki/display/FCDEV60/Home)
- [FarCry Committers Blog](http://blog.farcrycore.org)
- [FarCry Committers Blog](http://discourse.farcrycore.org/c/blog)
- [Daemon: Commercial Support/Training/Development](http://www.daemon.com.au)

### Code
Expand Down
94 changes: 51 additions & 43 deletions packages/cdn/s3.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -539,56 +539,64 @@
<cfset var data = "" />
<cfset var tmpfile = getCachedFile(config=arguments.config,file=arguments.file) />

<cfif len(tmpfile)>
<cftry>

<!--- Read cache file --->
<cfswitch expression="#arguments.datatype#">
<cfcase value="text">
<cffile action="read" file="#tmpfile#" variable="data" />
</cfcase>
<cfif len(tmpfile)>

<cfcase value="binary">
<cffile action="readBinary" file="#tmpfile#" variable="data" />
</cfcase>
<!--- Read cache file --->
<cfswitch expression="#arguments.datatype#">
<cfcase value="text">
<cffile action="read" file="#tmpfile#" variable="data" />
</cfcase>

<cfcase value="binary">
<cffile action="readBinary" file="#tmpfile#" variable="data" />
</cfcase>

<cfcase value="image">
<cfset data = imageread(tmpfile) />
</cfcase>
</cfswitch>

<cfcase value="image">
<cfset data = imageread(tmpfile) />
</cfcase>
</cfswitch>

<cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from local cache" />

<cfelse>
<cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from local cache" />

<cfelse>

<cfset tmpfile = getTemporaryFile(config=arguments.config,file=arguments.file) />

<cfset ioCopyFile(source_config=arguments.config,source_file=arguments.file,dest_localpath=tmpfile) />

<!--- Read cache file --->
<cfswitch expression="#arguments.datatype#">
<cfcase value="text">
<cffile action="read" file="#tmpfile#" variable="data" />
</cfcase>
<cfset tmpfile = getTemporaryFile(config=arguments.config,file=arguments.file) />

<cfcase value="binary">
<cffile action="readBinary" file="#tmpfile#" variable="data" />
</cfcase>
<cfset ioCopyFile(source_config=arguments.config,source_file=arguments.file,dest_localpath=tmpfile) />

<!--- Read cache file --->
<cfswitch expression="#arguments.datatype#">
<cfcase value="text">
<cffile action="read" file="#tmpfile#" variable="data" />
</cfcase>

<cfcase value="binary">
<cffile action="readBinary" file="#tmpfile#" variable="data" />
</cfcase>

<cfcase value="image">
<cfset data = imageread(tmpfile) />
</cfcase>
</cfswitch>

<cfif arguments.config.localCacheSize>
<cfset addCachedFile(config=arguments.config,file=arguments.file,path=tmpfile) />
<cfelse>
<!--- Delete temporary file --->
<cfset deleteTemporaryFile(tmpfile) />
</cfif>

<cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from S3" />

<cfcase value="image">
<cfset data = imageread(tmpfile) />
</cfcase>
</cfswitch>

<cfif arguments.config.localCacheSize>
<cfset addCachedFile(config=arguments.config,file=arguments.file,path=tmpfile) />
<cfelse>
<!--- Delete temporary file --->
<cfset deleteTemporaryFile(tmpfile) />
</cfif>

<cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from S3" />

</cfif>

<cfcatch>
<cflog file="#application.applicationname#_s3" text="Error reading [#arguments.config.name#] #sanitiseS3URL(arguments.file)#: #cfcatch.message#" />
<cfrethrow>
</cfcatch>
</cftry>

<cfreturn data />
</cffunction>
Expand Down
8 changes: 5 additions & 3 deletions packages/coapi/coapiUtilities.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,11 @@
<cfif len(arguments.typename)>
<!--- Just in case the whole package path has been passed in, we only need the actual typename --->
<cfset arguments.typename = listLast(arguments.typename,".") />

<cfset oCO = createObject("component", application.stcoapi[arguments.typename].packagePath) />
<cfset stResult = oCO.getData(argumentCollection="#arguments#") />

<cfif structKeyExists(application.stcoapi, arguments.typename)>
<cfset oCO = createObject("component", application.stcoapi[arguments.typename].packagePath) />
<cfset stResult = oCO.getData(argumentCollection="#arguments#") />
</cfif>
</cfif>

<cfreturn stResult />
Expand Down
8 changes: 4 additions & 4 deletions packages/dbgateways/BaseGateway.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
<cfif NOT bFirst>,</cfif><cfset bFirst = false />

<cfset stVal = getValueForDB(schema=arguments.schema.fields[thisfield],value=arguments.stProperties[thisfield]) />
<cfqueryparam cfsqltype="#stVal.cfsqltype#" null="#stVal.null#" value="#stVal.value#" />
<cfqueryparam attributeCollection="#stVal#" />
</cfif>
</cfloop>
)
Expand Down Expand Up @@ -341,7 +341,7 @@
<cfif NOT bFirst>AND</cfif><cfset bFirst = false />

<cfset stVal = getValueForDB(schema=arguments.schema.fields[thisfield],value=arguments.stProperties[thisfield]) />
#thisfield#=<cfqueryparam cfsqltype="#stVal.cfsqltype#" null="#stVal.null#" value="#stVal.value#" />
#thisfield#=<cfqueryparam attributeCollection="#stVal#" />
</cfloop>
</cfquery>

Expand All @@ -362,15 +362,15 @@
<cfif NOT bFirst>,</cfif><cfset bFirst = false />

<cfset stVal = getValueForDB(schema=arguments.schema.fields[thisfield],value=arguments.stProperties[thisfield]) />
#thisfield#=<cfqueryparam cfsqltype="#stVal.cfsqltype#" null="#stVal.null#" value="#stVal.value#" />
#thisfield#=<cfqueryparam attributeCollection="#stVal#" />
</cfif>
</cfloop>
WHERE <cfset bFirst = true />
<cfloop list="#arraytolist(arguments.schema.indexes.primary.fields)#" index="thisfield">
<cfif NOT bFirst>AND</cfif><cfset bFirst = false />

<cfset stVal = getValueForDB(schema=arguments.schema.fields[thisfield],value=arguments.stProperties[thisfield]) />
#thisfield#=<cfqueryparam cfsqltype="#stVal.cfsqltype#" null="#stVal.null#" value="#stVal.value#" />
#thisfield#=<cfqueryparam attributeCollection="#stVal#" />
</cfloop>
</cfquery>

Expand Down
59 changes: 57 additions & 2 deletions packages/dbgateways/MSSQL2012Gateway.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,63 @@

<cfreturn stResult />
</cffunction>



<cffunction name="getInsertSQL" access="public" output="false" returntype="string" hint="Returns the SQL to insert data into the table specified and used by the Farcry Content Export">
<cfargument name="table" type="string" required="true" />
<cfargument name="aTableColMD" type="array" required="true" />
<cfargument name="orderBy" type="string" required="true" />
<cfargument name="from" type="numeric" default="1" />
<cfargument name="to" type="numeric" default="0" />

<cfset var resultSQL = "">
<cfset var j = 0>
<cfset var k = "">
<cfset var stTableMetadata = introspectTable(arguments.table)>

<cfsavecontent variable="resultSQL">

<cfoutput>
SELECT (
<cfset j = 1>
<cfloop list="#structKeyList(stTableMetadata.fields)#" index="k">
<cfif j NEQ 1>
+
</cfif>

<cfif FindNoCase("char", stTableMetadata.fields[k].type)
OR FindNoCase("unique", stTableMetadata.fields[k].type)
OR FindNoCase("xml", stTableMetadata.fields[k].type)
OR FindNoCase("object", stTableMetadata.fields[k].type)
OR FindNoCase("string", stTableMetadata.fields[k].type)
>
'|---|' + COALESCE(#stTableMetadata.fields[k].Name#,'') + '|---|'
<cfelseif FindNoCase("text", stTableMetadata.fields[k].type) OR FindNoCase("longchar", stTableMetadata.fields[k].type)>
'|---|' + COALESCE( CONVERT( varchar(MAX) , #stTableMetadata.fields[k].Name#),'') + '|---|'
<cfelseif FindNoCase("date", stTableMetadata.fields[k].type) OR FindNoCase("time", stTableMetadata.fields[k].type)>
'|---|' + COALESCE( CONVERT ( varchar(25) , #stTableMetadata.fields[k].Name#, 120) ,'NULL') + '|---|'
<cfelse>
COALESCE( CONVERT( varchar, #stTableMetadata.fields[k].Name#),'=???=')
</cfif>

<cfif j NEQ structCount(stTableMetadata.fields)>
+ ','
</cfif>

<cfset j++>
</cfloop>
) as insertValues
FROM (
SELECT *, ROW_NUMBER() OVER (ORDER BY #arguments.orderBy# desc) AS RowNum
FROM #arguments.table#
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN #arguments.from# AND #arguments.to#
</cfoutput>

</cfsavecontent>

<cfreturn resultSQL>
</cffunction>

<!--- DATABASE INTROSPECTION --->
<cffunction name="introspectTable" returntype="struct" access="private" output="false" hint="Constructs a metadata struct for the table">
<cfargument name="tablename" type="string" required="True" hint="The table to introspect" />
Expand Down
1 change: 1 addition & 0 deletions packages/dbgateways/MSSQLGateway.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<cfset stResult.cfsqltype = "cf_sql_integer" />
<cfelse>
<cfset stResult.cfsqltype = "cf_sql_decimal" />
<cfset stResult.scale = listlast(arguments.schema.precision) />
</cfif>
<cfif arguments.schema.nullable and (arguments.value eq "" or arguments.value eq "NULL")>
<cfset stResult.value = 0 />
Expand Down
5 changes: 3 additions & 2 deletions packages/dbgateways/MySQLGateway.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<cfset stResult.cfsqltype = "cf_sql_integer" />
<cfelse>
<cfset stResult.cfsqltype = "cf_sql_decimal" />
<cfset stResult.scale = listlast(arguments.schema.precision) />
</cfif>
<cfif arguments.schema.nullable and (arguments.value eq "" or arguments.value eq "NULL")>
<cfset stResult.value = 0 />
Expand Down Expand Up @@ -216,7 +217,7 @@
</cfswitch>
<cfif stProp.nullable>NULL<cfelse>NOT NULL</cfif>
<cfset stVal = getValueForDB(schema=stProp,value=stProp.default) />
<cfif stProp.type neq "longchar">DEFAULT <cfqueryparam cfsqltype="#stVal.cfsqltype#" null="#stVal.null#" value="#stVal.value#" /></cfif>
<cfif stProp.type neq "longchar">DEFAULT <cfqueryparam attributeCollection="#stVal#" /></cfif>
</cfquery>

<cfset arrayappend(stResult.results,queryresult) />
Expand Down Expand Up @@ -277,7 +278,7 @@
</cfswitch>
<cfif stProp.nullable>NULL<cfelse>NOT NULL</cfif>
<cfset stVal = getValueForDB(schema=stProp,value=stProp.default) />
<cfif stProp.type neq "longchar">DEFAULT <cfqueryparam cfsqltype="#stVal.cfsqltype#" null="#stVal.null#" value="#stVal.value#" /></cfif>
<cfif stProp.type neq "longchar">DEFAULT <cfqueryparam attributeCollection="#stVal#" /></cfif>
</cfquery>

<cfset arrayappend(stResult.results,queryresult) />
Expand Down
Loading

0 comments on commit b416b7a

Please sign in to comment.