Frank,
Not sure how well the dev list handles attachments, but here is a test case for the change summary issue. Any suggestions for eliminating the remaining EMF artifacts in the test case would be helpful too.
As long as summarize() is populating the list of changes, we should be fine on that front.
Brent
On 1/31/06, Frank Budinsky <[EMAIL PROTECTED]> wrote:
Hi Brent,
I can't reproduce the problem you're having. I tried changing
ChangeSummaryTestCase so that it creates the datagraph and then calls
beginLogging() and it still works fine for me. I'll need you to give me a
simple test program that reproduces the problem you're seeing.
The behavior of summarize() hasn't changed since SDO1. You should be able
to just call summarize() as you did before. You shouldn't be calling
beginLogging() after that though, because it will still be logging. That's
the same as it was in SDO 1 - summarize() never turned off logging, it
just refreshed the current result.
Frank.
Brent Daniel <[EMAIL PROTECTED]> wrote on 01/31/2006 02:30:38 PM:
> Frank,
>
> I still have the issue that change recording is not taking place if
> beginRecording() is called after a DataGraph has already been built.
> Everything seems to work fine if it is turned on before initially
creating
> DataObject instances. I traced it down as far as
> DataObjectImpl.eNotificationRequired(), which returns false because the
> changeRecorder is null.
>
> I've also tried calling beginRecording(), building the data graph,
calling
> endRecording() and beginRecording() again. In this case, there is a
> changeRecorder object there, but for some reason the changes still do
not
> show up in the change history.
>
> The change to the behavior of summarize() is a problem for the DAS.
> Currently, we are calling summarize() to stop recording because
endLogging()
> followed by beginLogging() will blow away the change history. With
> summarize() and resumeLogging(), if we encounter an error while pushing
the
> changes to the database we can return the data graph in the state that
it
> was sent to us and allow the user to work around the problem. Using
> endLogging(), the user is forced to start over. We don't really need a
> summarize() command, but we do need the change history to be available
to us
> without having to call endLogging(). Not sure if this has changed since
the
> SDO1 implementation, but we have always had to call either summarize()
or
> endLogging() to force the runtime to populate the change history.
>
> Brent
>
>
> On 1/31/06, Frank Budinsky (JIRA) <[EMAIL PROTECTED]> wrote:
> >
> > [ http://issues.apache.org/jira/browse/TUSCANY-21?page=all ]
> >
> > Frank Budinsky resolved TUSCANY-21:
> > -----------------------------------
> >
> > Resolution: Invalid
> >
> > I don't think these are problems:
> >
> > 1) The EMF adapter list (eAdapters) isn't used to attach the change
> > recorder to dataobjects in SDO2. There is a dedicated instance
variable (
> > DataObjectImpl.changeRecorder) that is used for this. So even though
you
> > don't see an adapter, it still should be recording changes after you
call
> > beginLogging().
> >
> > 2) You need to call endLogging() before you call resumeLogging(). The
> > summarize() method doesn't stop logging so calling resumeLogging()
after
> > summarize() will fail. Note that summarize() and resumeLogging() are
> > implementation methods and not part of the SDO2 API, so use of them
should
> > be avoided.
> >
> > > SDO change summary not working properly
> > > ---------------------------------------
> > >
> > > Key: TUSCANY-21
> > > URL: http://issues.apache.org/jira/browse/TUSCANY-21
> > > Project: Tuscany
> > > Type: Bug
> > > Components: Java SDO Implementation
> > > Reporter: Brent Daniel
> >
> > >
> > > I'm having trouble with the change history in the SDO 2
implementation.
> > > 1) The normal pattern in the DAS is to build a data graph and then
turn
> > on change recording. When you do this, the adapter for the change
recorder
> > doesn't seem to get added to the DataObject instances in the graph, so
no
> > changes are recorded.
> > > 2) You can't do a summarize() and then resumeLogging(). The
> > implementation will complain that logging is still enabled.
> >
> > --
> > This message is automatically generated by JIRA.
> > -
> > If you think it was sent incorrectly contact one of the
administrators:
> > http://issues.apache.org/jira/secure/Administrators.jspa
> > -
> > For more information on JIRA, see:
> > http://www.atlassian.com/software/jira
> >
> >
package sandbox; import java.io.IOException; import java.io.InputStream; import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sdo.SDOFactory;
import org.apache.tuscany.sdo.impl.AttributeImpl;
import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl;
import org.apache.tuscany.sdo.impl.ReferenceImpl;
import org.apache.tuscany.sdo.util.DataObjectUtil;
import org.apache.tuscany.sdo.util.SDOUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import commonj.sdo.ChangeSummary;
import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import commonj.sdo.Type;
import commonj.sdo.helper.TypeHelper;
import commonj.sdo.helper.XSDHelper;
public class ChangeSummaryTest extends TestCase {
private EPackage dataGraphPackage;
public void testCS() {
initializeTypes();
DataObject rootObject = createDataGraph();
DataObject customer = rootObject.createDataObject("customer");
customer.setInt("id", 5);
ChangeSummary summary =
rootObject.getDataGraph().getChangeSummary();
summary.beginLogging();
customer.setInt("id", 6);
summary.endLogging();
System.out.println("Change Summary size after 1 change: "
+ summary.getChangedDataObjects().size());
}
private void initializeTypes() {
try {
URL url = getClass().getResource("/xml/sdoModel.xsd");
if (url == null)
throw new RuntimeException(
"Could not find resource:
xml/sdoModel.xsd");
InputStream inputStream = url.openStream();
XSDHelper.INSTANCE.define(inputStream, url.toString());
inputStream.close();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
private DataObject createDataGraph() {
Type type = createSchema();
DataGraph g = SDOUtil.createDataGraph();
ResourceSet resourceSet = DataObjectUtil.createResourceSet();
Resource r =
resourceSet.createResource(URI.createURI(type.getURI()));
r.getContents().add(g);
// Create the root object
return g.createRootObject(type);
}
private Type createSchema() {
EClass rootObject = (EClass) SDOFactory.eINSTANCE.createClass();
rootObject.setName("DataGraphRoot");
getEPackage().getEClassifiers().add(rootObject);
EClass customer = (EClass) SDOFactory.eINSTANCE.createClass();
customer.setName("customer");
Type dataType = TypeHelper.INSTANCE.getType("commonj.sdo",
"Integer");
AttributeImpl attr = (AttributeImpl)
getFactory().createAttribute();
attr.setName("id");
attr.setEType((EClassifier) dataType);
attr.setUnique(false);
customer.getEStructuralFeatures().add(attr);
getEPackage().getEClassifiers().add(customer);
EReference ref = createEReference("customer", customer);
rootObject.getEStructuralFeatures().add(ref);
return (Type) rootObject;
}
public EPackage getEPackage() {
if (this.dataGraphPackage == null)
this.dataGraphPackage = createEPackage();
return this.dataGraphPackage;
}
protected EPackage createEPackage() {
EPackage pkg = EcoreFactory.eINSTANCE.createEPackage();
pkg.setName("name");
pkg.setNsPrefix("prefix");
pkg.setNsURI("datagraph.ecore");
pkg.setEFactoryInstance(new EFactoryImpl() {
public EObject basicCreate(EClass cls) {
EObject result = new DynamicDataObjectImpl(cls);
return result;
}
});
return pkg;
}
public EReference createEReference(String name, EClass type) {
ReferenceImpl ref = (ReferenceImpl)
getFactory().createReference();
ref.setName(name);
ref.setEType(type);
ref.setLowerBound(0);
ref.setUpperBound(-1);
ref.setContainment(true);
ref.setResolveProxies(false);
ref.setChangeable(true);
return ref;
}
private SDOFactory getFactory() {
return SDOFactory.eINSTANCE;
}
}
