[ 
https://issues.apache.org/jira/browse/TUSCANY-1305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499819
 ] 

Kelvin Goodson commented on TUSCANY-1305:
-----------------------------------------

The issue here is that the generated code creates the metadata, and then 
initializes it,  but in between these two steps,  the getProperty() method of 
FactoryBase calls getEAllStructuralFeatures() in order to retrieve a newly 
created, but as yet uninitialized property. This method caches all structural 
features,  and it is true that all structural features are present.  But it 
does more than this,  in that it caches state associated with the nature of the 
features,  such as as which features are containments and which are not.  At 
the time that the caching is done this information has not been set.

The result of this is that the call to ChangeRecorder.addAdapter, which 
recurses over the containment hierarchy,  has an incorrect view of the 
containment hierarchy.

We need to avoid calling getEAllStructuralFeatures while metadata is still in 
the process of being established.  I will investigate a way of altering the 
generator template so that it uses the local index into the classes local 
features. 

> Changesummary of datagraph using static interfaces.
> ---------------------------------------------------
>
>                 Key: TUSCANY-1305
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1305
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-Next
>            Reporter: Steffen Glomb
>         Attachments: sources.zip
>
>
> I cant get Changesummary on a datagraph working correctly with the following 
> contents: (hope this is a realy a bug this time)
> Schema, generated by the xsdhelper:
> <xs:schema 
>       xmlns:sdo="commonj.sdo"         xmlns:sdoJava="commonj.sdo/java"        
> xmlns:stn_1="http://example.com/customer";       
> xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
>       attributeFormDefault="qualified"        elementFormDefault="qualified"  
> targetNamespace="http://example.com/customer";>
>       <xs:complexType abstract="false" name="Account">
>               <xs:sequence/>
>               <xs:attribute default="0" name="accountNum" type="xs:int"/>
>       </xs:complexType>
>       <xs:element name="account" type="stn_1:Account"/>
>       <xs:complexType abstract="false" name="Customer">
>               <xs:sequence>
>                       <xs:element name="account" type="stn_1:Account"/>
>               </xs:sequence>
>               <xs:attribute name="firstName" type="xs:string"/>
>       </xs:complexType>
>       <xs:element name="customer" type="stn_1:Customer"/>
> </xs:schema>
> After generation of interfaces the following code fails to work as I would 
> expect, because the changesummary does not contain the changed dataobject in 
> the graph.
> ....
> import org.apache.tuscany.sdo.api.SDOUtil;
> import com.example.customer.Account;
> import com.example.customer.Customer;
> import com.example.customer.CustomerFactory;
> import commonj.sdo.DataGraph;
> import commonj.sdo.Type;
> import commonj.sdo.helper.HelperContext;
> import commonj.sdo.impl.HelperProvider;
> public class TestChangesummary extends TestCase {
>       public void testChangeSummaryOnDatagraphWithContainmentStatic() throws 
> Exception {
>               
>               HelperContext hc = HelperProvider.getDefaultContext();
>               CustomerFactory.INSTANCE.register(hc);          
>               
>               Type customerType = hc.getTypeHelper().getType(Customer.class); 
>         
>               DataGraph dataGraph = SDOUtil.createDataGraph();
>               Customer customer = (Customer) 
> dataGraph.createRootObject(customerType);
>       
>               Account account = CustomerFactory.INSTANCE.createAccount();
>               customer.setAccount(account);
>               customer.setFirstName("John");
>               customer.getAccount().setAccountNum(1234);
>                       
>           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
>               SDOUtil.saveDataGraph(dataGraph, outputStream, null);
>               DataGraph loadDataGraph = SDOUtil.loadDataGraph(new 
> ByteArrayInputStream(outputStream.toByteArray()), null);
>               
>               loadDataGraph.getChangeSummary().beginLogging();
>               
>               customer = (Customer) loadDataGraph.getRootObject();
>               customer.getAccount().setAccountNum(987);               
>               
>               loadDataGraph.getChangeSummary().endLogging();
>               
>               List changedDataObjects = 
> loadDataGraph.getChangeSummary().getChangedDataObjects();             
>        assertEquals("in fact 1 Object was changed in the code", 1, 
> changedDataObjects.size());            
>       }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to