XUpdateResolver

Kind of class:class
Inherits from:MovieClip
Author:Jason Williams & Mark Rausch@codehint _xrs
Classpath:mx.data.components.XUpdateResolver
File last modified:Tuesday, 18 December 2007, 15:44:38
The Firefly resolver components provide developers with an easy and flexible method
of saving data back to any supported data source, including XML, Remoting recordsets,
and SQL Server. The resolver components offer a significant advantage over similar
technologies by creating a level of abstraction between the developer and the data
source. Using this architecture, you can easily add new functionality to your existing
applications by simply swapping one resolver for another without having to rewrite any
ActionScript code. The resolver is bound to a dataset's DeltaPacket property, and each
different type of resolver translates it from the generic DeltaPacket format into a
specific format (DiffGrams, UpdateGrams, XUpdate, etc.)

The XUpdateResolver is a specific resolver implementation that translates the DeltaPacket
into XUpdate, usable by any server or database that understands the language. The XUpdate
language spec can be found at http://www.xmldb.org/xupdate/xupdate-wd.html
Component metadata:
    Event
    "beforeApplyUpdates"

    Summary


    Constructor
    Instance properties
    Instance methods
    • decodeFieldValue (fieldName:String, value:String) : Object
      • Decode the field value from a string representation into the native datatype we are using to store it.
    • encodeFieldValue (fieldName:String, value:Object) : String
      • Encode the field value from it's internal representation to a string representation .
    • resendPacket (transID:String) : Boolean
      • Causes the specified packet in the unresolvedPackets list to be resent thru the xupdatePacket property.
    • createXUpdatePacketFromDelta (dp:DeltaPacket)
      • Creates the xupdate DOM, puts it into the xupdatePacket property, and fires the databinding event.
    • getAttribute (path) : String
      • Returns a string containing the name of the node or attribute at the end of the xpath input string
    • getChildNodeByName (node, nodeName) : XMLNode
      • Returns the first child node of the specified node found with the specified name.
    • getDeltaAsXML (dp:DeltaPacket) : XML
      • Uses the deltaPacket to create an XUpdate packet to be assigned to the XUpdatePacket property.
    • getLocalSchema (extSch:Object) : Object
      • This method will return a local schema object that includes any overrides that have been made on
    • getXUpdateElementDef (node:XMLNode) : String
      • Creates the following XUpdate structure for an inserted or appended node
    • removeUnresolvedPacket (transID:String) : Void
      • Removes the specified packet from the unresolvedPackets list.
    • updateResultsToDataset : Void
      • This method gets called when results come back to this component.
    • updateResultNodeToDelta (transID:String, node:XMLNode) : Delta
      • This method translates an individual result node into an instance of the DeltaImpl class
    • getDeltaSource (transID:String, opID:String) : Object
    • updateResultsAddDeltaItems (node:XMLNode, delta:Delta) : Void
      • This method iterates thru the field nodes for an operation result or change node and adds them as DeltaItems

    Constructor

    XUpdateResolver

    function XUpdateResolver (
    )

    Class constructor

    Instance properties

    __deltaPacket

    private __deltaPacket:DeltaPacket
    (read)

    This method returns the "source" object which is used by the Delta object. The source object is used to locate the record
    to be updated or deleted, or for an insert it contains all the field values for the insert operation. It's properties
    get set from the field nodes for an operation result or change node.
    Parameters:
    node :
    The operation result or change node under which to look for field nodes
    isInsert:
    A boolean value that determines if all fields or only key fields will be used, and whether to use newValue or oldValue
    Returns:
    • An anonymous object with properties named by field and whose value is set from either the old or new value attributes
    Author:
    • Mark Rausch
    Example:
    • The some examples of the field nodes are as follows:










    __includeDPInfo

    private __includeDPInfo:Boolean
    (read)

    __schema

    private __schema:Object
    (read)

    __unresolvedDeltas

    private __unresolvedDeltas:Array
    (read)

    __unresolvedPackets

    private __unresolvedPackets:Array
    (read)

    __updateResults

    private __updateResults:XML
    (read)

    __xupdatePacket

    private __xupdatePacket:XML
    (read)

    _fieldValueObj

    private _fieldValueObj:Object
    (read)

    _opNumber

    private _opNumber:Array
    (read)

    addEventListener

    addEventListener:Function
    (read)

    deltaPacket

    deltaPacket:DeltaPacket
    (read,write)

    Component metadata:
      Bindable
      type:
      "DeltaPacket"
      ChangeEvent
      "deltaPacketChanged"

      dispatchEvent

      dispatchEvent:Function
      (read)

      encoder

      includeDeltaPacketInfo

      includeDeltaPacketInfo:Boolean
      (read,write)

      Component metadata:
        Inspectable
        defaultValue:
        "false"

        removeEventListener

        removeEventListener:Function
        (read)

        unresolvedPackets

        unresolvedPackets:Array
        (read)

        This array property holds a list of all updatePackets which have been sent back but for which
        no updateResults have been received. When updateResults are received back, the corresponding
        updatePacket is immediately removed from this list.

        This allows the user to determine which updatePackets have perhaps been lost. Any of them can
        be resent by using the resendPacket() function.
        @property unresolvedPackets
        Author:
        • Mark Rausch
          tiptext List of packets for which results have not been returned
          help 1471
        Example:
        • //Resend all unresolvedPackets
          for (var transID in res.unresolvedPackets) {;
          resendPacket(transID);
          }

        updateResults

        updateResults:XML
        (read,write)

        Component metadata:
          Bindable
          ChangeEvent
          "updateResultsChanged"

          xupdatePacket

          xupdatePacket:XML
          (read)

          Component metadata:
            Bindable
            ChangeEvent
            "xupdatePacketChanged"

            Instance methods

            createXUpdatePacketFromDelta

            private function createXUpdatePacketFromDelta (

            Creates the xupdate DOM, puts it into the xupdatePacket property, and fires the databinding event.
            Author:
            • Jason Williams & Mark Rausch

            decodeFieldValue

            function decodeFieldValue (
            fieldName:String, value:String) : Object

            Decode the field value from a string representation into the native datatype we are using to store it. Use the data pipeline to
            do the translation.

            encodeFieldValue

            function encodeFieldValue (
            fieldName:String, value:Object) : String

            Encode the field value from it's internal representation to a string representation . Use the data pipeline to
            do the translation.

            getAttribute

            private function getAttribute (
            path) : String

            Returns a string containing the name of the node or attribute at the end of the xpath input string
            Parameters:
            path:
            string containing an XPath expression
            Author:
            • Jason Williams & Mark Rausch

            getChildNodeByName

            private function getChildNodeByName (
            node, nodeName) : XMLNode

            Returns the first child node of the specified node found with the specified name.
            Parameters:
            node :
            reference to the node object to search from
            nodeName:
            string containing the name of the desired child node
            Author:
            • Jason Williams

            getDeltaAsXML

            private function getDeltaAsXML (
            dp:DeltaPacket) : XML

            Uses the deltaPacket to create an XUpdate packet to be assigned to the XUpdatePacket property.
            Parameters:
            packetObj:
            reference to an instance of an FxDeltaPacketClass.
            Returns:
            • reference to a new XML object containing the translation of the deltapacket to XUpdate
            Author:
            • Jason Williams & Mark Rausch
            Example:
            • The format for the XUpdate is as follows:
              http://www.xmldb.org/xupdate\">



              [1st attr value]
              ...
              [Nth attr value]

              ...





              [1st attr value]
              ...
              [Nth attr value]

              ...




              [New Attribute or node value]

            getDeltaSource

            private function getDeltaSource (
            transID:String, opID:String) : Object

            getLocalSchema

            private function getLocalSchema (
            extSch:Object) : Object

            This method will return a local schema object that includes any overrides that have been made on
            this resolver to the associated connector schema, that is passed through the delta packet.
            Parameters:
            extSch:
            Object containing the schema from the external source, provided via the deltapacket
            Returns:
            • Object containing either the same schema or one that has been modified to include any overriden
              values.

            getXUpdateElementDef

            private function getXUpdateElementDef (
            node:XMLNode) : String

            Creates the following XUpdate structure for an inserted or appended node

            [1st attr value]
            ...
            [Nth attr value]

            ...

            removeUnresolvedPacket

            private function removeUnresolvedPacket (
            transID:String) : Void

            Removes the specified packet from the unresolvedPackets list.
            @function removeUnresolvedPacket
            Parameters:
            transID:
            The transaction ID for the updatePacket which should be removed
            Author:
            • Mark Rausch

            resendPacket

            public function resendPacket (
            transID:String) : Boolean

            Causes the specified packet in the unresolvedPackets list to be resent thru the xupdatePacket property. This
            can be used when packets have been sent but no response received back from the server, indicating that the
            server did not receive it. If the specified packet does not exist, this function returns false, otherwise it
            returns true.

            function resendPacket
            Parameters:
            transID:
            The transaction ID for the updatePacket which should be resent
            Author:
            • Mark Rausch
              tiptext Resends an unresolvedPacket
              help 1472
            Example:
            • //Resend all unresolvedPackets
              for (var transID in res.unresolvedPackets) {;
              resendPacket(transID);
              }

            updateResultNodeToDelta

            private function updateResultNodeToDelta (
            transID:String, node:XMLNode) : Delta

            This method translates an individual result node into an instance of the DeltaImpl class
            Returns:
            • reference to a new Delta instance
            Author:
            • Mark Rausch
            Example:
            • The general format for the XML in the results packet is as follows:







            updateResultsAddDeltaItems

            private function updateResultsAddDeltaItems (
            node:XMLNode, delta:Delta) : Void

            This method iterates thru the field nodes for an operation result or change node and adds them as DeltaItems
            to the Delta which is passed in.
            Parameters:
            node :
            The operation result or change node under which to look for field nodes
            delta:
            The Delta object which will hold the DeltaItems
            Author:
            • Mark Rausch
            Example:
            • The some examples of the field nodes are as follows:










            updateResultsToDataset

            private function updateResultsToDataset (
            ) : Void

            This method gets called when results come back to this component. It translates the results, fires
            an event to allow the user a chance to view/modify the it, assigns it to the DeltaPacket property,
            and then fires the event that triggers the databinding mechanism.
            Author:
            • Mark Rausch
            Example:
            • The general format for the XML in the results packet is as follows: