summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-07-20 06:07:14 (EDT)
committer Manik Kishore2012-07-30 01:50:20 (EDT)
commitf14ed6262bc942d6929db9602344b01903e3cb1f (patch)
tree49fa2b8c1ca03b883475cb692ae799436f6cc515
parent17401abf375cc58bfda737195fb0ead1c7f718af (diff)
downloadorg.eclipse.stardust.ui.web-f14ed6262bc942d6929db9602344b01903e3cb1f.zip
org.eclipse.stardust.ui.web-f14ed6262bc942d6929db9602344b01903e3cb1f.tar.gz
org.eclipse.stardust.ui.web-f14ed6262bc942d6929db9602344b01903e3cb1f.tar.bz2
Jira-ID: CRNT-25514,CRNT-25442
1)Added code to call command protocol from m_connection.js 2)Added code to create JSON response for TransitionConnectionType and Lanes in ModelElementMarshaller 3)Made changes in m_diagram.js to set the oid for connection in processCommand. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@57806 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/CommandHandlingMediator.java5
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/ConnectionCommandHandler.java474
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementMarshaller.java185
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js10
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js28
5 files changed, 699 insertions, 3 deletions
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/CommandHandlingMediator.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/CommandHandlingMediator.java
index 3048e9b..1200e26 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/CommandHandlingMediator.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/CommandHandlingMediator.java
@@ -20,6 +20,7 @@ import org.eclipse.stardust.model.xpdl.builder.session.EditingSession;
import org.eclipse.stardust.model.xpdl.builder.session.Modification;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.ui.web.modeler.edit.diagram.node.ActivityCommandHandler;
+import org.eclipse.stardust.ui.web.modeler.edit.diagram.node.ConnectionCommandHandler;
import org.eclipse.stardust.ui.web.modeler.edit.diagram.node.EventCommandHandler;
import org.eclipse.stardust.ui.web.modeler.edit.diagram.node.GatewayCommandHandler;
import org.eclipse.stardust.ui.web.modeler.edit.diagram.node.MoveNodeSymbolHandler;
@@ -116,6 +117,10 @@ public class CommandHandlingMediator
{
handler = new ApplicationTypeChangeCommandHandler();
}
+ else if ("connection.create".equals(commandId) || "connection.delete".equals(commandId))
+ {
+ handler = new ConnectionCommandHandler();
+ }
Modification change = null;
if (null != handler)
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/ConnectionCommandHandler.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/ConnectionCommandHandler.java
new file mode 100644
index 0000000..362a462
--- /dev/null
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/ConnectionCommandHandler.java
@@ -0,0 +1,474 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SunGard CSA LLC and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SunGard CSA LLC - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package org.eclipse.stardust.ui.web.modeler.edit.diagram.node;
+
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractBoolean;
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractInt;
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractLong;
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractString;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.gson.JsonObject;
+
+import org.eclipse.stardust.common.error.ObjectNotFoundException;
+import org.eclipse.stardust.engine.api.model.PredefinedConstants;
+import org.eclipse.stardust.model.xpdl.builder.common.AbstractElementBuilder;
+import org.eclipse.stardust.model.xpdl.builder.utils.MBFacade;
+import org.eclipse.stardust.model.xpdl.builder.utils.ModelerConstants;
+import org.eclipse.stardust.model.xpdl.builder.utils.XpdlModelUtils;
+import org.eclipse.stardust.model.xpdl.carnot.ActivitySymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.ActivityType;
+import org.eclipse.stardust.model.xpdl.carnot.CarnotWorkflowModelFactory;
+import org.eclipse.stardust.model.xpdl.carnot.DataMappingConnectionType;
+import org.eclipse.stardust.model.xpdl.carnot.DataMappingType;
+import org.eclipse.stardust.model.xpdl.carnot.DataSymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.DirectionType;
+import org.eclipse.stardust.model.xpdl.carnot.EndEventSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.IIdentifiableElement;
+import org.eclipse.stardust.model.xpdl.carnot.ModelType;
+import org.eclipse.stardust.model.xpdl.carnot.ProcessDefinitionType;
+import org.eclipse.stardust.model.xpdl.carnot.StartEventSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.TransitionConnectionType;
+import org.eclipse.stardust.model.xpdl.carnot.TransitionType;
+import org.eclipse.stardust.model.xpdl.carnot.XmlTextNode;
+import org.eclipse.stardust.model.xpdl.carnot.util.ModelUtils;
+import org.eclipse.stardust.ui.web.modeler.edit.ICommandHandler;
+
+/**
+ *
+ * @author Sidharth.Singh
+ *
+ */
+public class ConnectionCommandHandler implements ICommandHandler
+{
+
+ @Override
+ public boolean isValidTarget(Class<? > type)
+ {
+ return IIdentifiableElement.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public void handleCommand(String commandId, EObject targetElement, JsonObject request)
+ {
+ ModelType model = ModelUtils.findContainingModel(targetElement);
+ ProcessDefinitionType processDefinition = ModelUtils.findContainingProcess(targetElement);
+ if ("connection.create".equals(commandId))
+ {
+ createConnection(model, processDefinition, request);
+ }
+ else if ("connection.delete".equals(commandId))
+ {
+ deleteConnection(model, processDefinition, request);
+ }
+
+ }
+
+ private void createConnection(ModelType model,
+ ProcessDefinitionType processDefinition, JsonObject request)
+ {
+
+ synchronized (model)
+ {
+ long maxOid = XpdlModelUtils.getMaxUsedOid(model);
+ if (ModelerConstants.ACTIVITY_KEY.equals(extractString(request,
+ ModelerConstants.FROM_MODEL_ELEMENT_TYPE))
+ || ModelerConstants.GATEWAY.equals(extractString(request,
+ ModelerConstants.FROM_MODEL_ELEMENT_TYPE)))
+ {
+ if (ModelerConstants.ACTIVITY_KEY.equals(extractString(request,
+ ModelerConstants.TO_MODEL_ELEMENT_TYPE))
+ || ModelerConstants.GATEWAY.equals(extractString(request,
+ ModelerConstants.TO_MODEL_ELEMENT_TYPE)))
+ {
+ createControlFlowConnection(
+ request,
+ processDefinition,
+ MBFacade.findActivitySymbol(processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID)),
+ MBFacade.findActivitySymbol(processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
+ maxOid);
+ }
+ else if (ModelerConstants.EVENT_KEY.equals(extractString(request,
+ ModelerConstants.TO_MODEL_ELEMENT_TYPE)))
+ {
+ try
+ {
+ StartEventSymbol startEventSymbol = MBFacade.findStartEventSymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID));
+
+ createControlFlowConnection(request, processDefinition,
+ startEventSymbol, MBFacade.findActivitySymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request,
+ ModelerConstants.FROM_MODEL_ELEMENT_OID)), maxOid);
+ }
+ catch (ObjectNotFoundException x)
+ {
+ EndEventSymbol endEventSymbol = MBFacade.findEndEventSymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID));
+ createControlFlowConnection(request, processDefinition,
+ MBFacade.findActivitySymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request,
+ ModelerConstants.FROM_MODEL_ELEMENT_OID)),
+ endEventSymbol, maxOid);
+ }
+ }
+ else if (ModelerConstants.DATA.equals(extractString(request,
+ ModelerConstants.TO_MODEL_ELEMENT_TYPE)))
+ {
+ createDataFlowConnection(
+ request,
+ processDefinition,
+ MBFacade.findActivitySymbol(processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID)),
+ MBFacade.findDataSymbol(processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
+ maxOid);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown target symbol type "
+ + extractString(request, ModelerConstants.TO_MODEL_ELEMENT_TYPE)
+ + " for connection.");
+ }
+ }
+ else if (ModelerConstants.EVENT_KEY.equals(extractString(request,
+ ModelerConstants.FROM_MODEL_ELEMENT_TYPE)))
+ {
+ if (ModelerConstants.ACTIVITY_KEY.equals(extractString(request,
+ ModelerConstants.TO_MODEL_ELEMENT_TYPE)))
+ {
+ try
+ {
+ StartEventSymbol startEventSymbol = MBFacade.findStartEventSymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID));
+
+ createControlFlowConnection(
+ request,
+ processDefinition,
+ startEventSymbol,
+ MBFacade.findActivitySymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
+ maxOid);
+ }
+ catch (ObjectNotFoundException x)
+ {
+ EndEventSymbol endEventSymbol = MBFacade.findEndEventSymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID));
+ createControlFlowConnection(
+ request,
+ processDefinition,
+ MBFacade.findActivitySymbol(
+ processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
+ endEventSymbol, maxOid);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown target symbol type "
+ + extractString(request, ModelerConstants.TO_MODEL_ELEMENT_TYPE)
+ + " for connection.");
+ }
+ }
+ else if (ModelerConstants.DATA.equals(extractString(request,
+ ModelerConstants.FROM_MODEL_ELEMENT_TYPE)))
+ {
+ if (ModelerConstants.ACTIVITY_KEY.equals(extractString(request,
+ ModelerConstants.TO_MODEL_ELEMENT_TYPE)))
+ {
+ createDataFlowConnection(
+ request,
+ processDefinition,
+ MBFacade.findActivitySymbol(processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
+ MBFacade.findDataSymbol(processDefinition.getDiagram().get(0),
+ extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID)),
+ maxOid);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown target symbol type "
+ + extractString(request, ModelerConstants.TO_MODEL_ELEMENT_TYPE)
+ + " for connection.");
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unsupported source symbol type "
+ + extractString(request, ModelerConstants.FROM_MODEL_ELEMENT_TYPE)
+ + " for connection.");
+ }
+ }
+ }
+
+ private void deleteConnection(ModelType model,
+ ProcessDefinitionType processDefinition, JsonObject request)
+ {
+ Long connectionOid = extractLong(request, ModelerConstants.OID_PROPERTY);
+ synchronized (model)
+ {
+ try
+ {
+ TransitionConnectionType transitionConnection = MBFacade.findTransitionConnectionByModelOid(
+ processDefinition, connectionOid);
+
+ processDefinition.getDiagram()
+ .get(0)
+ .getPoolSymbols()
+ .get(0)
+ .getTransitionConnection()
+ .remove(transitionConnection);
+
+ if (transitionConnection.getTransition() != null)
+ {
+ processDefinition.getTransition().remove(
+ transitionConnection.getTransition());
+ }
+ }
+ catch (ObjectNotFoundException x)
+ {
+ DataMappingConnectionType dataMappingConnection = MBFacade.findDataMappingConnectionByModelOid(
+ processDefinition, connectionOid);
+
+ processDefinition.getDiagram()
+ .get(0)
+ .getDataMappingConnection()
+ .remove(dataMappingConnection);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param sourceActivitySymbol
+ * @param targetActivitySymbol
+ * @throws JSONException
+ */
+ private void createControlFlowConnection(JsonObject connectionJson,
+ ProcessDefinitionType processDefinition,
+ ActivitySymbolType sourceActivitySymbol,
+ ActivitySymbolType targetActivitySymbol, long maxOid)
+ {
+ JsonObject controlFlowJson = connectionJson.getAsJsonObject(ModelerConstants.MODEL_ELEMENT_PROPERTY);
+ TransitionType transition = AbstractElementBuilder.F_CWM.createTransitionType();
+
+ processDefinition.getTransition().add(transition);
+
+ transition.setElementOid(++maxOid);
+ transition.setFrom(sourceActivitySymbol.getActivity());
+ transition.setTo(targetActivitySymbol.getActivity());
+ transition.setId(extractString(controlFlowJson, ModelerConstants.ID_PROPERTY));
+
+ if (extractBoolean(controlFlowJson, ModelerConstants.OTHERWISE_PROPERTY))
+ {
+ transition.setCondition(ModelerConstants.OTHERWISE_KEY);
+ }
+ else
+ {
+ transition.setCondition(ModelerConstants.CONDITION_KEY);
+
+ XmlTextNode expression = CarnotWorkflowModelFactory.eINSTANCE.createXmlTextNode();
+ ModelUtils.setCDataString(expression.getMixed(), "true", true);
+ transition.setExpression(expression);
+
+ }
+
+ // setDescription(transition,
+ // controlFlowJson.getString(DESCRIPTION_PROPERTY));
+
+ TransitionConnectionType transitionConnection = AbstractElementBuilder.F_CWM.createTransitionConnectionType();
+
+ transition.getTransitionConnections().add(transitionConnection);
+ transitionConnection.setTransition(transition);
+
+ transitionConnection.setElementOid(++maxOid);
+ transitionConnection.setSourceActivitySymbol(sourceActivitySymbol);
+ transitionConnection.setTargetActivitySymbol(targetActivitySymbol);
+ transitionConnection.setSourceAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.FROM_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+ transitionConnection.setTargetAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+
+ // TODO Obtain pool from call
+
+ processDefinition.getDiagram()
+ .get(0)
+ .getPoolSymbols()
+ .get(0)
+ .getTransitionConnection()
+ .add(transitionConnection);
+ }
+
+ /**
+ *
+ * @param connectionJson
+ * @param processDefinition
+ * @param sourceActivitySymbol
+ * @param targetActivitySymbol
+ * @param maxOid
+ */
+ private void createControlFlowConnection(JsonObject connectionJson,
+ ProcessDefinitionType processDefinition, StartEventSymbol startEventSymbol,
+ ActivitySymbolType targetActivitySymbol, long maxOid)
+ {
+ TransitionConnectionType transitionConnection = AbstractElementBuilder.F_CWM.createTransitionConnectionType();
+
+ transitionConnection.setElementOid(++maxOid);
+ transitionConnection.setSourceNode(startEventSymbol);
+ transitionConnection.setTargetNode(targetActivitySymbol);
+ transitionConnection.setSourceAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.FROM_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+ transitionConnection.setTargetAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+ processDefinition.getDiagram()
+ .get(0)
+ .getPoolSymbols()
+ .get(0)
+ .getTransitionConnection()
+ .add(transitionConnection);
+ }
+
+ /**
+ *
+ * @param connectionJson
+ * @param processDefinition
+ * @param sourceActivitySymbol
+ * @param targetActivitySymbol
+ * @param maxOid
+ */
+ private void createControlFlowConnection(JsonObject connectionJson,
+ ProcessDefinitionType processDefinition,
+ ActivitySymbolType sourceActivitySymbol, EndEventSymbol endEventSymbol,
+ long maxOid)
+ {
+ TransitionConnectionType transitionConnection = AbstractElementBuilder.F_CWM.createTransitionConnectionType();
+ transitionConnection.setElementOid(++maxOid);
+ transitionConnection.setSourceNode(sourceActivitySymbol);
+ transitionConnection.setTargetNode(endEventSymbol);
+ transitionConnection.setSourceAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.FROM_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+ transitionConnection.setTargetAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+ // TODO Obtain pool from call
+
+ processDefinition.getDiagram()
+ .get(0)
+ .getPoolSymbols()
+ .get(0)
+ .getTransitionConnection()
+ .add(transitionConnection);
+ }
+
+ /**
+ *
+ * @param connectionJson
+ * @param processDefinition
+ * @param sourceActivitySymbol
+ * @param dataSymbol
+ * @param maxOid
+ */
+ private void createDataFlowConnection(JsonObject connectionJson,
+ ProcessDefinitionType processDefinition, ActivitySymbolType activitySymbol,
+ DataSymbolType dataSymbol, long maxOid)
+ {
+
+ System.out.println("Create data flow connection");
+
+ DataType data = dataSymbol.getData();
+ ActivityType activity = activitySymbol.getActivity();
+
+ DataMappingType dataMapping = AbstractElementBuilder.F_CWM.createDataMappingType();
+ DataMappingConnectionType dataMappingConnection = AbstractElementBuilder.F_CWM.createDataMappingConnectionType();
+
+ // TODO Add index
+
+ dataMapping.setId(data.getId());
+ dataMapping.setName(data.getName());
+
+ dataMapping.setDirection(DirectionType.get(DirectionType.OUT));
+ dataMapping.setData(data);
+
+ // TODO Incomplete
+
+ // if (activity.getImplementation().getLiteral().equals("Application"))
+ // {
+ // dataMapping.setContext(PredefinedConstants.APPLICATION_CONTEXT);
+ // dataMapping.setApplicationAccessPoint(element.getProps().getEnds()
+ // .getAccesspoint());
+ // }
+ // else
+ // {
+ dataMapping.setContext(PredefinedConstants.DEFAULT_CONTEXT);
+ // }
+
+ activity.getDataMapping().add(dataMapping);
+
+ // TODO Obtain pool from call
+
+ processDefinition.getDiagram()
+ .get(0)
+ .getPoolSymbols()
+ .get(0)
+ .getDataMappingConnection()
+ .add(dataMappingConnection);
+
+ dataMappingConnection.setElementOid(++maxOid);
+ dataMappingConnection.setActivitySymbol(activitySymbol);
+ dataMappingConnection.setDataSymbol(dataSymbol);
+ activitySymbol.getDataMappings().add(dataMappingConnection);
+ dataSymbol.getDataMappings().add(dataMappingConnection);
+ dataMappingConnection.setSourceAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.FROM_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+ dataMappingConnection.setTargetAnchor(mapAnchorOrientation(extractInt(
+ connectionJson, ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY)));
+
+ }
+
+ /**
+ *
+ * @param orientation
+ * @return
+ */
+ public static String mapAnchorOrientation(int orientation)
+ {
+ if (orientation == ModelerConstants.NORTH_KEY)
+ {
+ return "top";
+ }
+ else if (orientation == ModelerConstants.EAST_KEY)
+ {
+ return "right";
+ }
+ else if (orientation == ModelerConstants.SOUTH_KEY)
+ {
+ return "bottom";
+ }
+ else if (orientation == ModelerConstants.WEST_KEY)
+ {
+ return "left";
+ }
+
+ throw new IllegalArgumentException("Illegal orientation key " + orientation + ".");
+ }
+
+}
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementMarshaller.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementMarshaller.java
index 947934d..0e67157 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementMarshaller.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementMarshaller.java
@@ -35,6 +35,7 @@ import org.eclipse.stardust.model.xpdl.carnot.StartEventSymbol;
import org.eclipse.stardust.model.xpdl.carnot.TransitionConnectionType;
import org.eclipse.stardust.model.xpdl.carnot.TransitionType;
//import org.eclipse.stardust.ui.web.modeler.service.ModelService;
+import org.eclipse.stardust.model.xpdl.carnot.impl.LaneSymbolImpl;
import org.eclipse.stardust.model.xpdl.carnot.impl.ProcessDefinitionTypeImpl;
import org.eclipse.stardust.model.xpdl.carnot.util.ActivityUtil;
import org.eclipse.stardust.model.xpdl.carnot.util.AttributeUtil;
@@ -69,6 +70,10 @@ public class ModelElementMarshaller
{
jsResult = toProcessDefinition((ProcessDefinitionType) modelElement);
}
+ else if (modelElement instanceof LaneSymbolImpl)
+ {
+ jsResult = toLaneSymbol((LaneSymbolImpl) modelElement);
+ }
else if (modelElement instanceof ActivitySymbolType)
{
jsResult = toActivitySymbolJson((ActivitySymbolType) modelElement);
@@ -81,6 +86,10 @@ public class ModelElementMarshaller
{
jsResult = toApplication((ApplicationType) modelElement);
}
+ else if (modelElement instanceof TransitionConnectionType)
+ {
+ jsResult = toTransitionType((TransitionConnectionType) modelElement);
+ }
else
{
jsResult = new JsonObject();
@@ -145,6 +154,42 @@ public class ModelElementMarshaller
return processJson;
}
+
+ /**
+ *
+ * @param laneSymbol
+ * @return
+ */
+ public static JsonObject toLaneSymbol(LaneSymbol laneSymbol)
+ {
+ int poolOffsetX = 0;
+ int poolOffsetY = 0;
+
+ PoolSymbol container = (laneSymbol.eContainer() instanceof PoolSymbol)
+ ? (PoolSymbol) laneSymbol.eContainer()
+ : null;
+
+ while (null != container)
+ {
+ poolOffsetX += container.getXPos();
+ poolOffsetX += container.getYPos();
+
+ // recurse
+ container = (container.eContainer() instanceof PoolSymbol)
+ ? (PoolSymbol) container.eContainer()
+ : null;
+ }
+
+ JsonObject laneSymbolJson = new JsonObject();
+ laneSymbolJson.addProperty(ModelerConstants.OID_PROPERTY,
+ laneSymbol.getElementOid());
+ laneSymbolJson.addProperty(ModelerConstants.ID_PROPERTY, laneSymbol.getId());
+ laneSymbolJson.addProperty(ModelerConstants.NAME_PROPERTY, laneSymbol.getName());
+
+ //TODO - Analyse and set other properties
+ return laneSymbolJson;
+
+ }
/**
* @return
@@ -194,7 +239,7 @@ public class ModelElementMarshaller
JsonObject laneSymbolJson = new JsonObject();
laneSymbols.add(laneSymbolJson);
- laneSymbolJson.addProperty(ModelerConstants.OID_PROPERTY,
+ laneSymbolJson.addProperty(ModelerConstants.OID_PROPERTY,
laneSymbol.getElementOid());
laneSymbolJson.addProperty(ModelerConstants.ID_PROPERTY, laneSymbol.getId());
laneSymbolJson.addProperty(ModelerConstants.NAME_PROPERTY,
@@ -877,6 +922,144 @@ public class ModelElementMarshaller
}
/**
+ *
+ * @param transitionConnection
+ * @return
+ */
+ public static JsonObject toTransitionType(TransitionConnectionType transitionConnection)
+ {
+ JsonObject connectionJson = new JsonObject();
+ JsonObject modelElementJson = new JsonObject();
+
+ // Common settings
+
+ connectionJson.addProperty(ModelerConstants.FROM_ANCHOR_POINT_ORIENTATION_PROPERTY,
+ mapAnchorOrientation(transitionConnection.getSourceAnchor()));
+ connectionJson.addProperty(ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY,
+ mapAnchorOrientation(transitionConnection.getTargetAnchor()));
+
+ if (transitionConnection.getTransition() != null)
+ {
+ TransitionType transition = transitionConnection.getTransition();
+
+ connectionJson.addProperty(ModelerConstants.OID_PROPERTY,
+ transitionConnection.getElementOid());
+ connectionJson.add(ModelerConstants.MODEL_ELEMENT_PROPERTY, modelElementJson);
+
+ modelElementJson.addProperty(ModelerConstants.TYPE_PROPERTY,
+ ModelerConstants.CONTROL_FLOW_LITERAL);
+ modelElementJson.addProperty(ModelerConstants.ID_PROPERTY, transition.getId());
+
+ if (transition.getCondition().equals("CONDITION"))
+ {
+ modelElementJson.addProperty(ModelerConstants.CONDITION_EXPRESSION_PROPERTY,
+ (String) transition.getExpression().getMixed().getValue(0));
+ modelElementJson.addProperty(ModelerConstants.OTHERWISE_PROPERTY, false);
+ }
+ else
+ {
+ modelElementJson.addProperty(ModelerConstants.OTHERWISE_PROPERTY, true);
+ }
+
+ loadDescription(modelElementJson, transition);
+ loadAttributes(transition, modelElementJson);
+
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_OID,
+ transition.getFrom().getActivitySymbols().get(0).getElementOid());
+
+ // TODO Hack to identify gateways
+
+ if (transition.getFrom().getId().toLowerCase().startsWith("gateway"))
+ {
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_TYPE,
+ ModelerConstants.GATEWAY);
+ }
+ else
+ {
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_TYPE,
+ ModelerConstants.ACTIVITY_KEY);
+ }
+
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_OID,
+ transition.getTo().getActivitySymbols().get(0).getElementOid());
+
+ if (transition.getTo().getId().toLowerCase().startsWith("gateway"))
+ {
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_TYPE,
+ ModelerConstants.GATEWAY);
+ connectionJson.remove(ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY);
+ connectionJson.addProperty(
+ ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY,
+ ModelerConstants.NORTH_KEY);
+ }
+ else
+ {
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_TYPE,
+ ModelerConstants.ACTIVITY_KEY);
+ }
+
+ }
+ else if (transitionConnection.getSourceNode() instanceof StartEventSymbol)
+ {
+
+ connectionJson.addProperty(ModelerConstants.OID_PROPERTY,
+ transitionConnection.getElementOid());
+ connectionJson.add(ModelerConstants.MODEL_ELEMENT_PROPERTY, modelElementJson);
+
+ modelElementJson.addProperty(ModelerConstants.TYPE_PROPERTY,
+ ModelerConstants.CONTROL_FLOW_LITERAL);
+ modelElementJson.addProperty(
+ ModelerConstants.ID_PROPERTY,
+ transitionConnection.getSourceNode().getElementOid()
+ + "-"
+ + ((ActivitySymbolType) transitionConnection.getTargetActivitySymbol()).getActivity()
+ .getId());
+
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_OID,
+ transitionConnection.getSourceNode().getElementOid());
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_TYPE,
+ ModelerConstants.EVENT_KEY);
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_OID,
+ transitionConnection.getTargetActivitySymbol().getElementOid());
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_TYPE,
+ ModelerConstants.ACTIVITY_KEY);
+ }
+ else if (transitionConnection.getTargetNode() instanceof EndEventSymbol)
+ {
+ connectionJson.addProperty(ModelerConstants.OID_PROPERTY,
+ transitionConnection.getElementOid());
+ connectionJson.add(ModelerConstants.MODEL_ELEMENT_PROPERTY, modelElementJson);
+ modelElementJson.addProperty(ModelerConstants.TYPE_PROPERTY,
+ ModelerConstants.CONTROL_FLOW_LITERAL);
+ modelElementJson.addProperty(
+ ModelerConstants.ID_PROPERTY,
+ ((ActivitySymbolType) transitionConnection.getSourceActivitySymbol()).getActivity()
+ .getId()
+ + "-"
+ + String.valueOf(transitionConnection.getTargetNode()
+ .getElementOid()));
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_OID,
+ transitionConnection.getSourceActivitySymbol().getElementOid());
+ connectionJson.addProperty(ModelerConstants.FROM_MODEL_ELEMENT_TYPE,
+ ModelerConstants.ACTIVITY_KEY);
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_OID,
+ String.valueOf(transitionConnection.getTargetNode().getElementOid()));
+ connectionJson.addProperty(ModelerConstants.TO_MODEL_ELEMENT_TYPE,
+ ModelerConstants.EVENT_KEY);
+
+ // For end event symbol the anchorpoint orientation is set to "bottom", in
+ // the eclipse modeler.
+ // This causes wrong routing of the the connector.
+ // Hence overriding the property with "center" / or "undefined"
+ connectionJson.remove(ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY);
+ connectionJson.addProperty(
+ ModelerConstants.TO_ANCHOR_POINT_ORIENTATION_PROPERTY,
+ ModelerConstants.UNDEFINED_ORIENTATION_KEY);
+ }
+ return connectionJson;
+ }
+
+ /**
* @param model
* @return
*/
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js
index c663637..82def52 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js
@@ -475,7 +475,11 @@ define(
*/
Connection.prototype.complete = function() {
this.completeNoTransfer();
- this.submitCreation();
+ /*this.submitCreation();*/
+ var command = m_command.createCreateNodeCommand("connection.create",
+ this.diagram.model.id, this.diagram.process.oid,
+ this.createTransferObject());
+ m_commandsController.submitCommand(command);
};
// TODO Move to drawable
@@ -1185,6 +1189,10 @@ define(
this.toAnchorPoint.symbol.connections, this);
m_utils.removeItemFromArray(
this.fromAnchorPoint.symbol.connections, this);
+
+ var command = m_command.createRemoveNodeCommand("connection.delete", this.diagram.model.id,
+ this.oid, this.createTransferObject());
+ m_commandsController.submitCommand(command);
};
/**
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
index cb3973e..6e42a4f 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
@@ -461,6 +461,21 @@ define(
return null;
};
+
+ /**
+ *
+ */
+ Diagram.prototype.findConnectionByModelId = function(id) {
+
+ for ( var i = 0; i < this.connections.length; i++) {
+ if (this.connections[i].modelElement != null
+ && this.connections[i].modelElement.id == id) {
+ return this.connections[i];
+ }
+ }
+
+ return null;
+ };
/**
* The diagram serves as a dispatcher for all changes on model
@@ -480,7 +495,18 @@ define(
// TODO is lastSymbol still needed
for ( var i = 0; i < obj.changes.added.length; i++) {
- this.lastSymbol.oid = obj.changes.added[i].oid;
+ if (null != this.lastSymbol) {
+ this.lastSymbol.oid = obj.changes.added[i].oid;
+ } else if (null != obj.changes.added[i].modelElement) {
+ // for connections , search by connectionId to
+ // set OID
+ var conn = this
+ .findConnectionByModelId(obj.changes.added[i].modelElement.id);
+ if (null != symbol) {
+ conn.oid = obj.changes.added[i].oid;
+ conn.refresh();
+ }
+ }
}
this.lastSymbol = null;