/**
* Fix originalValueStores by deep copying the original dataObject:key and the original valueStore:value
* key is original deleted object in [deepCopies] - value is copy of the ValueStore
*/
ValueStore aVSCopy = null;
ValueStore aVSOriginal = null;
for (Iterator anIterator = originalCS.getOriginalValueStores().keySet().iterator();
anIterator.hasNext();) {
anOriginalObject = (DataObject)anIterator.next();
// deep copy to get corresponding copy DataObject (deleted objects were added to doMap)
aCopyOfOriginalObject = (DataObject)origDOCS1toCopyDOCS2Map.get(anOriginalObject);
/**
* Recursively shallow-copy elements (by iterating the ovs map and iterating the properties of each item)
* Fix the dataObject pointer
*/
aVSCopy = createValueStore();
aVSOriginal = (ValueStore)originalCS.getOriginalValueStores().get(anOriginalObject);
// changes made to the copy VS must not affect the original -hence the dataObject field must be a copy of the original
aVSCopy.initialize(aCopyOfOriginalObject);
Object aVSPropertyItem = null;
// get the # of non-opencontent properties for the object holding the CS - do not use DVS.getTypePropertyValues()
for (int size = ((SDOType) anOriginalObject.getType()).getDeclaredProperties().size(), i = 0;
i < size; i++) {
aVSPropertyItem = aVSOriginal.getDeclaredProperty(i);
// only iterate set properties
if (aVSOriginal.isSetDeclaredProperty(i)) {
// shallow copy the object values
// handle single case
SDOProperty currentProperty = (SDOProperty)((SDOType)anOriginalObject.getType()).getDeclaredProperties().get(i);
if (currentProperty.isMany()) {
propertyToOriginalListMap.put(aVSPropertyItem, currentProperty);
// handle many case - handled by originalElements
// container DO must be in our reference map
SDODataObject copyContainer = (SDODataObject)origDOCS1toCopyDOCS2Map.get(anOriginalObject);
ListWrapper aCopyOfListCopy = (ListWrapper)((DataObject)copyContainer).getList(currentProperty);
// add reference of new copy of original List keyed on original List
copyListWrapperCS2toCopyOfListCS2Map.put((anOriginalObject).getList(currentProperty), aCopyOfListCopy);
aVSCopy.setDeclaredProperty(i, aCopyOfListCopy);
} else {
// COMPLEX SINGLE
if (!currentProperty.getType().isDataType()) {
// are we using the cast to DataObject as a sort of instance check that would throw a CCE?
aVSCopy.setDeclaredProperty(i, origDOCS1toCopyDOCS2Map.get(aVSPropertyItem));
} else {
// SIMPLE SINGLE
// skip changeSummary property
if (!currentProperty.getType().isChangeSummaryType()) {
// simple singles set
aVSCopy.setDeclaredProperty(i, aVSPropertyItem);
}
}
}
}
}
// create list of unset and current open content properties
List ocPropertiesList = new ArrayList();
ocPropertiesList.addAll(originalCS.getUnsetOCProperties(anOriginalObject));
// add existing properties
ocPropertiesList.addAll(((SDODataObject)anOriginalObject)._getOpenContentProperties());
ocPropertiesList.addAll(((SDODataObject)anOriginalObject)._getOpenContentPropertiesAttributes());
// iterate existing open content properties
for (Iterator i = ocPropertiesList.iterator(); i.hasNext();) {
SDOProperty ocProperty = (SDOProperty)i.next();
if (aVSOriginal.isSetOpenContentProperty(ocProperty)) {
// get oc value
Object anOCPropertyItem = aVSOriginal.getOpenContentProperty(ocProperty);
// get oc copy - shallow copy the object values
if (ocProperty.isMany()) {
// handle many case - handled by originalElements
// container DO must be in our reference map