summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-12-20 07:08:03 (EST)
committer Stephan Born2013-01-25 12:36:48 (EST)
commit007c15362659b165548744e1b0f190b4d7fafdfb (patch)
tree0d66dbe33cce25a999bb438a4330bae1e26a2839
parentae3c5a911e0c6c5d4b14f82aeabcb2ee53368b3b (diff)
downloadorg.eclipse.stardust.ui.web-007c15362659b165548744e1b0f190b4d7fafdfb.zip
org.eclipse.stardust.ui.web-007c15362659b165548744e1b0f190b4d7fafdfb.tar.gz
org.eclipse.stardust.ui.web-007c15362659b165548744e1b0f190b4d7fafdfb.tar.bz2
Jira-ID: CRNT-27424 Pepper: External Packages and Filereferences not removed from XPDL correctly when Structured Data changed to local reference
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@61683 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/ExternalReferenceChangeTracker.java75
1 files changed, 49 insertions, 26 deletions
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/ExternalReferenceChangeTracker.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/ExternalReferenceChangeTracker.java
index 1f02b30..81dfecd 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/ExternalReferenceChangeTracker.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/ExternalReferenceChangeTracker.java
@@ -9,6 +9,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl;
import org.eclipse.stardust.model.xpdl.builder.session.Modification;
import org.eclipse.stardust.model.xpdl.builder.utils.WebModelerConnectionManager;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
import org.eclipse.stardust.model.xpdl.carnot.IExtensibleElement;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.util.AttributeUtil;
@@ -37,39 +38,62 @@ public class ExternalReferenceChangeTracker implements ChangePostprocessor
{
Collection<EObject> removedList = change.getRemovedElements();
+ Collection<EObject> modifiedList = change.getModifiedElements();
- ModelType model = null;
-
- if (!removedList.isEmpty())
+ if ( !removedList.isEmpty())
{
EObject removedElement = (EObject) removedList.toArray()[0];
if (removedElement.eContainer() instanceof ChangeDescriptionImpl)
{
- ChangeDescriptionImpl changeDescription = (ChangeDescriptionImpl) removedElement
- .eContainer();
+ ChangeDescriptionImpl changeDescription = (ChangeDescriptionImpl) removedElement.eContainer();
EObject container = changeDescription.getOldContainer(removedElement);
- model = ModelUtils.findContainingModel(container);
- List<String> uris = ModelUtils.getURIsForExternalPackages(model);
- for (Iterator<String> i = uris.iterator(); i.hasNext();)
+ trackExternalReferences(change, container);
+ }
+ }
+
+ if ( !modifiedList.isEmpty())
+ {
+ EObject modifiedElement = (EObject) modifiedList.toArray()[0];
+ trackExternalReferences(change, modifiedElement);
+ }
+
+ }
+
+ private void trackExternalReferences(Modification change, EObject container)
+ {
+ ModelType model;
+ model = ModelUtils.findContainingModel(container);
+ if (model == null)
+ {
+ if (container instanceof DataType)
+ {
+ DataType dataType = (DataType) container;
+ if (dataType.getType() != null)
{
- String uri = i.next();
- WebModelerConnectionManager cm = (WebModelerConnectionManager) model
- .getConnectionManager();
- Connection connection = (Connection) cm.findConnection(uri);
- List<EObject> references = this.getExternalReferences(model,
- (Connection) connection);
- if (references.size() == 1)
- {
- ExternalPackage externalReference = (ExternalPackage) references.get(0);
- removeConnection(externalReference);
- model.getExternalPackages().getExternalPackage()
- .remove(externalReference);
- change.markAlsoRemoved(externalReference);
- change.markAlsoModified(model);
- }
+ model = ModelUtils.findContainingModel(dataType.getType());
}
}
-
+ }
+ if (model == null)
+ {
+ return;
+ }
+ List<String> uris = ModelUtils.getURIsForExternalPackages(model);
+ for (Iterator<String> i = uris.iterator(); i.hasNext();)
+ {
+ String uri = i.next();
+ WebModelerConnectionManager cm = (WebModelerConnectionManager) model.getConnectionManager();
+ Connection connection = (Connection) cm.findConnection(uri);
+ List<EObject> references = this.getExternalReferences(model,
+ (Connection) connection);
+ if (references.size() == 1)
+ {
+ ExternalPackage externalReference = (ExternalPackage) references.get(0);
+ removeConnection(externalReference);
+ model.getExternalPackages().getExternalPackage().remove(externalReference);
+ change.markAlsoRemoved(externalReference);
+ change.markAlsoModified(model);
+ }
}
}
@@ -80,8 +104,7 @@ public class ExternalReferenceChangeTracker implements ChangePostprocessor
IConnectionManager.URI_ATTRIBUTE_NAME);
ConnectionImpl connection = (ConnectionImpl) model.getConnectionManager()
.findConnection(uri);
- WebModelerConnectionManager man = (WebModelerConnectionManager) model
- .getConnectionManager();
+ WebModelerConnectionManager man = (WebModelerConnectionManager) model.getConnectionManager();
man.getRepository().getConnection().remove(connection);
}