Adds/removes a selection of instances to/from an instance container identified by its container name and modelId. This function may also move instances between containers. The behaviour is controlled by the values given in the source and target parameters <sourceContainerId> and < targetContainerId >. The table below illustrates this;
source |
target |
Behaviour |
Unset |
Set |
The instances will be inserted into the target container. |
Set |
Unset |
The instances will be removed from the source container. |
Set |
Set |
The instances will be moved from source to target. I.e removed from the source container and inserted into the target container. |
Related functions: edmiRemoteCreateInstanceContainer, edmiRemoteDeleteInstanceContainer, edmiRemoteDeleteInstanceContainerBN, edmiRemoteEmptyContainer, edmiRemoteEmptyContainerBN, edmiRemoteGetInstanceContainerId, edmiRemoteGetInstanceContainers, edmiRemoteSetContainerCheckedout, edmiRemoteUnsetContainerCheckedout, edmiRemoteUnsetContainerCheckedoutBN, edmiRemoteSetContainerCheckedoutBN, edmiRemoteInstancesToContainer, edmiRemoteInstanceToContainer, edmiRemoteInstanceToContainerBN.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteInstancesToContainerBN(SdaiServerContext serverContextId,
SdaiModel modelId,
SdaiString sourceContainerName,
SdaiString targetContainerName,
SdaiAggr instancesId,
SdaiAppInstance *instanceBuffer,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
modelId |
The modelId that uniquely identifies the edmModel in the remote EDMdatabase |
sourceContainerName |
The name of the instance container from which to remove the instances. By default, the instances will not be removed from any container. |
targetContainerName |
The name of the instance container in which to insert the instances. By default, the instances will not be inserted into any container. |
instancesId |
A numeric aggregateID that identifies an aggregate containing all the instances to move to, from or between the containers. If this argument is zero, the <instanceBuffer> argument will be used instead. |
instanceBuffer |
A zero-terminated instance buffer containing all the instances to move to, from or between the containers. This argument is only considered when the <instancesId> is not used. |
edmiInvocationId |
Currently not used. |
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;
SdaiModel modelId;
SdaiContainer contId;
SdaiServerContext myContext;
SdaiQueryResult queryResult;
SdaiInteger index = 0, nHits = 10000;
. . .
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyRemoteServerContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Create a lock container */
rstat = edmiRemoteCreateInstanceContainer(myContext,
modelId, LOCK_CONTAINER, "FLOOR01",
"Check out of first floor", &contId, NULL);
/* Select instances to lock */
rstat = edmiRemoteSelectInstances(myContext,
"DataRepository", "GeneralHospital",
"CONSTRUCTION_ELEMENT", "FLOOR = 1",
SUBTYPES | ONLY_INSTANCE_IDS,
NULL, NULL, NULL, &index, &nHits, &queryResult,
NULL, NULL, NULL, NULL);
/* Put first floor in the container */
rstat = edmiRemoteInstancesToContainerBN(myContext, modelId,
NULL, "FLOOR01", 0, queryResult->instanceIds, NULL);
edmiFreeQueryResult(queryResult);
/* Check out the container */
rstat = edmiRemoteProtectInstance(myContext, contId,
(PUBLIC_READ | GROUP_READ | OWNER_WRITE), NULL);
rstat = edmiRemoteSetContainerCheckedoutBN(myContext,
modelId, "FLOOR01", NULL);
. . .
/* Manipulate data here */
. . .
/* Check in the container */
rstat = edmiRemoteUnsetContainerCheckedoutBN(myContext,
modelId, "FLOOR01", NULL);
rstat = edmiRemoteProtectInstance(myContext, contId,
(PUBLIC_READ | GROUP_WRITE | OWNER_WRITE), NULL);
/* Empty and delete the container */
rstat = edmiRemoteEmptyContainerBN(myContext, modelId, "FLOOR01", NULL);
rstat = edmiRemoteDeleteInstanceContainerBN(myContext, modelId,
"FLOOR01", NULL);
. . .