### User and Session Management Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3314679826 This section details how to connect as a superuser, open a session, and manage users and groups. ```APIDOC ## Connect as superuser ### Description Connects to the EDMdatabase as the superuser. ### Method C API (example) ### Endpoint N/A (Database connection) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters - **username** (string) - Required - The username to connect with (e.g., "superuser"). - **password** (string) - Required - The password for the user. - **dbPwd** (string) - Required - The password for the database. #### Query Parameters None #### Request Body None ### Request Example ```c if (rstat = edmiConnect("superuser", NULL, dbPwd, &unavailMess)) { printf("\nERROR: Failed to connect as superuser with error '%s'", edmiGetErrorText(rstat)); goto err; } ``` ### Response #### Success Response (0) - **rstat** (int) - 0 indicates successful connection. - **unavailMess** (string) - Message provided if the database is temporarily unavailable. #### Response Example ```json { "status": "success", "message": "" } ``` --- ## Open a session ### Description Opens a new session for the currently connected user. ### Method C API (example) ### Endpoint N/A (Session management) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c if ((suSessId = sdaiOpenSession()) == 0) { printf("\nERROR: Failed to open session for superuser with error '%s'", edmiGetErrorText(rstat)); goto err; } ``` ### Response #### Success Response (>0) - **suSessId** (int) - A non-zero session ID indicating a successful session opening. #### Response Example ```json { "sessionId": 12345 } ``` ``` -------------------------------- ### Example Usage of edmiRemoteInstancesToContainerBN in C Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179586/edmiRemoteInstancesToContainerBN This C code example demonstrates the practical application of edmiRemoteInstancesToContainerBN. It shows the setup of a remote server context, creation of an instance container, selection of instances, and then using edmiRemoteInstancesToContainerBN to move these instances into the created container. The example also includes subsequent steps for protecting, checking out, and finally cleaning up the container. ```c EdmiError rstat; SdaiModel modelId; SdaiContainer contId; SdaiServerContext myContext; SdaiQueryResult queryResult; SdaiInteger index = 0, nHits = 10000; . . . /* Define Remote Server Context */ rstat = edmiDefineServerContext("MyRemoteServerContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Create a lock container */ rstat = edmiRemoteCreateInstanceContainer(myContext, modelId, LOCK_CONTAINER, "FLOOR01", "Check out of first floor", &contId, NULL); /* Select instances to lock */ rstat = edmiRemoteSelectInstances(myContext, "DataRepository", "GeneralHospital", "CONSTRUCTION_ELEMENT", "FLOOR = 1", SUBTYPES | ONLY_INSTANCE_IDS, NULL, NULL, NULL, &index, &nHits, &queryResult, NULL, NULL, NULL, NULL); /* Put first floor in the container */ rstat = edmiRemoteInstancesToContainerBN(myContext, modelId, NULL, "FLOOR01", 0, queryResult->instanceIds, NULL); edmiFreeQueryResult(queryResult); /* Check out the container */ rstat = edmiRemoteProtectInstance(myContext, contId, (PUBLIC_READ | GROUP_READ | OWNER_WRITE), NULL); rstat = edmiRemoteSetContainerCheckedoutBN(myContext, modelId, "FLOOR01", NULL); . . . /* Manipulate data here */ . . . /* Check in the container */ rstat = edmiRemoteUnsetContainerCheckedoutBN(myContext, modelId, "FLOOR01", NULL); rstat = edmiRemoteProtectInstance(myContext, contId, (PUBLIC_READ | GROUP_WRITE | OWNER_WRITE), NULL); /* Empty and delete the container */ rstat = edmiRemoteEmptyContainerBN(myContext, modelId, "FLOOR01", NULL); rstat = edmiRemoteDeleteInstanceContainerBN(myContext, modelId, "FLOOR01", NULL); . . . ``` -------------------------------- ### Example One: Hello world Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888 A C-LateBinding example demonstrating basic EDM functionality: creating a database, compiling a schema, creating a data model, populating an instance, and retrieving an attribute value. ```APIDOC ## Example One: Hello world ### Description This example demonstrates the basic principles of EDM, including database creation, schema compilation, model creation, instance population, and attribute retrieval using C-LateBinding. ### Key Steps 1. Creates and opens a database. 2. Compiles an EXPRESS schema. 3. Creates a data model. 4. Populates an instance. 5. Retrieves an attribute value. ### Code Snippet ```c #include #include "sdai.h" #define DBLOC "db" #define EXP_FILE "hello.exp" #define DBNAME "db" #define DBPASSW "db" #define MYSCHEMA "hello_schema" #define MYMODEL "HELLO" #define DIA_FILE "comp.dia" #define STEP_FILE "hello.stp" void main() { long rstat,nwarnings,nerrors; SdaiRepository data_repository; SdaiSession sessionId; SdaiModel mymodel; SdaiInstance hello_instance; SdaiString hello_world; char c; // CREATE DATABASE AND OPEN SESSION rstat = edmiDeleteDatabase(DBLOC,DBNAME,DBPASSW); rstat = sdaiErrorQuery(); rstat = edmiCreateDatabase(DBLOC,DBNAME,DBPASSW); rstat = edmiOpenDatabase(DBLOC,DBNAME,DBPASSW); sessionId = sdaiOpenSession(); if(rstat = sdaiErrorQuery()) goto err; // COMPILE THE SCHEMA if(rstat = edmiDefineSchema(EXP_FILE, DIA_FILE, NULL, 0, &nwarnings, &nerrors)) goto err; if(nerrors){ printf("\nErrors when compiling %s",EXP_FILE); goto end; } // OPEN THE DATA REPOSITORY,CREATE A MODEL AND OPEN IT data_repository = sdaiOpenRepositoryBN("DataRepository"); mymodel = sdaiCreateModelBN(data_repository,MYMODEL,MYSCHEMA); mymodel = sdaiOpenModelBN(data_repository,MYMODEL,sdaiRW); if(rstat = sdaiErrorQuery()) goto err; // POPULATE INSTANCE hello_instance = sdaiCreateInstanceBN(mymodel,"HELLO"); sdaiPutAttrBN(hello_instance,"HELLO",sdaiSTRING,"Hello world!"); if(rstat = sdaiErrorQuery()) goto err; // RETRIEVE ATTRIBUTE VALUE sdaiGetAttrBN(hello_instance,"HELLO",sdaiSTRING,&hello_world); if(rstat = sdaiErrorQuery()) goto err; printf("\n%s\n",hello_world); goto end; err: // ERROR printf("\nERROR: rstat= %d: %s",rstat,edmiGetErrorText(rstat)); end: // CLOSE DATABASE edmiCloseDatabase(""); if(rstat){ printf("\nError\n"); } else { printf("\nNo error\n"); } #ifdef _WINDOWS c = getchar(); #endif } ``` ``` -------------------------------- ### Parse the Query Result Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3314679826/www.atlassian Provides an example of how to parse and extract data from the `queryResult` structure returned by `edmiRemoteSelectInstances`. ```APIDOC ## Parse the Query Result ### Description Parses the `queryResult` data structure obtained from `edmiRemoteSelectInstances` to extract and display specific fields from the query results. ### Method C Code Snippet ### Endpoint N/A (Data Processing) ### Parameters None ### Request Example ```c if (queryResult) { SdaiString *gid = (SdaiString *) queryResult->columnDescr[0]->pvalue; SdaiString *name = (SdaiString *) queryResult->columnDescr[1]->pvalue; SdaiString *owner = (SdaiString *) queryResult->columnDescr[2]->pvalue; printf("\n%-24s%-6s%-30s", "GlobalId", "Name", "Owner Name"); printf("\n======================================================="); for (i = 0; i < queryResult->rows; i++) { printf("\n%-24s%-6s%-30s", gid[i], name[i], owner[i]); } } ``` ### Response #### Success Response Prints the extracted data to the console in a formatted table. #### Response Example ``` GlobalId Name Owner Name ======================================================= 123456789012345678901234 A1 John Doe ``` ``` -------------------------------- ### JSON Response Example Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/4218716164/Installation%2BGuide%2B4 This JSON object represents a server response, likely indicating the duration of the server's processing time and a unique identifier for the request. ```json { "serverDuration": 11, "requestCorrelationId": "03c782ccf3434a229b4664efe416531c" } ``` -------------------------------- ### Starting EDMsix Server with Configuration Parameter Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3312354932/www.atlassian This command line example shows how to start the EDMsix server with specific configuration parameters. It includes database path, port, name, password, and the '-ae' argument to set 'EXTENDED_ACCESS_CHECKING' to 'TRUE'. This method is applicable to EDMsixServer and EDMapplicationServers. ```bash C:\> edmserver.exe -lc:\db -s4500 -nMyDB -pMyPwd_2017 -c -aeEXTENDED_ACCESS_CHECKING=TRUE ``` -------------------------------- ### C-LateBinding Hello World Example Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888 A simplified C example demonstrating late-binding functionality. It covers creating and opening a database, compiling an EXPRESS schema, creating a data model, populating an instance, and retrieving an attribute value. ```C #include #include "sdai.h" #define DBLOC "db" #define EXP_FILE "hello.exp" #define DBNAME "db" #define DBPASSW "db" #define MYSCHEMA "hello_schema" #define MYMODEL "HELLO" #define DIA_FILE "comp.dia" #define STEP_FILE "hello.stp" void main() { long rstat,nwarnings,nerrors; SdaiRepository data_repository; SdaiSession sessionId; SdaiModel mymodel; SdaiInstance hello_instance; SdaiString hello_world; char c; /* CREATE DATABASE AND OPEN SESSION */ rstat = edmiDeleteDatabase(DBLOC,DBNAME,DBPASSW); rstat = sdaiErrorQuery(); rstat = edmiCreateDatabase(DBLOC,DBNAME,DBPASSW); rstat = edmiOpenDatabase(DBLOC,DBNAME,DBPASSW); sessionId = sdaiOpenSession(); if(rstat = sdaiErrorQuery()) goto err; /* COMPILE THE SCHEMA */ if(rstat = edmiDefineSchema(EXP_FILE, DIA_FILE, NULL, 0, &nwarnings, &nerrors)) goto err; if(nerrors){ printf("\nErrors when compiling %s",EXP_FILE); goto end; } /* OPEN THE DATA REPOSITORY,CREATE A MODEL AND OPEN IT */ data_repository = sdaiOpenRepositoryBN("DataRepository"); mymodel = sdaiCreateModelBN(data_repository,MYMODEL,MYSCHEMA); mymodel = sdaiOpenModelBN(data_repository,MYMODEL,sdaiRW); if(rstat = sdaiErrorQuery()) goto err; /* POPULATE INSTANCE */ hello_instance = sdaiCreateInstanceBN(mymodel,"HELLO"); sdaiPutAttrBN(hello_instance,"HELLO",sdaiSTRING,"Hello world!"); if(rstat = sdaiErrorQuery()) goto err; /* RETRIEVE ATTRIBUTE VALUE */ sdaiGetAttrBN(hello_instance,"HELLO",sdaiSTRING,&hello_world); if(rstat = sdaiErrorQuery()) goto err; printf("\n%s\n",hello_world); goto end; err: /* ERROR */ printf("\nERROR: rstat= %d: %s",rstat,edmiGetErrorText(rstat)); end: /* CLOSE DATABASE */ edmiCloseDatabase(""); if(rstat){ printf("\nError\n"); } else { printf("\nNo error\n"); } #ifdef _WINDOWS c = getchar(); #endif } ``` -------------------------------- ### Create EDM Repository Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3314679826/Sample%2B01 This code example shows how to create a new EDM repository, which serves a similar purpose to directories in a file system. The `edmiCreateRepository` function is used, and it returns a unique repository ID. This repository can then be used to store data sets. ```c if (rstat = edmiCreateRepository(repositoryName, &repositoryId)) { printf("\nERROR: Could not create the '%s' repository with error '%s'", repositoryName, edmiGetErrorText(rstat)); goto err; } ``` -------------------------------- ### C-LateBinding Hello World Example Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888/DEVELOPING%2BAPPLICATIONS%2BWITH%2BEDMinterface A C-LateBinding example demonstrating basic EDM interface functionality. It includes creating and opening a database, compiling an EXPRESS schema, creating a data model, populating an instance, retrieving an attribute value, and handling errors. This example requires the 'sdai.h' header and defines several constants for database and file paths. ```c #include #include "sdai.h" #define DBLOC "db" #define EXP_FILE "hello.exp" #define DBNAME "db" #define DBPASSW "db" #define MYSCHEMA "hello_schema" #define MYMODEL "HELLO" #define DIA_FILE "comp.dia" #define STEP_FILE "hello.stp" void main() { long rstat,nwarnings,nerrors; SdaiRepository data_repository; SdaiSession sessionId; SdaiModel mymodel; SdaiInstance hello_instance; SdaiString hello_world; char c; /**------------------------------------------** / /* CREATE DATABASE AND OPEN SESSION */ /* -----------------------------------------*/ rstat = edmiDeleteDatabase(DBLOC,DBNAME,DBPASSW); rstat = sdaiErrorQuery(); rstat = edmiCreateDatabase(DBLOC,DBNAME,DBPASSW); rstat = edmiOpenDatabase(DBLOC,DBNAME,DBPASSW); sessionId = sdaiOpenSession(); if(rstat = sdaiErrorQuery()) goto err; /**------------------------------------------** / /* COMPILE THE SCHEMA */ /* -----------------------------------------*/ if(rstat = edmiDefineSchema(EXP_FILE, DIA_FILE, NULL, 0, &nwarnings, &nerrors)) goto err; if(nerrors){ printf("\nErrors when compiling %s",EXP_FILE); goto end; } /**-----------------------------------------------------** / /* OPEN THE DATA REPOSITORY,CREATE A MODEL AND OPEN IT */ /* ----------------------------------------------------*/ data_repository = sdaiOpenRepositoryBN("DataRepository"); mymodel = sdaiCreateModelBN(data_repository,MYMODEL,MYSCHEMA); mymodel = sdaiOpenModelBN(data_repository,MYMODEL,sdaiRW); if(rstat = sdaiErrorQuery()) goto err; /**-----------------------------------------------------** / /* POPULATE INSTANCE */ /* ----------------------------------------------------*/ hello_instance = sdaiCreateInstanceBN(mymodel,"HELLO"); sdaiPutAttrBN(hello_instance,"HELLO",sdaiSTRING,"Hello world!"); if(rstat = sdaiErrorQuery()) goto err; /**-----------------------------------------------------** / /* RETRIEVE ATTRIBUTE VALUE */ /* ----------------------------------------------------*/ sdaiGetAttrBN(hello_instance,"HELLO",sdaiSTRING,&hello_world); if(rstat = sdaiErrorQuery()) goto err; printf("\n%s\n",hello_world); goto end; err: /**-------** / /* ERROR */ /* ------*/ printf("\nERROR: rstat= %d: %s",rstat,edmiGetErrorText(rstat)); end: /**-----------------** / /* CLOSE DATABASE */ /* ----------------*/ edmiCloseDatabase(""); if(rstat){ printf("\nError\n"); } else { printf("\nNo error\n"); } #ifdef _WINDOWS c = getchar(); #endif } ``` -------------------------------- ### Install and Run EDMservice Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3438936698/Removing%2BEDM%2Blicense%2Band%2BEDM_HOME_ This snippet shows how to install the EDMservice as a Windows service and then run it. Installation requires administrator privileges. Running the executable without arguments starts the service. ```batch EDM6Service.exe -i EDM6Service.exe ``` -------------------------------- ### Query IFCBUILDINGSTOREY instances and format as XML (C) Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3314679826/Sample%2B01 This C code snippet demonstrates how to select IFCBUILDINGSTOREY instances based on a name pattern and retrieve them in XML format. It utilizes the edmiRemoteSelectInstances function and handles potential errors. The example also explains the use of 'index' and 'numberOfHits' for iterating through large result sets. ```c numberOfHits = 100; /* Read only the 100 first hits in this invocation */ index = 0; if (rstat = edmiRemoteSelectInstances(contextId, repositoryName, modelName, "ifcBuildingStorey", "xpxLike(Name,'*etg*',XPXCASE_INSENSITIVE) or xpxLike(Name,'*storey*',XPXCASE_INSENSITIVE)", RESULT_IN_FILE | XML_FORMAT, NULL, NULL, NULL, &index, &numberOfHits, &queryResult, NULL, &resultString, queryResultFile, NULL)) { printf("\nERROR: Select IFCBUILDINGSTOREY objects failed with error '%s'", edmiGetErrorText(rstat)); goto err; } ``` -------------------------------- ### EDMinterface Setup and Files Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888/www.atlassian Details the necessary files and setup procedures for application development using the EDMsdk toolkit on both WINDOWS and UNIX platforms. ```APIDOC ## EDMinterface Setup and Files ### Description This section outlines the files required for application development with the EDMsdk toolkit and the necessary setup steps for different platforms. ### Platform Specific Files **WINDOWS Platform:** * `\Include\sdai.h` - The EDMI header file. * `\bin\edmikit400.lib` - The EDMinterface library. * `\bin\edmikit400.dll` - The EDMinterface library. * `\Include\cpp_edmi.h` - The EDMinterface/C++ header file. * `\bin\cpp_edmi.lib` - The EDMinterface/C++ library. * `\bin\cpp_edmi.dll` - The EDMinterface/C++ library. **UNIX Platforms:** * `/sdai.h` - The EDMI header file. * `/edmi.a` - The EDMinterface static library. ### Compilation and Environment Setup * Use the ANSI C conformance option when compiling C code. * Add `` to the preprocessor `#include` file search path. * Define `LD_LIBRARY_PATH` (or `LIBPATH`) and `CLASSPATH` environment variables upon login. ``` -------------------------------- ### C: Database Initialization and Schema Compilation Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888 This C code snippet demonstrates the initialization of a database, including deleting an existing one, creating a new one, and opening a session. It then proceeds to compile a schema definition file. Error checking is performed after each significant operation. ```c /* CREATE DATABASE AND OPEN SESSION */ /* -----------------------------------------*/ rstat = edmiDeleteDatabase(DBLOC,DBNAME,DBPASSW); rstat = sdaiErrorQuery(); rstat = edmiCreateDatabase(DBLOC,DBNAME,DBPASSW); rstat = edmiOpenDatabase(DBLOC,DBNAME,DBPASSW); sessionId = sdaiOpenSession(); CHECK_ERR(__FILE,LINE_ _); /* COMPILE THE SCHEMA */ /* -----------------------------------------*/ rstat = edmiDefineSchema(EXP_FILE,DIA_FILE,NULL,0 ,&nwarnings,&nerrors); CHECK_ERR(__FILE,LINE_ _); if(nerrors){ printf("\nErrors when compiling %s",EXP_FILE); goto end; } ``` -------------------------------- ### Get Schema ID Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3314679826/www.atlassian Retrieves the unique identifier for a compiled schema. This function is used when the schema ID is needed for subsequent operations. ```APIDOC ## GET /api/schemas/{schemaName}/id ### Description Retrieves the unique identifier for a compiled schema. This function is used when the schema ID is needed for subsequent operations. ### Method GET ### Endpoint /api/schemas/{schemaName}/id ### Parameters #### Path Parameters - **schemaName** (string) - Required - The name of the schema to retrieve the ID for. ### Request Body This endpoint does not require a request body. ### Response #### Success Response (200) - **schemaId** (integer) - The unique identifier of the schema. #### Response Example ```json { "schemaId": 12345 } ``` ``` -------------------------------- ### C Late-Binding Hello World Example Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888/www.atlassian A C-language example demonstrating late-binding functionality. It covers creating and opening a database, compiling an EXPRESS schema, creating a data model, populating an instance, and retrieving an attribute value. This example utilizes functions like edmiDeleteDatabase, sdaiOpenSession, edmiDefineSchema, sdaiCreateModelBN, sdaiCreateInstanceBN, sdaiPutAttrBN, and sdaiGetAttrBN. ```c #include #include "sdai.h" #define DBLOC "db" #define EXP_FILE "hello.exp" #define DBNAME "db" #define DBPASSW "db" #define MYSCHEMA "hello_schema" #define MYMODEL "HELLO" #define DIA_FILE "comp.dia" #define STEP_FILE "hello.stp" void main() { long rstat,nwarnings,nerrors; SdaiRepository data_repository; SdaiSession sessionId; SdaiModel mymodel; SdaiInstance hello_instance; SdaiString hello_world; char c; /**------------------------------------------** / /* CREATE DATABASE AND OPEN SESSION */ /* -----------------------------------------*/ rstat = edmiDeleteDatabase(DBLOC,DBNAME,DBPASSW); rstat = sdaiErrorQuery(); rstat = edmiCreateDatabase(DBLOC,DBNAME,DBPASSW); rstat = edmiOpenDatabase(DBLOC,DBNAME,DBPASSW); sessionId = sdaiOpenSession(); if(rstat = sdaiErrorQuery()) goto err; /**------------------------------------------** / /* COMPILE THE SCHEMA */ /* -----------------------------------------*/ if(rstat = edmiDefineSchema(EXP_FILE, DIA_FILE, NULL, 0, &nwarnings, &nerrors)) goto err; if(nerrors){ printf("\nErrors when compiling %s",EXP_FILE); goto end; } /**-----------------------------------------------------** / /* OPEN THE DATA REPOSITORY,CREATE A MODEL AND OPEN IT */ /* ----------------------------------------------------*/ data_repository = sdaiOpenRepositoryBN("DataRepository"); mymodel = sdaiCreateModelBN(data_repository,MYMODEL,MYSCHEMA); mymodel = sdaiOpenModelBN(data_repository,MYMODEL,sdaiRW); if(rstat = sdaiErrorQuery()) goto err; /**-----------------------------------------------------** / /* POPULATE INSTANCE */ /* ----------------------------------------------------*/ hello_instance = sdaiCreateInstanceBN(mymodel,"HELLO"); sdaiPutAttrBN(hello_instance,"HELLO",sdaiSTRING,"Hello world!"); if(rstat = sdaiErrorQuery()) goto err; /**-----------------------------------------------------** / /* RETRIEVE ATTRIBUTE VALUE */ /* ----------------------------------------------------*/ sdaiGetAttrBN(hello_instance,"HELLO",sdaiSTRING,&hello_world); if(rstat = sdaiErrorQuery()) goto err; printf("\n%s\n",hello_world); goto end; err: /**-------** / /* ERROR */ /* ------*/ printf("\nERROR: rstat= %d: %s",rstat,edmiGetErrorText(rstat)); end: /**-----------------** / /* CLOSE DATABASE */ /* ----------------*/ edmiCloseDatabase(""); if(rstat){ printf("\nError\n"); } else { printf("\nNo error\n"); } #ifdef _WINDOWS c = getchar(); #endif } ``` -------------------------------- ### Example: Define, Start, Stop, and Close EDM Expression Log (C) Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179025/www.atlassian This example demonstrates the complete lifecycle of expression logging using EDM functions. It shows how to define log parameters, start logging, stop logging, and finally close the log session. Error handling is included for the definition step. ```c EdmiError rstat; ... If (rstat = edmiDefineExpressionsLog ( "Man2MaleAdult, Woman2FemaleAdult, Child2BoyOrGirl", "Child2BoyOrGirl, 200 - 550, 1100 - 1290", "/usr/hkd/tmp/expressions.log", 0, "/usr/hkd/tmp/user_output.text", FULL_LOG | LOG_TO_FILE | USER_OUTPUT_TO_FILE)) { /* Error in operation */ printf("\nError in edmiDefineExpressionsLog: %s", edmiGetErrorText(rstat)); goto error; } ... edmiStartExpressionsLog(); . . . edmiStopExpressionsLog(); . . . edmiStartExpressionsLog(); . . . edmiCloseExpressionsLog(); . . . ``` -------------------------------- ### Example Usage of xpxGetDate and Date Formatting Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317183679/xpxGetDate This example procedure, dateExample, demonstrates how to call xpxGetDate to obtain current date and time components. It then uses xpfDateToString to format these components into a human-readable string, which is subsequently printed using xpxPrintf. Error handling is included via ON_ERROR_DO. ```Pseudocode PROCEDURE dateExample; LOCAL seconds,minutes,hours,day,month,year : INTEGER; stringDate : STRING; END_LOCAL; ON_ERROR_DO; xpxPrintf('\nError.'); xpxThrow; END_ON_ERROR_DO; xpxGetDate(seconds,minutes,hours,day,month,year); stringDate := xpfDateToString(seconds,minutes,hours,day,month,year); xpxPrintf('\nCurrent date : %s',stringDate); RETURN; END_PROCEDURE; ``` -------------------------------- ### edmiGetScratchEntityExtent Usage Example (C) Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179230/www.atlassian A C code example demonstrating the usage of edmiGetScratchEntityExtent. It shows how to retrieve the scratch extent, check for errors, get the number of members, and iterate through the instances. ```c SdaiAggr scratchExtentId; SdaiEntity entityId; SdaiErrorCode rstat; SdaiInstance id; SdaiInteger index, members; . . . scratchExtentId = edmiGetScratchEntityExtent(entityId); if (! scratchExtentId) { /* Error in operation */ printf("\nError: %s in edmiGetScratchEntityExtent\n", edmiGetErrorText(sdaiErrorQuery())); goto error; } members = sdaiGetMemberCounts(scratchExtentId); /* Print instanceID of all scratch instances of the specified type */ for (index = 0; index < members; index++) { edmiGetAggrElement(scratchExtentId, index, sdaiINSTANCE, &id); rstat = sdaiErrorQuery(); if (rstat) { /* Error in operation */ printf("\nError: %s in edmiGetAggrElement\n", edmiGetErrorText(sdaiErrorQuery())); goto error; } printf ("\nInstanceID: %lu", id); } . . . ``` -------------------------------- ### C Example: Using edmiGetInstanceAccessRights Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179190/www.atlassian Provides a C code example demonstrating the usage of the `edmiGetInstanceAccessRights` function. It shows how to call the function, check for errors using `edmiGetErrorText`, and handle potential issues during the operation. The example includes the definition of a structure for access rights. ```c EdmiError rstat; struct { SdaiInstance UserOrGroup; SdaiAccessCode AccessCode; } *accFor; . . if (rstat = edmiGetInstanceAccessRights(myModel, &userId, &groupId, &protection, &administrators, (SdaiVoid *) &accFor)) { /* Error in operation */ printf("\nError: %s in edmiGetInstanceAccessRights \n", edmiGetErrorText(rstat)); goto error; } ``` -------------------------------- ### xpxGetDate Usage Example Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317183679/www.atlassian An example procedure demonstrating how to call xpxGetDate to get the current date and time, and then use xpfDateToString to format it into a string for display. Includes basic error handling. ```PL/SQL PROCEDURE dateExample; LOCAL seconds,minutes,hours,day,month,year : INTEGER; stringDate : STRING; END_LOCAL; ON_ERROR_DO; xpxPrintf('\nError.'); xpxThrow; END_ON_ERROR_DO; xpxGetDate(seconds,minutes,hours,day,month,year); stringDate := xpfDateToString(seconds,minutes,hours,day,month,year); xpxPrintf('\nCurrent date : %s',stringDate); RETURN; END_PROCEDURE; ``` -------------------------------- ### Example: Using edmiRemoteGetAttrDefinition in C Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179514/edmiRemoteGetAttrDefinition This C code example demonstrates how to use edmiRemoteGetAttrDefinition to obtain attribute IDs for 'NAME', 'AGE', 'WEIGHT', and 'MARRIED' attributes of a 'PERSON' entity. It also shows the preceding steps of defining a server context, getting a model ID, and getting an entity ID, followed by creating an instance and setting attributes. ```c EdmiError rstat; SdaiServerContext myContext; SdaiInstance instId; SdaiModel modelId; SdaiEntity entityId; SdaiAttr nameAttrId, ageAttrId; SdaiAttr weightAttrId, marriedAttrId; /* Create Server Context */ rstat = edmiDefineServerContext("MyContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Get the model Id */ rstat = edmiRemoteGetModelBN(myContext, "DataRepository", "MySocialNetwork", &modelId, NULL); /* Get the entity Id */ rstat = edmiRemoteGetEntity(myContext, modelId, "PERSON", &entityId, NULL); /* Get the attribute Ids */ rstat = edmiRemoteGetAttrDefinition(myContext, entityId, "NAME", &nameAttrId, NULL); rstat = edmiRemoteGetAttrDefinition(myContext, entityId, "AGE", &ageAttrId, NULL); rstat = edmiRemoteGetAttrDefinition(myContext, entityId, "WEIGHT", &weightAttrId, NULL); rstat = edmiRemoteGetAttrDefinition(myContext, entityId, "MARRIED", &marriedAttrId, NULL); /* Add lucy to my social network */ rstat = edmiRemoteCreateInstanceAndPutAttrs(myContext, modelId, entityId, 4, &instId, NULL, nameAttrId, sdaiSTRING, "Lucy Schmidt", ageAttrId, sdaiINTEGER, 32, weightAttrId, sdaiREAL, 59.5, marriedAttrId, sdaiBOOLEAN, sdaiFALSE); . . . ``` -------------------------------- ### Example: Managing Instance Containers (C) Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179500/edmiRemoteEmptyContainerBN This C code example demonstrates the usage of 'edmiRemoteEmptyContainerBN' along with other related functions like 'edmiDefineServerContext', 'edmiRemoteCreateInstanceContainer', 'edmiRemoteSelectInstances', 'edmiRemoteInstancesToContainerBN', 'edmiRemoteProtectInstance', 'edmiRemoteSetContainerCheckedoutBN', 'edmiRemoteUnsetContainerCheckedoutBN', 'edmiRemoteProtectInstance', and 'edmiRemoteDeleteInstanceContainerBN'. It covers creating, populating, checking out, manipulating, checking in, emptying, and deleting an instance container. ```c EdmiError rstat; SdaiModel modelId; SdaiContainer contId; SdaiServerContext myContext; SdaiQueryResult queryResult; SdaiInteger index = 0, nHits = 10000; . . . /* Define Remote Server Context */ rstat = edmiDefineServerContext("MyRemoteServerContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Create a lock container */ rstat = edmiRemoteCreateInstanceContainer(myContext, modelId, LOCK_CONTAINER, "FLOOR01", "Check out of first floor", &contId, NULL); /* Select instances to lock */ rstat = edmiRemoteSelectInstances(myContext, "DataRepository", "GeneralHospital", "CONSTRUCTION_ELEMENT", "FLOOR = 1", SUBTYPES | ONLY_INSTANCE_IDS, NULL, NULL, NULL, &index, &nHits, &queryResult, NULL, NULL, NULL, NULL); /* Put first floor in the container */ rstat = edmiRemoteInstancesToContainerBN(myContext, modelId, NULL, "FLOOR01", 0, queryResult->instanceIds, NULL); edmiFreeQueryResult(queryResult); /* Check out the container */ rstat = edmiRemoteProtectInstance(myContext, contId, (PUBLIC_READ | GROUP_READ | OWNER_WRITE), NULL); rstat = edmiRemoteSetContainerCheckedoutBN(myContext, modelId, "FLOOR01", NULL); . . . /* Manipulate data here */ . . . /* Check in the container */ rstat = edmiRemoteUnsetContainerCheckedoutBN(myContext, modelId, "FLOOR01", NULL); rstat = edmiRemoteProtectInstance(myContext, contId, (PUBLIC_READ | GROUP_WRITE | OWNER_WRITE), NULL); /* Empty and delete the container */ rstat = edmiRemoteEmptyContainerBN(myContext, modelId, "FLOOR01", NULL); rstat = edmiRemoteDeleteInstanceContainerBN(myContext, modelId, "FLOOR01", NULL); . . . ``` -------------------------------- ### Example: Extract Filename from Path Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317183996/www.atlassian This example demonstrates how to use the xpfFindLastCharInString function to extract a filename from a concatenated path/name string. It finds the last occurrence of the backslash character to determine the start of the filename. ```ABAP -- cut file name from concatenated path/name string i := xpfFindLastCharInString(pathname,'\'); IF i>0 THEN file_name := pathname[i+1:LENGTH(pathname)]; ELSE file_name := pathname; END_IF; ``` -------------------------------- ### EDMinterface Setup Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888/DEVELOPING%2BAPPLICATIONS%2BWITH%2BEDMinterface Information on setting up your development environment for EDMinterface on Windows and UNIX platforms, including necessary files and compilation options. ```APIDOC ## EDMinterface Setup ### Description Details on setting up the development environment for EDMinterface, including necessary files and compilation instructions for Windows and UNIX platforms. ### Platform Specific Setup #### WINDOWS Platform: - **Include Files:** `\Include\sdai.h` (EDMI header file), `\Include\cpp_edmi.h` (_EDMinterface/C++_ header file) - **Libraries:** `\bin\edmikit400.lib` (_EDMinterface_ library), `\bin\cpp_edmi.lib` (_EDMinterface/C++_ library) - **DLLs:** `\bin\edmikit400.dll`, `\bin\cpp_edmi.dll` #### UNIX Platforms: - **Include Files:** `/sdai.h` (EDMI header file) - **Libraries:** `/edmi.a` (_EDMinterface_ static library) ### Compilation and Environment Variables: - Use the ANSI C conformance option when compiling C code. - Add `` to the preprocessor `#include` file search path. - Define `LD_LIBRARY_PATH` (or `LIBPATH`) and `CLASSPATH` environment variables as needed. ``` -------------------------------- ### Date Formatting Example using xpxGetDate Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317183679 Demonstrates how to use the xpxGetDate procedure to retrieve the current date and time, and then format it into a string using xpfDateToString. Includes error handling. ```Pascal PROCEDURE dateExample; LOCAL seconds,minutes,hours,day,month,year : INTEGER; stringDate : STRING; END_LOCAL; ON_ERROR_DO; xpxPrintf('\nError.'); xpxThrow; END_ON_ERROR_DO; xpxGetDate(seconds,minutes,hours,day,month,year); stringDate := xpfDateToString(seconds,minutes,hours,day,month,year); xpxPrintf('\nCurrent date : %s',stringDate); RETURN; END_PROCEDURE; ``` -------------------------------- ### getEntityExtent Example Usage Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317183684/xpxGetEntityExtentBN An example function 'getEntityExtent' that utilizes xpxGetEntityExtentBN to retrieve entity extent information. It then uses xpfGetMemberCount to get the number of members and prints the result. Error handling is included. ```EDM FUNCTION getEntityExtent(modelId : GENERIC ; entityName : STRING) : GENERIC; LOCAL extentId : GENERIC; members : INTEGER; END_LOCAL; ON_ERROR_DO; xpxPrintf('\nError.'); xpxThrow; END_ON_ERROR_DO; xpxGetEntityExtentBN(modelId,entityName,extentId); members := xpfGetMemberCount(extentId); xpxPrintf('\n%d Members of type %s in model.',members,entityName); RETURN(extentId); END_FUNCTION; ``` -------------------------------- ### C Example: Creating and Deleting a Lockable Instance Container Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179443/edmiRemoteCreateInstanceContainer An example demonstrating the usage of edmiRemoteCreateInstanceContainer to create a lockable instance container named 'FLOOR01' with a description. It also shows the subsequent deletion of the container using edmiRemoteDeleteInstanceContainer. This example requires prior setup of a server context. ```c EdmiError rstat; SdaiModel modelId; SdaiContainer contId; SdaiServerContext myContext; /* Define Remote Server Context */ rstat = edmiDefineServerContext("MyRemoteServerContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Create a lock container */ rstat = edmiRemoteCreateInstanceContainer(myContext, modelId, LOCK_CONTAINER, "FLOOR01", "Check out of first floor", &contId, NULL); /* Delete the container */ rstat = edmiRemoteDeleteInstanceContainer(myContext, contId, NULL); ``` -------------------------------- ### Example: Managing Server Context, Users, and Groups (C) Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179438/edmiRemoteCreateGroup This C code example demonstrates a sequence of operations including defining a server context for a superuser, changing passwords, creating users and groups if they don't exist, and assigning users to groups. It showcases the usage of `edmiDefineServerContext`, `edmiRemoteDefinePassword`, `edmiDeleteServerContext`, `edmiRemoteGetUser`, `edmiRemoteCreateUser`, `edmiRemoteGetGroup`, `edmiRemoteCreateGroup`, `edmiRemoteUserToGroup`, and `edmiRemoteChangePassword`. ```c EdmiError rstat; SdaiServerContext suContext; SdaiUser userId; SdaiGroup groupId; /* Define Remote Server Context for the superuser */ rstat = edmiDefineServerContext("SuperUserContext", "superuser", NULL, "dbName", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &suContext); /* First, change the superuser password from the factory setting to the somewhat more complicated 'xfx56kl9' */ rstat = edmiRemoteDefinePassword(suContext, "xfx56kl9", NULL); /* The new password makes the current context obsolete. */ rstat = edmiDeleteServerContext(suContext); /* A new context must be created to reflect the change in password */ rstat = edmiDefineServerContext("SuperUserContext", "superuser", NULL, "xfx56kl9", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &suContext); /* Check if 'Lucy' exists as user */ rstat = edmiRemoteGetUser(suContext, "Lucy", &userId, NULL); if (rstat = edmiENOUSER) { rstat = edmiRemoteCreateUser(suContext, "Lucy", &userId, NULL); } /* Check if 'Guest' exists as user */ rstat = edmiRemoteGetGroup(suContext, "Guest", &groupId, NULL); if (rstat = edmiENOGROUP) { rstat = edmiRemoteCreateGroup(suContext, "Guest", &groupId, NULL); } /* Put 'Lucy' in the 'Guest' group */ rstat = edmiRemoteUserToGroup(suContext, groupId, userId, NULL); /* Change Lucys password from the default 'Lucy' to 'ddf54y' */ rstat = edmiRemoteChangePassword(suContext, userId, "ddf54y", NULL); . . . ``` -------------------------------- ### C Example: Using edmiRemoteGetAttrsEx to Get Person Attributes Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179521/edmiRemoteGetAttrsEx This C code example demonstrates how to use `edmiRemoteGetAttrsEx` to fetch the first name, last name, and phone number of 'Person' instances from a remote EDM database. It includes setting up the server context, getting attribute definitions, selecting instances, retrieving attributes, and freeing allocated memory. ```c #define S_NATTR 3 int i, j; EdmiError rstat; SdaiServerContext myContext; SdaiInteger index, nHits; SdaiAttr attrIds[S_NATTR]; tSdaiSelect sel[S_NATTR]; SdaiSelect attrVals[S_NATTR] = {&sel[0], &sel[1], &sel[2]}; SdaiQueryResult qexRes; /* Create Server Context */ rstat = edmiDefineServerContext("MyContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Get attribute ids of the Person entity */ rstat = edmiRemoteGetAttrDefinitionBN(myContext, "MySocialRelations", "Person", "FIRST_NAME", &attrIds[0], NULL); rstat = edmiRemoteGetAttrDefinitionBN(myContext, "MySocialRelations", "Person", "LAST_NAME", &attrIds[1], NULL); rstat = edmiRemoteGetAttrDefinitionBN(myContext, "MySocialRelations", "Person", "PHONE_NO", &attrIds[2], NULL); /* Select all person instances */ rstat = edmiSelectInstances(myContext, "MyRepository", "MySocialRelations", "Person", NULL, ONLY_INSTANCE_IDS, NULL, NULL, NULL, &index, &nHits, &qexRes, NULL, NULL, NULL, NULL); /* Get their names and phone numbers */ for (i=0;iinstanceIds[i], 0, S_NATTR, attrIds, &attrVals[0], GET_ATTRS, NULL); printf("\n%s %s, Phone No. %s", attrVals[0]->value.stringVal, attrVals[1]->value.stringVal, attrVals[2]->value.stringVal); for (j=0;j<=S_NATTR;j++) { edmiFree(attrVals[j]->value.stringVal); } } edmiFreeQueryResult(qexRes); . . . ``` -------------------------------- ### C: Database Operations and Schema Compilation Source: https://jotne.atlassian.net/wiki/spaces/EDM/pages/3317179888/www.atlassian This C code snippet demonstrates the initialization and setup of a database for the EDM system. It includes functions for deleting and creating a database, opening a session, and compiling a schema file. Error checking is performed after each critical operation using the CHECK_ERR macro. ```c #include #include "sdai.h" #define DBLOC "db" #define EXP_FILE "family.exp" #define DBNAME "db" #define DBPASSW "db" #define MYSCHEMA "family_schema" #define MYMODEL "FAMILY" #define DIA_FILE "comp.dia" #define STEP_FILE "family.stp" // ... (CHECK_ERR macro definition) ... void main() { long rstat,nwarnings,nerrors; SdaiRepository data_repository; SdaiSession sessionId; SdaiErrorCode sdaiError; SdaiModel mymodel; // ... (other variable declarations) ... char* _casefile_ ; int _caseline_ ; /* CREATE DATABASE AND OPEN SESSION */ rstat = edmiDeleteDatabase(DBLOC,DBNAME,DBPASSW); rstat = sdaiErrorQuery(); rstat = edmiCreateDatabase(DBLOC,DBNAME,DBPASSW); rstat = edmiOpenDatabase(DBLOC,DBNAME,DBPASSW); sessionId = sdaiOpenSession(); CHECK_ERR(__FILE,LINE_ _); /* COMPILE THE SCHEMA */ rstat = edmiDefineSchema(EXP_FILE,DIA_FILE,NULL,0 ,&nwarnings,&nerrors); CHECK_ERR(__FILE,LINE_ _); if(nerrors){ printf("\nErrors when compiling %s",EXP_FILE); goto end; } /* OPEN THE DATA REPOSITORY,CREATE A MODEL AND OPEN IT */ data_repository = sdaiOpenRepositoryBN("DataRepository"); mymodel = sdaiCreateModelBN(data_repository,MYMODEL,MYSCHEMA); mymodel = sdaiOpenModelBN(data_repository,MYMODEL,sdaiRW); CHECK_ERR(__FILE,LINE_ _); // ... (rest of the main function) ... } ```