summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-09-06 08:45:28 (EDT)
committer Stephan Born2012-09-10 08:46:55 (EDT)
commit21e00cd8ffda53594258598204ed9fd1f06d49ed (patch)
tree82dc85738f78963068b10f10e8e2d4e48d756262
parent0674556396d00841cb0bc4850327b83cb2e4ebad (diff)
downloadorg.eclipse.stardust.ide-21e00cd8ffda53594258598204ed9fd1f06d49ed.zip
org.eclipse.stardust.ide-21e00cd8ffda53594258598204ed9fd1f06d49ed.tar.gz
org.eclipse.stardust.ide-21e00cd8ffda53594258598204ed9fd1f06d49ed.tar.bz2
CRNT-26096 Pepper: Provide methods in ModelBuilderFacade to transform a data into another
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@58963 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.java87
1 files changed, 65 insertions, 22 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 4ea062f..e7569cd 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
@@ -40,6 +40,10 @@ 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;
+import org.eclipse.stardust.model.xpdl.builder.initializer.DataStructInitializer;
+import org.eclipse.stardust.model.xpdl.builder.initializer.DmsDocumentInitializer;
+import org.eclipse.stardust.model.xpdl.builder.initializer.PrimitiveDataInitializer;
+import org.eclipse.stardust.model.xpdl.builder.initializer.SerializableDataInitializer;
import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.builder.variable.BpmDocumentVariableBuilder;
import org.eclipse.stardust.model.xpdl.builder.variable.BpmStructVariableBuilder;
@@ -74,6 +78,7 @@ 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.spi.IDataInitializer;
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;
@@ -418,6 +423,20 @@ public class ModelBuilderFacade
return data;
}
+
+ public void convertDataType(DataType data, String targetTypeID)
+ {
+ if (data.getType().getId().equals(targetTypeID))
+ {
+ return;
+ }
+ ModelType model = ModelUtils.findContainingModel(data);
+ IDataInitializer init = getInitializer(targetTypeID);
+ init.initialize(data, data.getAttribute());
+ data.setType(ModelUtils.findIdentifiableElement(model.getDataType(), targetTypeID));
+ }
+
+
/**
* Update the type of a primitive data.
*
@@ -448,35 +467,38 @@ public class ModelBuilderFacade
String sourceModelID = getModelId(typeFullID);
ModelType typeDeclarationModel = getModelManagementStrategy().getModels().get(
sourceModelID);
- String declarationID = stripFullId(typeFullID);
- TypeDeclarationType typeDeclaration = this.findTypeDeclaration(typeFullID);
+ if (typeDeclarationModel != null) {
+ String declarationID = stripFullId(typeFullID);
+ TypeDeclarationType typeDeclaration = this.findTypeDeclaration(typeFullID);
- if(sourceModelID.equals(model.getId()))
- {
- AttributeUtil.setAttribute(data, StructuredDataConstants.TYPE_DECLARATION_ATT,
- declarationID);
- } else {
- String fileConnectionId = WebModelerConnectionManager.createFileConnection(model, typeDeclarationModel);
+ if(sourceModelID.equals(model.getId()))
+ {
+ AttributeUtil.setAttribute(data, StructuredDataConstants.TYPE_DECLARATION_ATT,
+ declarationID);
+ } else {
+ String fileConnectionId = WebModelerConnectionManager.createFileConnection(model, typeDeclarationModel);
- String bundleId = CarnotConstants.DIAGRAM_PLUGIN_ID;
- URI uri = URI.createURI("cnx://" + fileConnectionId + "/");
+ 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);
+ 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());
+ 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);
}
- reference.setXref(declarationID);
- data.setExternalReference(reference);
}
+
}
/**
@@ -1989,4 +2011,25 @@ public class ModelBuilderFacade
return ids[0];
}
+
+ private IDataInitializer getInitializer(String dataTypeTypeID)
+ {
+ if (dataTypeTypeID.equals(PredefinedConstants.PRIMITIVE_DATA))
+ {
+ return new PrimitiveDataInitializer();
+ }
+ if (dataTypeTypeID.equals(PredefinedConstants.STRUCTURED_DATA))
+ {
+ return new DataStructInitializer();
+ }
+ if (dataTypeTypeID.equals(PredefinedConstants.SERIALIZABLE_DATA))
+ {
+ return new SerializableDataInitializer();
+ }
+ if (dataTypeTypeID.equals("dmsDocument"))
+ {
+ return new DmsDocumentInitializer();
+ }
+ return null;
+ }
}