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 »


 
Invokes the EDMmodelChecker to validate an application instance against a specified local rule (also denoted Where Rules) in a remote EDMdatabase. The local rule must be defined within the dictionary model of the data model. It may be defined in the data models underlying Express Schema or in any EDMruleSchema that has been compiled to extend the data models dictionary model.
The result of the validation may be a plain text report or a population of the EDM_VALIDATION_RESULT_SCHEMA. The validation result population may be used for generating validation reports with a user defined layout and format.
The expressions logging can be used to trace the validation process in the EDMexpressVM. The EDMsupervisor and the interactive EDMdebugger may be used for testing and debugging rules as well as for getting detailed information from the validation process.
Related functions: edmiRemoteValidateGlobalRule , edmiRemoteValidateInstance , edmiRemoteValidateInstanceType , edmiRemoteValidateModel
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteValidateWhereRule(SdaiServerContext  serverContextId,
                                       SdaiAppInstance    currInst,
                                       SdaiVersion        version, 
                                       SdaiString         remoteWhereRuleName, 
                                       SdaiInteger        nFileMappings,
                                       SdaiFileMapping    fileMapping[]
                                       SdaiInteger        options,
                                       SdaiString         remoteRuleSchemaName,
                                       SdaiLogDescription logDescription,
                                       SdaiInteger        numberOfParameters,
                                       SdaiSelect         parameters[],
                                       SdaiSelect         userReturnedValue,
                                       SdaiLogical        *result,
                                       SdaiInvocationId   *edmiInvocationId);
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

currInst

A numeric instanceID that uniquely identifies the application instance to be validated in the remote _EDMdatabase{_}.

version

The version of the edmModel for which to apply this operation. A zero value means the current version.

remoteWhereRuleName

The name of the local rule to validate. Rule names are case insensitive. If the <remoteWhereRuleName> is not unique within the specified instance, the rule name must be qualified with the name of the entity from which it was originally inherited.

nFileMappings

Currently not used.

FileMapping

Currently not used.

options

Currently not used.

remoteRuleSchemaName

The name of the EDMruleSchema to use for the validation. Rule schema names are case insensitive. If this argument is NULL or an empty string, the population will be validated against the rules and constraints defined in the models underlying Express Schema.

logDescription

An SdaiLogDescription structure containing the specifications for the logging of the validation process.

numberOfParameters

The number of parameters in the <parameters> argument.

parameters

Buffer of pointers to locally allocated tSdaiSelect structures. Each tSdaiSelect structure defines the type and value of an input parameter to the validation process.

userReturnedValue

Pointer to a locally allocated tSdaiSelect structure that may be used by the global rule to communicate a user defined status with the calling application.

result

An SdaiLogical variable that will receive the result of the local rule validation. The returned logical values means;
sdaiTRUE: No local rules were violated.
sdaiFALSE: One or more local rules were violated
sdaiUNKNOWN: Undetermined status due to unset values or error in operation.

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:
/*
– -------------------------------------- 
– File: c:/data/furniture.exp 
– -------------------------------------- 
SCHEMA Furniture; 
TYPE tScrewType = ENUMERATION OF (PHILIPS, ALLEN, FLAT); END_TYPE; 
ENTITY Screw; 
Id : STRING; 
Typ : tScrewType; 
Len : REAL; 
Dia : REAL; 
END_ENTITY; 
ENTITY Dining_Table; 
Name : STRING; 
Legs : INTEGER; 
Len : REAL; 
Width : REAL; 
Height : REAL; 
Screws : BAG OF Screw; 
END_ENTITY; 
END_SCHEMA; 
 
– -------------------------------------- 
– File: c:/data/furniture_rule.rex. 
– -------------------------------------- 
RULE_SCHEMA Furniture_Rule FOR Furniture; 
 
– GLOBAL RULE: 
– At least N tables in stock, where N 
– is an input parameter to the rule. 
RULE globalRule FOR (Dining_Table); 
LOCAL 
nTables : INTEGER; 
END_LOCAL; 
xpxGetUserParameter(1, nTables); 
WHERE 
w_nTables : SIZEOF(Dining_Table) > nTables; 
END_RULE; 
 
– LOCAL RULE: 
– A dining table must have 4 legs 
ENTITY Dining_Table; 
WHERE 
w_nLegs : Legs = 4; 
END_ENTITY; 
 
END_RULE_SCHEMA; 
*/
EdmiError rstat, error;
SdaiInteger nErr, nWrn, index, nHits;
SdaiServerContext myContext;
SdaiInstance tableId;
tSdaiSelect sel;
SdaiSelect retVal = &sel;
SdaiLogical result;
SdaiQueryResult qexRes;
tSdaiLogDescription logDescr = {
FULL_LOG | LOG_TO_FILE,  
NULL, NULL, 
"c:/temp/globalRule.dia", 
"c:/temp/globalRule.out", 
104857600 }; 
 
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyRemoteServerContext",
"Johnny", "Supervisor", "cf37ftr", 
"TCP", "9090", "MyServerHost", 
NULL, NULL, NULL, NULL, NULL, &myContext); 
 
/* Compile the Express Schema */
rstat = edmiRemoteDefineSchema(myContext, EXPRESS_SCHEMA_TYPE,
"c:/data/furniture.exp", "c:/temp/furniture.dia",  
"Furniture", 0, &nWrn, &nErr, NULL); 
 
/* Compile the Rule Schema */
rstat = edmiRemoteDefineSchema(myContext, RULE_SCHEMA_TYPE,
"c:/data/furniture_rule.rex", "c:/temp/furniture_rule.dia", 
"Furniture_Rule", 0, &nWrn, &nErr, NULL); 
 
/* Import the product catalogue from a p21 file
into the model Products in the DataRepository */ 
rstat = edmiRemoteReadStepFile(myContext, "DataRepository",
"Products", NULL, NULL, "c:/data/furniture.stp", 
"c:/temp/furniture.stp.dia", "Furniture", NULL, 
0, &nWrn, &nErr, &error, NULL); 
 
/* Get the Id of the table PIZA-210 */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "DataRepository",
"Products", "Dining_Table", "NAME = 'PIZA-210'",  
ONLY_INSTANCE_IDS, NULL, NULL, NULL,  
&index, &nHits, &qexRes,  
NULL, NULL, NULL, NULL); 
tableId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
 
/* Validate local rules */
rstat = edmiRemoteValidateWhereRule(myContext, tableId, 0, "w_Legs",
0, NULL, LOG_TO_FILE, "Furniture_Rule", &logDescr,  
0, NULL, retVal, &result, NULL);  
 
/* Check the validation result */
switch(result) {
case sdaiFALSE:  
printf("\nError: Illegal number of legs"); 
break; 
case sdaiUNKNOWN: 
printf("\nError: Undetermined status"); 
break; 
case sdaiTRUE: 
printf("\nThe stock is rule compliant"); 
break; 
}
. . .

  • No labels