summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-09-05 05:04:22 (EDT)
committer Stephan Born2012-09-10 08:46:51 (EDT)
commitb68508d09d084acfb58fe2fda212f41fa6cabb8d (patch)
tree6490ad2d552be937de62c10c6bccf487c4212730
parent262bf67f73e43b1c6f534254a27bfa61434984ef (diff)
downloadorg.eclipse.stardust.ide-b68508d09d084acfb58fe2fda212f41fa6cabb8d.zip
org.eclipse.stardust.ide-b68508d09d084acfb58fe2fda212f41fa6cabb8d.tar.gz
org.eclipse.stardust.ide-b68508d09d084acfb58fe2fda212f41fa6cabb8d.tar.bz2
Added methods for updating StructuredData and Primitives.
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@58925 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/ModelBuilderFacade.java42
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java10
2 files changed, 50 insertions, 2 deletions
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/ModelBuilderFacade.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/ModelBuilderFacade.java
index 695b355..16e5ce4 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/ModelBuilderFacade.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/ModelBuilderFacade.java
@@ -34,6 +34,7 @@ import org.eclipse.emf.ecore.EObject;
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.api.model.PredefinedConstants;
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;
@@ -72,12 +73,15 @@ import org.eclipse.stardust.model.xpdl.carnot.StartEventSymbol;
import org.eclipse.stardust.model.xpdl.carnot.TransitionConnectionType;
import org.eclipse.stardust.model.xpdl.carnot.extensions.ExtensionsFactory;
import org.eclipse.stardust.model.xpdl.carnot.extensions.FormalParameterMappingsType;
+import org.eclipse.stardust.model.xpdl.carnot.merge.MergeUtils;
import org.eclipse.stardust.model.xpdl.carnot.util.AttributeUtil;
import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
import org.eclipse.stardust.model.xpdl.carnot.util.ModelUtils;
+import org.eclipse.stardust.model.xpdl.util.IConnectionManager;
import org.eclipse.stardust.model.xpdl.xpdl2.BasicTypeType;
import org.eclipse.stardust.model.xpdl.xpdl2.DeclaredTypeType;
import org.eclipse.stardust.model.xpdl.xpdl2.ExternalPackage;
+import org.eclipse.stardust.model.xpdl.xpdl2.ExternalReferenceType;
import org.eclipse.stardust.model.xpdl.xpdl2.FormalParameterType;
import org.eclipse.stardust.model.xpdl.xpdl2.FormalParametersType;
import org.eclipse.stardust.model.xpdl.xpdl2.ModeType;
@@ -87,7 +91,9 @@ import org.eclipse.stardust.model.xpdl.xpdl2.TypeType;
import org.eclipse.stardust.model.xpdl.xpdl2.XpdlFactory;
import org.eclipse.stardust.model.xpdl.xpdl2.XpdlPackage;
import org.eclipse.stardust.model.xpdl.xpdl2.util.TypeDeclarationUtils;
+import org.eclipse.stardust.modeling.repository.common.descriptors.ReplaceEObjectDescriptor;
import org.eclipse.stardust.modeling.repository.common.descriptors.ReplaceModelElementDescriptor;
+import org.eclipse.stardust.modeling.repository.common.util.ImportUtils;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDCompositor;
import org.eclipse.xsd.XSDElementDeclaration;
@@ -412,6 +418,42 @@ public class ModelBuilderFacade
return data;
}
+ public void updatePrimitiveData(DataType data, String primitiveTypeID)
+ {
+ AttributeUtil.setAttribute(data, PredefinedConstants.TYPE_ATT,
+ Type.class.getName(), primitiveTypeID);
+ }
+
+ public void updateStructuredDataType(DataType data, String typeFullID)
+ {
+ ModelType model = ModelUtils.findContainingModel(data);
+ String sourceModelID = getModelId(typeFullID);
+ ModelType typeDeclarationModel = getModelManagementStrategy().getModels().get(
+ sourceModelID);
+ String declarationID = stripFullId(typeFullID);
+ TypeDeclarationType typeDeclaration = this.findTypeDeclaration(typeFullID);
+
+ String fileConnectionId = WebModelerConnectionManager.createFileConnection(model, typeDeclarationModel);
+
+ String bundleId = CarnotConstants.DIAGRAM_PLUGIN_ID;
+ URI uri = URI.createURI("cnx://" + fileConnectionId + "/");
+
+ ReplaceEObjectDescriptor descriptor = new ReplaceEObjectDescriptor(MergeUtils.createQualifiedUri(uri, typeDeclaration, true), data,
+ typeDeclaration.getId(), typeDeclaration.getName(), typeDeclaration.getDescription(),
+ bundleId, null);
+
+ AttributeUtil.setAttribute(data, "carnot:engine:path:separator", StructuredDataConstants.ACCESS_PATH_SEGMENT_SEPARATOR); //$NON-NLS-1$
+ AttributeUtil.setBooleanAttribute(data, "carnot:engine:data:bidirectional", true); //$NON-NLS-1$
+ AttributeUtil.setAttribute(data, IConnectionManager.URI_ATTRIBUTE_NAME, descriptor.getURI().toString());
+ ExternalReferenceType reference = XpdlFactory.eINSTANCE.createExternalReferenceType();
+ if (typeDeclarationModel != null)
+ {
+ reference.setLocation(ImportUtils.getPackageRef(descriptor, model, typeDeclarationModel).getId());
+ }
+ reference.setXref(declarationID);
+ data.setExternalReference(reference);
+ }
+
/**
* Created a primitive data.
*
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 2ca4c2f..440a826 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
@@ -79,6 +79,8 @@ public class CrossModelSupportModelBuilderTest
private DataType localPrimitive;
private DataType localComposite;
private DataType implementingComposite;
+ private DataType localConsumerComposite;
+ private DataType localConsumerPrimitive;
private static final int[] elementFeatureIds = {
XpdlPackage.FORMAL_PARAMETER_TYPE__ID, XpdlPackage.FORMAL_PARAMETER_TYPE__NAME,
@@ -102,11 +104,13 @@ public class CrossModelSupportModelBuilderTest
//Primitive Data
localPrimitive = facade.createPrimitiveData(providerModel, "ProvidedPrimitive", "ProvidedPrimitive", ModelerConstants.STRING_PRIMITIVE_DATA_TYPE);
+ localConsumerPrimitive = facade.createPrimitiveData(consumerModel, "ConsumerPrimitive", "ConsumerPrimitive", ModelerConstants.STRING_PRIMITIVE_DATA_TYPE);
+ facade.updatePrimitiveData(localConsumerPrimitive, Type.Integer.getId());
DataType implementingPrimitive = facade.createPrimitiveData(consumerModel, "ImplementingPrimitive", "ImplementingPrimitive", ModelerConstants.STRING_PRIMITIVE_DATA_TYPE);
-
//Type Declaration
- facade.createTypeDeclaration(providerModel, "ProvidedComposite", "ProvidedComposite");
+ facade.createTypeDeclaration(providerModel, "ProvidedComposite", "ProvidedComposite");
+ facade.createTypeDeclaration(consumerModel, "ConsumerComposite", "ConsumerComposite");
//Processes
ProcessDefinitionType providedProcess = facade.createProcess(providerModel, "ProvidedProcess", "ProvidedProcess");
@@ -118,6 +122,8 @@ public class CrossModelSupportModelBuilderTest
//Structured Data / Document Data
localComposite = facade.createStructuredData(providerModel, "LocalComposite1", "LocalComposite1", "ProviderModel:ProvidedComposite");
implementingComposite = facade.createStructuredData(consumerModel, "ProvidedComposite1", "ProvidedComposite1", "ProviderModel:ProvidedComposite");
+ localConsumerComposite = facade.createStructuredData(consumerModel, "ConsumerComposite1", "ConsumerComposite1", "ConsumerModel:ConsumerComposite");
+ facade.updateStructuredDataType(localConsumerComposite, "ProviderModel:ProvidedComposite");
facade.createDocumentData(providerModel, "LocalDocument", "LocalDocument", "ProvidedComposite");
//Process Interface (Creation)