Thursday, July 15, 2010

My solution to the XmlID XmlIDREF and the object graph reconstruction

At the previous stage, I stopped with a situation where I could  get an entity (a patient) but nothing about a related entity (a doctor). The reason being that to break the serialization loop I used the XmldID and XmlIDREF annotations.


In the soap response I can see the doctor id (2). In Java the doctor field of the patient points to null (because as shown in the previous post, the doctor is not transfered).

By the way in Open ERP I would get not the doctor but at least the in id in the Python object. One more shame on Oracle/Sun stuff.

Anyway, I created another web service that does not return a single patient record but a compound of entities (a collection of patients and doctors) :

public class wsbr {
    private Collection patientCollection;
    private Collection doctorCollection;
    public Collection getPatientCollection() { return patientCollection ;};
    public void setPatientCollection(Collection p ) {  patientCollection = p;};

    public Collection getDoctorCollection() { return doctorCollection ;};
    public void setDoctorCollection(Collection p ) {  doctorCollection = p;};

   
}


Building a web service that returns such object and populating properly the two collection makes possible to transfer the entire graph which is rebuilt properly at the client side (automatically).

Here is the soap :



So my solution is to build a big compound referencing object that will ensure that all references will be carried properly.

No comments: