Hi, I have searched the internet for a way to use a datagraph in a static manner. I found the the the Issue above.
To be sure, that I'll no use old code, I checkout out the sources from https://svn.apache.org/repos/asf/incubator/tuscany/java/sdo $ svn up At revision 598650. and make a full build. Based on the mail trace, a create the described tescases and schemas an run the provided test cases and get the following results: a) The schema <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://abc.com/services" xmlns:tns="http://abc.com/services" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" xmlns:sdoXml="commonj.sdo/xml" sdoJava:package="com.abc.services" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:import namespace="commonj.sdo" schemaLocation="datagraph.xsd" /> <xsd:complexType name="NestedType"> <xsd:sequence> <xsd:element name="test1" type="xsd:string" /> <xsd:element name="test2" type="xsd:string" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="MyDataGraph"> <complexContent> <extension base="sdo:BaseDataGraphType"> <xsd:sequence> <xsd:element name="NestedType" type="tns:NestedType" /> </xsd:sequence> </extension> </complexContent> </xsd:complexType> <xsd:complexType name="Input"> <xsd:sequence> <xsd:element name="MyDataGraph" type="tns:MyDataGraph" /> </xsd:sequence> </xsd:complexType> </xsd:schema> b) The Test Driver package com.abc.services.test; import java.io.ByteArrayOutputStream; import java.io.IOException; import org.apache.tuscany.sdo.api.SDOUtil; import com.abc.services.Input; import com.abc.services.MyDataGraph; import com.abc.services.NestedType; import com.abc.services.ServicesFactory; import com.abc.services.impl.ServicesFactoryImpl; import commonj.sdo.DataGraph; import commonj.sdo.DataObject; import commonj.sdo.Type; import commonj.sdo.helper.XMLHelper; import commonj.sdo.impl.HelperProvider; public class TestABC { public static void main(String[] args) { ServicesFactory.INSTANCE.register(HelperProvider.getDefaultContext()); NestedType nested; System.out .println("**************** static graph **********************\n"); Input input = ServicesFactory.INSTANCE.createInput(); MyDataGraph staticGraph = ServicesFactory.INSTANCE.createMyDataGraph(); nested = ServicesFactory.INSTANCE.createNestedType(); staticGraph.setNestedType(nested); ((DataObject) nested).set("test1", "test1"); ((DataObject) nested).set("test2", "test2"); staticGraph.getChangeSummary().beginLogging(); ((DataObject) nested).set("test2", "test2_modified"); nested.setTest1("test1_modified"); input.setMyDataGraph(staticGraph); saveGraph(staticGraph); System.out.println("\n\n"); System.out .println("**************** dynamic graph **********************\n"); DataGraph dynamicGraph = SDOUtil.createDataGraph(); Type type = ((ServicesFactoryImpl) ServicesFactory.INSTANCE) .getNestedType(); nested = (NestedType) dynamicGraph.createRootObject(type); ((DataObject) nested).set("test1", "test1"); ((DataObject) nested).set("test2", "test2"); dynamicGraph.getChangeSummary().beginLogging(); ((DataObject) nested).set("test2", "test2_modified"); nested.setTest1("test1_modified"); saveGraph(dynamicGraph); } /** * @param dataobject */ private static void saveGraph(MyDataGraph dataobject) { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { XMLHelper.INSTANCE.save((DataObject) dataobject, null, "datagraph", os); System.out.println(os.toString()); } catch (IOException e) { e.printStackTrace(); } } /** * @param datagraph */ private static void saveGraph(DataGraph datagraph) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); SDOUtil.saveDataGraph(datagraph, os, null); System.out.println(os.toString()); } catch (IOException e1) { e1.printStackTrace(); } } } c) The Execution Result The ChangeSummary entries are missing ! **************** static graph ********************** <?xml version="1.0" encoding="ASCII"?> <datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://abc.com/services" xsi:type="tns:MyDataGraph"> <changeSummary logging="true" xmlns:sdo="commonj.sdo"> <NestedType sdo:ref="#//NestedType"> <test2>test2</test2> <test1>test1</test1> </NestedType> </changeSummary> <NestedType> <test1>test1_modified</test1> <test2>test2_modified</test2> </NestedType> </datagraph> **************** dynamic graph ********************** <?xml version="1.0" encoding="ASCII"?> <sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo" xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:tns="http://abc.com/services"> <changeSummary xmlns="" logging="true"> <objectChanges key="#//@eRootObject"> <value xsi:type="sdo_1:ChangeSummarySetting" featureName="test2" dataValue="test2"/> <value xsi:type="sdo_1:ChangeSummarySetting" featureName="test1" dataValue="test1"/> </objectChanges> </changeSummary> <tns:NestedType> <test1>test1_modified</test1> <test2>test2_modified</test2> </tns:NestedType> </sdo:datagraph> Additionally I've check the following: a) The Schema <xsd:schema targetNamespace="http://uk.customer.org/services/supporter" xmlns:sup="http://uk.customer.org/services/supporter" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" elementFormDefault="qualified"> <xsd:import namespace="commonj.sdo" schemaLocation="datagraph.xsd" /> <xsd:element name="SupporterDataGraph" type="sup:SupporterDataGraph" /> <xsd:complexType name="SupporterDataGraph"> <xsd:complexContent> <xsd:extension base="sdo:BaseDataGraphType"> <xsd:sequence> <xsd:element name="supporter" type="sup:Supporter" maxOccurs="unbounded" /> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:complexType name="Supporter"> <xsd:sequence> <xsd:element name="srn" type="xsd:long" /> <xsd:element name="title" type="xsd:string" /> <xsd:element name="surname" type="xsd:string" /> <xsd:element name="forename" type="xsd:string" /> <xsd:element name="email" type="xsd:string" /> <xsd:element name="addresses" type="sup:Address" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="Address"> <xsd:sequence> <xsd:element name="name" type="xsd:string" /> <xsd:element name="street" type="xsd:string" /> <xsd:element name="city" type="xsd:string" /> <xsd:element name="state" type="xsd:string" /> <xsd:element name="zip" type="xsd:string" /> <xsd:element name="country" type="xsd:string" /> </xsd:sequence> <xsd:attribute name="language" type="xsd:language" /> </xsd:complexType> </xsd:schema> b) The Test Driver 1 package org.customer.uk.services.supporter.test; 2 3 import java.util.List; 4 5 import org.customer.uk.services.supporter.Supporter; 6 import org.customer.uk.services.supporter.SupporterFactory; 7 8 import commonj.sdo.DataObject; 9 10 public class Main { 11 12 public static void main(String[] args) { 13 DataObject dg = (DataObject)SupporterFactory.INSTANCE.createSupporterDataGraph(); 14 dg.getChangeSummary().beginLogging(); 15 { >>>>16 Supporter s0 = >>>>Supporter.class.cast(dg.createDataObject("supporter")); 17 s0.setSurname("S0"); 18 19 System.out.println(s0); 20 21 Supporter s1 = Supporter.class.cast(dg.createDataObject("supporter")); 22 s1.setSurname("S1"); 23 24 System.out.println(s1); 25 } 26 27 dg.getChangeSummary().endLogging(); 28 29 List<DataObject> l = dg.getChangeSummary().getChangedDataObjects(); 30 for (DataObject dataObject : l) { 31 System.out.println(dataObject); 32 } 33 34 } 35 } c) The Execution Result Exception in thread "main" org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException: index=0, size=0 at org.eclipse.emf.common.util.BasicEList.remove(BasicEList.java:908) at org.eclipse.emf.ecore.change.util.ChangeRecorder.handleFeature(ChangeRecorder.java:429) at org.eclipse.emf.ecore.change.util.ChangeRecorder.notifyChanged(ChangeRecorder.java:312) at org.apache.tuscany.sdo.impl.ChangeSummaryImpl$SDOChangeRecorder.notifyChanged(ChangeSummaryImpl.java:475) at org.apache.tuscany.sdo.impl.DataObjectImpl.eNotify(DataObjectImpl.java:1358) at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:234) at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:292) at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:600) at org.apache.tuscany.sdo.util.DataObjectUtil.createDataObject(DataObjectUtil.java:433) at org.apache.tuscany.sdo.util.DataObjectUtil.createDataObject(DataObjectUtil.java:473) at org.apache.tuscany.sdo.impl.DataObjectImpl.createDataObject(DataObjectImpl.java:1195) at org.customer.uk.services.supporter.test.Main.main(Main.java:16) I'll go on with some debugging ... Any help in this regard would be appreciated. Many Thanks & Regards, Michael --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
