You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Adriano Crestani <ad...@apache.org> on 2007/10/08 07:27:04 UTC
SDO C++ doubts about change summary
Hi,
I'm getting upset about how change summary logs a isMany property.
1- What does Setting& ChangeSummary::getOldValue( DataObjectPtr dataobject,
const Property & property) returns if the property is many=true?
2- How can I retrieve info from the ChangeSummary, about a DO A that was
removed from DO B where the Property C that relates these 2 DOs is many=true
and reference=true? Because the there is no Setting on DO B SettingList that
Setting::getProperty()=Property C and Setting::getDataObjectValue()=DO A.
Adriano Crestani
Re: SDO C++ doubts about change summary
Posted by Adriano Crestani <ad...@apache.org>.
Thanks a lot amita :)
I think in c++ it works differently, cause there is no Setting.getValue()
that I can cast to a List, but I will check it out ;)
Regards,
Adriano Crestani
On 10/9/07, Amita Vadhavkar <am...@gmail.com> wrote:
>
> when I use getOldValue(DO, Prop), instead of getOldValues(DO), I get same
> results -
>
> Code:
> ChangeSummary.Setting ovCust1 = csCust.getOldValue
> ((DataObject)coCust.get(0),
> orderProp);
> Property povCust1 = ovCust1.getProperty();
> System.out.println("povCust1 " + povCust1.getName());
> Object custv = ovCust1.getValue();
> System.out.println("changes in first change " + ((List)custv).size());
>
> System.out.println("1st change is in order1 ID:"
> +((DataObject)((List)custv).get(0)).getInt("ID"));
> System.out.println("2nd change is in order2 ID:"
> +((DataObject)((List)custv).get(1)).getInt("ID"));
>
> ChangeSummary.Setting ovCust2 = csCust.getOldValue
> ((DataObject)coCust.get(0),
> idProp);
> Property povCust2 = ovCust2.getProperty();
> System.out.println("povCust2 "+povCust2.getName());
> System.out.println("old value customer ID: "+ ovCust2.getValue());
>
> Result:
> povCust1 orders
> changes in first change 2
> 1st change is in order1 ID:10
> 2nd change is in order2 ID:0
> povCust2 ID
> old value customer ID: 1
>
> Regards,
> Amita
>
> On 10/8/07, Amita Vadhavkar <am...@gmail.com> wrote:
> >
> > Not sure about C++ , but below is what happens in java impls. Giving
> > example xsd, test case and result (and 1 question)
> >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > test case
> >
> > public class ChangeSummaryMyTestCase extends TestCase {
> >
> > HelperContext hc;
> > XSDHelper xh;
> > TypeHelper th;
> >
> > public void testCustomerDG() {
> >
> > Type idt = th.getType(" commonj.sdo", "Int");
> >
> > Type custt = SDOUtil.createType(hc, "testcases.changesummary",
> > "Customer", false);
> > Type ordert = SDOUtil.createType(hc, "testcases.changesummary ",
> > "AnOrder", false);
> > Type cst = th.getType("commonj.sdo","ChangeSummaryType");
> >
> > Property idProp = SDOUtil.createProperty(custt, "ID", idt);
> > Property ordProp = SDOUtil.createProperty(custt, "orders", ordert);
> > SDOUtil.setMany(ordProp, true);
> >
> > Property idordProp= SDOUtil.createProperty(ordert, "ID", idt);
> > SDOUtil.createProperty(ordert, "changeSummary", cst);
> >
> > DataGraph graph = SDOUtil.createDataGraph();
> > DataObject cust = graph.createRootObject(custt);
> >
> > final DataObject order1 = hc.getDataFactory().create(ordert);
> > final DataObject order2 = hc.getDataFactory().create(ordert);
> > order1.setInt("ID", 1);
> > order2.setInt("ID", 2);
> >
> > final ArrayList list = new ArrayList();
> > list.add(order1);
> > list.add(order2);
> >
> > cust.setList(ordProp, list);
> > cust.set("ID", new Integer(1));
> > testCustomerBody(ordProp, cust, ordert);
> > }
> >
> > private void testCustomerBody(Property orderProp, DataObject cust,
> Type
> > ordert) {
> > ChangeSummary csCust = cust.getChangeSummary();
> > csCust.beginLogging();
> >
> > if(cust.getList(orderProp) == null)
> > System.out.println("orderProp is null");
> > else
> > System.out.println("orderProp is not null, orders in
> customer
> > size "+cust.getList(orderProp).size());
> >
> > if(
> > ((DataObject)cust.getList(orderProp).get(0)).getChangeSummary() == null
> ||
> >
> > ((DataObject)cust.getList(orderProp).get(1)).getChangeSummary() == null
> )
> > System.out.println("orders change summary is null");
> > else
> > System.out.println("orders change summary is not null");
> >
> > ChangeSummary csOrd1 =
> > ((DataObject)cust.getList(orderProp).get(0)).getChangeSummary();
> > csOrd1.beginLogging();
> >
> > ChangeSummary csOrd2 =
> > ((DataObject)cust.getList(orderProp).get(1)).getChangeSummary();
> > csOrd2.beginLogging();
> >
> > List coCust = csCust.getChangedDataObjects();
> >
> > assertEquals(0, coCust.size());
> >
> > ((DataObject)cust.getList(orderProp).get(0)).setInt("ID", 10);
> > ((DataObject)cust.getList(orderProp).get(1)).setInt("ID", 11);
> > ((DataObject)cust.getList(orderProp).get(1)).delete();
> >
> > final DataObject order3 = hc.getDataFactory().create(ordert);
> > ChangeSummary csOrd3 = order3.getChangeSummary();
> > csOrd3.beginLogging();
> > order3.setInt("ID", 12);
> >
> > cust.getList(orderProp).add(order3);
> > cust.setInt("ID", 2);
> >
> > assertEquals(0, coCust.size());
> >
> > coCust = csCust.getChangedDataObjects();
> >
> > assertEquals(1, coCust.size()); //TODO? why 1 why not 3 changes
> -
> > 1 add order, 1 delete order, 1 change cust id
> >
> > List custOldValues = csCust.getOldValues
> > ((DataObject)coCust.get(0));
> >
> > System.out.println("customer change history OldValues size
> > "+custOldValues.size());
> >
> > ChangeSummary.Setting ovCust1 = (ChangeSummary.Setting
> )custOldValues.get(0);
> >
> > Property povCust1 = ovCust1.getProperty();
> > System.out.println("povCust1 " + povCust1.getName());
> > Object custv = ovCust1.getValue();
> > System.out.println("changes in first change " +
> > ((List)custv).size());
> > System.out.println("1st change is in order1 ID:"
> > +((DataObject)((List)custv).get(0)).getInt("ID"));
> > System.out.println("2nd change is in order2 ID:"
> > +((DataObject)((List)custv).get(1)).getInt("ID"));
> > System.out.println("new num of orders in customer
> > "+cust.getList(orderProp).size());
> >
> > ChangeSummary.Setting ovCust2 = (ChangeSummary.Setting
> > )custOldValues.get(1);
> > Property povCust2 = ovCust2.getProperty();
> > System.out.println("povCust2 "+povCust2.getName());
> > assertEquals("ID", povCust2.getName());
> > System.out.println("old value customer ID: "+ ovCust2.getValue
> ());
> > System.out.println("new value customer ID
> > :"+((DataObject)coCust.get(0)).get("ID"));
> >
> > System.out.println("csOrd1 co size
> > "+((List)csOrd1.getChangedDataObjects()).size());
> > System.out.println("csOrd1 co size
> > "+((List)csOrd1.getChangedDataObjects()).size());
> >
> > ChangeSummary.Setting ovOrd1 = (ChangeSummary.Setting
> >
> )((List)csOrd1.getOldValues((DataObject)((List)csOrd1.getChangedDataObjects()).get(0))).get(0);
> > Property pOrd1 = ovOrd1.getProperty();
> > assertEquals("ID", pOrd1.getName());
> > Object vOrd1 = ovOrd1.getValue();
> > System.out.println("order1 old value ID:"+vOrd1);
> > System.out.println("order1 new value
> >
> ID:"+((DataObject)((List)csOrd1.getChangedDataObjects()).get(0)).getInt("ID"));
> >
> >
> > ChangeSummary.Setting ovOrd2 = (ChangeSummary.Setting
> >
> )((List)csOrd2.getOldValues((DataObject)((List)csOrd2.getChangedDataObjects()).get(0))).get(0);
> > Property pOrd2 = ovOrd2.getProperty ();
> > assertEquals("ID", pOrd2.getName());
> > Object vOrd2 = ovOrd2.getValue();
> > System.out.println("order2 old value ID:"+vOrd2);
> > System.out.println("order2 new value
> >
> ID:"+((DataObject)((List)csOrd2.getChangedDataObjects()).get(0)).getInt("ID"));
> >
> >
> > ChangeSummary.Setting ovOrd3 = (ChangeSummary.Setting
> >
> )((List)csOrd3.getOldValues((DataObject)((List)csOrd3.getChangedDataObjects()).get(0))).get(0);
> > Property pOrd3 = ovOrd3.getProperty();
> > assertEquals("ID", pOrd3.getName());
> > Object vOrd3 = ovOrd3.getValue();
> > System.out.println("order3 old value ID:"+vOrd3);
> > System.out.println("order3 new value
> >
> ID:"+((DataObject)((List)csOrd3.getChangedDataObjects()).get(0)).getInt("ID"));
> >
> >
> > csCust.endLogging();
> > csOrd1.endLogging();
> > csOrd2.endLogging();
> > assertFalse(csCust.isLogging());
> > assertFalse(csOrd1.isLogging());
> > assertFalse(csOrd2.isLogging ());
> > }
> >
> > protected void setUp() throws Exception {
> > super.setUp();
> > URL url = getClass().getResource("/customer.xsd");
> > InputStream inputStream = url.openStream();
> > hc = SDOUtil.createHelperContext();
> > th = hc.getTypeHelper();
> > xh = hc.getXSDHelper();
> > xh.define(inputStream, url.toString());
> > inputStream.close();
> > }
> >
> > }
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > customer.xsd
> >
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:this="
> http:///org.apache.tuscany.das.rdb.test/customer.xsd"
> > targetNamespace="http:///org.apache.tuscany.das.rdb.test/customer.xsd">
> >
> > <xsd:complexType name="Customer">
> > <xsd:sequence>
> > <xsd:element name="ID" nillable="false" type="xsd:int"/>
> > <xsd:element maxOccurs="unbounded" name="orders"
> > type="this:AnOrder"/>
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > <!-- An Order -->
> > <xsd:complexType name="AnOrder">
> > <xsd:sequence>
> > <xsd:element name="ID" nillable="false" type="xsd:int"/>
> > <xsd:element name="changes"
> type="sdo:ChangeSummaryType"/>
> > </xsd:sequence>
> > </xsd:complexType>
> > </xsd:schema>
> >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > Output with: ((DataObject)cust.getList(orderProp).get(1)).delete();
> >
> > orderProp is not null, orders in customer size 2
> > orders change summary is not null
> > customer change history OldValues size 2
> > povCust1 orders
> > changes in first change 2
> > 1st change is in order1 ID:10
> > 2nd change is in order2 ID:0
> > new num of orders in customer 3
> > povCust2 ID
> > old value customer ID: 1
> > new value customer ID :2
> > csOrd1 co size 1
> > csOrd1 co size 1
> > order1 old value ID:1
> > order1 new value ID:10
> > order2 old value ID:2
> > order2 new value ID:0
> > order3 old value ID:0
> > order3 new value ID:12
> >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> >
> > Output with: //((DataObject)cust.getList(orderProp).get(1)).delete();
> >
> > orderProp is not null, orders in customer size 2
> > orders change summary is not null
> > customer change history OldValues size 2
> > povCust1 orders
> > changes in first change 2
> > 1st change is in order1 ID:10
> > 2nd change is in order2 ID:11
> > new num of orders in customer 3
> > povCust2 ID
> > old value customer ID: 1
> > new value customer ID :2
> > csOrd1 co size 1
> > csOrd1 co size 1
> > order1 old value ID:1
> > order1 new value ID:10
> > order2 old value ID:2
> > order2 new value ID:11
> > order3 old value ID:0
> > order3 new value ID:12
> >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > questions:
> >
> > Why the add of order3 in customer is not registered by csCust (change
> > summary of customer)
> >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> >
> > Regards,
> > Amita
> >
> > On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
> > >
> > > Sorry, item 2 was my fault, not a sdo c++ problem. But the item 1
> > > question
> > > remains.
> > >
> > > Adriano Crestani
> > >
> > > On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I'm getting upset about how change summary logs a isMany property.
> > > >
> > > > 1- What does Setting& ChangeSummary::getOldValue( DataObjectPtr
> > > > dataobject, const Property & property) returns if the property is
> > > many=true?
> > > >
> > > >
> > > > 2- How can I retrieve info from the ChangeSummary, about a DO A that
> > > was
> > > > removed from DO B where the Property C that relates these 2 DOs is
> > > many=true
> > > > and reference=true? Because the there is no Setting on DO B
> > > SettingList that
> > > > Setting::getProperty()=Property C and
> Setting::getDataObjectValue()=DO
> > > A.
> > > >
> > > > Adriano Crestani
> > > >
> > > >
> > > >
> > >
> >
> >
>
Re: SDO C++ doubts about change summary
Posted by Amita Vadhavkar <am...@gmail.com>.
when I use getOldValue(DO, Prop), instead of getOldValues(DO), I get same
results -
Code:
ChangeSummary.Setting ovCust1 = csCust.getOldValue((DataObject)coCust.get(0),
orderProp);
Property povCust1 = ovCust1.getProperty();
System.out.println("povCust1 " + povCust1.getName());
Object custv = ovCust1.getValue();
System.out.println("changes in first change " + ((List)custv).size());
System.out.println("1st change is in order1 ID:"
+((DataObject)((List)custv).get(0)).getInt("ID"));
System.out.println("2nd change is in order2 ID:"
+((DataObject)((List)custv).get(1)).getInt("ID"));
ChangeSummary.Setting ovCust2 = csCust.getOldValue((DataObject)coCust.get(0),
idProp);
Property povCust2 = ovCust2.getProperty();
System.out.println("povCust2 "+povCust2.getName());
System.out.println("old value customer ID: "+ ovCust2.getValue());
Result:
povCust1 orders
changes in first change 2
1st change is in order1 ID:10
2nd change is in order2 ID:0
povCust2 ID
old value customer ID: 1
Regards,
Amita
On 10/8/07, Amita Vadhavkar <am...@gmail.com> wrote:
>
> Not sure about C++ , but below is what happens in java impls. Giving
> example xsd, test case and result (and 1 question)
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> test case
>
> public class ChangeSummaryMyTestCase extends TestCase {
>
> HelperContext hc;
> XSDHelper xh;
> TypeHelper th;
>
> public void testCustomerDG() {
>
> Type idt = th.getType(" commonj.sdo", "Int");
>
> Type custt = SDOUtil.createType(hc, "testcases.changesummary",
> "Customer", false);
> Type ordert = SDOUtil.createType(hc, "testcases.changesummary ",
> "AnOrder", false);
> Type cst = th.getType("commonj.sdo","ChangeSummaryType");
>
> Property idProp = SDOUtil.createProperty(custt, "ID", idt);
> Property ordProp = SDOUtil.createProperty(custt, "orders", ordert);
> SDOUtil.setMany(ordProp, true);
>
> Property idordProp= SDOUtil.createProperty(ordert, "ID", idt);
> SDOUtil.createProperty(ordert, "changeSummary", cst);
>
> DataGraph graph = SDOUtil.createDataGraph();
> DataObject cust = graph.createRootObject(custt);
>
> final DataObject order1 = hc.getDataFactory().create(ordert);
> final DataObject order2 = hc.getDataFactory().create(ordert);
> order1.setInt("ID", 1);
> order2.setInt("ID", 2);
>
> final ArrayList list = new ArrayList();
> list.add(order1);
> list.add(order2);
>
> cust.setList(ordProp, list);
> cust.set("ID", new Integer(1));
> testCustomerBody(ordProp, cust, ordert);
> }
>
> private void testCustomerBody(Property orderProp, DataObject cust, Type
> ordert) {
> ChangeSummary csCust = cust.getChangeSummary();
> csCust.beginLogging();
>
> if(cust.getList(orderProp) == null)
> System.out.println("orderProp is null");
> else
> System.out.println("orderProp is not null, orders in customer
> size "+cust.getList(orderProp).size());
>
> if(
> ((DataObject)cust.getList(orderProp).get(0)).getChangeSummary() == null ||
>
> ((DataObject)cust.getList(orderProp).get(1)).getChangeSummary() == null )
> System.out.println("orders change summary is null");
> else
> System.out.println("orders change summary is not null");
>
> ChangeSummary csOrd1 =
> ((DataObject)cust.getList(orderProp).get(0)).getChangeSummary();
> csOrd1.beginLogging();
>
> ChangeSummary csOrd2 =
> ((DataObject)cust.getList(orderProp).get(1)).getChangeSummary();
> csOrd2.beginLogging();
>
> List coCust = csCust.getChangedDataObjects();
>
> assertEquals(0, coCust.size());
>
> ((DataObject)cust.getList(orderProp).get(0)).setInt("ID", 10);
> ((DataObject)cust.getList(orderProp).get(1)).setInt("ID", 11);
> ((DataObject)cust.getList(orderProp).get(1)).delete();
>
> final DataObject order3 = hc.getDataFactory().create(ordert);
> ChangeSummary csOrd3 = order3.getChangeSummary();
> csOrd3.beginLogging();
> order3.setInt("ID", 12);
>
> cust.getList(orderProp).add(order3);
> cust.setInt("ID", 2);
>
> assertEquals(0, coCust.size());
>
> coCust = csCust.getChangedDataObjects();
>
> assertEquals(1, coCust.size()); //TODO? why 1 why not 3 changes -
> 1 add order, 1 delete order, 1 change cust id
>
> List custOldValues = csCust.getOldValues
> ((DataObject)coCust.get(0));
>
> System.out.println("customer change history OldValues size
> "+custOldValues.size());
>
> ChangeSummary.Setting ovCust1 = (ChangeSummary.Setting)custOldValues.get(0);
>
> Property povCust1 = ovCust1.getProperty();
> System.out.println("povCust1 " + povCust1.getName());
> Object custv = ovCust1.getValue();
> System.out.println("changes in first change " +
> ((List)custv).size());
> System.out.println("1st change is in order1 ID:"
> +((DataObject)((List)custv).get(0)).getInt("ID"));
> System.out.println("2nd change is in order2 ID:"
> +((DataObject)((List)custv).get(1)).getInt("ID"));
> System.out.println("new num of orders in customer
> "+cust.getList(orderProp).size());
>
> ChangeSummary.Setting ovCust2 = (ChangeSummary.Setting
> )custOldValues.get(1);
> Property povCust2 = ovCust2.getProperty();
> System.out.println("povCust2 "+povCust2.getName());
> assertEquals("ID", povCust2.getName());
> System.out.println("old value customer ID: "+ ovCust2.getValue());
> System.out.println("new value customer ID
> :"+((DataObject)coCust.get(0)).get("ID"));
>
> System.out.println("csOrd1 co size
> "+((List)csOrd1.getChangedDataObjects()).size());
> System.out.println("csOrd1 co size
> "+((List)csOrd1.getChangedDataObjects()).size());
>
> ChangeSummary.Setting ovOrd1 = (ChangeSummary.Setting
> )((List)csOrd1.getOldValues((DataObject)((List)csOrd1.getChangedDataObjects()).get(0))).get(0);
> Property pOrd1 = ovOrd1.getProperty();
> assertEquals("ID", pOrd1.getName());
> Object vOrd1 = ovOrd1.getValue();
> System.out.println("order1 old value ID:"+vOrd1);
> System.out.println("order1 new value
> ID:"+((DataObject)((List)csOrd1.getChangedDataObjects()).get(0)).getInt("ID"));
>
>
> ChangeSummary.Setting ovOrd2 = (ChangeSummary.Setting
> )((List)csOrd2.getOldValues((DataObject)((List)csOrd2.getChangedDataObjects()).get(0))).get(0);
> Property pOrd2 = ovOrd2.getProperty ();
> assertEquals("ID", pOrd2.getName());
> Object vOrd2 = ovOrd2.getValue();
> System.out.println("order2 old value ID:"+vOrd2);
> System.out.println("order2 new value
> ID:"+((DataObject)((List)csOrd2.getChangedDataObjects()).get(0)).getInt("ID"));
>
>
> ChangeSummary.Setting ovOrd3 = (ChangeSummary.Setting
> )((List)csOrd3.getOldValues((DataObject)((List)csOrd3.getChangedDataObjects()).get(0))).get(0);
> Property pOrd3 = ovOrd3.getProperty();
> assertEquals("ID", pOrd3.getName());
> Object vOrd3 = ovOrd3.getValue();
> System.out.println("order3 old value ID:"+vOrd3);
> System.out.println("order3 new value
> ID:"+((DataObject)((List)csOrd3.getChangedDataObjects()).get(0)).getInt("ID"));
>
>
> csCust.endLogging();
> csOrd1.endLogging();
> csOrd2.endLogging();
> assertFalse(csCust.isLogging());
> assertFalse(csOrd1.isLogging());
> assertFalse(csOrd2.isLogging ());
> }
>
> protected void setUp() throws Exception {
> super.setUp();
> URL url = getClass().getResource("/customer.xsd");
> InputStream inputStream = url.openStream();
> hc = SDOUtil.createHelperContext();
> th = hc.getTypeHelper();
> xh = hc.getXSDHelper();
> xh.define(inputStream, url.toString());
> inputStream.close();
> }
>
> }
>
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> customer.xsd
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:this="http:///org.apache.tuscany.das.rdb.test/customer.xsd"
> targetNamespace="http:///org.apache.tuscany.das.rdb.test/customer.xsd">
>
> <xsd:complexType name="Customer">
> <xsd:sequence>
> <xsd:element name="ID" nillable="false" type="xsd:int"/>
> <xsd:element maxOccurs="unbounded" name="orders"
> type="this:AnOrder"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <!-- An Order -->
> <xsd:complexType name="AnOrder">
> <xsd:sequence>
> <xsd:element name="ID" nillable="false" type="xsd:int"/>
> <xsd:element name="changes" type="sdo:ChangeSummaryType"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Output with: ((DataObject)cust.getList(orderProp).get(1)).delete();
>
> orderProp is not null, orders in customer size 2
> orders change summary is not null
> customer change history OldValues size 2
> povCust1 orders
> changes in first change 2
> 1st change is in order1 ID:10
> 2nd change is in order2 ID:0
> new num of orders in customer 3
> povCust2 ID
> old value customer ID: 1
> new value customer ID :2
> csOrd1 co size 1
> csOrd1 co size 1
> order1 old value ID:1
> order1 new value ID:10
> order2 old value ID:2
> order2 new value ID:0
> order3 old value ID:0
> order3 new value ID:12
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Output with: //((DataObject)cust.getList(orderProp).get(1)).delete();
>
> orderProp is not null, orders in customer size 2
> orders change summary is not null
> customer change history OldValues size 2
> povCust1 orders
> changes in first change 2
> 1st change is in order1 ID:10
> 2nd change is in order2 ID:11
> new num of orders in customer 3
> povCust2 ID
> old value customer ID: 1
> new value customer ID :2
> csOrd1 co size 1
> csOrd1 co size 1
> order1 old value ID:1
> order1 new value ID:10
> order2 old value ID:2
> order2 new value ID:11
> order3 old value ID:0
> order3 new value ID:12
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> questions:
>
> Why the add of order3 in customer is not registered by csCust (change
> summary of customer)
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Regards,
> Amita
>
> On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
> >
> > Sorry, item 2 was my fault, not a sdo c++ problem. But the item 1
> > question
> > remains.
> >
> > Adriano Crestani
> >
> > On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
> > >
> > > Hi,
> > >
> > > I'm getting upset about how change summary logs a isMany property.
> > >
> > > 1- What does Setting& ChangeSummary::getOldValue( DataObjectPtr
> > > dataobject, const Property & property) returns if the property is
> > many=true?
> > >
> > >
> > > 2- How can I retrieve info from the ChangeSummary, about a DO A that
> > was
> > > removed from DO B where the Property C that relates these 2 DOs is
> > many=true
> > > and reference=true? Because the there is no Setting on DO B
> > SettingList that
> > > Setting::getProperty()=Property C and Setting::getDataObjectValue()=DO
> > A.
> > >
> > > Adriano Crestani
> > >
> > >
> > >
> >
>
>
Re: SDO C++ doubts about change summary
Posted by Amita Vadhavkar <am...@gmail.com>.
Not sure about C++ , but below is what happens in java impls. Giving example
xsd, test case and result (and 1 question)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test case
public class ChangeSummaryMyTestCase extends TestCase {
HelperContext hc;
XSDHelper xh;
TypeHelper th;
public void testCustomerDG() {
Type idt = th.getType("commonj.sdo", "Int");
Type custt = SDOUtil.createType(hc, "testcases.changesummary",
"Customer", false);
Type ordert = SDOUtil.createType(hc, "testcases.changesummary",
"AnOrder", false);
Type cst = th.getType("commonj.sdo","ChangeSummaryType");
Property idProp = SDOUtil.createProperty(custt, "ID", idt);
Property ordProp = SDOUtil.createProperty(custt, "orders", ordert);
SDOUtil.setMany(ordProp, true);
Property idordProp= SDOUtil.createProperty(ordert, "ID", idt);
SDOUtil.createProperty(ordert, "changeSummary", cst);
DataGraph graph = SDOUtil.createDataGraph();
DataObject cust = graph.createRootObject(custt);
final DataObject order1 = hc.getDataFactory().create(ordert);
final DataObject order2 = hc.getDataFactory().create(ordert);
order1.setInt("ID", 1);
order2.setInt("ID", 2);
final ArrayList list = new ArrayList();
list.add(order1);
list.add(order2);
cust.setList(ordProp, list);
cust.set("ID", new Integer(1));
testCustomerBody(ordProp, cust, ordert);
}
private void testCustomerBody(Property orderProp, DataObject cust, Type
ordert) {
ChangeSummary csCust = cust.getChangeSummary();
csCust.beginLogging();
if(cust.getList(orderProp) == null)
System.out.println("orderProp is null");
else
System.out.println("orderProp is not null, orders in customer
size "+cust.getList(orderProp).size());
if( ((DataObject)cust.getList(orderProp).get(0)).getChangeSummary()
== null ||
((DataObject)cust.getList(orderProp).get(1)).getChangeSummary()
== null )
System.out.println("orders change summary is null");
else
System.out.println("orders change summary is not null");
ChangeSummary csOrd1 =
((DataObject)cust.getList(orderProp).get(0)).getChangeSummary();
csOrd1.beginLogging();
ChangeSummary csOrd2 =
((DataObject)cust.getList(orderProp).get(1)).getChangeSummary();
csOrd2.beginLogging();
List coCust = csCust.getChangedDataObjects();
assertEquals(0, coCust.size());
((DataObject)cust.getList(orderProp).get(0)).setInt("ID", 10);
((DataObject)cust.getList(orderProp).get(1)).setInt("ID", 11);
((DataObject)cust.getList(orderProp).get(1)).delete();
final DataObject order3 = hc.getDataFactory().create(ordert);
ChangeSummary csOrd3 = order3.getChangeSummary();
csOrd3.beginLogging();
order3.setInt("ID", 12);
cust.getList(orderProp).add(order3);
cust.setInt("ID", 2);
assertEquals(0, coCust.size());
coCust = csCust.getChangedDataObjects();
assertEquals(1, coCust.size()); //TODO? why 1 why not 3 changes - 1
add order, 1 delete order, 1 change cust id
List custOldValues = csCust.getOldValues((DataObject)coCust.get(0));
System.out.println("customer change history OldValues size
"+custOldValues.size());
ChangeSummary.Setting ovCust1 =
(ChangeSummary.Setting)custOldValues.get(0);
Property povCust1 = ovCust1.getProperty();
System.out.println("povCust1 " + povCust1.getName());
Object custv = ovCust1.getValue();
System.out.println("changes in first change " +
((List)custv).size());
System.out.println("1st change is in order1 ID:"
+((DataObject)((List)custv).get(0)).getInt("ID"));
System.out.println("2nd change is in order2 ID:"
+((DataObject)((List)custv).get(1)).getInt("ID"));
System.out.println("new num of orders in customer
"+cust.getList(orderProp).size());
ChangeSummary.Setting ovCust2 = (ChangeSummary.Setting
)custOldValues.get(1);
Property povCust2 = ovCust2.getProperty();
System.out.println("povCust2 "+povCust2.getName());
assertEquals("ID", povCust2.getName());
System.out.println("old value customer ID: "+ ovCust2.getValue());
System.out.println("new value customer ID
:"+((DataObject)coCust.get(0)).get("ID"));
System.out.println("csOrd1 co size
"+((List)csOrd1.getChangedDataObjects()).size());
System.out.println("csOrd1 co size
"+((List)csOrd1.getChangedDataObjects()).size());
ChangeSummary.Setting ovOrd1 = (ChangeSummary.Setting
)((List)csOrd1.getOldValues((DataObject)((List)csOrd1.getChangedDataObjects()).get(0))).get(0);
Property pOrd1 = ovOrd1.getProperty();
assertEquals("ID", pOrd1.getName());
Object vOrd1 = ovOrd1.getValue();
System.out.println("order1 old value ID:"+vOrd1);
System.out.println("order1 new value
ID:"+((DataObject)((List)csOrd1.getChangedDataObjects()).get(0)).getInt("ID"));
ChangeSummary.Setting ovOrd2 = (ChangeSummary.Setting
)((List)csOrd2.getOldValues((DataObject)((List)csOrd2.getChangedDataObjects()).get(0))).get(0);
Property pOrd2 = ovOrd2.getProperty();
assertEquals("ID", pOrd2.getName());
Object vOrd2 = ovOrd2.getValue();
System.out.println("order2 old value ID:"+vOrd2);
System.out.println("order2 new value
ID:"+((DataObject)((List)csOrd2.getChangedDataObjects()).get(0)).getInt("ID"));
ChangeSummary.Setting ovOrd3 = (ChangeSummary.Setting
)((List)csOrd3.getOldValues((DataObject)((List)csOrd3.getChangedDataObjects()).get(0))).get(0);
Property pOrd3 = ovOrd3.getProperty();
assertEquals("ID", pOrd3.getName());
Object vOrd3 = ovOrd3.getValue();
System.out.println("order3 old value ID:"+vOrd3);
System.out.println("order3 new value
ID:"+((DataObject)((List)csOrd3.getChangedDataObjects()).get(0)).getInt("ID"));
csCust.endLogging();
csOrd1.endLogging();
csOrd2.endLogging();
assertFalse(csCust.isLogging());
assertFalse(csOrd1.isLogging());
assertFalse(csOrd2.isLogging());
}
protected void setUp() throws Exception {
super.setUp();
URL url = getClass().getResource("/customer.xsd");
InputStream inputStream = url.openStream();
hc = SDOUtil.createHelperContext();
th = hc.getTypeHelper();
xh = hc.getXSDHelper();
xh.define(inputStream, url.toString());
inputStream.close();
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
customer.xsd
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:this="
http:///org.apache.tuscany.das.rdb.test/customer.xsd" targetNamespace="
http:///org.apache.tuscany.das.rdb.test/customer.xsd">
<xsd:complexType name="Customer">
<xsd:sequence>
<xsd:element name="ID" nillable="false" type="xsd:int"/>
<xsd:element maxOccurs="unbounded" name="orders"
type="this:AnOrder"/>
</xsd:sequence>
</xsd:complexType>
<!-- An Order -->
<xsd:complexType name="AnOrder">
<xsd:sequence>
<xsd:element name="ID" nillable="false" type="xsd:int"/>
<xsd:element name="changes" type="sdo:ChangeSummaryType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Output with: ((DataObject)cust.getList(orderProp).get(1)).delete();
orderProp is not null, orders in customer size 2
orders change summary is not null
customer change history OldValues size 2
povCust1 orders
changes in first change 2
1st change is in order1 ID:10
2nd change is in order2 ID:0
new num of orders in customer 3
povCust2 ID
old value customer ID: 1
new value customer ID :2
csOrd1 co size 1
csOrd1 co size 1
order1 old value ID:1
order1 new value ID:10
order2 old value ID:2
order2 new value ID:0
order3 old value ID:0
order3 new value ID:12
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Output with: //((DataObject)cust.getList(orderProp).get(1)).delete();
orderProp is not null, orders in customer size 2
orders change summary is not null
customer change history OldValues size 2
povCust1 orders
changes in first change 2
1st change is in order1 ID:10
2nd change is in order2 ID:11
new num of orders in customer 3
povCust2 ID
old value customer ID: 1
new value customer ID :2
csOrd1 co size 1
csOrd1 co size 1
order1 old value ID:1
order1 new value ID:10
order2 old value ID:2
order2 new value ID:11
order3 old value ID:0
order3 new value ID:12
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
questions:
Why the add of order3 in customer is not registered by csCust (change
summary of customer)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Regards,
Amita
On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
>
> Sorry, item 2 was my fault, not a sdo c++ problem. But the item 1 question
> remains.
>
> Adriano Crestani
>
> On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
> >
> > Hi,
> >
> > I'm getting upset about how change summary logs a isMany property.
> >
> > 1- What does Setting& ChangeSummary::getOldValue( DataObjectPtr
> > dataobject, const Property & property) returns if the property is
> many=true?
> >
> >
> > 2- How can I retrieve info from the ChangeSummary, about a DO A that was
> > removed from DO B where the Property C that relates these 2 DOs is
> many=true
> > and reference=true? Because the there is no Setting on DO B SettingList
> that
> > Setting::getProperty()=Property C and Setting::getDataObjectValue()=DO
> A.
> >
> > Adriano Crestani
> >
> >
> >
>
Re: SDO C++ doubts about change summary
Posted by Adriano Crestani <ad...@apache.org>.
Sorry, item 2 was my fault, not a sdo c++ problem. But the item 1 question
remains.
Adriano Crestani
On 10/8/07, Adriano Crestani <ad...@apache.org> wrote:
>
> Hi,
>
> I'm getting upset about how change summary logs a isMany property.
>
> 1- What does Setting& ChangeSummary::getOldValue( DataObjectPtr
> dataobject, const Property & property) returns if the property is many=true?
>
>
> 2- How can I retrieve info from the ChangeSummary, about a DO A that was
> removed from DO B where the Property C that relates these 2 DOs is many=true
> and reference=true? Because the there is no Setting on DO B SettingList that
> Setting::getProperty()=Property C and Setting::getDataObjectValue()=DO A.
>
> Adriano Crestani
>
>
>