summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-08-15 03:01:28 (EDT)
committerManik Kishore2012-08-15 03:01:28 (EDT)
commitf3822780a824b4698c053e339993b1828dd43f1f (patch)
tree48e9f356c98b8fc718c9e7eb4f5cbe81a083ff35
parent1700aca3d941303aea72df83612681c1353ea4a4 (diff)
downloadorg.eclipse.stardust.ide-f3822780a824b4698c053e339993b1828dd43f1f.zip
org.eclipse.stardust.ide-f3822780a824b4698c053e339993b1828dd43f1f.tar.gz
org.eclipse.stardust.ide-f3822780a824b4698c053e339993b1828dd43f1f.tar.bz2
CRNT-25760 Refactor/Clean up MB Facade
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@58420 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java3
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java55
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/variable/BpmStructVariableBuilder.java2
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java10
4 files changed, 60 insertions, 10 deletions
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java
index eb46374..1b5e617 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java
@@ -33,6 +33,7 @@ import org.eclipse.stardust.engine.api.runtime.Document;
import org.eclipse.stardust.engine.api.runtime.DocumentManagementService;
import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.builder.utils.JcrConnectionManager;
+import org.eclipse.stardust.model.xpdl.builder.utils.MBFacade;
import org.eclipse.stardust.model.xpdl.builder.utils.PepperIconFactory;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
@@ -74,7 +75,7 @@ public class JcrConnectionHandler implements ConnectionHandler
synchronized ModelType loadModel(String id)
{
// TODO properly resolve current modelManagementStrategy
- ModelManagementStrategy modelManagementStrategy = null;
+ ModelManagementStrategy modelManagementStrategy = MBFacade.getInstance().getModelManagementStrategy();
return modelManagementStrategy.loadModel(id);
}
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java
index b1307a3..eb6e54c 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java
@@ -28,9 +28,11 @@ import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.stardust.common.StringUtils;
import org.eclipse.stardust.common.error.ObjectNotFoundException;
import org.eclipse.stardust.engine.core.pojo.data.Type;
+import org.eclipse.stardust.engine.core.struct.StructuredDataConstants;
import org.eclipse.stardust.model.xpdl.builder.activity.BpmApplicationActivityBuilder;
import org.eclipse.stardust.model.xpdl.builder.activity.BpmSubProcessActivityBuilder;
import org.eclipse.stardust.model.xpdl.builder.common.AbstractElementBuilder;
@@ -63,9 +65,19 @@ import org.eclipse.stardust.model.xpdl.carnot.StartEventSymbol;
import org.eclipse.stardust.model.xpdl.carnot.TransitionConnectionType;
import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
import org.eclipse.stardust.model.xpdl.carnot.util.ModelUtils;
+import org.eclipse.stardust.model.xpdl.xpdl2.SchemaTypeType;
import org.eclipse.stardust.model.xpdl.xpdl2.TypeDeclarationType;
import org.eclipse.stardust.model.xpdl.xpdl2.XpdlFactory;
+import org.eclipse.stardust.model.xpdl.xpdl2.util.TypeDeclarationUtils;
import org.eclipse.stardust.modeling.repository.common.descriptors.ReplaceModelElementDescriptor;
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDCompositor;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDFactory;
+import org.eclipse.xsd.XSDModelGroup;
+import org.eclipse.xsd.XSDPackage;
+import org.eclipse.xsd.XSDParticle;
+import org.eclipse.xsd.XSDSchema;
public class MBFacade
{
@@ -161,6 +173,40 @@ public class MBFacade
structuredDataType.setId(typeId);
structuredDataType.setName(typeName);
+ SchemaTypeType schema = XpdlFactory.eINSTANCE.createSchemaTypeType();
+ structuredDataType.setSchemaType(schema);
+
+ XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
+ xsdSchema.getQNamePrefixToNamespaceMap().put(XSDPackage.eNS_PREFIX,
+ XMLResource.XML_SCHEMA_URI);
+ xsdSchema.setSchemaForSchemaQNamePrefix(XSDPackage.eNS_PREFIX);
+
+ xsdSchema.setTargetNamespace(TypeDeclarationUtils.computeTargetNamespace(model,
+ structuredDataType.getId()));
+ String prefix = TypeDeclarationUtils.computePrefix(structuredDataType.getId(),
+ xsdSchema.getQNamePrefixToNamespaceMap().keySet());
+ xsdSchema.getQNamePrefixToNamespaceMap()
+ .put(prefix, xsdSchema.getTargetNamespace());
+ xsdSchema.setSchemaLocation(StructuredDataConstants.URN_INTERNAL_PREFIX
+ + structuredDataType.getId());
+ schema.setSchema(xsdSchema);
+
+ XSDComplexTypeDefinition xsdComplexTypeDefinition = XSDFactory.eINSTANCE
+ .createXSDComplexTypeDefinition();
+ xsdComplexTypeDefinition.setName(structuredDataType.getId());
+ XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
+ XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
+ particle.setContent(modelGroup);
+ modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
+ xsdComplexTypeDefinition.setContent(particle);
+ xsdSchema.getContents().add(xsdComplexTypeDefinition);
+
+ XSDElementDeclaration xsdElementDeclaration = XSDFactory.eINSTANCE
+ .createXSDElementDeclaration();
+ xsdElementDeclaration.setName(structuredDataType.getId());
+ xsdElementDeclaration.setTypeDefinition(xsdComplexTypeDefinition);
+ xsdSchema.getContents().add(xsdElementDeclaration);
+
model.getTypeDeclarations().getTypeDeclaration().add(structuredDataType);
return structuredDataType;
@@ -181,17 +227,18 @@ public class MBFacade
return data;
}
- public DataType createStructuredData(ModelType model, String stripFullId_, String id,
- String name, String structuredDataFullId)
+
+ public DataType createStructuredData(ModelType model, String dataID, String dataName, String typeFullID)
{
DataType data;
+ String sourceModelID = MBFacade.getInstance().getModelId(typeFullID);
ModelType typeDeclarationModel = getModelManagementStrategy().getModels().get(
- stripFullId_);
+ sourceModelID);
BpmStructVariableBuilder structVariable = newStructVariable(model);
structVariable.setTypeDeclarationModel(typeDeclarationModel);
- data = structVariable.withIdAndName(id, name).ofType(structuredDataFullId).build();
+ data = structVariable.withIdAndName(dataID, dataName).ofType(this.stripFullId(typeFullID)).build();
return data;
}
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/variable/BpmStructVariableBuilder.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/variable/BpmStructVariableBuilder.java
index 1c1c8d5..7d26fa9 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/variable/BpmStructVariableBuilder.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/variable/BpmStructVariableBuilder.java
@@ -115,7 +115,7 @@ public class BpmStructVariableBuilder
String bundleId = CarnotConstants.DIAGRAM_PLUGIN_ID;
URI uri = URI.createURI("cnx://" + fileConnectionId + "/");
- ReplaceEObjectDescriptor descriptor = new ReplaceEObjectDescriptor(MergeUtils.createQualifiedUri(uri, typeDeclaration, true), typeDeclaration,
+ ReplaceEObjectDescriptor descriptor = new ReplaceEObjectDescriptor(MergeUtils.createQualifiedUri(uri, typeDeclaration, true), element,
typeDeclaration.getId(), typeDeclaration.getName(), typeDeclaration.getDescription(),
bundleId, null);
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java b/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java
index ea0202d..509ae20 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java
@@ -52,14 +52,16 @@ public class CrossModelSupportModelBuilderTest
ProcessDefinitionType providedProcess = MBFacade.getInstance().createProcess(providerModel,
"ProvidedProcess", "ProvidedProcess");
ProcessDefinitionType consumerProcess = MBFacade.getInstance().createProcess(consumerModel,
- "ConsumerProcess", "ConsumerProcess");
- MBFacade.getInstance().createStructuredData(consumerModel, "ProviderModel", "ProvidedComposite1",
- "ProvidedComposite1", "ProvidedComposite");
+ "ConsumerProcess", "ConsumerProcess");
+ MBFacade.getInstance().createStructuredData(providerModel, "LocalComposite1", "LocalComposite1", "ProviderModel:ProvidedComposite");
+
+ MBFacade.getInstance().createStructuredData(consumerModel, "ProvidedComposite1", "ProvidedComposite1", "ProviderModel:ProvidedComposite");
+
long maxOid = XpdlModelUtils.getMaxUsedOid(consumerModel);
MBFacade.getInstance().createActivity("ConsumerModel", consumerProcess, "Subprocess", null,
"ProvidedProcess1", "ProvidedProcess1", null,
"ProviderModel:ProvidedProcess", maxOid);
- byte[] modelContent = XpdlModelIoUtils.saveModel(consumerModel);
+ byte[] modelContent = XpdlModelIoUtils.saveModel(providerModel);
System.out.println(new String(modelContent));
}