Creates a new data model within a given repository in a remote EDMdatabase. One may think of a data model as a logical container for instances of entities defined by an Express Schema. No data models of such an underlying Express Schema may be created until the Express Schema has been successfully compiled to form a dictionary model in the remote EDMdatabase. Only data models may be created by this functions. To create dictionary models from Express Schemas, use edmiRemoteDefineSchema.
This function offers a set of options that may be used to disable various features of a data model. These options may have great effect on system performance.
A numeric modelID that uniquely identifies the created model in the remote EDMdatabase will be returned. The modelID may be used to identify the model in subsequent EDMinterface function calls. However, a model name must be unique within a repository, and a repository name must be unique within an EDMdatabase. Therefore, the model and repository names is sufficient to uniquely identify a model within the scope of an EDMdatabase.
The executing EDMuser and EDMgroup accounts will be assigned ownership and group ownership of the created model respectively. The model protection will be set according to the default model protection that has been set for the executing EDMuser.
Related functions: edmiRemoteCreateModelVersion, edmiRemoteDeleteModel, edmiRemoteDeleteModelContents, edmiRemoteDeleteModelContentsBN, edmiRemoteDeleteModelVersion, edmiRemoteGetModel, edmiRemoteGetModelBN
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteCreateModel(SdaiServerContext serverContextId,
SdaiString repositoryName,
SdaiString modelName,
SdaiString remoteSchemaName,
SdaiOptions options,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
repositoryName |
The name of the repository in which to create the data model. Repository names are case sensitive |
modelName |
The name to assign to the new model. Model names must be unique within the scope of a repository and must start with a letter followed by any combination of alphanumeric characters and underscore. Model names are case sensitive. |
remoteSchemaName |
The name of the Express Schema to use as underlying Express Schema for the new data model. |
options |
See description of available options below. |
edmiInvocationId |
Currently not used. |
Options: Descriptions:
M_USER_CONTROLLED_INVERSE |
No automatic update and maintenance of INVERSE attributes in the actual model |
M_INSTANCE_REFERENCES |
The system will keep track of all references to an instance in the model. This is the default option for sdaiCreateModel function |
M_DELETE_INSTANCE_REFS_ON_DELETE |
All references to an instance will implicitly be deleted when the instance is deleted. |
M_INSTANCE_REFS_MUST_BE_DELETED |
An instance cannot be deleted as long as the instance is referenced by another instance. |
M_PACKED_MODEL |
No garbage collection for model when data is freed on data deletion or data change operation. |
USE_DEFAULT_OPTIONS |
|
M_INSTANCES_HASH_TABLE |
|
INSTANCES_HASH_TABLE |
same as M_INSTANCES_HASH_TABLE. used to mark that modelInstanceHashTable is defined by edmiHashModelInstances function |
M_IGNORE_PERSISTENT_ATTR_HASH_TABLE |
|
IGNORE_PERSISTENT_ATTR_HASH_TABLE |
M_IGNORE_PERSISTENT_ATTR_HASH_TABLE |
PERSISTENT_INSTANCES_HASH_TABLE |
creates a EDMpersistentInstancesHashTable |
CHAR_ENCODING_UTF_8 |
|
CHAR_ENCODING_UTF_16 |
|
CHAR_ENCODING_ISO_10646_UCS_2 |
|
CHAR_ENCODING_ISO_10646_UCS_4 |
|
CHAR_ENCODING_ISO_LATIN_1 |
|
CHAR_ENCODING_ISO_LATIN_2 |
|
CHAR_ENCODING_ISO_8859_3 |
|
CHAR_ENCODING_ISO_8859_4 |
|
CHAR_ENCODING_ISO_8859_5 |
|
CHAR_ENCODING_ISO_8859_6 |
|
CHAR_ENCODING_ISO_8859_7 |
|
CHAR_ENCODING_ISO_8859_8 |
|
CHAR_ENCODING_ISO_8859_9 |
|
CHAR_ENCODING_ISO_2022_JP |
|
CHAR_ENCODING_SHIFT_JIS |
|
CHAR_ENCODING_EUC_JP |
|
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;
SdaiServerContext myContext;
SdaiInteger index, nHits;
SdaiQueryResult qexRes;
SdaiInstance johnnysId, *tarInstIds;
SdaiModel modelId;
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get Johnnys PERSON instance Id from
his primary key attribute 'PID' */
nHits = 1;
index = 0;
rstat = edmiRemoteSelectInstances(myContext,
"DataRepository", "SocialRelations",
"Person", "PID = '16126353127'",
(ONLY_INSTANCE_IDS | SUBTYPES),
NULL, NULL, NULL,
&index, &nHits, &qexRes,
NULL, NULL, NULL, NULL);
if (!nHits) {
printf("\nRequested pid not found.");
goto err;
}
johnnysId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Create a social relations model
for Johnnys relations only. */
rstat = edmiRemoteCreateModel(myContext, "JohnnysRepository",
"JohnnysSocialRelations", "SocialRelations",
0, NULL);
rstat = edmiRemoteGetModelBN(myContext, "JohnnysRepository",
"JohnnysSocialRelations", &modelId, NULL);
/* Get instancIds of all persons that
refer to Johnny as their best friend
in their social network */
rstat = edmiRemoteSelectInstanceReferences(myContext,
0, johnnysId, "(BEST_FRIEND :=: johnnysId)",
ONLY_INSTANCE_IDS, NULL, NULL, NULL,
&index, &nHits, &qexRes, NULL,
NULL, NULL, NULL);
/* Copy the social relations graphs
of all persons that consider Johnny
their best friend */
rstat = edmiRemoteConditionalDeepCopyInstances(myContext,
qexRes->instanceIds, 0, modelId,
0, NULL, &tarInstIds, NULL);
edmiFree(tarInstIds);
edmiFreeQueryResult(qexRes);
. . .