summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-07-31 07:29:49 (EDT)
committerManik Kishore2012-08-07 05:01:46 (EDT)
commit23ae3845e1187b0ee2d863d26c3d48b01a9f70cd (patch)
tree2b3153eb1cc97f0cdada6afe2d7d080a1b014bc6
parentc74cc057d60959d001d392a96da68be7d25454a3 (diff)
downloadorg.eclipse.stardust.ui.web-23ae3845e1187b0ee2d863d26c3d48b01a9f70cd.zip
org.eclipse.stardust.ui.web-23ae3845e1187b0ee2d863d26c3d48b01a9f70cd.tar.gz
org.eclipse.stardust.ui.web-23ae3845e1187b0ee2d863d26c3d48b01a9f70cd.tar.bz2
Jira-ID: CRNT-25440
1)Added java class to create Data symbols 2)Made change to m_dataSymbol.js to set fullId in createDataSymbol() 3)Moved the code of createDataSymbol from ModelService to DataCommandHandler.java. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@58052 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/DataCommandHandler.java122
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementMarshaller.java44
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/rest/ModelerResource.java20
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/service/ModelService.java60
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_dataSymbol.js4
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_model.js7
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_outline.js16
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js7
8 files changed, 188 insertions, 92 deletions
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/DataCommandHandler.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/DataCommandHandler.java
new file mode 100644
index 0000000..7289080
--- /dev/null
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/DataCommandHandler.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * 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.extractInt;
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractLong;
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractString;
+
+import javax.annotation.Resource;
+
+import org.springframework.context.ApplicationContext;
+
+import com.google.gson.JsonObject;
+
+import org.eclipse.stardust.common.error.ObjectNotFoundException;
+import org.eclipse.stardust.model.xpdl.builder.common.EObjectUUIDMapper;
+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.DataSymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.LaneSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.ModelType;
+import org.eclipse.stardust.model.xpdl.carnot.ProcessDefinitionType;
+import org.eclipse.stardust.model.xpdl.carnot.util.ModelUtils;
+import org.eclipse.stardust.ui.web.modeler.edit.spi.CommandHandler;
+import org.eclipse.stardust.ui.web.modeler.edit.spi.OnCommand;
+
+/**
+ *
+ * @author Sidharth.Singh
+ *
+ */
+@CommandHandler
+public class DataCommandHandler
+{
+
+ @Resource
+ private ApplicationContext springContext;
+
+ /**
+ *
+ * @param parentLaneSymbol
+ * @param model
+ * @param processDefinition
+ * @param request
+ */
+ @OnCommand(commandId = "dataSymbol.create")
+ public void createData(LaneSymbol parentLaneSymbol, JsonObject request)
+ {
+ ModelType model = ModelUtils.findContainingModel(parentLaneSymbol);
+ ProcessDefinitionType processDefinition = ModelUtils.findContainingProcess(parentLaneSymbol);
+ String dataFullID = extractString(request, ModelerConstants.DATA_FULL_ID_PROPERTY);
+ String dataID = extractString(request, ModelerConstants.DATA_ID_PROPERTY);
+ String dataName = extractString(request, ModelerConstants.DATA_NAME_PROPERTY);
+ int xProperty = extractInt(request, ModelerConstants.X_PROPERTY);
+ int yProperty = extractInt(request, ModelerConstants.Y_PROPERTY);
+ int widthProperty = extractInt(request, ModelerConstants.WIDTH_PROPERTY);
+ int heightProperty = extractInt(request, ModelerConstants.HEIGHT_PROPERTY);
+
+ synchronized (model)
+ {
+ EObjectUUIDMapper mapper = springContext.getBean(EObjectUUIDMapper.class);
+ long maxOid = XpdlModelUtils.getMaxUsedOid(model);
+
+ DataType data;
+
+ try
+ {
+ data = MBFacade.getDataFromExistingModel(model.getId(), model, dataFullID);
+ }
+ catch (ObjectNotFoundException x)
+ {
+ if (true)
+ {
+ data = MBFacade.createNewPrimitive(model, dataID, dataName);
+ mapper.map(data);
+ data.setElementOid(++maxOid);
+ }
+ }
+
+ DataSymbolType dataSymbol = MBFacade.createDataSymbol(processDefinition,
+ xProperty, yProperty, widthProperty, heightProperty, parentLaneSymbol,
+ maxOid, data);
+ mapper.map(dataSymbol);
+ }
+ }
+
+ /**
+ *
+ * @param parentLaneSymbol
+ * @param request
+ */
+ @OnCommand(commandId = "dataSymbol.delete")
+ public void deleteData(LaneSymbol parentLaneSymbol, JsonObject request)
+ {
+ ModelType model = ModelUtils.findContainingModel(parentLaneSymbol);
+ ProcessDefinitionType processDefinition = ModelUtils.findContainingProcess(parentLaneSymbol);
+ Long dataOID = extractLong(request, ModelerConstants.OID_PROPERTY);
+ String dataFullID = extractString(request, ModelerConstants.DATA_FULL_ID_PROPERTY);
+ DataType data = MBFacade.getDataFromExistingModel(model.getId(), model, dataFullID);
+ DataSymbolType dataSymbol = MBFacade.findDataSymbolRecursively(parentLaneSymbol,
+ dataOID);
+ synchronized (model)
+ {
+ data.getDataSymbols().remove(dataSymbol);
+ processDefinition.getDiagram().get(0).getDataSymbol().remove(dataSymbol);
+ parentLaneSymbol.getDataSymbol().remove(dataSymbol);
+ }
+
+ }
+
+}
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 5d133eb..87b6374 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
@@ -26,6 +26,7 @@ import org.eclipse.stardust.model.xpdl.carnot.AttributeType;
import org.eclipse.stardust.model.xpdl.carnot.ContextType;
import org.eclipse.stardust.model.xpdl.carnot.DataMappingConnectionType;
import org.eclipse.stardust.model.xpdl.carnot.DataSymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
import org.eclipse.stardust.model.xpdl.carnot.EndEventSymbol;
import org.eclipse.stardust.model.xpdl.carnot.GatewaySymbol;
import org.eclipse.stardust.model.xpdl.carnot.IIdentifiableModelElement;
@@ -41,6 +42,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.DataTypeImpl;
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;
@@ -101,6 +103,10 @@ public class ModelElementMarshaller
{
jsResult = toTransitionType((TransitionConnectionType) modelElement);
}
+ else if (modelElement instanceof DataSymbolType)
+ {
+ jsResult = toDataJson((DataSymbolType) modelElement);
+ }
else
{
jsResult = new JsonObject();
@@ -800,6 +806,36 @@ public class ModelElementMarshaller
/**
*
+ * @param data
+ * @return
+ */
+ public JsonObject toDataTypeJson(DataType data)
+ {
+ JsonObject dataJson = new JsonObject();
+
+ dataJson.addProperty(ModelerConstants.ID_PROPERTY, data.getId());
+ dataJson.addProperty(ModelerConstants.NAME_PROPERTY, data.getName());
+ dataJson.addProperty(ModelerConstants.UUID_PROPERTY, eObjectUUIDMapper().getUUID(data));
+ ModelType model = ModelUtils.findContainingModel(data);
+ dataJson.addProperty("modelUUID", eObjectUUIDMapper().getUUID(model));
+ if (null != data.getDescription())
+ {
+ dataJson.addProperty(ModelerConstants.DESCRIPTION_PROPERTY,
+ (String) data.getDescription().getMixed().get(0).getValue());
+ }
+ else
+ {
+ dataJson.addProperty(ModelerConstants.DESCRIPTION_PROPERTY, "");
+ }
+ if (data.getType() != null)
+ {
+ dataJson.addProperty(ModelerConstants.TYPE_PROPERTY, data.getType().getId());
+ }
+ return dataJson;
+ }
+
+ /**
+ *
* @param startEventSymbol
* @return
*/
@@ -811,9 +847,11 @@ public class ModelElementMarshaller
dataSymbol.getElementOid());
dataSymbolJson.addProperty(ModelerConstants.X_PROPERTY, dataSymbol.getXPos());
dataSymbolJson.addProperty(ModelerConstants.Y_PROPERTY, dataSymbol.getYPos());
-
- dataSymbolJson.addProperty(ModelerConstants.DATA_FULL_ID_PROPERTY,
- MBFacade.createFullId(ModelUtils.findContainingModel(dataSymbol.getData()), dataSymbol.getData()));
+ dataSymbolJson.addProperty(ModelerConstants.TYPE_PROPERTY, ModelerConstants.DATA_SYMBOL);
+ dataSymbolJson.add("data", toDataTypeJson(dataSymbol.getData()));
+
+ dataSymbolJson.addProperty(ModelerConstants.DATA_FULL_ID_PROPERTY,
+ MBFacade.createFullId(ModelUtils.findContainingModel(dataSymbol.getData()), dataSymbol.getData()));
return dataSymbolJson;
}
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/rest/ModelerResource.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/rest/ModelerResource.java
index 95c620a..08aa310 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/rest/ModelerResource.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/rest/ModelerResource.java
@@ -487,26 +487,6 @@ public class ModelerResource {
}
}
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("models/{modelId}/processes/{processId}/dataSymbols")
- public Response createDataSymbol(@PathParam("modelId") String modelId,
- @PathParam("processId") String processId, String postedData) {
- try {
- JsonObject json = jsonIo.readJsonObject(postedData);
-
- String result = getModelService().createDataSymbol(modelId,
- processId, json);
-
- return Response.ok(result, APPLICATION_JSON_TYPE).build();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/service/ModelService.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/service/ModelService.java
index 60bd148..bea9a38 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/service/ModelService.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/service/ModelService.java
@@ -36,7 +36,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.eclipse.stardust.common.StringUtils;
-import org.eclipse.stardust.common.error.ObjectNotFoundException;
import org.eclipse.stardust.engine.api.model.PredefinedConstants;
import org.eclipse.stardust.engine.api.query.UserQuery;
import org.eclipse.stardust.engine.api.runtime.DmsUtils;
@@ -1479,65 +1478,6 @@ public class ModelService {
* @param postedData
* @return
*/
- public String createDataSymbol(String modelId, String processId,
- JsonObject commandJson) {
- JsonObject dataSymbolJson = commandJson
- .getAsJsonObject(NEW_OBJECT_PROPERTY);
- ModelType model = getModelManagementStrategy().getModels().get(modelId);
- ProcessDefinitionType processDefinition = MBFacade.findProcessDefinition(model,
- processId);
- EditingSession editSession = getEditingSession(model);
- String dataFullID = extractString(dataSymbolJson,
- ModelerConstants.DATA_FULL_ID_PROPERTY);
- String dataID = extractString(dataSymbolJson, ModelerConstants.DATA_ID_PROPERTY);
- String dataName = extractString(dataSymbolJson, ModelerConstants.DATA_NAME_PROPERTY);
- int xProperty = extractInt(dataSymbolJson, X_PROPERTY);
- int yProperty = extractInt(dataSymbolJson, Y_PROPERTY);
- int widthProperty = extractInt(dataSymbolJson, WIDTH_PROPERTY);
- int heightProperty = extractInt(dataSymbolJson, HEIGHT_PROPERTY);
- String parentSymbolID = extractString(dataSymbolJson, PARENT_SYMBOL_ID_PROPERTY);
-
- synchronized (model) {
- editSession.beginEdit();
-
- long maxOid = XpdlModelUtils.getMaxUsedOid(model);
-
- DataType data;
-
- try {
- data = MBFacade.getDataFromExistingModel(modelId, model, dataFullID);
- } catch (ObjectNotFoundException x) {
- if (true) {
- data = MBFacade.createNewPrimitive(model, dataID, dataName);
-
- JsonObject dataJson = loadData(model, data);
-
- dataSymbolJson.add("data", dataJson);
- dataSymbolJson.addProperty("dataFullId",
- MBFacade.createFullId(model, data));
- }
- }
-
- DataSymbolType dataSymbol = MBFacade.createDataSymbol(processDefinition, xProperty,
- yProperty, widthProperty, heightProperty, parentSymbolID, maxOid, data);
-
- dataSymbolJson
- .addProperty(OID_PROPERTY, dataSymbol.getElementOid());
- editSession.endEdit();
- }
-
- return commandJson.toString();
- }
-
-
-
- /**
- *
- * @param modelId
- * @param processId
- * @param postedData
- * @return
- */
public String dropDataSymbol(String modelId, String processId,
JsonObject dataSymbolJson) {
ModelType model = getModelManagementStrategy().getModels().get(modelId);
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_dataSymbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_dataSymbol.js
index 92190fd..11f1361 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_dataSymbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_dataSymbol.js
@@ -26,8 +26,8 @@ define(
dataSymbol.dataId = "Data" + index;
dataSymbol.dataName = "Data " + index;
-// dataSymbol.dataFullId = m_model.getFullId(diagram.model,
-// "Data" + index);
+ dataSymbol.dataFullId = m_model.getFullId(diagram.model,
+ "Data" + index);
return dataSymbol;
},
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_model.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_model.js
index 8f4f583..7da35ce 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_model.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_model.js
@@ -216,6 +216,13 @@ define(
+ " in path " + path)
+ ".";
}
+ },
+
+ /**
+ *
+ */
+ getFullId : function(model, symbolId) {
+ return model.id + ":" +symbolId;
}
};
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_outline.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_outline.js
index 65bf5e5..0c22554 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_outline.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_outline.js
@@ -13,11 +13,11 @@ define(
"m_communicationController", "m_commandsController",
"m_command", "m_session", "m_model", "m_process",
"m_application", "m_dataStructure", "m_participant",
- "m_outlineToolbarController" ],
+ "m_outlineToolbarController", "m_data" ],
function(m_utils, m_urlUtils, m_constants, m_extensionManager,
m_communicationController, m_commandsController, m_command,
m_session, m_model, m_process, m_application, m_dataStructure,
- m_participant, m_outlineToolbarController) {
+ m_participant, m_outlineToolbarController, m_data) {
var modelCounter = 0;
var processCounter = 0;
@@ -1542,7 +1542,7 @@ define(
} else if (m_constants.STRUCTURED_DATA_TYPE == command.changes.added[i].type) {
this
.createStructuredDataType(command.changes.added[i]);
- } else if (m_constants.DATA == command.changes.added[i].type) {
+ } else if (m_constants.DATA_SYMBOL == command.changes.added[i].type) {
this
.createData(command.changes.added[i].data);
} else if (m_constants.APPLICATION == command.changes.added[i].type) {
@@ -1768,8 +1768,14 @@ define(
*
*/
Outline.prototype.createData = function(transferObject) {
- var model = m_model.findModelByUuid(transferObject.modelUUID);
- var data = m_data.initializeFromJson(
+ try{
+ var model = m_model.findModelByUuid(transferObject.modelUUID);
+
+ }
+ catch (e) {
+ alert("error"+e);
+ }
+ var data = m_data.initializeFromJson(
model, transferObject);
var parentSelector = '#data_' + model.id;
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js
index 0294114..c3a7b10 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js
@@ -242,8 +242,11 @@ define(
commandType = "gateSymbol." + str;
} else if (this.type == m_constants.EVENT_SYMBOL) {
commandType = "eventSymbol." + str;
- /*} else if (this.type == m_constants.DATA_SYMBOL) {
- commandType = "dataSymbol." + str;*/
+ } // For data symbol only Create is implemented with
+ // change protocol
+ else if (this.type == m_constants.DATA_SYMBOL
+ && str.match("create")) {
+ commandType = "dataSymbol." + str;
} else if (m_constants.SWIMLANE_SYMBOL.match(this.type)) {
commandType = "swimlaneSymbol." + str;
}