summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-08-16 09:02:25 (EDT)
committerManik Kishore2012-08-16 09:02:25 (EDT)
commit1e402c54fddebc852abd573566364b165d871c90 (patch)
treeebb493eca13a021990f6a01d9c38d64694b52738
parent69a6c3e839f395ded05a5bbbb481ff9943beb8ec (diff)
downloadorg.eclipse.stardust.ui.web-1e402c54fddebc852abd573566364b165d871c90.zip
org.eclipse.stardust.ui.web-1e402c54fddebc852abd573566364b165d871c90.tar.gz
org.eclipse.stardust.ui.web-1e402c54fddebc852abd573566364b165d871c90.tar.bz2
CRNT-25760 Refactor/Clean up MB Facade: Remove Singleton stuff
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@58462 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/ConnectionCommandHandler.java50
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/model/element/ParticipantChangeCommandHandler.java29
2 files changed, 54 insertions, 25 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 69d2bdd..31a7cb6 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,6 +16,8 @@ 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 javax.annotation.Resource;
+
import com.google.gson.JsonObject;
import org.eclipse.stardust.common.error.ObjectNotFoundException;
@@ -43,6 +45,8 @@ 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.spi.CommandHandler;
import org.eclipse.stardust.ui.web.modeler.edit.spi.OnCommand;
+import org.eclipse.stardust.ui.web.modeler.service.ModelService;
+import org.springframework.context.ApplicationContext;
/**
* @author Sidharth.Singh
@@ -50,6 +54,10 @@ import org.eclipse.stardust.ui.web.modeler.edit.spi.OnCommand;
@CommandHandler
public class ConnectionCommandHandler
{
+ @Resource
+ private ApplicationContext springContext;
+ private MBFacade facade;
+
@OnCommand(commandId = "connection.create")
public void createConnection(IIdentifiableElement targetElement, JsonObject request)
{
@@ -72,34 +80,34 @@ public class ConnectionCommandHandler
createControlFlowConnection(
request,
processDefinition,
- MBFacade.getInstance().findActivitySymbol(processDefinition.getDiagram().get(0),
+ facade().findActivitySymbol(processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID)),
- MBFacade.getInstance().findActivitySymbol(processDefinition.getDiagram().get(0),
+ facade().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)))
{
- StartEventSymbol startEventSymbol = MBFacade.getInstance().findStartEventSymbol(
+ StartEventSymbol startEventSymbol = facade().findStartEventSymbol(
processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID));
if (null != startEventSymbol)
{
createControlFlowConnection(request, processDefinition,
- startEventSymbol, MBFacade.getInstance().findActivitySymbol(
+ startEventSymbol, facade().findActivitySymbol(
processDefinition.getDiagram().get(0),
extractLong(request,
ModelerConstants.FROM_MODEL_ELEMENT_OID)), maxOid);
}
else
{
- EndEventSymbol endEventSymbol = MBFacade.getInstance().findEndEventSymbol(
+ EndEventSymbol endEventSymbol = facade().findEndEventSymbol(
processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID));
createControlFlowConnection(request, processDefinition,
- MBFacade.getInstance().findActivitySymbol(
+ facade().findActivitySymbol(
processDefinition.getDiagram().get(0),
extractLong(request,
ModelerConstants.FROM_MODEL_ELEMENT_OID)),
@@ -113,9 +121,9 @@ public class ConnectionCommandHandler
createDataFlowConnection(
request,
processDefinition,
- MBFacade.getInstance().findActivitySymbol(processDefinition.getDiagram().get(0),
+ facade().findActivitySymbol(processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID)),
- MBFacade.getInstance().findDataSymbol(processDefinition.getDiagram().get(0),
+ facade().findDataSymbol(processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
maxOid, false);
}
@@ -134,7 +142,7 @@ public class ConnectionCommandHandler
{
try
{
- StartEventSymbol startEventSymbol = MBFacade.getInstance().findStartEventSymbol(
+ StartEventSymbol startEventSymbol = facade().findStartEventSymbol(
processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID));
@@ -142,20 +150,20 @@ public class ConnectionCommandHandler
request,
processDefinition,
startEventSymbol,
- MBFacade.getInstance().findActivitySymbol(
+ facade().findActivitySymbol(
processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
maxOid);
}
catch (ObjectNotFoundException x)
{
- EndEventSymbol endEventSymbol = MBFacade.getInstance().findEndEventSymbol(
+ EndEventSymbol endEventSymbol = facade().findEndEventSymbol(
processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID));
createControlFlowConnection(
request,
processDefinition,
- MBFacade.getInstance().findActivitySymbol(
+ facade().findActivitySymbol(
processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
endEventSymbol, maxOid);
@@ -177,9 +185,9 @@ public class ConnectionCommandHandler
createDataFlowConnection(
request,
processDefinition,
- MBFacade.getInstance().findActivitySymbol(processDefinition.getDiagram().get(0),
+ facade().findActivitySymbol(processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.TO_MODEL_ELEMENT_OID)),
- MBFacade.getInstance().findDataSymbol(processDefinition.getDiagram().get(0),
+ facade().findDataSymbol(processDefinition.getDiagram().get(0),
extractLong(request, ModelerConstants.FROM_MODEL_ELEMENT_OID)),
maxOid, true);
}
@@ -210,7 +218,7 @@ public class ConnectionCommandHandler
{
try
{
- TransitionConnectionType transitionConnection = MBFacade.getInstance().findTransitionConnectionByModelOid(
+ TransitionConnectionType transitionConnection = facade().findTransitionConnectionByModelOid(
processDefinition, connectionOid);
processDefinition.getDiagram()
@@ -228,7 +236,7 @@ public class ConnectionCommandHandler
}
catch (ObjectNotFoundException x)
{
- DataMappingConnectionType dataMappingConnection = MBFacade.getInstance().findDataMappingConnectionByModelOid(
+ DataMappingConnectionType dataMappingConnection = facade().findDataMappingConnectionByModelOid(
processDefinition, connectionOid);
processDefinition.getDiagram()
@@ -460,5 +468,15 @@ public class ConnectionCommandHandler
throw new IllegalArgumentException("Illegal orientation key " + orientation + ".");
}
+
+ private MBFacade facade()
+ {
+ if (facade == null)
+ {
+ facade = new MBFacade(springContext.getBean(ModelService.class)
+ .getModelManagementStrategy());
+ }
+ return facade;
+ }
}
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/model/element/ParticipantChangeCommandHandler.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/model/element/ParticipantChangeCommandHandler.java
index a44735f..9e435cc 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/model/element/ParticipantChangeCommandHandler.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/model/element/ParticipantChangeCommandHandler.java
@@ -45,6 +45,7 @@ public class ParticipantChangeCommandHandler
{
@Resource
private ApplicationContext springContext;
+ private MBFacade facade;
/**
* @param model
@@ -58,7 +59,7 @@ public class ParticipantChangeCommandHandler
RoleType role = null;
synchronized (model)
{
- role = MBFacade.getInstance().createRole(model, roleID, roleName);
+ role = facade().createRole(model, roleID, roleName);
}
long maxOid = XpdlModelUtils.getMaxUsedOid(model);
role.setElementOid(++maxOid);
@@ -80,7 +81,7 @@ public class ParticipantChangeCommandHandler
OrganizationType org = null;
synchronized (model)
{
- org = MBFacade.getInstance().createOrganization(model, orgID, orgName);
+ org = facade().createOrganization(model, orgID, orgName);
}
long maxOid = XpdlModelUtils.getMaxUsedOid(model);
org.setElementOid(++maxOid);
@@ -103,8 +104,8 @@ public class ParticipantChangeCommandHandler
ModelType model = ModelUtils.findContainingModel(org);
synchronized (model)
{
- role = MBFacade.getInstance().createRole(model, roleID, roleName);
- MBFacade.getInstance().addOrganizationParticipant(org, role);
+ role = facade().createRole(model, roleID, roleName);
+ facade().addOrganizationParticipant(org, role);
}
long maxOid = XpdlModelUtils.getMaxUsedOid(model);
role.setElementOid(++maxOid);
@@ -127,8 +128,8 @@ public class ParticipantChangeCommandHandler
ModelType model = ModelUtils.findContainingModel(org);
synchronized (model)
{
- newOrg = MBFacade.getInstance().createOrganization(model, orgID, orgName);
- MBFacade.getInstance().addOrganizationParticipant(org, newOrg);
+ newOrg = facade().createOrganization(model, orgID, orgName);
+ facade().addOrganizationParticipant(org, newOrg);
}
long maxOid = XpdlModelUtils.getMaxUsedOid(model);
newOrg.setElementOid(++maxOid);
@@ -150,7 +151,7 @@ public class ParticipantChangeCommandHandler
ModelType model = ModelUtils.findContainingModel(org);
synchronized (model)
{
- MBFacade.getInstance().setTeamLeader(org, tealLeader);
+ facade().setTeamLeader(org, tealLeader);
}
}
@@ -162,13 +163,13 @@ public class ParticipantChangeCommandHandler
public void deleteParticipant(ModelType model, JsonObject request)
{
String participantId = extractString(request, ModelerConstants.ID_PROPERTY);
- IModelParticipant modelParticipantInfo = MBFacade.getInstance().findParticipant(
+ IModelParticipant modelParticipantInfo = facade().findParticipant(
model, participantId);
if (modelParticipantInfo instanceof RoleType)
{
synchronized (model)
{
- List<OrganizationType> parentOrgs = MBFacade.getInstance()
+ List<OrganizationType> parentOrgs = facade()
.getParentOrganizations(model, modelParticipantInfo);
for (OrganizationType org : parentOrgs)
@@ -231,4 +232,14 @@ public class ParticipantChangeCommandHandler
{
return springContext.getBean(ModelService.class);
}
+
+ private MBFacade facade()
+ {
+ if (facade == null)
+ {
+ facade = new MBFacade(springContext.getBean(ModelService.class)
+ .getModelManagementStrategy());
+ }
+ return facade;
+ }
}