You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by fr...@apache.org on 2007/07/13 23:05:22 UTC
svn commit: r556147 -
/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java
Author: frankb
Date: Fri Jul 13 14:05:21 2007
New Revision: 556147
URL: http://svn.apache.org/viewvc?view=rev&rev=556147
Log:
Fix for TUSCANY-1421
Modified:
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java
Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java?view=diff&rev=556147&r1=556146&r2=556147
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java Fri Jul 13 14:05:21 2007
@@ -43,6 +43,7 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
@@ -175,23 +176,26 @@
protected void save(OutputStream outputStream, Document document, Object options) throws IOException
{
EObject oldContainer = null;
+ Resource oldResource = null;
EReference oldContainmentReference = null;
int oldContainmentIndex = -1;
if (documentRoot != null)
{
- //TODO also check if rootObject is directly contained in a resource
oldContainer = rootObject.eContainer();
if (oldContainer != null)
- {
oldContainmentReference = rootObject.eContainmentFeature();
- }
+ else
+ oldResource = rootObject.eResource();
if (oldContainer != documentRoot || oldContainmentReference != rootElement)
{
- if (oldContainmentReference != null && FeatureMapUtil.isMany(oldContainer, oldContainmentReference))
+ if (oldResource != null)
{
- oldContainmentIndex = ((List)oldContainer.eGet(oldContainmentReference)).indexOf(rootObject);
+ oldContainmentIndex = oldResource.getContents().indexOf(rootObject);
+ oldResource.getContents().remove(oldContainmentIndex);
}
+ else if (oldContainmentReference != null && FeatureMapUtil.isMany(oldContainer, oldContainmentReference))
+ oldContainmentIndex = ((List)oldContainer.eGet(oldContainmentReference)).indexOf(rootObject);
Object rootValue =
rootElement instanceof EAttribute && rootObject instanceof SimpleAnyTypeDataObject ?
@@ -206,23 +210,26 @@
else // if (document != null)
resource.save(document, (Map)options, null);
- if (oldContainer != null)
+ if (oldResource != null)
{
- if (oldContainer != documentRoot || oldContainmentReference != rootElement)
+ oldResource.getContents().add(oldContainmentIndex, rootObject);
+ }
+ if (rootElement instanceof EReference)
+ {
+ if (oldContainer != null)
{
- if (FeatureMapUtil.isMany(oldContainer, oldContainmentReference))
- {
- ((List)oldContainer.eGet(oldContainmentReference)).add(oldContainmentIndex, rootObject);
- }
- else
+ if (oldContainer != documentRoot || oldContainmentReference != rootElement)
{
- oldContainer.eSet(oldContainmentReference, rootObject);
+ if (FeatureMapUtil.isMany(oldContainer, oldContainmentReference))
+ ((List)oldContainer.eGet(oldContainmentReference)).add(oldContainmentIndex, rootObject);
+ else
+ oldContainer.eSet(oldContainmentReference, rootObject);
}
}
- }
- else if (documentRoot != null)
- {
- documentRoot.eSet(rootElement, null);
+ else if (documentRoot != null)
+ {
+ documentRoot.eSet(rootElement, null);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org