Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
themeConfluence
EdmiError edmiRemoteSelectInstanceReferences(SdaiServerContext serverContextId,
                                              SdaiInstance      currInst,
                                              SdaiVersion       version,
                                              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 remote edmModel with a given server context for instances that externally reference a given instance and that 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 the instances that refer to the given instance.

...

For each application instance in the edmModel the system automatically maintains a reference aggregate containing the instanceIds of all the instances that externally refers to it. Hence, these externally referring instances, which of course may be of any instance type, will allways be available in the instances reference aggregate. It is this reference aggregate that will be searched for instances that match the given condition. Note that if the edmModel was created with the option NO_INSTANCE_REFERENCES, no reference aggregate will be maintained. The advantage of this is that data manipulation performance improves for the edmModel. On the other hand, the drawback is that this function will not work.

...

The index of the first reference aggregate element to check, and the maximum number of matching instances to return, are specified as input arguments to the function. The actual number of matching instances returned and the "index of the last returned matching instance in the reference aggregate" will be returned from the function. This makes it possible to query through huge amounts of instances by means of a loop where each iteration handles a small subset of the total reference aggregate. See the example below.

...

  The <condition> argument will be compiled by the EDMexpressXCompiler

...

. The specified query will be executed by the EDMexpressVM

...

.

...

The <attributes> argument may contain a "dot expression" including Express built-in functions and EDMexpressX

...

xpf built-in functions.
Attributes argument syntax example: "Name sizeof(sdai_model.underlying_schema.entities)"
This example is from an edmiRemoteSelectInstances operation on the EDM_MODEL objects in the SystemRepository.ExpressDataManager model. There will be 2 columns

  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. By using the "->" characters, a new column name can be specified.
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 can be used in the attribute name/attribute expression.
The remote edmModel to query must be open before this operation can be successfully performed.
The total number of hits will be returned in the <numberOfHits> argument.
Related functions:
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteSelectInstanceReferences(SdaiServerContext serverContextId,
                                              SdaiInstance      currInst,
                                              SdaiVersion       version,
                                              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);
Arguments:successfully performed. The total number of hits will be returned in the <numberOfHits> argument.

Arguments

...

1TypeNameComment
2SdaiServerContext

serverContextId

Context identification, from edmiDefineServerContext

3SdaiInstance

currInst

The instance Id that uniquely identifies the application instance in the remote EDMdatabase for which the given condition shall be checked for all its external references.

4SdaiVersion

version

The version number of the edmModel to run the query on. The version number is a sequense number counting from one by increments of one. Use version 0 for current version.

5SdaiString

condition

The condition that the instances in the reference 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 reference instance type. Because the reference aggregate may contain instances of any type, the situation where the condition referres referees to attributes that are not defined for that particular instance type may occur. In this case, the logical expression will evaluate to xpxUNKNOWN. Hence, that instance will not be considered matching the condition.
Example conditions:
"xpxTRUETRUE"
Equivalent to NULL or empty string. Matches all the elements in the reference aggregate.
"(NAME LIKE 'John*') AND (AGE > 30)"
Maches Matches Johnny and Johnatan Jonathan 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.

6SdaiOptions

options

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

7SdaiString

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.
  If an attribute is not relevant for an instance, its returned value will be unset. Whitespace, comma end semicolon are all used as field delimiters.

8SdaiVoid

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 entityIds
  • If the option FILTER_AS_ENTITY_NAMES is used, this parameter will be interpreted as a buffer of strings containing entity names.
  • If the option INCLUDE_FILTER is used, only instances of the entities
explicitely
  • explicitly listed in this argument will be searched.
  • If the option EXCLUDE_FILTER is used, instances of any type except for the entities listed in this argument will be searched.
9SdaiString

orderBy

Name of the query result column to use for sorting. The column may be specified by 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 aplicable applicable when one of the options HTML_FORMAT or ASCII_FORMAT is used. Use the options ASCENDING and DESCENDING to specify the sorting direction.

10SdaiInteger

index

  • In: The index of the element in the reference aggregate to start searching from. The first element in the reference aggregate is indexed zero. Hence the legal index range is: [ 0 <= index < N ] , where N is the number of instances in the reference aggregate.
  • Out: The index of the "last returned matching element" +1. Hence it may be used as input value for a succeeding call to the same function. This way, the second call will start reading instances where the first call finished.
11SdaiInteger

numberOfHits

  • In: Specifies the maximum number of matching instances to return.
  • Out: The number of matching instances found
.
  • .
12SdaiQueryResult

queryResult

A variable that will receive the result of the query. Use edmiFreeQueryResult to release allocated memory.

13SdaiString

xmlConfigurationName

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

14SdaiString

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.

15SdaiString

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.

16SdaiInvocationId

edmiInvocationId

Currently not used.

Options: Descriptions:

Return Value

...

Insert excerpt
US:_r_EDMInterface
US:_r_EDMInterface
nopaneltrue

 

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 aditional 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

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.

7

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.

8

ASCENDING

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

9

DESCENDING

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

10

ONLY_INSTANCE_IDS

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

11

INCLUDE_INSTANCE_IDS

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

12

INCLUDE_FILTER

Only instances of the entities listed in the <include_exclude_filter> argument will be queried.

13

EXCLUDE_FILTER

All instances except those of the entities listed in the <include_exclude_filter> argument will be queried

14

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.

15

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.

16

FILTER_AS_ENTITY_NAMES

The <include_exclude_filter> argument will be interpreted as a NULL-terminated buffer of string pointers. Each string pointer must give the name of an entity to include into or exclude from the query.

17

FILTER_AS_ENTITY_IDS

The <include_exclude_filter> argument will be interpreted as a zero-terminated buffer of entityIds. Each entityId must identify an entity to include into or exclude from the query.

18

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.

19

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.

OLD_XML_FORMAT

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

_IN_STRING.

20

OLD_XML_FORMAT

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

ZIPPED_FILE

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

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.

...

21

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.

22

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.

23

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

...

 

Code Block
languagecpp
#define S_BATCHSIZE 10
 EdmiError rstat;
 SdaiServerContext myContext;
 SdaiInteger index, nHits, nTot;
 SdaiQueryResult qexRes;
 char condition[1024], *pCond;
 char attrs[1024], *pAttrs;
 SdaiOptions options;
 SdaiInstance johnnysId;
  
 /* Create Server Context */
 rstat = edmiDefineServerContext("MyContext",
 "Johnny", "Supervisor", "cf37ftr", 
 "TCP", "9090", "MyServerHost", 
 NULL, NULL, NULL, NULL, NULL, &myContext); 
  
 /* Get Johnnys instance Id */
 nHits = S_BATCHSIZE;
 index = 0;
 options = ONLY_INSTANCE_IDS | SUBTYPES;
 pCond = &condition[0];
 pCond += sprintf(pCond, "(LAST_NAME = 'Jackson')");
 pCond += sprintf(pCond, " AND (FIRST_NAME = 'Johnny')");
 pCond += sprintf(pCond, " AND (BIRTH_DATE = '19631216)')");

...


 rstat = edmiRemoteSelectInstances(myContext, "DataRepository",

...


 "SocialRelations", "Person", condition,

...

 
 options, NULL, NULL, NULL,

...

  
 &index, &nHits, &qexRes,

...

 
 NULL, NULL, NULL, NULL);

...

 
 if (nHits != 1) {

...


 printf("\n%s", nHits ? "Ambigious" : "Not found");

...

 
 if (nHits) edmiFreeQueryResult(qexRes);

...

 
 goto err;

...

 
 }
 johnnysId = qexRes->instanceIds[0];

...


 edmiFreeQueryResult(qexRes);

...


  
 /* Are there any females older than 16 years

...


 that refere to Johnny as their boyfriend */

...

 
 pCond = &condition[0];

...


 pCond += sprintf(pCond, "(BOYFRIEND :=: johnnysId)");

...


 pCond += sprintf(pCond, " AND (AGE >= 16)");

...


 options = TRANSFER_NO_DATA;

...


 index = 0;

...


 nHits = 1; /* One is enough. */

...


 rstat = edmiRemoteSelectInstanceReferences(myContext,

...


 0, johnnysId, condition, options,

...

  
 NULL, NULL, NULL,

...

 
 &index, &nHits, &qexRes,

...

  
 NULL, NULL, NULL, NULL);

...

 
 if (nHits) {

...


 /* Read them in batches of 10.

...

 Note 
 that index now already points at  
 johnnys first potential girlfriend */ 
 nTot = 0; 
 nHits = S_BATCHSIZE; 
 options = RESULT_IN_STRING | ASCENDING;

...

 
 pAttrs = &attrs[0];

...

 
 pAttrs += sprintf(pAttrs, "LAST_NAME->FamilyName");

...

 
 pAttrs += sprintf(pAttrs, ";FIRST_NAME->Name");

...

 
 pAttrs += sprintf(pAttrs, ";AGE->Age");

...

 
 pAttrs += sprintf(pAttrs, ";PHONE_NO->Phone");

...

 
 while (nHits = S_BATCHSIZE) {

...

 
 SdaiString _resString;

...

 
 rstat = edmiRemoteSelectInstanceReferences(myContext,

...

  
 0, johnnysId, condition, options,

...

  
 attrs, NULL, "AGE",

...

 
 &index, &nHits, &qexRes, NULL,

...

  
 &_resString, NULL, NULL);

...

 
  
 printf("\n\n%s", _resString);

...

 
 edmiFree(_resString);

...

 
 nTot += nHits;

...

 
 ++index;

...

 
 } 
 printf("\n\n%d potential girlfriends found", nTot);

...

 
 } else {

...


 printf("\nSorry Johnny, no potential girlfriends found.");

...

 
 }
 . . . 

 

See also

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "model" and parent = "6062220"