edmiRemoteCreateNestedAggrAndWriteAggrElements


 

EdmiError edmiRemoteCreateNestedAggrAndWriteAggrElements(SdaiServerContext serverContextId, 
                                                           SdaiAggr          parentAggrId, 
                                                           SdaiAggrFunction  aggrFunction,
                                                           SdaiAggrIndex     aggrIndex,
                                                           SdaiAggrIndex     elementIndex,
                                                           SdaiInteger       elements, 
                                                           SdaiPrimitiveType datatype, 
                                                           SdaiVoid          dataValues, 
                                                           SdaiAggr          *newAggrId, 
                                                           SdaiInvocationId  *edmiInvocationId); 


Creates a nested aggregate within an already existing aggregate and inserts any number of given data values in the nested 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 child aggregate within the remote EDMdatabase. This aggregateID will remain unchanged throughout the lifetime of the child aggregate and may be used to identify it 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 <parentAggr> 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 application instances.

Arguments


 

1TypeNameComment
2 SdaiServerContext

serverContextId

Context identification, from edmiDefineServerContext

3 SdaiAggr

parentAggrId

A numeric aggregateID that uniquely identifies the aggregate of interest in the remote EDMdatabase

4 SdaiAggrFunction

aggrFunction

Determines the insert point of the created nested aggregate in its parent aggregate. This argument has no effect on the ordering of the elements that are written to the created nested 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.
5 SdaiAggrIndex

aggrIndex

The parent aggregate element position in which the child aggregate will be inserted.
Applicable only for the ordered aggregates List and Array

6 SdaiAggrIndex

elementIndex

The child aggregate element to start inserting the values given in the <dataValues> aggregate. This argument is applicable for Array aggregates only. Note that the index range of an array is declared in the underlying Express Schema of the edmModel. The declared lower and upper bounds of the index range for an array may be obtained by the function edmiRemoteGetAggrDescr.

7 SdaiInteger

elements

The number of elements to write to the specified nested aggregate.

8 SdaiPrimitiveType

datatype

Currently, this function can only handle the datatype sdaiSELECT.

9 SdaiVoid

dataValues

A buffer of tSdaiSelect data stuctures. Each element contains a value to be written to the created nested aggregate.

10 SdaiAggr

newAggrId

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

11 SdaiInvocationId

edmiInvocationId

Currently not used.

Return Value


Error rendering macro 'excerpt-include' : User 'null' does not have permission to view the page 'US:_r_EDMInterface'.

 

Options


  

 

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, johnnyId, lucyId;
 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 Johnny */
 rstat = edmiRemoteCreateInstanceAndPutAttrsBN(myContext,
 "AdminRepository", "Employees", 
 "Person", 2, &johnnyId, NULL,  
 "NAME", sdaiSTRING, "Johnny",  
 "AGE", sdaiINTEGER, 32); 
  
 /* Create Lucy */
 rstat = edmiRemoteCreateInstanceAndPutAttrsBN(myContext,
 "AdminRepository", "Employees", 
 "Person", 2, &lucyId, NULL,  
 "NAME", sdaiSTRING, "Johnny",  
 "AGE", sdaiINTEGER, 32); 
  
  
 /* Create child aggregates for all company divisions
 Johnny and Lucy are employees of all divisions */ 
 for (i=0;i<S_NOOF_DIVISIONS;i++) {
 SdaiInstance _staff[2] = {johnnyId, lucyId}; 
 rstat = edmiRemoteCreateNestedAggrAndWriteAggrElements(myContext,  
 parentAggrId, ACCESS_BY_INDEX, i, 0, 2, 
 sdaiINSTANCE, _staff, &childAggrId[i], NULL); 
 }
 . . . 

 

See also

Filter by label

There are no items with the selected labels at this time.