summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-10-18 06:08:06 (EDT)
committer Manik Kishore2012-10-18 06:08:06 (EDT)
commite50ad653d7f8947a5167297c829a2ff42ff41bd5 (patch)
treee55c0c574a6d4b3664b13c3dcb7192bce119cfcc
parentcbc6e5d3e2682cbe7f20b4cd39f1e0a25a3e4802 (diff)
downloadorg.eclipse.stardust.ui.web-e50ad653d7f8947a5167297c829a2ff42ff41bd5.zip
org.eclipse.stardust.ui.web-e50ad653d7f8947a5167297c829a2ff42ff41bd5.tar.gz
org.eclipse.stardust.ui.web-e50ad653d7f8947a5167297c829a2ff42ff41bd5.tar.bz2
CRNT-25651
Made changes in updateDataMapping for DataFlow in ModelElementUnmarshaller.java Added code to remove dataMapping on connection delete. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@60143 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/ConnectionCommandHandler.java13
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementUnmarshaller.java179
2 files changed, 124 insertions, 68 deletions
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
index 86fb0c7..91d06ce 100644
--- 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
@@ -16,12 +16,15 @@ import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractIn
import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractLong;
import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractString;
+import java.util.List;
+
import javax.annotation.Resource;
import org.springframework.context.ApplicationContext;
import com.google.gson.JsonObject;
+import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.error.ObjectNotFoundException;
import org.eclipse.stardust.engine.api.model.PredefinedConstants;
import org.eclipse.stardust.model.xpdl.builder.common.AbstractElementBuilder;
@@ -239,7 +242,7 @@ public class ConnectionCommandHandler
{
DataMappingConnectionType dataMappingConnection = getModelBuilderFacade().findDataMappingConnectionByModelOid(
processDefinition, connectionOid);
- DataMappingType dataMapping = null;
+ List<DataMappingType> dataMapping = CollectionUtils.newArrayList();
for (DataMappingType dataMappingType : dataMappingConnection.getActivitySymbol()
.getActivity()
.getDataMapping())
@@ -248,13 +251,17 @@ public class ConnectionCommandHandler
.getId()
.equals(dataMappingConnection.getDataSymbol().getData().getId()))
{
- dataMapping = dataMappingType;
+ dataMapping.add(dataMappingType);
}
}
dataMappingConnection.getActivitySymbol()
.getActivity()
.getDataMapping()
- .remove(dataMapping);
+ .removeAll(dataMapping);
+ dataMappingConnection.getDataSymbol()
+ .getData()
+ .getDataMappings()
+ .removeAll(dataMapping);
processDefinition.getDiagram()
.get(0)
.getPoolSymbols()
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementUnmarshaller.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementUnmarshaller.java
index 9671ddb..ec3c35b 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementUnmarshaller.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/marshaling/ModelElementUnmarshaller.java
@@ -35,6 +35,7 @@ import org.eclipse.stardust.model.xpdl.builder.common.AbstractElementBuilder;
import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.builder.utils.ModelBuilderFacade;
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.AccessPointType;
import org.eclipse.stardust.model.xpdl.carnot.ActivityImplementationType;
import org.eclipse.stardust.model.xpdl.carnot.ActivitySymbolType;
@@ -491,19 +492,7 @@ public abstract class ModelElementUnmarshaller implements ModelUnmarshaller
if (dataFlowJson.has(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY)
|| dataFlowJson.has(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY))
{
- for (DataMappingType dataMapping : dataFlowConnection.getActivitySymbol()
- .getActivity()
- .getDataMapping())
- {
- System.out.println("Data Mapping: " + dataMapping.getId());
- System.out.println(" Direction: " + dataMapping.getDirection());
-
- if (dataMapping.getData().getId().equals(
- dataFlowConnection.getDataSymbol().getData().getId()))
- {
- updateDataMapping(dataFlowJson, dataMapping);
- }
- }
+ updateDataMapping(dataFlowConnection, dataFlowJson);
}
}
@@ -1710,77 +1699,137 @@ public abstract class ModelElementUnmarshaller implements ModelUnmarshaller
}
/**
+ * Create new dataMapping when 1 dataMapping(IN) exist and user creates new(OUT)
+ * between same 2 symbols
+ *
+ * @param activity
+ * @param model
+ * @param data
+ * @return
+ */
+ private DataMappingType createDataMapping(ActivityType activity, ModelType model,
+ DataType data)
+ {
+ long maxOid = XpdlModelUtils.getMaxUsedOid(model);
+ DataMappingType newDataMapping = AbstractElementBuilder.F_CWM.createDataMappingType();
+ newDataMapping.setElementOid(++maxOid);
+ newDataMapping.setId(data.getId());
+ newDataMapping.setName(data.getName());
+ newDataMapping.setData(data);
+ return newDataMapping;
+ }
+
+ /**
*
* @param dataFlowJson
* @param dataMapping
*/
- private void updateDataMapping(JsonObject dataFlowJson, DataMappingType dataMapping)
+ private void updateDataMapping(DataMappingConnectionType dataFlowConnection,
+ JsonObject dataFlowJson)
{
- // If both IN-OUT mapping is present
- if (dataFlowJson.has(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY)
- && dataFlowJson.has(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY))
- {
- if (dataFlowJson.get(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY).getAsBoolean()
- && dataFlowJson.get(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY)
- .getAsBoolean())
+ DataMappingType newDataMapping = null;
+ DataMappingType currentDataMapping = null;
+ boolean removeCurrentMapping = false;
+ ActivitySymbolType activitySymbol = dataFlowConnection.getActivitySymbol();
+ DataSymbolType dataSymbol = dataFlowConnection.getDataSymbol();
+ ModelType model = ModelUtils.findContainingModel(dataFlowConnection.getDataSymbol());
+ List<DataMappingType> activityMapping = activitySymbol.getActivity()
+ .getDataMapping();
+ for (DataMappingType dataMapping : activityMapping)
+ {
+ if (dataMapping.getData()
+ .getId()
+ .equals(dataFlowConnection.getDataSymbol().getData().getId()))
{
- dataMapping.setDirection(DirectionType.INOUT_LITERAL);
- }
- }
- // IN data mapping is updates
- else if (dataFlowJson.has(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY))
- {
- if (dataFlowJson.get(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY).getAsBoolean())
- {
- // If OUT mapping was already set , update to IN-OUT mapping
- if (dataMapping.getDirection().equals(DirectionType.OUT_LITERAL))
- {
- dataMapping.setDirection(DirectionType.INOUT_LITERAL);
- }
- else
- {
- dataMapping.setDirection(DirectionType.IN_LITERAL);
- }
- }
- else
- {
- if (dataMapping.getDirection().equals(DirectionType.INOUT_LITERAL))
+
+ // In-Out mapping creation from canvas
+ if (dataFlowJson.has(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY)
+ && dataFlowJson.has(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY))
{
- dataMapping.setDirection(DirectionType.OUT_LITERAL);
+ if (dataFlowJson.get(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY)
+ .getAsBoolean()
+ && dataFlowJson.get(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY)
+ .getAsBoolean())
+ {
+ newDataMapping = createDataMapping(activitySymbol.getActivity(), model,
+ dataFlowConnection.getDataSymbol().getData());
+ if (dataMapping.getDirection().equals(DirectionType.OUT_LITERAL))
+ newDataMapping.setDirection(DirectionType.IN_LITERAL);
+ else
+ newDataMapping.setDirection(DirectionType.OUT_LITERAL);
+ }
}
- }
- }
- // OUT data mapping is updates
- else if (dataFlowJson.has(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY))
- {
- if (dataFlowJson.get(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY).getAsBoolean())
- {
- // If IN mapping was already set , update to IN-OUT mapping
- if (dataMapping.getDirection().equals(DirectionType.IN_LITERAL))
+
+ // In Data Mapping update from properties panel
+ else if (dataFlowJson.has(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY))
{
- dataMapping.setDirection(DirectionType.INOUT_LITERAL);
+ if (dataFlowJson.get(ModelerConstants.INPUT_DATA_MAPPING_PROPERTY)
+ .getAsBoolean())
+ {
+ // Create new mapping
+ if (dataMapping.getDirection().equals(DirectionType.OUT_LITERAL))
+ {
+ newDataMapping = createDataMapping(activitySymbol.getActivity(),
+ model, dataFlowConnection.getDataSymbol().getData());
+ newDataMapping.setDirection(DirectionType.IN_LITERAL);
+ }
+ }
+ else
+ {
+ // flag to remove exisiting IN mapping element
+ if (dataMapping.getDirection().equals(DirectionType.IN_LITERAL))
+ {
+ removeCurrentMapping = true;
+ currentDataMapping = dataMapping;
+ }
+ }
}
- else
+
+ // Out Data Mapping update from properties panel.
+ else if (dataFlowJson.has(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY))
{
- dataMapping.setDirection(DirectionType.OUT_LITERAL);
+ if (dataFlowJson.get(ModelerConstants.OUTPUT_DATA_MAPPING_PROPERTY)
+ .getAsBoolean())
+ {
+ // Create new mapping
+ if (dataMapping.getDirection().equals(DirectionType.IN_LITERAL))
+ {
+ newDataMapping = createDataMapping(activitySymbol.getActivity(),
+ model, dataFlowConnection.getDataSymbol().getData());
+ newDataMapping.setDirection(DirectionType.OUT_LITERAL);
+ }
+ }
+ else
+ {
+ // flag to remove exisiting IN mapping element
+ if (dataMapping.getDirection().equals(DirectionType.OUT_LITERAL))
+ {
+ removeCurrentMapping = true;
+ currentDataMapping = dataMapping;
+ }
+ }
}
- }
- else
- {
- if (dataMapping.getDirection().equals(DirectionType.INOUT_LITERAL))
+
+ if (dataFlowJson.has(ModelerConstants.ACCESS_POINT_ID_PROPERTY))
{
- dataMapping.setDirection(DirectionType.IN_LITERAL);
+ dataMapping.setApplicationAccessPoint(dataFlowJson.get(
+ ModelerConstants.ACCESS_POINT_ID_PROPERTY).getAsString());
+ dataMapping.setContext(dataFlowJson.get(
+ ModelerConstants.ACCESS_POINT_CONTEXT_PROPERTY).getAsString());
}
}
}
- if (dataFlowJson.has(ModelerConstants.ACCESS_POINT_ID_PROPERTY))
+ if (removeCurrentMapping && activityMapping.size() > 1)
+ {
+ dataSymbol.getData().getDataMappings().remove(currentDataMapping);
+ activityMapping.remove(currentDataMapping);
+ }
+ if (newDataMapping != null)
{
- dataMapping.setApplicationAccessPoint(dataFlowJson.get(
- ModelerConstants.ACCESS_POINT_ID_PROPERTY).getAsString());
- dataMapping.setContext(dataFlowJson.get(
- ModelerConstants.ACCESS_POINT_CONTEXT_PROPERTY).getAsString());
+ activitySymbol.getActivity().getDataMapping().add(newDataMapping);
}
+
}
/**