}
n = n.getNextSibling();
}
//instead of iterating over all props can we just check elements in cs and get appropriate properties from DO
for (int k = 0; k < modifiedProps.size(); k++) {
SDOProperty nextProp = (SDOProperty)modifiedProps.get(k);
if (!nextProp.getType().isDataType()) {
if (nextProp.isMany()) {
//original value is the list from the changesummary xml
List originalValue = unmarshalledDO.getList(nextProp);
List newList = new ArrayList();
List toDelete = new ArrayList();
List indexsToDelete = new ArrayList();
for (int l = 0; l < originalValue.size(); l++) {
SDODataObject nextInList = (SDODataObject)originalValue.get(l);
String sdoRef = nextInList._getSdoRef();
if (sdoRef != null) {
//if sdoRef is not null then object is modified
String sdoRefPath = convertXPathToSDOPath(sdoRef);
int nextSlash = sdoRefPath.indexOf('/');
if(nextSlash != -1) {
sdoRefPath = sdoRefPath.substring(nextSlash + 1);
} else {
sdoRefPath = "/";
}
newList.add(targetDataObject.getDataObject(sdoRefPath));
} else {
//if sdo ref is null there is a deleted object
toDelete.add(nextInList);
indexsToDelete.add(new Integer(l));
newList.add(nextInList);
}
}
//lw is the list from the real current data object
ListWrapper lw = ((ListWrapper)nextModifiedDO.getList(nextProp));
if (indexsToDelete.size() > 0) {
//after this loop, lw will have the entire list when logging was turned on
nextCS.pauseLogging();
for (int m = 0; m < indexsToDelete.size(); m++) {
int toDeleteIndex = ((Integer)indexsToDelete.get(m)).intValue();
SDODataObject nextToDelete = (SDODataObject)toDelete.get(m);
lw.add(toDeleteIndex, nextToDelete);
}
nextCS.setPropertyInternal(nextModifiedDO, nextProp, lw);
SDOSequence nextSeq = ((SDOSequence)nextCS.getOriginalSequences().get(nextModifiedDO));
nextCS.resumeLogging();
nextModifiedDO._setModified(true);
for (int m = indexsToDelete.size() - 1; m >= 0; m--) {
int toDeleteIndex = ((Integer)indexsToDelete.get(m)).intValue();
SDODataObject nextToDelete = (SDODataObject)toDelete.get(m);
if(nextSeq != null){
nextSeq.addSettingWithoutModifyingDataObject(-1, nextProp, nextToDelete);
}
nextToDelete.resetChanges();
lw.remove(toDeleteIndex);
}
}
nextCS.getOriginalElements().put(lw, newList);
} else {
SDODataObject value = (SDODataObject)unmarshalledDO.getDataObject(nextProp);
if (value != null) {
String sdoRef = value._getSdoRef();
if (sdoRef != null) {
//modified
nextModifiedDO._setModified(true);
} else {
//deleted
value._setChangeSummary(nextCS);
nextModifiedDO._setModified(true);
nextCS.pauseLogging();
boolean wasSet = nextModifiedDO.isSet(nextProp);
Object existingValue = nextModifiedDO.get(nextProp);
// grab index of nextProp's Setting for use during setting below
Sequence nextModifiedDOSequence = nextModifiedDO.getSequence();
int settingIdx = -1;
if (nextModifiedDOSequence != null) {
settingIdx = ((SDOSequence)nextModifiedDOSequence).getIndexForProperty(nextProp);
}
value._setContainmentPropertyName(null);
value._setContainer(null);
nextModifiedDO.set(nextProp, value);
nextCS.setPropertyInternal(nextModifiedDO, nextProp, value);
SDOSequence nextSeq = ((SDOSequence)nextCS.getOriginalSequences().get(nextModifiedDO));
if(nextSeq != null){
nextSeq.addSettingWithoutModifyingDataObject(-1, nextProp, value);
}
nextCS.resumeLogging();
nextModifiedDO._setModified(true);
value.resetChanges();
value.delete();
if (wasSet) {
// need to add at the right pos in the list, not at the end
nextModifiedDO.set(nextProp, existingValue, false);
if (settingIdx != -1) {
((SDOSequence)nextModifiedDO.getSequence()).addSettingWithoutModifyingDataObject(settingIdx, nextProp, existingValue);
}
} else {
nextModifiedDO.unset(nextProp);
}
}
} else {
nextModifiedDO._setModified(true);
nextCS.setPropertyInternal(nextModifiedDO, nextProp, null);
}
}
} else {
nextModifiedDO._setModified(true);
Object value = unmarshalledDO.get(nextProp);
//lw is the list from the real current data object
if(nextProp.isMany()){
Property theProp = nextModifiedDO.getInstanceProperty(nextProp.getName());
if(theProp == null){
Property newProp = nextModifiedDO.defineOpenContentProperty(nextProp.getName(), new ArrayList(), nextProp.getType());
nextModifiedDO.set(newProp, new ArrayList());
theProp = newProp;
}
List lw = nextModifiedDO.getList(theProp.getName());
nextCS.setPropertyInternal(nextModifiedDO, theProp, lw);
nextCS.getOriginalElements().put(lw, ((ListWrapper)value).getCurrentElements());
}else{
nextCS.setPropertyInternal(nextModifiedDO, nextProp, value);
}
}
}
for (int k = 0; k < unsetValueList.size(); k++) {
Property nextProp = unmarshalledDO.getInstanceProperty((String)unsetValueList.get(k));
if (nextProp != null) {
Object oldValue = null;
if (nextProp.getType().isDataType() || nextProp.isMany()) {
//to get default
oldValue = unmarshalledDO.get(nextProp);
}
nextModifiedDO._setModified(true);
nextCS.setPropertyInternal(nextModifiedDO, nextProp, oldValue);