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 »


 
Creates an empty nested aggregate within an already existing aggregate. The existing aggregate is denoted the parent aggregate. The nested aggregate to be created is denoted the child aggregate of its parent aggregate.
The type of child aggregate that results from this operation is determined by the aggregate element declaration of the parent aggregate in the underlying Express Schema of the edmModel. Suppose the declaration of the attribute myAttr is;
myAttr : LIST [1:3] OF ARRAY [1:12] OF STRING;
This function would create an array of 12 elements within one of the three elements of the list. The list would have to be created and identified by its aggregateId before invoking this function.
A numeric aggregateID will be returned from the function. This id uniquely identifies the aggregate within the remote EDMdatabase. The aggregateID will remain unchanged throughout the lifetime of the aggregate and may be used to identify the aggregate in subsequent calls to EDMinterface API functions.
The parent aggregate that will be the owner of the nested child aggregate is specified by its aggregateId in the <parentAggrId> argument. AggregateIDs may not be considered plain data values. Nested child aggregates must be created within their parent aggregates. Child aggregateIds may be retrieved by EDMinterface Get operations, but they may not be used to populate parent aggregates by means of EDMinterface Put operations.
This operation is only applicable to aggregates owned by explicit attributes of application instances.
Related functions: edmiRemoteCreateNestedAggrAndWriteAggrElements
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteCreateNestedAggr(SdaiServerContext serverContextId,
                                      SdaiAggr          parentAggrId, 
                                      SdaiAggrFunction  aggrFunction, 
                                      SdaiAggrIndex     aggrIndex,
                                      SdaiAggr          *newAggrId, 
                                      SdaiInvocationId  *edmiInvocationId); 
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

parentAggrId

A numeric aggregateID that uniquely identifies the aggregate of interest in the remote _EDMdatabase{_}.

aggrFunction

Determines the insert point of the created nested aggregate in its parent aggregate. The following is a description of each of the legal values of this argument.
ADD_ELEMENTS: Applicable for the unordered aggregates Set and Bag. May also be used for List, but will then be interpreted as APPEND_ELEMENTS
APPEND_ELEMENTS: The nested aggregate will be appended to the end of the existing list. Applicable for List aggregates only.
PREPEND_ELEMENTS: The nested aggregate will be prepended to the start of the existing list. Applicable for List aggregates only.
INSERT_BEFORE_INDEX: The nested aggregate will be created in the array element with an index that is one less than the index given by the <index> argument. Applicable only for the ordered aggregates aggregates List and Array.
INSERT_AFTER_INDEX: The nested aggregate will be created in the array element with the index given by the <index> argument. Applicable only for the ordered aggregates aggregates List and Array.
ACCESS_BY_INDEX: The nested aggregate will be created in the array element with an index that is one greater than the index given by the <index> argument. Applicable only for the ordered aggregates aggregates List and Array.

aggrIndex

A parent aggregate element position that is used to determine the insertion point of the created nested aggregate.
Applicable only for the ordered aggregates List and Array

newAggrId

Variable that will receive the aggregateId that uniquely identifies the nested typed aggregate in the remote EDMdatabase.

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:
/*
SCHEMA Employees
ENTITY person; 
Name : STRING; 
Age : INTEGER; 
END_ENTITY; 
 
ENTITY Manning; 
DivisionStaff : ARRAY [0:4] OF SET OF person; 
END_ENTITY; 
END_SCHEMA;
*/
 
#define S_NOOF_DIVISIONS 5
int i;
EdmiError rstat;
SdaiServerContext myContext;
SdaiInstance manningId;
SdaiAggr parentAggrId;
SdaiAggr childAggrId[S_NOOF_DIVISIONS];
 
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr", 
"TCP", "9090", "MyServerHost", 
NULL, NULL, NULL, NULL, NULL, &myContext); 
 
/* Create instance of Employees */
rstat = edmiRemoteCreateInstanceAndPutAttrsBN(myContext,
"AdminRepository", "Employees", 
"Manning", 0, &manningId, NULL); 
 
/* Create the parent aggregate */
rstat = edmiRemoteCreateAggrAndWriteAggrElementsBN(myContext,
manningId, "DivisionStaff", 0, 0, 0, NULL, 
&parentAggrId, NULL); 
 
 
/* Create child aggregates for
all company divisions */ 
for (i=0;i<S_NOOF_DIVISIONS;i++) {
rstat = edmiRemoteCreateNestedAggr(myContext, parentAggrId,  
ACCESS_BY_INDEX, i, &childAggrId[i], NULL); 
}
. . .

  • No labels