Server object (POJO|POCO) - XML synchronization.

Scope of document covers transformation rules for full and partial Object to XML and XML to Object transformation in compliance with “Server object (POJO|POCO) - HTML UI synchronization” document. XML is a source for data and operations definition. 

FullXml has complete presentation of Object’s data up to defined embedding level. If Object’s field’s value does not match, it carries Update operation. I.e. values from XML will be populated in Object. Request and response content stays same. Error info(if any) will be attached to own field in response.
DiffXml is subset of full one which includes only one or several fields to be updated. It could include additional info next to the field, like validation error code/message or suggested values. It also used for operations for object fields and array elements: List, Create, Update, Delete.

For sample object with structure

·        A

o       B

§         C

o       FieldA

o       Darr[3] (array of type D elements)

§         Darr[0]

§         Darr[1]

§         Darr[2]

·        E

COP

Request

Obj. model

Response

Description

 

Object/Field

List

<A>

A

<A>
<B/>
<FieldA>9</FieldA>
<Darr arraylength=”3”/>
</A>

Return member names and values for simple objects.

Get object A details.

<A><B/></A>

A.B

<A><B><C/></B></A>

 

Get A.B details

 

<A><FieldA/></A>

A.FieldA

<A>
<FieldA>9</FieldA>
</A>

 

Get A.FieldA value

Create

<A>

A

 

New A

Same as in List, but subObject will be created if no exist

<A><B/></A>

 

 

A.B=new B

Update

<A>
<FieldA>9AM</FieldA>
</A>

A.FieldA=9

-||-

Set A.FieldA to “9AM

Reassign field value

<A>
<FieldA errCode=”Numeric value expected”>
<error>
<original>1</original>
<guess>9</guess>
</error>
AM</FieldA>
</A>

Assigning to A.FieldA new value failed. Error info is attached

Assign new value failed.

Delete

<A deleted=”1”>

deleteA; A=null;

-||-

 

Remove object

 

<A>
<B A deleted=”1”/>
</A>

Delete A.B;
A.B=null;

-||-

 

Remove subobject

 

Array elements

GetArr

<A><Darr /></A>

A.Darr

<A><Darr >
<D id=”1”/>
<D id=”2”/>
<D id=”3”/>
</Darr></A>

Get references to A.Darr elements.

Reference: element root node with id in array.

List of array elements ids

GetArrEl

<A><Darr >
<D id=”2”/></Darr></A>

A.Darr[1]
id=arr.index+1

<A><Darr >
<D id=”2”><E/></D>
</Darr></A>

Get a.Darr[1] (second element) content

Single array element get.

 

<A><Darr >
<D id=”2”/>
<D id=”3”/>
</Darr></A>

 

 

Only elements with requested id  will be retrieved

Paging get
(few elements a time)

Append

<A><Darr><D/></Darr></A>

A.Darr
+= New D

<A><Darr >
<D id=”4” />
</Darr></A>

No id in array element means “create one”. 4th element will be created and attached to array

Increment array size

Extract

<A><Darr >
<D id=”2” deleted=”1” /></Darr></A>

 

-||-

 

Remove element from array

Reposition

TBD

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-||- ::= response is s ::= response is same as request XML.

TBD: validation
  1. Whole Obj -> XML retrieval
  2. Single field -> subXML retrieval
  3. SubObject -> subXML retrieval
  4. arrayElement
Validation use cases:
- Edit UI initially highlights validation errors
- Edit object/field change sets the new value and does the validation. Optionnaly model could perform validation in setter and prevent new value setting.
Object load
Xml -> Obj
Edit
Obj ->Xml+validation
 
After object read body from XML
        DiffXml.Initialize(obj)
            subfields initialized
            obj.Init() (if method exist)
            obj.Validate() (if method exist)
WriteObjBody
        obj.Validate()   (if method exist)
 
Exceptions are collected by DiffXml serializer Exceptions are collected by DiffXml serializer
and ebedded into XML as "errorcode" attributes.
 

ToDo: pass context to initializer and validator 

obj.Init() called after all child fields initialized.
                        It creates all needed temporary/transient fields,
                        performs draft or full integrity validation.
                        Throws exception if initialization or validation have not passed.
obj.Validate() called either after or during initialisation or during "read object with validation" serialization.
                        It performs full integrity validation.
                        Throws exception if validation have not passed.

X - input Xml
O - object
R - Result XML
Init - initialisation after serializinf from Xml
XOR                
∀ X ≃ O                
  O::         X? !X && Validate  
  simple O = X     \      
  complex ∀Of≃Xf  \          
  Heap ∀Oi≃Xi - XOR - Init Validate  
  O=new |X| /           Validate    
                 

Using XMLOutput (R) sequence diagram
XOR                            
∀ X ≃ O                            
  O::   X?     !X && Validate  
simple   O = X
\        
complex   ∀Of≃Xf  <Of... \ XOR
Heap @length=xxx ∀Oi≃Xi <Oi id=xxx...
Init @errorcode=initErr     Validate @errorcode=validateErr >value
  O=new |X|   /   |_
Validate @errorcode=validateErr /  
R:: <O...  

Any of XOR paramer=ters could be missing
X O R Init Validate      
Full processing. Usual for Editor UI.    
      Retrieve XML
Save object into XML
   
    Retrieve XML and validation results
Viewer UI.
   
      Create object from XML    
               

 

© 2008 Oleksandr Firsov