LCOV - code coverage report
Current view: top level - data/source/storage - data_database_diagram_reader.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 361 392 92.1 %
Date: 2024-10-26 21:44:38 Functions: 14 14 100.0 %

          Line data    Source code
       1             : /* File: data_database_diagram_reader.c; Copyright and License: see below */
       2             : 
       3             : #include "storage/data_database_diagram_reader.h"
       4             : #include "u8/u8_trace.h"
       5             : #include "u8/u8_log.h"
       6             : #include "utf8stringbuf/utf8stringbuf.h"
       7             : #include <sqlite3.h>
       8             : #include <assert.h>
       9             : 
      10          99 : u8_error_t data_database_diagram_reader_init ( data_database_diagram_reader_t *this_, data_database_t *database )
      11             : {
      12          99 :     U8_TRACE_BEGIN();
      13          99 :     assert( NULL != database );
      14          99 :     u8_error_t result = U8_ERROR_NONE;
      15             : 
      16          99 :     (*this_).database = database;
      17             : 
      18          99 :     (*this_).statement_diagram_by_id = NULL;
      19          99 :     (*this_).statement_diagram_by_uuid = NULL;
      20          99 :     (*this_).statement_diagrams_by_parent_id = NULL;
      21          99 :     (*this_).statement_diagrams_by_parent_id_null = NULL;
      22          99 :     (*this_).statement_diagrams_by_classifier_id = NULL;
      23          99 :     (*this_).statement_diagram_ids_by_parent_id = NULL;
      24          99 :     (*this_).statement_diagram_ids_by_parent_id_null = NULL;
      25          99 :     (*this_).statement_diagram_ids_by_classifier_id = NULL;
      26          99 :     (*this_).statement_diagramelement_by_id = NULL;
      27          99 :     (*this_).statement_diagramelement_by_uuid = NULL;
      28          99 :     (*this_).statement_diagramelements_by_diagram_id = NULL;
      29          99 :     (*this_).statement_diagramelements_by_classifier_id = NULL;
      30             : 
      31          99 :     result |= data_database_diagram_reader_private_open( this_ );
      32             : 
      33          99 :     U8_TRACE_END_ERR(result);
      34          99 :     return result;
      35             : }
      36             : 
      37          99 : u8_error_t data_database_diagram_reader_destroy ( data_database_diagram_reader_t *this_ )
      38             : {
      39          99 :     U8_TRACE_BEGIN();
      40          99 :     u8_error_t result = U8_ERROR_NONE;
      41             : 
      42          99 :     result |= data_database_diagram_reader_private_close( this_ );
      43             : 
      44          99 :     (*this_).database = NULL;
      45             : 
      46          99 :     U8_TRACE_END_ERR(result);
      47          99 :     return result;
      48             : }
      49             : 
      50             : /* ================================ DIAGRAM ================================ */
      51             : 
      52             : /*!
      53             :  *  \brief predefined search statement to find a diagram by id
      54             :  */
      55             : static const char DATA_DATABASE_READER_SELECT_DIAGRAM_BY_ID[] =
      56             :     "SELECT id,parent_id,diagram_type,stereotype,name,description,list_order,display_flags,uuid "
      57             :     "FROM diagrams WHERE id=?;";
      58             : 
      59             : /*!
      60             :  *  \brief predefined search statement to find a diagram by uuid
      61             :  */
      62             : static const char DATA_DATABASE_READER_SELECT_DIAGRAM_BY_UUID[] =
      63             :     "SELECT id,parent_id,diagram_type,stereotype,name,description,list_order,display_flags,uuid "
      64             :     "FROM diagrams WHERE uuid=?;";
      65             : 
      66             : /*!
      67             :  *  \brief predefined search statement to find diagrams by parent-id
      68             :  */
      69             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_PARENT_ID[] =
      70             :     "SELECT id,parent_id,diagram_type,stereotype,name,description,list_order,display_flags,uuid "
      71             :     "FROM diagrams WHERE parent_id=? ORDER BY list_order ASC;";
      72             : 
      73             : /*!
      74             :  *  \brief predefined search statement to find diagrams by NULL parent-id
      75             :  */
      76             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_PARENT_ID_NULL[] =
      77             :     "SELECT id,parent_id,diagram_type,stereotype,name,description,list_order,display_flags,uuid "
      78             :     "FROM diagrams WHERE parent_id IS NULL ORDER BY list_order ASC;";
      79             : 
      80             : /*!
      81             :  *  \brief predefined search statement to find diagrams by classifier-id
      82             :  */
      83             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_CLASSIFIER_ID[] =
      84             :     "SELECT diagrams.id,diagrams.parent_id,diagrams.diagram_type,diagrams.stereotype,"
      85             :     "diagrams.name,diagrams.description,diagrams.list_order,diagrams.display_flags,diagrams.uuid "
      86             :     "FROM diagrams "
      87             :     "INNER JOIN diagramelements ON diagramelements.diagram_id=diagrams.id "
      88             :     "WHERE diagramelements.classifier_id=? "
      89             :     "GROUP BY diagrams.id "  /* filter duplicates if a classifier exists twice in a diagram */
      90             :     "ORDER BY diagrams.list_order ASC;";
      91             : 
      92             : /*!
      93             :  *  \brief the column id of the result where this parameter is stored: id
      94             :  */
      95             : static const int RESULT_DIAGRAM_ID_COLUMN = 0;
      96             : 
      97             : /*!
      98             :  *  \brief the column id of the result where this parameter is stored: parent_id
      99             :  */
     100             : static const int RESULT_DIAGRAM_PARENT_ID_COLUMN = 1;
     101             : 
     102             : /*!
     103             :  *  \brief the column id of the result where this parameter is stored: type
     104             :  */
     105             : static const int RESULT_DIAGRAM_TYPE_COLUMN = 2;
     106             : 
     107             : /*!
     108             :  *  \brief the column id of the result where this parameter is stored: stereotype
     109             :  */
     110             : static const int RESULT_DIAGRAM_STEREOTYPE_COLUMN = 3;
     111             : 
     112             : /*!
     113             :  *  \brief the column id of the result where this parameter is stored: name
     114             :  */
     115             : static const int RESULT_DIAGRAM_NAME_COLUMN = 4;
     116             : 
     117             : /*!
     118             :  *  \brief the column id of the result where this parameter is stored: description
     119             :  */
     120             : static const int RESULT_DIAGRAM_DESCRIPTION_COLUMN = 5;
     121             : 
     122             : /*!
     123             :  *  \brief the column id of the result where this parameter is stored: list_order
     124             :  */
     125             : static const int RESULT_DIAGRAM_LIST_ORDER_COLUMN = 6;
     126             : 
     127             : /*!
     128             :  *  \brief the column id of the result where this parameter is stored: display_flags
     129             :  */
     130             : static const int RESULT_DIAGRAM_DISPLAY_FLAGS_COLUMN = 7;
     131             : 
     132             : /*!
     133             :  *  \brief the column id of the result where this parameter is stored: uuid
     134             :  */
     135             : static const int RESULT_DIAGRAM_UUID_COLUMN = 8;
     136             : 
     137             : /*!
     138             :  *  \brief predefined search statement to find diagram ids by parent-id
     139             :  */
     140             : static const char DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_PARENT_ID[] =
     141             :     "SELECT id "
     142             :     "FROM diagrams WHERE parent_id=? ORDER BY list_order ASC;";
     143             : 
     144             : /*!
     145             :  *  \brief predefined search statement to find diagram ids by NULL parent-id
     146             :  */
     147             : static const char DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_PARENT_ID_NULL[] =
     148             :     "SELECT id "
     149             :     "FROM diagrams WHERE parent_id IS NULL ORDER BY list_order ASC;";
     150             : 
     151             : /*!
     152             :  *  \brief predefined search statement to find diagram ids by classifier-id
     153             :  */
     154             : static const char DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_CLASSIFIER_ID[] =
     155             :     "SELECT diagrams.id "
     156             :     "FROM diagrams "
     157             :     "INNER JOIN diagramelements ON diagramelements.diagram_id=diagrams.id "
     158             :     "WHERE diagramelements.classifier_id=? "
     159             :     "GROUP BY diagrams.id "  /* filter duplicates if a classifier exists twice in a diagram */
     160             :     "ORDER BY diagrams.list_order ASC;";
     161             : 
     162          74 : u8_error_t data_database_diagram_reader_get_diagram_by_id ( data_database_diagram_reader_t *this_,
     163             :                                                             data_row_id_t id,
     164             :                                                             data_diagram_t *out_diagram )
     165             : {
     166          74 :     U8_TRACE_BEGIN();
     167          74 :     assert( NULL != out_diagram );
     168          74 :     u8_error_t result = U8_ERROR_NONE;
     169             :     int sqlite_err;
     170             :     sqlite3_stmt *prepared_statement;
     171             : 
     172             :     {
     173          74 :         prepared_statement = (*this_).statement_diagram_by_id;
     174             : 
     175          74 :         result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, id );
     176             : 
     177          74 :         U8_TRACE_INFO( "sqlite3_step()" );
     178          74 :         sqlite_err = sqlite3_step( prepared_statement );
     179          74 :         if ( SQLITE_ROW != sqlite_err )
     180             :         {
     181             :             /* This may happen e.g. when a diagram is deleted and a window still tries to show it. */
     182           4 :             U8_TRACE_INFO_INT( "sqlite3_step did not find a row for id", id );
     183           4 :             result |= U8_ERROR_DB_STRUCTURE;
     184             :         }
     185             : 
     186          74 :         if ( SQLITE_ROW == sqlite_err )
     187             :         {
     188         140 :             result |= data_diagram_init( out_diagram,
     189          70 :                                          sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_ID_COLUMN ),
     190          70 :                                          sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ),
     191          70 :                                          sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_TYPE_COLUMN ),
     192          70 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_STEREOTYPE_COLUMN ),
     193          70 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_NAME_COLUMN ),
     194          70 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_DESCRIPTION_COLUMN ),
     195             :                                          sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_LIST_ORDER_COLUMN ),
     196          70 :                                          sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_DISPLAY_FLAGS_COLUMN ),
     197          70 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_UUID_COLUMN )
     198             :                                        );
     199          70 :             if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ) )
     200             :             {
     201          48 :                 (*out_diagram).parent_id = DATA_ROW_ID_VOID;
     202             :             }
     203             : 
     204          70 :             data_diagram_trace( out_diagram );
     205             : 
     206          70 :             sqlite_err = sqlite3_step( prepared_statement );
     207          70 :             if ( SQLITE_DONE != sqlite_err )
     208             :             {
     209           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     210           0 :                 result |= U8_ERROR_DB_STRUCTURE;
     211             :             }
     212             :         }
     213             :     }
     214             : 
     215          74 :     U8_TRACE_END_ERR( result );
     216          74 :     return result;
     217             : }
     218             : 
     219          10 : u8_error_t data_database_diagram_reader_get_diagram_by_uuid ( data_database_diagram_reader_t *this_,
     220             :                                                               const char *uuid,
     221             :                                                               data_diagram_t *out_diagram )
     222             : {
     223          10 :     U8_TRACE_BEGIN();
     224          10 :     assert( NULL != uuid );
     225          10 :     assert( NULL != out_diagram );
     226          10 :     u8_error_t result = U8_ERROR_NONE;
     227             :     int sqlite_err;
     228             :     sqlite3_stmt *prepared_statement;
     229             : 
     230             :     {
     231          10 :         prepared_statement = (*this_).statement_diagram_by_uuid;
     232             : 
     233          10 :         result |= data_database_diagram_reader_private_bind_text_to_statement( this_, prepared_statement, uuid );
     234             : 
     235          10 :         U8_TRACE_INFO( "sqlite3_step()" );
     236          10 :         sqlite_err = sqlite3_step( prepared_statement );
     237          10 :         if ( SQLITE_ROW != sqlite_err )
     238             :         {
     239             :             /* Do not log this incident, the caller may not expect to find a row. */
     240           6 :             U8_TRACE_INFO_STR( "sqlite3_step did not find a row for uuid", uuid );
     241           6 :             result |= U8_ERROR_NOT_FOUND;
     242             :         }
     243             : 
     244          10 :         if ( SQLITE_ROW == sqlite_err )
     245             :         {
     246           8 :             result |= data_diagram_init( out_diagram,
     247           4 :                                          sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_ID_COLUMN ),
     248           4 :                                          sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ),
     249           4 :                                          sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_TYPE_COLUMN ),
     250           4 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_STEREOTYPE_COLUMN ),
     251           4 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_NAME_COLUMN ),
     252           4 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_DESCRIPTION_COLUMN ),
     253             :                                          sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_LIST_ORDER_COLUMN ),
     254           4 :                                          sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_DISPLAY_FLAGS_COLUMN ),
     255           4 :                                          (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_UUID_COLUMN )
     256             :                                        );
     257           4 :             if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ) )
     258             :             {
     259           3 :                 (*out_diagram).parent_id = DATA_ROW_ID_VOID;
     260             :             }
     261             : 
     262           4 :             data_diagram_trace( out_diagram );
     263             : 
     264           4 :             sqlite_err = sqlite3_step( prepared_statement );
     265           4 :             if ( SQLITE_DONE != sqlite_err )
     266             :             {
     267           0 :                 U8_LOG_ERROR_INT( "sqlite3_step not done yet:", sqlite_err );
     268           0 :                 result |= U8_ERROR_DB_STRUCTURE;
     269             :             }
     270             :         }
     271             :     }
     272             : 
     273          10 :     U8_TRACE_END_ERR( result );
     274          10 :     return result;
     275             : }
     276             : 
     277         176 : u8_error_t data_database_diagram_reader_get_diagrams_by_parent_id ( data_database_diagram_reader_t *this_,
     278             :                                                                     data_row_id_t parent_id,
     279             :                                                                     uint32_t max_out_array_size,
     280             :                                                                     data_diagram_t (*out_diagram)[],
     281             :                                                                     uint32_t *out_diagram_count )
     282             : {
     283         176 :     U8_TRACE_BEGIN();
     284         176 :     assert( NULL != out_diagram_count );
     285         176 :     assert( NULL != out_diagram );
     286         176 :     u8_error_t result = U8_ERROR_NONE;
     287             :     int sqlite_err;
     288             :     sqlite3_stmt *prepared_statement;
     289             : 
     290             :     {
     291         176 :         if ( DATA_ROW_ID_VOID == parent_id )
     292             :         {
     293          39 :             prepared_statement = (*this_).statement_diagrams_by_parent_id_null;
     294          39 :             result |= data_database_diagram_reader_private_bind_void_to_statement( this_, prepared_statement );
     295             :         }
     296             :         else
     297             :         {
     298         137 :             prepared_statement = (*this_).statement_diagrams_by_parent_id;
     299         137 :             result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, parent_id );
     300             :         }
     301             : 
     302         176 :         *out_diagram_count = 0;
     303         176 :         sqlite_err = SQLITE_ROW;
     304         391 :         for ( uint32_t row_index = 0; (SQLITE_ROW == sqlite_err) && (row_index <= max_out_array_size); row_index ++ )
     305             :         {
     306         215 :             U8_TRACE_INFO( "sqlite3_step()" );
     307         215 :             sqlite_err = sqlite3_step( prepared_statement );
     308         215 :             if (( SQLITE_ROW != sqlite_err )&&( SQLITE_DONE != sqlite_err ))
     309             :             {
     310           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     311           0 :                 result |= U8_ERROR_AT_DB;
     312             :             }
     313         215 :             if (( SQLITE_ROW == sqlite_err )&&(row_index < max_out_array_size))
     314             :             {
     315          39 :                 *out_diagram_count = row_index+1;
     316          39 :                 data_diagram_t *current_diag = &((*out_diagram)[row_index]);
     317             : 
     318          78 :                 result |= data_diagram_init( current_diag,
     319          39 :                                              sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_ID_COLUMN ),
     320          39 :                                              sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ),
     321          39 :                                              sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_TYPE_COLUMN ),
     322          39 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_STEREOTYPE_COLUMN ),
     323          39 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_NAME_COLUMN ),
     324          39 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_DESCRIPTION_COLUMN ),
     325             :                                              sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_LIST_ORDER_COLUMN ),
     326          39 :                                              sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_DISPLAY_FLAGS_COLUMN ),
     327          39 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_UUID_COLUMN )
     328             :                                            );
     329          39 :                 if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ) )
     330             :                 {
     331          36 :                     (*current_diag).parent_id = DATA_ROW_ID_VOID;
     332             :                 }
     333             : 
     334          39 :                 data_diagram_trace( current_diag );
     335             :             }
     336         215 :             if (( SQLITE_ROW == sqlite_err )&&(row_index >= max_out_array_size))
     337             :             {
     338           1 :                 U8_LOG_ANOMALY_INT( "out_diagram[] full:", (row_index+1) );
     339           1 :                 result |= U8_ERROR_ARRAY_BUFFER_EXCEEDED;
     340             :             }
     341         215 :             if ( SQLITE_DONE == sqlite_err )
     342             :             {
     343         175 :                 U8_TRACE_INFO( "sqlite3_step finished: SQLITE_DONE" );
     344             :             }
     345             :         }
     346             :     }
     347             : 
     348         176 :     U8_TRACE_END_ERR( result );
     349         176 :     return result;
     350             : }
     351             : 
     352          14 : u8_error_t data_database_diagram_reader_get_diagrams_by_classifier_id ( data_database_diagram_reader_t *this_,
     353             :                                                                         data_row_id_t classifier_id,
     354             :                                                                         uint32_t max_out_array_size,
     355             :                                                                         data_diagram_t (*out_diagram)[],
     356             :                                                                         uint32_t *out_diagram_count )
     357             : {
     358          14 :     U8_TRACE_BEGIN();
     359          14 :     assert( NULL != out_diagram_count );
     360          14 :     assert( NULL != out_diagram );
     361          14 :     u8_error_t result = U8_ERROR_NONE;
     362             :     int sqlite_err;
     363             :     sqlite3_stmt *prepared_statement;
     364             : 
     365             :     {
     366          14 :         prepared_statement = (*this_).statement_diagrams_by_classifier_id;
     367             : 
     368          14 :         result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, classifier_id );
     369             : 
     370          14 :         *out_diagram_count = 0;
     371          14 :         sqlite_err = SQLITE_ROW;
     372          35 :         for ( uint32_t row_index = 0; (SQLITE_ROW == sqlite_err) && (row_index <= max_out_array_size); row_index ++ )
     373             :         {
     374          21 :             U8_TRACE_INFO( "sqlite3_step()" );
     375          21 :             sqlite_err = sqlite3_step( prepared_statement );
     376          21 :             if (( SQLITE_ROW != sqlite_err )&&( SQLITE_DONE != sqlite_err ))
     377             :             {
     378           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     379           0 :                 result |= U8_ERROR_AT_DB;
     380             :             }
     381          21 :             if (( SQLITE_ROW == sqlite_err )&&(row_index < max_out_array_size))
     382             :             {
     383           7 :                 *out_diagram_count = row_index+1;
     384           7 :                 data_diagram_t *current_diag = &((*out_diagram)[row_index]);
     385             : 
     386          14 :                 result |= data_diagram_init( current_diag,
     387           7 :                                              sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_ID_COLUMN ),
     388           7 :                                              sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ),
     389           7 :                                              sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_TYPE_COLUMN ),
     390           7 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_STEREOTYPE_COLUMN ),
     391           7 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_NAME_COLUMN ),
     392           7 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_DESCRIPTION_COLUMN ),
     393             :                                              sqlite3_column_int( prepared_statement, RESULT_DIAGRAM_LIST_ORDER_COLUMN ),
     394           7 :                                              sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_DISPLAY_FLAGS_COLUMN ),
     395           7 :                                              (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAM_UUID_COLUMN )
     396             :                                            );
     397           7 :                 if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAM_PARENT_ID_COLUMN ) )
     398             :                 {
     399           6 :                     (*current_diag).parent_id = DATA_ROW_ID_VOID;
     400             :                 }
     401             : 
     402           7 :                 data_diagram_trace( current_diag );
     403             :             }
     404          21 :             if (( SQLITE_ROW == sqlite_err )&&(row_index >= max_out_array_size))
     405             :             {
     406           0 :                 U8_LOG_ANOMALY_INT( "out_diagram[] full:", (row_index+1) );
     407           0 :                 result |= U8_ERROR_ARRAY_BUFFER_EXCEEDED;
     408             :             }
     409          21 :             if ( SQLITE_DONE == sqlite_err )
     410             :             {
     411          14 :                 U8_TRACE_INFO( "sqlite3_step finished: SQLITE_DONE" );
     412             :             }
     413             :         }
     414             :     }
     415             : 
     416          14 :     U8_TRACE_END_ERR( result );
     417          14 :     return result;
     418             : }
     419             : 
     420          20 : u8_error_t data_database_diagram_reader_get_diagram_ids_by_parent_id ( data_database_diagram_reader_t *this_,
     421             :                                                                        data_row_id_t parent_id,
     422             :                                                                        data_small_set_t *out_diagram_ids )
     423             : {
     424          20 :     U8_TRACE_BEGIN();
     425          20 :     assert( NULL != out_diagram_ids );
     426          20 :     u8_error_t result = U8_ERROR_NONE;
     427             :     int sqlite_err;
     428             :     sqlite3_stmt *prepared_statement;
     429             : 
     430             :     {
     431          20 :         if ( DATA_ROW_ID_VOID == parent_id )
     432             :         {
     433          18 :             prepared_statement = (*this_).statement_diagram_ids_by_parent_id_null;
     434          18 :             result |= data_database_diagram_reader_private_bind_void_to_statement( this_, prepared_statement );
     435             :         }
     436             :         else
     437             :         {
     438           2 :             prepared_statement = (*this_).statement_diagram_ids_by_parent_id;
     439           2 :             result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, parent_id );
     440             :         }
     441             : 
     442          20 :         data_small_set_clear( out_diagram_ids );
     443          20 :         sqlite_err = SQLITE_ROW;
     444          57 :         for ( uint32_t row_index = 0; (SQLITE_ROW == sqlite_err) && (row_index <= DATA_SMALL_SET_MAX_SET_SIZE); row_index ++ )
     445             :         {
     446          37 :             U8_TRACE_INFO( "sqlite3_step()" );
     447          37 :             sqlite_err = sqlite3_step( prepared_statement );
     448          37 :             if (( SQLITE_ROW != sqlite_err )&&( SQLITE_DONE != sqlite_err ))
     449             :             {
     450           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     451           0 :                 result |= U8_ERROR_AT_DB;
     452             :             }
     453          37 :             if (( SQLITE_ROW == sqlite_err )&&(row_index < DATA_SMALL_SET_MAX_SET_SIZE))
     454             :             {
     455             :                 data_id_t current_diag_id;
     456          17 :                 data_id_init( &current_diag_id, DATA_TABLE_DIAGRAM, sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_ID_COLUMN ) );
     457          17 :                 result |= data_small_set_add_obj( out_diagram_ids, current_diag_id );
     458             :             }
     459          37 :             if (( SQLITE_ROW == sqlite_err )&&(row_index >= DATA_SMALL_SET_MAX_SET_SIZE))
     460             :             {
     461           0 :                 U8_LOG_ANOMALY_INT( "out_diagram_ids[] full:", (row_index+1) );
     462           0 :                 result |= U8_ERROR_ARRAY_BUFFER_EXCEEDED;
     463             :             }
     464          37 :             if ( SQLITE_DONE == sqlite_err )
     465             :             {
     466          20 :                 U8_TRACE_INFO( "sqlite3_step finished: SQLITE_DONE" );
     467             :             }
     468             :         }
     469          20 :         data_small_set_trace( out_diagram_ids );
     470             :     }
     471             : 
     472          20 :     U8_TRACE_END_ERR( result );
     473          20 :     return result;
     474             : }
     475             : 
     476           1 : u8_error_t data_database_diagram_reader_get_diagram_ids_by_classifier_id ( data_database_diagram_reader_t *this_,
     477             :                                                                            data_row_id_t classifier_id,
     478             :                                                                            data_small_set_t *out_diagram_ids )
     479             : {
     480           1 :     U8_TRACE_BEGIN();
     481           1 :     assert( NULL != out_diagram_ids );
     482           1 :     u8_error_t result = U8_ERROR_NONE;
     483             :     int sqlite_err;
     484             :     sqlite3_stmt *prepared_statement;
     485             : 
     486             :     {
     487           1 :         prepared_statement = (*this_).statement_diagram_ids_by_classifier_id;
     488             : 
     489           1 :         result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, classifier_id );
     490             : 
     491           1 :         sqlite_err = SQLITE_ROW;
     492           4 :         for ( uint32_t row_index = 0; (SQLITE_ROW == sqlite_err) && (row_index <= DATA_SMALL_SET_MAX_SET_SIZE); row_index ++ )
     493             :         {
     494           3 :             U8_TRACE_INFO( "sqlite3_step()" );
     495           3 :             sqlite_err = sqlite3_step( prepared_statement );
     496           3 :             if (( SQLITE_ROW != sqlite_err )&&( SQLITE_DONE != sqlite_err ))
     497             :             {
     498           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     499           0 :                 result |= U8_ERROR_AT_DB;
     500             :             }
     501           3 :             if (( SQLITE_ROW == sqlite_err )&&(row_index < DATA_SMALL_SET_MAX_SET_SIZE))
     502             :             {
     503             :                 data_id_t current_diag_id;
     504           2 :                 data_id_init( &current_diag_id, DATA_TABLE_DIAGRAM, sqlite3_column_int64( prepared_statement, RESULT_DIAGRAM_ID_COLUMN ) );
     505           2 :                 result |= data_small_set_add_obj( out_diagram_ids, current_diag_id );
     506           2 :                 data_id_trace( &current_diag_id );
     507             :             }
     508           3 :             if (( SQLITE_ROW == sqlite_err )&&(row_index >= DATA_SMALL_SET_MAX_SET_SIZE))
     509             :             {
     510           0 :                 U8_LOG_ANOMALY_INT( "out_diagram_ids[] full:", (row_index+1) );
     511           0 :                 result |= U8_ERROR_ARRAY_BUFFER_EXCEEDED;
     512             :             }
     513           3 :             if ( SQLITE_DONE == sqlite_err )
     514             :             {
     515           1 :                 U8_TRACE_INFO( "sqlite3_step finished: SQLITE_DONE" );
     516             :             }
     517             :         }
     518             :     }
     519             : 
     520           1 :     U8_TRACE_END_ERR( result );
     521           1 :     return result;
     522             : }
     523             : 
     524             : /* ================================ DIAGRAMELEMENT ================================ */
     525             : 
     526             : /*!
     527             :  *  \brief predefined search statement to find a diagramelement by id
     528             :  */
     529             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMELEMENT_BY_ID[] =
     530             :     "SELECT id,diagram_id,classifier_id,display_flags,focused_feature_id,uuid FROM diagramelements WHERE id=?;";
     531             : 
     532             : /*!
     533             :  *  \brief predefined search statement to find a diagramelement by uuid
     534             :  */
     535             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMELEMENT_BY_UUID[] =
     536             :     "SELECT id,diagram_id,classifier_id,display_flags,focused_feature_id,uuid FROM diagramelements WHERE uuid=?;";
     537             : 
     538             : /*!
     539             :  *  \brief predefined search statement to find diagramelements by diagram id
     540             :  *
     541             :  *  The "order by id" is important to get reproducable results, e.g. for json export
     542             :  */
     543             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMELEMENTS_BY_DIAGRAM_ID[] =
     544             :     "SELECT id,diagram_id,classifier_id,display_flags,focused_feature_id,uuid FROM diagramelements "
     545             :     "WHERE diagram_id=? ORDER BY id ASC;";
     546             : 
     547             : /*!
     548             :  *  \brief predefined search statement to find diagramelements by classifier id
     549             :  *
     550             :  *  The "order by id" is important to get reproducable results, e.g. for json export
     551             :  */
     552             : static const char DATA_DATABASE_READER_SELECT_DIAGRAMELEMENTS_BY_CLASSIFIER_ID[] =
     553             :     "SELECT id,diagram_id,classifier_id,display_flags,focused_feature_id,uuid FROM diagramelements "
     554             :     "WHERE classifier_id=? ORDER BY id ASC;";
     555             : 
     556             : /*!
     557             :  *  \brief the column id of the result where this parameter is stored: id
     558             :  */
     559             : static const int RESULT_DIAGRAMELEMENT_ID_COLUMN = 0;
     560             : 
     561             : /*!
     562             :  *  \brief the column id of the result where this parameter is stored: diagram_id
     563             :  */
     564             : static const int RESULT_DIAGRAMELEMENT_DIAGRAM_ID_COLUMN = 1;
     565             : 
     566             : /*!
     567             :  *  \brief the column id of the result where this parameter is stored: classifier_id
     568             :  */
     569             : static const int RESULT_DIAGRAMELEMENT_CLASSIFIER_ID_COLUMN = 2;
     570             : 
     571             : /*!
     572             :  *  \brief the column id of the result where this parameter is stored: display_flags
     573             :  */
     574             : static const int RESULT_DIAGRAMELEMENT_DISPLAY_FLAGS_COLUMN = 3;
     575             : 
     576             : /*!
     577             :  *  \brief the column id of the result where this parameter is stored: focused_feature_id
     578             :  */
     579             : static const int RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN = 4;
     580             : 
     581             : /*!
     582             :  *  \brief the column id of the result where this parameter is stored: uuid
     583             :  */
     584             : static const int RESULT_DIAGRAMELEMENT_UUID_COLUMN = 5;
     585             : 
     586          38 : u8_error_t data_database_diagram_reader_get_diagramelement_by_id ( data_database_diagram_reader_t *this_,
     587             :                                                                    data_row_id_t id,
     588             :                                                                    data_diagramelement_t *out_diagramelement )
     589             : {
     590          38 :     U8_TRACE_BEGIN();
     591          38 :     assert( NULL != out_diagramelement );
     592          38 :     u8_error_t result = U8_ERROR_NONE;
     593             :     int sqlite_err;
     594             :     sqlite3_stmt *prepared_statement;
     595             : 
     596             :     {
     597          38 :         prepared_statement = (*this_).statement_diagramelement_by_id;
     598             : 
     599          38 :         result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, id );
     600             : 
     601          38 :         U8_TRACE_INFO( "sqlite3_step()" );
     602          38 :         sqlite_err = sqlite3_step( prepared_statement );
     603          38 :         if ( SQLITE_ROW != sqlite_err )
     604             :         {
     605           3 :             U8_TRACE_INFO_INT( "sqlite3_step did not find a row for id", id );
     606           3 :             result |= U8_ERROR_DB_STRUCTURE;
     607             :         }
     608             : 
     609          38 :         if ( SQLITE_ROW == sqlite_err )
     610             :         {
     611          35 :             result |= data_diagramelement_init( out_diagramelement,
     612          35 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_ID_COLUMN ),
     613          35 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DIAGRAM_ID_COLUMN ),
     614          35 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_CLASSIFIER_ID_COLUMN ),
     615          35 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DISPLAY_FLAGS_COLUMN ),
     616          35 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ),
     617          35 :                                                 (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAMELEMENT_UUID_COLUMN )
     618             :                                               );
     619          35 :             if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ) )
     620             :             {
     621          23 :                 data_diagramelement_set_focused_feature_row_id ( out_diagramelement, DATA_ROW_ID_VOID );
     622             :             }
     623             : 
     624          35 :             data_diagramelement_trace( out_diagramelement );
     625             : 
     626          35 :             sqlite_err = sqlite3_step( prepared_statement );
     627          35 :             if ( SQLITE_DONE != sqlite_err )
     628             :             {
     629           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     630           0 :                 result |= U8_ERROR_DB_STRUCTURE;
     631             :             }
     632             :         }
     633             :     }
     634             : 
     635          38 :     U8_TRACE_END_ERR( result );
     636          38 :     return result;
     637             : }
     638             : 
     639           2 : u8_error_t data_database_diagram_reader_get_diagramelement_by_uuid ( data_database_diagram_reader_t *this_,
     640             :                                                                      const char *uuid,
     641             :                                                                      data_diagramelement_t *out_diagramelement )
     642             : {
     643           2 :     U8_TRACE_BEGIN();
     644           2 :     assert( NULL != uuid );
     645           2 :     assert( NULL != out_diagramelement );
     646           2 :     u8_error_t result = U8_ERROR_NONE;
     647             :     int sqlite_err;
     648             :     sqlite3_stmt *prepared_statement;
     649             : 
     650             :     {
     651           2 :         prepared_statement = (*this_).statement_diagramelement_by_uuid;
     652             : 
     653           2 :         result |= data_database_diagram_reader_private_bind_text_to_statement( this_, prepared_statement, uuid );
     654             : 
     655           2 :         U8_TRACE_INFO( "sqlite3_step()" );
     656           2 :         sqlite_err = sqlite3_step( prepared_statement );
     657           2 :         if ( SQLITE_ROW != sqlite_err )
     658             :         {
     659             :             /* Do not log this incident, the caller may not expect to find a row. */
     660           1 :             U8_TRACE_INFO_STR( "sqlite3_step did not find a row for uuid", uuid );
     661           1 :             result |= U8_ERROR_NOT_FOUND;
     662             :         }
     663             : 
     664           2 :         if ( SQLITE_ROW == sqlite_err )
     665             :         {
     666           1 :             result |= data_diagramelement_init( out_diagramelement,
     667           1 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_ID_COLUMN ),
     668           1 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DIAGRAM_ID_COLUMN ),
     669           1 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_CLASSIFIER_ID_COLUMN ),
     670           1 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DISPLAY_FLAGS_COLUMN ),
     671           1 :                                                 sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ),
     672           1 :                                                 (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAMELEMENT_UUID_COLUMN )
     673             :                                               );
     674           1 :             if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ) )
     675             :             {
     676           1 :                 data_diagramelement_set_focused_feature_row_id ( out_diagramelement, DATA_ROW_ID_VOID );
     677             :             }
     678             : 
     679           1 :             data_diagramelement_trace( out_diagramelement );
     680             : 
     681           1 :             sqlite_err = sqlite3_step( prepared_statement );
     682           1 :             if ( SQLITE_DONE != sqlite_err )
     683             :             {
     684           0 :                 U8_LOG_ERROR_INT( "sqlite3_step not done yet:", sqlite_err );
     685           0 :                 result |= U8_ERROR_DB_STRUCTURE;
     686             :             }
     687             :         }
     688             :     }
     689             : 
     690           2 :     U8_TRACE_END_ERR( result );
     691           2 :     return result;
     692             : }
     693             : 
     694           5 : u8_error_t data_database_diagram_reader_get_diagramelements_by_diagram_id ( data_database_diagram_reader_t *this_,
     695             :                                                                             data_row_id_t diagram_id,
     696             :                                                                             uint32_t max_out_array_size,
     697             :                                                                             data_diagramelement_t (*out_diagramelement)[],
     698             :                                                                             uint32_t *out_diagramelement_count )
     699             : {
     700           5 :     U8_TRACE_BEGIN();
     701           5 :     assert( NULL != out_diagramelement_count );
     702           5 :     assert( NULL != out_diagramelement );
     703           5 :     u8_error_t result = U8_ERROR_NONE;
     704             :     int sqlite_err;
     705             :     sqlite3_stmt *prepared_statement;
     706             : 
     707             :     {
     708           5 :         prepared_statement = (*this_).statement_diagramelements_by_diagram_id;
     709             : 
     710           5 :         result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, diagram_id );
     711             : 
     712           5 :         *out_diagramelement_count = 0;
     713           5 :         sqlite_err = SQLITE_ROW;
     714          14 :         for ( uint32_t row_index = 0; (SQLITE_ROW == sqlite_err) && (row_index <= max_out_array_size); row_index ++ )
     715             :         {
     716           9 :             U8_TRACE_INFO( "sqlite3_step()" );
     717           9 :             sqlite_err = sqlite3_step( prepared_statement );
     718           9 :             if (( SQLITE_ROW != sqlite_err )&&( SQLITE_DONE != sqlite_err ))
     719             :             {
     720           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     721           0 :                 result |= U8_ERROR_AT_DB;
     722             :             }
     723           9 :             if (( SQLITE_ROW == sqlite_err )&&(row_index < max_out_array_size))
     724             :             {
     725           4 :                 *out_diagramelement_count = row_index+1;
     726           4 :                 data_diagramelement_t *current_diagele = &((*out_diagramelement)[row_index]);
     727             : 
     728           4 :                 result |= data_diagramelement_init( current_diagele,
     729           4 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_ID_COLUMN ),
     730           4 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DIAGRAM_ID_COLUMN ),
     731           4 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_CLASSIFIER_ID_COLUMN ),
     732           4 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DISPLAY_FLAGS_COLUMN ),
     733           4 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ),
     734           4 :                                                     (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAMELEMENT_UUID_COLUMN )
     735             :                                                   );
     736           4 :                 if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ) )
     737             :                 {
     738           2 :                     data_diagramelement_set_focused_feature_row_id ( current_diagele, DATA_ROW_ID_VOID );
     739             :                 }
     740             : 
     741           4 :                 data_diagramelement_trace( current_diagele );
     742             :             }
     743           9 :             if (( SQLITE_ROW == sqlite_err )&&(row_index >= max_out_array_size))
     744             :             {
     745           0 :                 U8_LOG_ANOMALY_INT( "out_diagramelement[] full:", (row_index+1) );
     746           0 :                 result |= U8_ERROR_ARRAY_BUFFER_EXCEEDED;
     747             :             }
     748           9 :             if ( SQLITE_DONE == sqlite_err )
     749             :             {
     750           5 :                 U8_TRACE_INFO( "sqlite3_step finished: SQLITE_DONE" );
     751             :             }
     752             :         }
     753             :     }
     754             : 
     755           5 :     U8_TRACE_END_ERR( result );
     756           5 :     return result;
     757             : }
     758             : 
     759          10 : u8_error_t data_database_diagram_reader_get_diagramelements_by_classifier_id ( data_database_diagram_reader_t *this_,
     760             :                                                                                data_row_id_t classifier_id,
     761             :                                                                                uint32_t max_out_array_size,
     762             :                                                                                data_diagramelement_t (*out_diagramelement)[],
     763             :                                                                                uint32_t *out_diagramelement_count )
     764             : {
     765          10 :     U8_TRACE_BEGIN();
     766          10 :     assert( NULL != out_diagramelement_count );
     767          10 :     assert( NULL != out_diagramelement );
     768          10 :     u8_error_t result = U8_ERROR_NONE;
     769             :     int sqlite_err;
     770             :     sqlite3_stmt *prepared_statement;
     771             : 
     772             :     {
     773          10 :         prepared_statement = (*this_).statement_diagramelements_by_classifier_id;
     774             : 
     775          10 :         result |= data_database_diagram_reader_private_bind_id_to_statement( this_, prepared_statement, classifier_id );
     776             : 
     777          10 :         *out_diagramelement_count = 0;
     778          10 :         sqlite_err = SQLITE_ROW;
     779          31 :         for ( uint32_t row_index = 0; (SQLITE_ROW == sqlite_err) && (row_index <= max_out_array_size); row_index ++ )
     780             :         {
     781          21 :             U8_TRACE_INFO( "sqlite3_step()" );
     782          21 :             sqlite_err = sqlite3_step( prepared_statement );
     783          21 :             if (( SQLITE_ROW != sqlite_err )&&( SQLITE_DONE != sqlite_err ))
     784             :             {
     785           0 :                 U8_LOG_ERROR_INT( "sqlite3_step failed:", sqlite_err );
     786           0 :                 result |= U8_ERROR_AT_DB;
     787             :             }
     788          21 :             if (( SQLITE_ROW == sqlite_err )&&(row_index < max_out_array_size))
     789             :             {
     790          11 :                 *out_diagramelement_count = row_index+1;
     791          11 :                 data_diagramelement_t *current_diagele = &((*out_diagramelement)[row_index]);
     792             : 
     793          11 :                 result |= data_diagramelement_init( current_diagele,
     794          11 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_ID_COLUMN ),
     795          11 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DIAGRAM_ID_COLUMN ),
     796          11 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_CLASSIFIER_ID_COLUMN ),
     797          11 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_DISPLAY_FLAGS_COLUMN ),
     798          11 :                                                     sqlite3_column_int64( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ),
     799          11 :                                                     (const char*) sqlite3_column_text( prepared_statement, RESULT_DIAGRAMELEMENT_UUID_COLUMN )
     800             :                                                   );
     801          11 :                 if ( SQLITE_NULL == sqlite3_column_type( prepared_statement, RESULT_DIAGRAMELEMENT_FOCUSED_FEATURE_ID_COLUMN ) )
     802             :                 {
     803           2 :                     data_diagramelement_set_focused_feature_row_id ( current_diagele, DATA_ROW_ID_VOID );
     804             :                 }
     805             : 
     806          11 :                 data_diagramelement_trace( current_diagele );
     807             :             }
     808          21 :             if (( SQLITE_ROW == sqlite_err )&&(row_index >= max_out_array_size))
     809             :             {
     810           0 :                 U8_LOG_ANOMALY_INT( "out_diagramelement[] full:", (row_index+1) );
     811           0 :                 result |= U8_ERROR_ARRAY_BUFFER_EXCEEDED;
     812             :             }
     813          21 :             if ( SQLITE_DONE == sqlite_err )
     814             :             {
     815          10 :                 U8_TRACE_INFO( "sqlite3_step finished: SQLITE_DONE" );
     816             :             }
     817             :         }
     818             :     }
     819             : 
     820          10 :     U8_TRACE_END_ERR( result );
     821          10 :     return result;
     822             : }
     823             : 
     824             : /* ================================ private ================================ */
     825             : 
     826          99 : u8_error_t data_database_diagram_reader_private_open ( data_database_diagram_reader_t *this_ )
     827             : {
     828          99 :     U8_TRACE_BEGIN();
     829          99 :     u8_error_t result = U8_ERROR_NONE;
     830             : 
     831             :     {
     832          99 :         result |= data_database_prepare_statement( (*this_).database,
     833             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAM_BY_ID,
     834             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAM_BY_ID ),
     835             :                                                    &((*this_).statement_diagram_by_id)
     836             :                                                  );
     837             : 
     838          99 :         result |= data_database_prepare_statement( (*this_).database,
     839             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAM_BY_UUID,
     840             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAM_BY_UUID ),
     841             :                                                    &((*this_).statement_diagram_by_uuid)
     842             :                                                  );
     843             : 
     844          99 :         result |= data_database_prepare_statement( (*this_).database,
     845             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_PARENT_ID,
     846             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_PARENT_ID ),
     847             :                                                    &((*this_).statement_diagrams_by_parent_id)
     848             :                                                  );
     849             : 
     850          99 :         result |= data_database_prepare_statement( (*this_).database,
     851             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_PARENT_ID_NULL,
     852             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_PARENT_ID_NULL ),
     853             :                                                    &((*this_).statement_diagrams_by_parent_id_null)
     854             :                                                  );
     855             : 
     856          99 :         result |= data_database_prepare_statement( (*this_).database,
     857             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_CLASSIFIER_ID,
     858             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMS_BY_CLASSIFIER_ID ),
     859             :                                                    &((*this_).statement_diagrams_by_classifier_id)
     860             :                                                  );
     861             : 
     862          99 :         result |= data_database_prepare_statement( (*this_).database,
     863             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_PARENT_ID,
     864             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_PARENT_ID ),
     865             :                                                    &((*this_).statement_diagram_ids_by_parent_id)
     866             :                                                  );
     867             : 
     868          99 :         result |= data_database_prepare_statement( (*this_).database,
     869             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_PARENT_ID_NULL,
     870             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_PARENT_ID_NULL ),
     871             :                                                    &((*this_).statement_diagram_ids_by_parent_id_null)
     872             :                                                  );
     873             : 
     874          99 :         result |= data_database_prepare_statement( (*this_).database,
     875             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_CLASSIFIER_ID,
     876             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAM_IDS_BY_CLASSIFIER_ID ),
     877             :                                                    &((*this_).statement_diagram_ids_by_classifier_id)
     878             :                                                  );
     879             : 
     880          99 :         result |= data_database_prepare_statement( (*this_).database,
     881             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMELEMENT_BY_ID,
     882             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMELEMENT_BY_ID ),
     883             :                                                    &((*this_).statement_diagramelement_by_id)
     884             :                                                  );
     885             : 
     886          99 :         result |= data_database_prepare_statement( (*this_).database,
     887             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMELEMENT_BY_UUID,
     888             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMELEMENT_BY_UUID ),
     889             :                                                    &((*this_).statement_diagramelement_by_uuid)
     890             :                                                  );
     891             : 
     892          99 :         result |= data_database_prepare_statement( (*this_).database,
     893             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMELEMENTS_BY_DIAGRAM_ID,
     894             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMELEMENTS_BY_DIAGRAM_ID ),
     895             :                                                    &((*this_).statement_diagramelements_by_diagram_id)
     896             :                                                  );
     897             : 
     898          99 :         result |= data_database_prepare_statement( (*this_).database,
     899             :                                                    DATA_DATABASE_READER_SELECT_DIAGRAMELEMENTS_BY_CLASSIFIER_ID,
     900             :                                                    sizeof( DATA_DATABASE_READER_SELECT_DIAGRAMELEMENTS_BY_CLASSIFIER_ID ),
     901             :                                                    &((*this_).statement_diagramelements_by_classifier_id)
     902             :                                                  );
     903             : 
     904          99 :         if ( result != U8_ERROR_NONE )
     905             :         {
     906           0 :             U8_LOG_ERROR( "A prepared statement could not be prepared." );
     907             :         }
     908             :     }
     909             : 
     910          99 :     U8_TRACE_END_ERR(result);
     911          99 :     return result;
     912             : }
     913             : 
     914          99 : u8_error_t data_database_diagram_reader_private_close ( data_database_diagram_reader_t *this_ )
     915             : {
     916          99 :     U8_TRACE_BEGIN();
     917          99 :     u8_error_t result = U8_ERROR_NONE;
     918             : 
     919             :     {
     920          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagram_by_id );
     921          99 :         (*this_).statement_diagram_by_id = NULL;
     922             : 
     923          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagram_by_uuid );
     924          99 :         (*this_).statement_diagram_by_uuid = NULL;
     925             : 
     926          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagrams_by_parent_id );
     927          99 :         (*this_).statement_diagrams_by_parent_id = NULL;
     928             : 
     929          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagrams_by_parent_id_null );
     930          99 :         (*this_).statement_diagrams_by_parent_id_null = NULL;
     931             : 
     932          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagrams_by_classifier_id );
     933          99 :         (*this_).statement_diagrams_by_classifier_id = NULL;
     934             : 
     935          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagram_ids_by_parent_id );
     936          99 :         (*this_).statement_diagram_ids_by_parent_id = NULL;
     937             : 
     938          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagram_ids_by_parent_id_null );
     939          99 :         (*this_).statement_diagram_ids_by_parent_id_null = NULL;
     940             : 
     941          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagram_ids_by_classifier_id );
     942          99 :         (*this_).statement_diagram_ids_by_classifier_id = NULL;
     943             : 
     944          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagramelement_by_id );
     945          99 :         (*this_).statement_diagramelement_by_id = NULL;
     946             : 
     947          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagramelement_by_uuid );
     948          99 :         (*this_).statement_diagramelement_by_uuid = NULL;
     949             : 
     950          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagramelements_by_diagram_id );
     951          99 :         (*this_).statement_diagramelements_by_diagram_id = NULL;
     952             : 
     953          99 :         result |= data_database_finalize_statement( (*this_).database, (*this_).statement_diagramelements_by_classifier_id );
     954          99 :         (*this_).statement_diagramelements_by_classifier_id = NULL;
     955             : 
     956             :     }
     957             : 
     958          99 :     U8_TRACE_END_ERR(result);
     959          99 :     return result;
     960             : }
     961             : 
     962             : 
     963             : /*
     964             : Copyright 2016-2024 Andreas Warnke
     965             : 
     966             : Licensed under the Apache License, Version 2.0 (the "License");
     967             : you may not use this file except in compliance with the License.
     968             : You may obtain a copy of the License at
     969             : 
     970             :     http://www.apache.org/licenses/LICENSE-2.0
     971             : 
     972             : Unless required by applicable law or agreed to in writing, software
     973             : distributed under the License is distributed on an "AS IS" BASIS,
     974             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     975             : See the License for the specific language governing permissions and
     976             : limitations under the License.
     977             : */

Generated by: LCOV version 1.16