summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-10-15 05:52:45 (EDT)
committerManik Kishore2012-10-15 05:52:45 (EDT)
commit30fb6a0e7bd0316183756b096cc0b680705c3a9e (patch)
tree4f52008125a88051e1923ad7076594afa21ad8e2
parentdef7244388fe35d8d08d1ab71daf96bec2bbce73 (diff)
downloadorg.eclipse.stardust.ui.web-30fb6a0e7bd0316183756b096cc0b680705c3a9e.zip
org.eclipse.stardust.ui.web-30fb6a0e7bd0316183756b096cc0b680705c3a9e.tar.gz
org.eclipse.stardust.ui.web-30fb6a0e7bd0316183756b096cc0b680705c3a9e.tar.bz2
CRNT-26156 Pepper: 'Participant' does not update to the Lane Participant
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@60032 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/LaneParticipantChangeTracker.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/LaneParticipantChangeTracker.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/LaneParticipantChangeTracker.java
new file mode 100644
index 0000000..d079094
--- /dev/null
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/postprocessing/LaneParticipantChangeTracker.java
@@ -0,0 +1,83 @@
+package org.eclipse.stardust.ui.web.modeler.edit.postprocessing;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.stardust.model.xpdl.builder.session.Modification;
+import org.eclipse.stardust.model.xpdl.carnot.ActivitySymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.ActivityType;
+import org.eclipse.stardust.model.xpdl.carnot.CarnotWorkflowModelPackage;
+import org.eclipse.stardust.model.xpdl.carnot.IModelParticipant;
+import org.eclipse.stardust.model.xpdl.carnot.LaneSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.util.ActivityUtil;
+import org.eclipse.stardust.ui.web.modeler.edit.spi.ChangePostprocessor;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LaneParticipantChangeTracker implements ChangePostprocessor
+{
+ private static final CarnotWorkflowModelPackage PKG_XPDL = CarnotWorkflowModelPackage.eINSTANCE;
+
+ private Modification modification;
+
+ @Override
+ public int getInspectionPhase()
+ {
+ return 100;
+ }
+
+ @Override
+ public void inspectChange(Modification change)
+ {
+ modification = change;
+ for (EObject candidate : change.getModifiedElements())
+ {
+ if ((candidate instanceof LaneSymbol)
+ && change
+ .wasModified(candidate, PKG_XPDL.getISwimlaneSymbol_Participant()))
+ {
+ LaneSymbol lane = (LaneSymbol) candidate;
+ IModelParticipant participant = lane.getParticipant();
+ setParticipant(lane, participant);
+ }
+ }
+ }
+
+ private void setParticipant(LaneSymbol lane, IModelParticipant participant)
+ {
+ List<ActivitySymbolType> activitySymbols = lane.getActivitySymbol();
+ for (int i = 0; i < activitySymbols.size(); i++)
+ {
+ ActivitySymbolType activitySymbol = (ActivitySymbolType) activitySymbols.get(i);
+ ActivityType activity = (ActivityType) activitySymbol.getModelElement();
+
+ if (ActivityUtil.isInteractive(activity))
+ {
+ setPerformer(activity, participant, activity.getPerformer(), false);
+ }
+ }
+ }
+
+
+
+
+ private void setPerformer(ActivityType activity, IModelParticipant newPerformer,
+ IModelParticipant originalPerformer, boolean updateConnectionsOnly)
+ {
+ if (!updateConnectionsOnly && newPerformer != originalPerformer)
+ {
+ activity.setPerformer(newPerformer);
+ modification.markAlsoModified(activity);
+ }
+
+ }
+
+ public static String getPerformerName(IModelParticipant performer)
+ {
+ return performer == null ? "" : performer.getName() != null //$NON-NLS-1$
+ ? performer.getName()
+ : performer.getId() != null ? performer.getId() : Long.toString(performer
+ .getElementOid());
+ }
+
+}