edmiRemoteSelectAggrInstances

EdmiError edmiRemoteSelectAggrInstances (SdaiServerContext serverContextId,
                                          SdaiAggr          aggrId, 
                                          SdaiVersion       version, 
                                          SdaiInstance      *instanceBuffer,  
                                          SdaiString        condition, 
                                          SdaiOptions       options,
                                          SdaiString        attributes, 
                                          SdaiVoid          include_exclude_filter 
                                          SdaiString        orderBy 
                                          SdaiInteger       *index, 
                                          SdaiInteger       *numberOfHits, 
                                          SdaiQueryResult   *queryResult, 
                                          SdaiString        xmlConfigurationName, 
                                          SdaiString        *resultString, 
                                          SdaiString        resultFileName, 
                                          SdaiInvocationId  *edmiInvocationId); 


Search in the specified aggregate in a remote edmModel for instance elements that match a given condition. The condition may be any legal symbolic Express-X logical expression. A NULL or empty string condition will match all aggregate elements. Each matching aggregate element may be identified by its element index. A matching element will generate a row in the <queryResult> argument. The attributes of the matching instances may be returned in any number of individual columns in the query result table. The index of the first instance element to check, and the maximum number of matching elements to return, are specified as input arguments to the function. The actual number of matching indexes returned and the index of the last returned matching instance in the instance aggregate will be returned from the function. This makes it possible to query through huge aggregates by means of a loop where each iteration handles a small subset of the total aggregate. See the example below.  The logical expression given in the <condition> argument will be compiled by the EDMexpressXCompiler. The query will be executed by the EDMexpressVM. The <attributes> argument may used to specify which instance attribute values to return in the query result table. It may contain "dot expressions", Express built-in functions and EDMexpressX xpf built-in functions.  Attributes argument syntax example: "Name sizeof(sdai_model.underlying_schema.entities)" This example will return two columns for instances of EDM_MODEL type in the SystemRepository.ExpressDataManager model. The two columns are.

  1. The Name attribute of the EDM_MODEL
  2. The number of entities in the "underlying schema" of the model.

The column names in the resulting query table will be "name" and "sizeof(sdai_model.underlying_schema.entities)" respectively. Different column names may be specified by using the "->" operator. Example: if we want the 2nd column to be given the name "entities", we may write the 2nd attribute like this: "sizeof(sdai_model.underlying_schema.entities)->Entities"
Note that the characters white space, comma, and semicolon are all used as delimiters between the attribute "names" in the <attributes> argument, hence none of these characters may be used in the attribute name/attribute expression. The total number of hits will be returned in the <numberOfHits> argument.

Arguments


1TypeNameComment
2SdaiServerContext

serverContextId

Context identification, from edmiDefineServerContext

3SdaiAggr

aggrId

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

4SdaiVersion

version

The version of the edmModel to apply this function call on. The <version> parameter is a numeric sequence number counting from one by increments of one for each new model version that is created. A zero model version number means the current version.

5SdaiInstance

instanceBuffer

Zero terminated instance buffer

6SdaiString

condition

The condition that the instances in the instance aggregate shall match. A NULL or empty string condition will match all the instances in the aggregate.  A valid condition is any Express-X logical expression that refers to any number of attributes defined for the type of instance that is stored in the aggregate element. The instances in the aggregate elements may be of different types. Instances that do not possess one or more attributes that are being referred to in the <condition> argument will always evaluate to UNKNOWN. These elements are considered not matching. The logical expression may also refer to attributes of referenced instances by using dot-notation.
Example conditions:
a. "TRUE"
Equivalent to NULL or empty string.
"(NAME LIKE 'JOHN*') AND (AGE > 30)"
Marches Johnny and John if they are older than 30 years.
"WIFE.MOTHER.DOG.NAME = 'Fido'"
Matches all men with a mother in law that owns a dog named Fido.

7SdaiOptions

options

See description of available options below.  Options may be joined by using the bitwise OR operator

8SdaiString

attributes

Specification of the title and contents of each column of the returned query result table. The following examples illustrate the syntax.
"NAME SEX AGE" :
The attributes name, sex and age will be returned in column 1, 2 and 3 of the returned query table. The title of the columns will be NAME, SEX and AGE respectively.
"NAME,WIFE.MOTHER.DOG.NAME->DOG"
The first column will contain the mans name. The second column will contain the mans mother in laws dogs name. The title of the columns will be NAME and DOG respectively.
"DOG.NAME->DOG;xpfGetMemberCount(DOG. PUPPIES)->PUPPIES"
The first column will contain the dogs name. The second column will contain its number of puppies . The title of the columns will be DOG and PUPPIES respectively.  White space, comma end semicolon are all used as field delimiters.

9SdaiVoid

include_exclude_filter

A zero-terminated buffer of entityIds or a NULL-terminated buffer of string pointers to entity names.

  • If the option FILTER_AS_ENTITY_IDS is used, this parameter will be interpreted as a buffer of instance types.
  • If the option FILTER_AS_ENTITY_NAMES is used, this parameter will be interpreted as a buffer instance type names.
  • If the option INCLUDE_FILTER is used, no instances but those of a type explicitly listed by this argument will be included.
  • If the option EXCLUDE_FILTER is used, all instances but those of a type explicitly listed by this argument will be included.
10SdaiString

orderBy

Name of the query result column to use for sorting. The column may be specified with its constructor or by the column title.  If the <attributes> argument is:
"DOG.NAME->DOG"
The order by argument may be either "DOG" or "DOG.NAME".  This argument is only applicable when one of the options HTML_FORMAT or ASCII_FORMAT is used. Use the options ASCENDING and DESCENDING to specify the sorting direction.

11SdaiInteger

index

In: The index of the element in the instance aggregate to start searching from. The first element in the instance aggregate is indexed zero. Hence the legal index range is: [ 0 <= index < N ] , where N is the number of elements in the instance aggregate.
Out: The index of the last returned matching element. If the return value is incremented by one, it may be used as input value for succeeding calls to the same function. This way, the second call will continue reading elements where the first call finished.

12SdaiInteger

numberOfHits

  • In: The maximum number of matching aggregate elements to return.
  • Out: The number of found matching aggregate elements.
13SdaiQueryResult

queryResult

A variable that will receive the result of the query. 

14SdaiString

xmlConfigurationName

The name of the XML configuration to apply to the resulting XML formatted query result when the option XML_FORMAT is used.

15SdaiString

resultString

Variable that will receive the returned XML, HTML or ASCII formatted query result when the option RESULT_IN_STRING is used with one of the options HTML_FORMAT, ASCII_FORMAT or XML_FORMAT.

16SdaiString

resultFileName

The name of the file that will contain the returned XML, HTML or ASCII formatted query result. Only applicable when using the RESULT_IN_FILE option in combination with one of the options HTML_FORMAT, ASCII_FORMAT or XML_FORMAT.
Use the ZIPPED_FILE option to compress the generated file.

17SdaiInvocationId

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


  

1OptionComment
2

ALL_ATTRIBUTES

When the argument <attributes> is NULL or an empty string, all attributes of the instances will be included in the query result. However, if the <attributes> argument is used to add one or more additional constructed columns or to rename a column in the query result, the return of all the instance attributes will be hindered due to an <attributes> argument that is no longer NULL or an empty string. Use this option to force the including of all instance attributes even when the <attributes> argument is not NULL or an empty string.

3

INCLUDE_CONFIGURATION

Includes the XML Configuration in the generated ISO10303-28 compliant XML formatted query result. This option has no effect unless combined with the option XML_FORMAT.

4

INCLUDE_SCHEMA

Includes the underlying meta data in the generated ISO10303-28 compliant XML formatted query result. This option has no effect unless combined with the option XML_FORMAT.

5

RESULT_IN_STRING

The resulting table will be returned in a string allocated in heap-memory of the calling application.   Use the option RESULT_IN_FILE to write the table to a file.

6

INSTANCES_IN_MEMORY_BUFFER

 

7

EXTRACT_SHALLOW

Use this option to force a shallow XML formatted query result. ISO10303-28 compliant XML Query results are deep by default. No other query result format supported by this function is deep. Hence, this option has no effect unless combined with the option XML_FORMAT.

8

TRANSFER_NO_DATA

No query result will be returned from the remote EDMdatabase. Use this option when the number of matching instances is the only information needed or for testing the query syntax before actually performing it.

9

ASCENDING

Arrange the query result instances in ascending order. This option is only applicable when the <orderBy> argument is used.

10

DESCENDING

Arrange the query result instances in descending order. This option is only applicable when the <orderBy> argument is used.

11

ONLY_INSTANCE_IDS

Return only a single column with the instanceIds of the matching instances.

12

INCLUDE_INSTANCE_IDS

Prepend all attribute columns in the query result with an instanceId column.

13

INCLUDE_FILTER

Only the aggregate elements of types that are explicitly listed in the <include_exclude_filter> argument will be queried for matching instances.

14

EXCLUDE_FILTER

All the aggregate elements, but those of types that are explicitly listed in the <include_exclude_filter> argument, will be queried for matching instances.

15

RESULT_IN_FILE

The resulting table will be written to a file on the local file system of the calling application. The name of the file must be specified in the <resultFileName> argument.

16

EDM_IDENTIFIERS

The instanceIds that uniquely identify the instances in the remote EDMdatabase will be used as xmlIds for identification of the instances within the ISO10303-28 compliant XML formatted query result.

17

FILTER_AS_ENTITY_NAMES

The <include_exclude_filter> argument will be interpreted as a NULL-terminated buffer of entity names.

18

FILTER_AS_ENTITY_IDS

The <include_exclude_filter> argument will be interpreted as a zero-terminated buffer of entityIds.

19

HTML_FORMAT

The query result table will be presented in HTML format in a locally allocated string or in a file on the local file system. See the options RESULT_IN_FILE and RESULT_IN_STRING.

20

ASCII_FORMAT

The query result table will be presented in plain ASCII format in a locally allocated string or in a file on the local file system. See the options RESULT_IN_FILE and RESULT_IN_STRING.

21

OLD_XML_FORMAT

The result of the query will be returned in a simple well formed XML formatted file on the local file system.

22

XML_FORMAT

The result of the query will be returned in an ISO10303-28 compliant XML formatted string or in a file on the local file system.

23

ZIPPED_FILE

The file given by the argument <resultFileName> will be compressed . This option has no effect unless combined with the option RESULT_IN_FILE.

24

IGNORE_EMPTY_COLUMNS

Columns for attributes that do not have defined values for any of the returned instances will be left out of the query result table.

 

Example


 

/*
 SCHEMA Relations 
 ENTITY person; 
 Name : STRING; 
 Age : INTEGER; 
 Pid : INTEGER; 
 Nick : SET OF STRING; 
 Child : SET OF person; 
 END_ENTITY; 
 END_SCHEMA; 
 */
 #define S_BATCHSIZE 10
 int i;
 EdmiError rstat;
 SdaiInteger nHits, nTot, index;
 SdaiServerContext myContext;
 SdaiInstance personId;
 SdaiAggr aggrId;
 SdaiQueryResult qexRes;
  
 /* Create Server Context */
 rstat = edmiDefineServerContext("MyContext",
 "Johnny", "Supervisor", "cf37ftr", 
 "TCP", "9090", "MyServerHost", 
 NULL, NULL, NULL, NULL, NULL, &myContext); 
  
 /* Get the id of the person with
 uniqiue Pid = 16126356667. */ 
 index = 0;
 nHits = 1;
 rstat = edmiRemoteSelectInstances(myContext, "DataRepository",
 "Relations", "Person", "PID = 16126356667",  
 ONLY_INSTANCE_IDS, NULL, NULL, NULL,  
 &index, &nHits, &qexRes,  
 NULL, NULL, NULL, NULL); 
 personId = qexRes->instanceIds[0];
 edmiFreeQueryResult(qexRes);
  
 /* Get the child aggregate Id */
 rstat = edmiRemoteGetAttrsBN(myContext, personId, 0, 1, NULL,
 "Child", sdaiAGGR, &aggrId); 
  
 /* Get all teenage children.
 Read them in batches of 10 */ 
 nTot = 0;
 index = 0;
 nHits = S_BATCHSIZE;
 while (nHits = S_BATCHSIZE) {
  
 rstat = edmiRemoteSelectAggrInstances(myContext, aggrId, 0,  
 "AGE between 13 19", ASCENDING,  
 "NAME AGE", NULL, "AGE",  
 &index, &nHits, &qexRes,  
 NULL, NULL, NULL, NULL); 
  
 /* Get name and age */ 
 for (i=0;i<nHits;i++) {
 SdaiString _name;
 SdaiInteger _age; 
 rstat = edmiRemoteGetAttrsBN(myContext,  
 qexRes->instanceIds[i], 0, 2, NULL,  
 "NAME", sdaiSTRING, &_name, 
 "AGE", sdaiINTEGER, &_age); 
  
 printf("\n%d - Name: %s, Age: %d", (nTot+i), _name, _age); 
 edmiFree(_name); 
 } 
 edmiFreeQueryResult(qexRes); 
 nTot += nHits;
 ++index; 
 }
 printf ("\n%d teenage children found", nTot);
 . . .

 

See also

Filter by label

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

Â