Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


 
Stores the current version of an edmModel using the built in revision control system of edm.
Any number of versions may be generated for an edmModel. All new verisons of an edmModel will be a appended to the list of modelVersionIds in the VERSIONS attribute of the model. A modelVersionId is an instance of the entity EDM_MODEL_VERSION in the ExpressDataManager model. This instance contains administrative information about the model version such as name, creation date and ownership.
Related functions: edmiDeleteModelVersion, edmiDeleteModelVersionBN, edmiGetModelVersionId, edmiGetModelVersionIdBN, edmiRollbackModel, edmiRollbackModelBN, edmiVersionGetAttr, edmiVersionGetAttrBN, edmiVersionGetAttrDatatype, edmiVersionGetAttrDatatypeBN.
Header:
#include "sdai.h"
 
Prototype:
EdmiError edmiCreateModelVersion(SdaiString       repositoryName,
                                  SdaiString       modelName,
                                  SdaiString       modelVersionName,
                                  SdaiModelVersion modelVersionId);
Arguments:

repositoryName

The name of the repository that contains the model of interest in the EDMdatabase. Repository names are case sensitive.

modelName

The name of the edmModel for which a new version shall be created.

modelVersionName

Optional name of the new model version. A model version name must start with a letter followed by any sequence of alphanumeric characters and underscore. Model names are case sensitive. All named versions of an edmModel must have unique names.

modelVersionId

Variable that will receive the modelVersionId that uniquely identifies the model version in the EDMdatabase.

 
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an EDMinterface error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
EdmiError rstat;
SdaiInteger nWrn, nErr;
SdaiRepository repId;
SdaiModel modelId;
SdaiVersion version1Id, version2Id;
SdaiModelVersion modelVersionId;
SdaiInteger myInteger;
SdaiReal myReal;
SdaiInstance instId;
SdaiAttr attrId;
SdaiPrimitiveType type;
 
/* Compile schema */
rstat = edmiCompileFile("c:/data/MyFile.exp",
"c:/tmp/MyFile.dia", 
"MySchema", 0, &nWrn, &nErr); 
/* Create Model */
rstat = edmiGetRepository("MyRepository", &repId);
modelId = edmiCreateModelBN(repId, "MyModel", "MySchema", 0);
/* Populate Model */
instId = edmiCreateInstanceAndPutAttrsBN(modelId, "MyEntity", 1,
"REAL_ATTR", sdaiREAL, 3.14);  
/* Create version 1 */
rstat = edmiCreateModelVersion("MyRepository", "MyModel",
"V1", &modelVersionId); 
/* Change population */
sdaiPutAttrBN(instId, "REAL_ATTR", sdaiINTEGER, 1);
/* Create version 2 */
rstat = edmiCreateModelVersion("MyRepository", "MyModel",
NULL, &modelVersionId); 
/* Get Id of version 1 */
rstat = edmiGetModelVersionIdBN("MyRepository", "MyModel",
"V1", &modelVersionId, &version1Id); 
/* Type is sdaiREAL */
rstat = edmiVersionGetAttrDatatypeBN(instId, version1Id,
"REAL_ATTR", &type);
/* Value is 3.14 */ 
if (type != sdaiREAL) goto error;
rstat = edmiVersionGetAttrBN(instId, version1Id, "REAL_ATTR",
type, &myReal); 
/* Get Id of version 2 */
attrId = sdaiGetAttrDefinitionBN("MySchema", "MyEntity", "REAL_ATTR");
rstat = edmiGetModelVersionId(modelId, "version2",
&modelVersionId, &version2Id); 
/* Type is now sdaiINTEGER */
rstat = edmiVersionGetAttrDatatype(instId, version2Id,
attrId, &type); 
/* Value is 1 */
if (type != sdaiINTEGER) goto error;
rstat = edmiVersionGetAttr(instId, version2Id, attrId,
type, &myInteger);
/* Roll back to version 1 */
rstat = edmiRollbackModel(modelId, version1Id,
KEEP_ALL_MODEL_VERSIONS); 
/* Delete version 2 */
edmiDeleteModelVersion(modelId, version2Id);
error:
. . .

  • No labels