Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 650

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Cusmanager.cfc
<cfcomponent implements="CFIDE.AIR.ISyncManager">
<!----Fetch method--->
<cffunction name="fetch" returnType="Array" access="remote">
<cfset cus = ArrayNew(1)>
<cfset cus = EntityLoad("customer")>
<cfreturn cus>
</cffunction>
<!----SYNC method--->
<cffunction name="sync" returntype="any">
<cfargument name="operations" type="array" required="true">
<cfargument name="clientobjects" type="array" required="true">
<cfargument name="originalobjects" type="array" required="false">
<cfset conclits = ArrayNew(1)>
<cfset conflictcount = 1>
<cfloop index="i" from="1" to="#ArrayLen( operations )#">
<cfset operation = operations[i]>
<cfset clientobject = clientobjects[i]>
<cfset originalobject = originalobjects[i]>
<cfif operation eq "INSERT">
<cfset obj = ORMGetSession().merge(clientobject)>
<cfset EntitySave(obj)>
<cfelseif listfindnocase("UPDATE,DELETE",operation) neq 0>
<cfset serverobject = EntityLoadByPK("employee",originalobject.getcid())>
<cfif not isdefined('serverobject') >
<cflog text="CONFLICT::SERVER OBJECT NOT FOUND, RECORD MAY BE DELETED ALREADY">
<cfset conflict = CreateObject("component","CFIDE.AIR.conflict")>
<cfset conflict.clientobject = clientobject>
<cfset conflict.originalobject = originalobject>
<cfset conflict.operation = operation>
<cfset conflicts[conflictcount++] = conflict>
<cfcontinue>
</cfif>
<cfset isNotConflict = ObjectEquals(originalobject, serverobject)>
<cfif isNotConflict>
<cfif operation eq "UPDATE">
<cfelseif operation eq "DELETE">
<cfset obj = ORMGetSession().merge(clientobject)>
<cfset EntitySave(obj)>
<cfset obj = ORMGetSession().merge(originalobject)>
Last updated 1/20/2012
645

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents