In talking to Frank yesterday, we decided that Tuscany 153 may not be
the problem that is blocking the DAS from implementing T-154. Our
issue is that:

1) We can't create a dynamic root object with the same URI as the
generated DataObjects because the implementation will attempt to
delegate to the generated package when we create the root object,
which will fail.

2) If we use a different URI, the change history does not work
correctly. I assumed this was because of T-153, but Frank believes
that this scenario should be working today and asked for a test case.

Attached is a simple test case that shows the problem. I'll just
attach an XSD instead of the generated types.
package org.apache.tuscany.das.rdb.test;

import java.util.Iterator;
import java.util.List;

import org.apache.tuscany.das.rdb.test.test.Customer;
import org.apache.tuscany.das.rdb.test.test.Order;
import org.apache.tuscany.das.rdb.test.test.impl.TestPackageImpl;
import org.apache.tuscany.sdo.util.SDOUtil;

import commonj.sdo.ChangeSummary;
import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import commonj.sdo.Property;
import commonj.sdo.Type;
import commonj.sdo.helper.TypeHelper;

public class Tuscany153 {

        public static void main(String[] args) {
                Tuscany153 test = new Tuscany153();
                test.runTest();
        }

        private void runTest() {                                        
                TypeHelper types = TypeHelper.INSTANCE;
                Type rootType = SDOUtil.createType(types, "rootURI", 
"DataGraphRoot", false);   
                Iterator i = 
TestPackageImpl.eINSTANCE.getEClassifiers().iterator();
                while ( i.hasNext()) {
                        Type type = (Type) i.next();
                        Property property = SDOUtil.createProperty(rootType, 
type.getName(), type);
                        SDOUtil.setMany(property,true);         
                        SDOUtil.setContainment(property, true);
                        
                }
                
                  // Create the DataGraph
        DataGraph g = SDOUtil.createDataGraph();

        // Create the root object
        DataObject root = g.createRootObject(rootType);
        Order order = (Order) root.createDataObject("Order");
        Customer customer = (Customer) root.createDataObject("Customer");
        ChangeSummary summary = g.getChangeSummary();   
        summary.beginLogging();
        
        order.setQuantity(5);
        customer.setID(5);
        
        // Changes to DataObjects in the graph do not show up
        printChanges(summary);
        
        Order order2 = (Order) root.createDataObject("Order");
        order2.setID(10);
       
        // Property changes on the root show up, changes on the child objects 
do not.
                printChanges(summary);     
       
                
        }

        private void printChanges(ChangeSummary summary) {
                List changes = summary.getChangedDataObjects();
                if ( changes.size() == 0)
                        System.out.println("No changes");
                else { 
                        Iterator i = changes.iterator();
                while ( i.hasNext()) {
                        System.out.println(i.next());
                }
                }
        }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to