* input: changeSummary output: createdDataObjects, deletedDataObjects & modifiedDataObjects
* implement: careful if compute from changeSummary.getChangedDataObjects() since it also includes children of deleted objects (thank Frank)
*/
if (changeSummary.isLogging())
((ChangeSummaryImpl) changeSummary).summarize();
ChangeDescription changeDescription = (ChangeDescription) changeSummary;
Iterator createdDataObjects = changeDescription.getObjectsToDetach().iterator();
deletedDataObjects = changeDescription.getObjectsToAttach();
EMap objectChanges = changeDescription.getObjectChanges();
modifiedDataObjects = objectChanges.keySet(); // may contain DO(s) from createdDataObjects and/or deletedDataObjects
/*
* 6-2. Prepare to compute (X)Path
* input: changeSummary
* output: rootResource
*/
/*not to support DataGraph 3-3
Object dataGraph = changeSummary.getDataGraph();
if (dataGraph == null) {
DataObject rootObject = changeSummary.getRootObject();
// assert rootObject != null;
rootResource = rootObject.getContainer() == null ? ((EObject) rootObject).eResource() // Can be null since this *StAX* writer does NOT
// require rootObject contained by an *EMF* Resource
: null; // eResource() direct content may not necessarily always be the XML document
} else
// assert dataGraph instanceof DataGraphImpl;
rootResource = ((org.apache.tuscany.sdo.impl.DataGraphImpl) dataGraph).getRootResource(); */
/*
* 6-2. Start ChangeSummary element
* input: writer, options, elementCS, changeSummary & changeDescription (6-1)
*/
nsPrefixSuffix = 0;
this.writer = writer;
this.options = options;
lineBreak = "";
indent = margin = pathRootObject = STRING_OPTION;
nest = 0;
changeSummaryElementNS = changeSummaryElement.getNamespaceURI();
changeSummaryElementName = changeSummaryElement.getLocalPart();
writeStartElement(changeSummaryElement.getPrefix(), changeSummaryElementNS, changeSummaryElementName);
lineBreak = STRING_OPTION;
rootObject = changeSummary.getRootObject();
extendedMetaData = (ExtendedMetaData) options.get(XMLResource.OPTION_EXTENDED_META_DATA);
if (extendedMetaData == null)
{
extendedMetaData = ExtendedMetaData.INSTANCE;
xsdHelper = XSDHelper.INSTANCE;
}
else{
xsdHelper = (new HelperContextImpl(extendedMetaData, false)).getXSDHelper();
}
Property declaration = changeSummaryElementNS == null
? rootObject.getType().getProperty(changeSummaryElementName)
: xsdHelper.getGlobalProperty(changeSummaryElementNS, changeSummaryElementName, true);
if (declaration != null)
{
EClassifier type = changeDescription.eClass();
if (type != declaration.getType() && type != CHANGE_SUMMARY)
writeGlobalAttribute(ExtendedMetaData.XSI_PREFIX, ExtendedMetaData.XSI_URI, XMLResource.TYPE, new StringBuffer(prefix(extendedMetaData.getNamespace(type), null))
.append(':').append(extendedMetaData.getName(type)).toString());
}