LCOV - code coverage report
Current view: top level - ctrl/source - ctrl_diagram_controller.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 199 244 81.6 %
Date: 2024-04-07 11:14:42 Functions: 14 16 87.5 %

          Line data    Source code
       1             : /* File: ctrl_diagram_controller.c; Copyright and License: see below */
       2             : 
       3             : #include "ctrl_diagram_controller.h"
       4             : #include "u8/u8_trace.h"
       5             : #include "u8/u8_log.h"
       6             : 
       7          42 : void ctrl_diagram_controller_init ( ctrl_diagram_controller_t *this_,
       8             :                                     ctrl_undo_redo_list_t *undo_redo_list,
       9             :                                     ctrl_diagram_trigger_t *policy_enforcer,
      10             :                                     data_database_t *database,
      11             :                                     data_database_reader_t *db_reader,
      12             :                                     data_database_writer_t *db_writer )
      13             : {
      14          42 :     U8_TRACE_BEGIN();
      15             : 
      16          42 :     (*this_).undo_redo_list = undo_redo_list;
      17          42 :     (*this_).policy_enforcer = policy_enforcer;
      18          42 :     (*this_).database = database;
      19          42 :     (*this_).db_reader = db_reader;
      20          42 :     (*this_).db_writer = db_writer;
      21             : 
      22          42 :     U8_TRACE_END();
      23          42 : }
      24             : 
      25          42 : void ctrl_diagram_controller_destroy ( ctrl_diagram_controller_t *this_ )
      26             : {
      27          42 :     U8_TRACE_BEGIN();
      28             : 
      29          42 :     (*this_).undo_redo_list = NULL;
      30          42 :     (*this_).policy_enforcer = NULL;
      31          42 :     (*this_).database = NULL;
      32          42 :     (*this_).db_reader = NULL;
      33          42 :     (*this_).db_writer = NULL;
      34             : 
      35          42 :     U8_TRACE_END();
      36          42 : }
      37             : 
      38             : /* ================================ DIAGRAM ================================ */
      39             : 
      40          29 : u8_error_t ctrl_diagram_controller_create_diagram ( ctrl_diagram_controller_t *this_,
      41             :                                                     const data_diagram_t *new_diagram,
      42             :                                                     ctrl_undo_redo_action_boundary_t add_to_latest_undo_set,
      43             :                                                     data_row_id_t* out_new_id )
      44             : {
      45          29 :     U8_TRACE_BEGIN();
      46          29 :     assert( NULL != new_diagram );
      47             :     data_diagram_t to_be_created;
      48          29 :     u8_error_t result = U8_ERROR_NONE;
      49             :     u8_error_t data_result;
      50             :     data_row_id_t new_id;
      51             : 
      52          29 :     data_diagram_copy( &to_be_created, new_diagram );
      53             : 
      54          29 :     data_result = data_database_writer_create_diagram( (*this_).db_writer, &to_be_created, &new_id );
      55          29 :     if ( U8_ERROR_NONE == data_result )
      56             :     {
      57             :         /* store new id to diagram object */
      58          28 :         data_diagram_set_row_id( &to_be_created, new_id );
      59             : 
      60             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
      61          28 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
      62             :         {
      63             :             u8_error_t internal_err;
      64           1 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
      65           1 :             if ( U8_ERROR_NONE != internal_err )
      66             :             {
      67           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
      68             :             }
      69             :         }
      70             : 
      71             :         /* store the new diagram to the undo redo list */
      72          28 :         ctrl_undo_redo_list_add_create_diagram( (*this_).undo_redo_list, &to_be_created );
      73          28 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
      74             : 
      75             :         /* copy new id to out parameter */
      76          28 :         if ( NULL != out_new_id )
      77             :         {
      78          28 :             *out_new_id = new_id;
      79             :         }
      80             :     }
      81          29 :     result = (u8_error_t) data_result;
      82             : 
      83          29 :     data_diagram_destroy( &to_be_created );
      84             : 
      85          29 :     U8_TRACE_END_ERR( result );
      86          29 :     return result;
      87             : }
      88             : 
      89         134 : u8_error_t ctrl_diagram_controller_private_create_child_diagram ( ctrl_diagram_controller_t *this_,
      90             :                                                                   data_row_id_t parent_diagram_id,
      91             :                                                                   data_diagram_type_t diagram_type,
      92             :                                                                   const char* diagram_name,
      93             :                                                                   data_row_id_t* out_new_id )
      94             : {
      95         134 :     U8_TRACE_BEGIN();
      96             :     data_diagram_t to_be_created;
      97         134 :     u8_error_t result = U8_ERROR_NONE;
      98             :     u8_error_t data_result;
      99             :     data_row_id_t new_id;
     100             : 
     101         134 :     data_diagram_init_new( &to_be_created, parent_diagram_id, diagram_type, "", diagram_name, "", 0, DATA_DIAGRAM_FLAG_NONE );
     102             : 
     103         134 :     data_result = data_database_writer_create_diagram( (*this_).db_writer, &to_be_created, &new_id );
     104         134 :     if ( U8_ERROR_NONE == data_result )
     105             :     {
     106             :         /* store new id to diagram object */
     107         134 :         data_diagram_set_row_id( &to_be_created, new_id );
     108             : 
     109             :         /* store the new diagram to the undo redo list */
     110         134 :         ctrl_undo_redo_list_add_create_diagram( (*this_).undo_redo_list, &to_be_created );
     111         134 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     112             : 
     113             :         /* copy new id to out parameter */
     114         134 :         if ( NULL != out_new_id )
     115             :         {
     116         134 :             *out_new_id = new_id;
     117             :         }
     118             :     }
     119         134 :     result = (u8_error_t) data_result;
     120             : 
     121         134 :     data_diagram_destroy( &to_be_created );
     122             : 
     123         134 :     U8_TRACE_END_ERR( result );
     124         134 :     return result;
     125             : }
     126             : 
     127           5 : u8_error_t ctrl_diagram_controller_create_root_diagram_if_not_exists ( ctrl_diagram_controller_t *this_,
     128             :                                                                        data_diagram_type_t diagram_type,
     129             :                                                                        const char* diagram_name,
     130             :                                                                        data_row_id_t* out_new_id )
     131             : {
     132           5 :     U8_TRACE_BEGIN();
     133           5 :     u8_error_t result = U8_ERROR_NONE;
     134             :     u8_error_t data_result;
     135             :     data_diagram_t root_diag_buf[1];
     136             : 
     137             :     /* load all without parent */
     138             :     uint32_t count;
     139           5 :     data_result = data_database_reader_get_diagrams_by_parent_id( (*this_).db_reader,
     140             :                                                                   DATA_ROW_ID_VOID,
     141             :                                                                   1,
     142             :                                                                   &(root_diag_buf),
     143             :                                                                   &count
     144             :                                                                 );
     145           5 :     if ( U8_ERROR_NONE != data_result )
     146             :     {
     147           0 :         result = (u8_error_t) data_result;
     148             :     }
     149             :     else
     150             :     {
     151           5 :         if ( 0 == count )
     152             :         {
     153             :             /* no root diagram exists */
     154           5 :             result = ctrl_diagram_controller_private_create_child_diagram( this_, DATA_ROW_ID_VOID, diagram_type, diagram_name, out_new_id );
     155             :         }
     156             :         else
     157             :         {
     158           0 :             if ( NULL != out_new_id )
     159             :             {
     160           0 :                 *out_new_id = DATA_ROW_ID_VOID;
     161             :             }
     162             :         }
     163             :     }
     164             : 
     165           5 :     U8_TRACE_END_ERR( result );
     166           5 :     return result;
     167             : }
     168             : 
     169           3 : u8_error_t ctrl_diagram_controller_delete_diagram ( ctrl_diagram_controller_t *this_,
     170             :                                                     data_row_id_t obj_id,
     171             :                                                     ctrl_undo_redo_action_boundary_t add_to_latest_undo_set )
     172             : {
     173           3 :     U8_TRACE_BEGIN();
     174           3 :     u8_error_t result = U8_ERROR_NONE;
     175             : 
     176             :     /* delete diagram */
     177             :     /* data_database_writer_delete_diagram checks that this diagram is not a parent */
     178             :     /* and is not referenced by diagramelements */
     179             :     /* fails otherwise: U8_ERROR_OBJECT_STILL_REFERENCED */
     180             :     data_diagram_t old_diagram;
     181             :     u8_error_t current_result3;
     182           3 :     current_result3 = data_database_writer_delete_diagram ( (*this_).db_writer, obj_id, &old_diagram );
     183             : 
     184           3 :     if ( U8_ERROR_NONE == current_result3 )
     185             :     {
     186             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
     187           2 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
     188             :         {
     189             :             u8_error_t internal_err;
     190           2 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
     191           2 :             if ( U8_ERROR_NONE != internal_err )
     192             :             {
     193           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
     194             :             }
     195             :         }
     196             : 
     197             :         /* store the deleted diagram to the undo redo list */
     198           2 :         ctrl_undo_redo_list_add_delete_diagram( (*this_).undo_redo_list, &old_diagram );
     199           2 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     200             : 
     201           2 :         data_diagram_destroy( &old_diagram );
     202             :     }
     203             : 
     204           3 :     result |= (u8_error_t) current_result3;
     205             : 
     206           3 :     U8_TRACE_END_ERR( result );
     207           3 :     return result;
     208             : }
     209             : 
     210           0 : u8_error_t ctrl_diagram_controller_update_diagram_parent_id ( ctrl_diagram_controller_t *this_,
     211             :                                                               data_row_id_t diagram_id,
     212             :                                                               data_row_id_t new_diagram_parent_id,
     213             :                                                               ctrl_undo_redo_action_boundary_t add_to_latest_undo_set )
     214             : {
     215           0 :     U8_TRACE_BEGIN();
     216           0 :     u8_error_t result = U8_ERROR_NONE;
     217             :     u8_error_t data_result;
     218             :     data_diagram_t old_diagram;
     219             : 
     220           0 :     data_result = data_database_writer_update_diagram_parent_id( (*this_).db_writer, diagram_id, new_diagram_parent_id, &old_diagram );
     221           0 :     if ( U8_ERROR_NONE == data_result )
     222             :     {
     223             :         /* prepare the new diagram */
     224             :         data_diagram_t new_diagram;
     225           0 :         data_diagram_copy( &new_diagram, &old_diagram );
     226           0 :         data_diagram_set_parent_row_id( &new_diagram, new_diagram_parent_id );
     227             : 
     228             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
     229           0 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
     230             :         {
     231             :             u8_error_t internal_err;
     232           0 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
     233           0 :             if ( U8_ERROR_NONE != internal_err )
     234             :             {
     235           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
     236             :             }
     237             :         }
     238             : 
     239             :         /* store the change of the diagram to the undo redo list */
     240           0 :         ctrl_undo_redo_list_add_update_diagram( (*this_).undo_redo_list, &old_diagram, &new_diagram );
     241           0 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     242             : 
     243           0 :         data_diagram_destroy( &new_diagram );
     244           0 :         data_diagram_destroy( &old_diagram );
     245             :     }
     246           0 :     result = (u8_error_t) data_result;
     247             : 
     248           0 :     U8_TRACE_END_ERR( result );
     249           0 :     return result;
     250             : }
     251             : 
     252           5 : u8_error_t ctrl_diagram_controller_update_diagram_type ( ctrl_diagram_controller_t *this_,
     253             :                                                          data_row_id_t diagram_id,
     254             :                                                          data_diagram_type_t new_diagram_type,
     255             :                                                          data_stat_t *io_stat )
     256             : {
     257           5 :     U8_TRACE_BEGIN();
     258           5 :     assert( io_stat != NULL );
     259           5 :     u8_error_t result = U8_ERROR_NONE;
     260             :     data_diagram_t old_diagram;
     261             : 
     262           5 :     result |= data_database_writer_update_diagram_type( (*this_).db_writer, diagram_id, new_diagram_type, &old_diagram );
     263           5 :     if ( U8_ERROR_NONE == result )
     264             :     {
     265             :         /* prepare the new diagram */
     266             :         data_diagram_t new_diagram;
     267           5 :         data_diagram_copy( &new_diagram, &old_diagram );
     268           5 :         data_diagram_set_diagram_type( &new_diagram, new_diagram_type );
     269             : 
     270             :         /* store the change of the diagram to the undo redo list */
     271           5 :         ctrl_undo_redo_list_add_update_diagram( (*this_).undo_redo_list, &old_diagram, &new_diagram );
     272           5 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     273             : 
     274             :         /* apply policy rules */
     275           5 :         result |= ctrl_diagram_trigger_post_update_diagram_type( (*this_).policy_enforcer, &new_diagram );
     276             : 
     277           5 :         data_diagram_destroy( &new_diagram );
     278           5 :         data_diagram_destroy( &old_diagram );
     279             : 
     280             :         /* report statistics */
     281           5 :         result |= ctrl_undo_redo_list_get_last_statistics( (*this_).undo_redo_list, io_stat );
     282             :     }
     283             :     else
     284             :     {
     285           0 :         data_stat_inc_count ( io_stat, DATA_STAT_TABLE_DIAGRAM, DATA_STAT_SERIES_ERROR );
     286             :     }
     287             : 
     288           5 :     U8_TRACE_END_ERR( result );
     289           5 :     return result;
     290             : }
     291             : 
     292           0 : u8_error_t ctrl_diagram_controller_update_diagram_stereotype ( ctrl_diagram_controller_t *this_,
     293             :                                                                data_row_id_t diagram_id,
     294             :                                                                const char* new_diagram_stereotype )
     295             : {
     296           0 :     U8_TRACE_BEGIN();
     297           0 :     u8_error_t result = U8_ERROR_NONE;
     298             :     u8_error_t data_result;
     299             :     data_diagram_t old_diagram;
     300             : 
     301           0 :     data_result = data_database_writer_update_diagram_stereotype( (*this_).db_writer, diagram_id, new_diagram_stereotype, &old_diagram );
     302           0 :     if  (( U8_ERROR_NONE == data_result ) || ( U8_ERROR_STRING_BUFFER_EXCEEDED == data_result ))
     303             :     {
     304             :         /* prepare the new diagram */
     305             :         data_diagram_t new_diagram;
     306           0 :         data_diagram_copy( &new_diagram, &old_diagram );
     307           0 :         data_diagram_set_stereotype( &new_diagram, new_diagram_stereotype );
     308             :         /* store the change of the diagram to the undo redo list */
     309           0 :         ctrl_undo_redo_list_add_update_diagram( (*this_).undo_redo_list, &old_diagram, &new_diagram );
     310           0 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     311             : 
     312           0 :         data_diagram_destroy( &new_diagram );
     313           0 :         data_diagram_destroy( &old_diagram );
     314             :     }
     315           0 :     result = (u8_error_t) data_result;
     316             : 
     317           0 :     U8_TRACE_END_ERR( result );
     318           0 :     return result;
     319             : }
     320             : 
     321           2 : u8_error_t ctrl_diagram_controller_update_diagram_name ( ctrl_diagram_controller_t *this_,
     322             :                                                          data_row_id_t diagram_id,
     323             :                                                          const char* new_diagram_name )
     324             : {
     325           2 :     U8_TRACE_BEGIN();
     326           2 :     u8_error_t result = U8_ERROR_NONE;
     327             :     u8_error_t data_result;
     328             :     data_diagram_t old_diagram;
     329             : 
     330           2 :     data_result = data_database_writer_update_diagram_name( (*this_).db_writer, diagram_id, new_diagram_name, &old_diagram );
     331           2 :     if  (( U8_ERROR_NONE == data_result ) || ( U8_ERROR_STRING_BUFFER_EXCEEDED == data_result ))
     332             :     {
     333             :         /* prepare the new diagram */
     334             :         data_diagram_t new_diagram;
     335           2 :         data_diagram_copy( &new_diagram, &old_diagram );
     336           2 :         data_diagram_set_name( &new_diagram, new_diagram_name );
     337             :         /* store the change of the diagram to the undo redo list */
     338           2 :         ctrl_undo_redo_list_add_update_diagram( (*this_).undo_redo_list, &old_diagram, &new_diagram );
     339           2 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     340             : 
     341           2 :         data_diagram_destroy( &new_diagram );
     342           2 :         data_diagram_destroy( &old_diagram );
     343             :     }
     344           2 :     result = (u8_error_t) data_result;
     345             : 
     346           2 :     U8_TRACE_END_ERR( result );
     347           2 :     return result;
     348             : }
     349             : 
     350           1 : u8_error_t ctrl_diagram_controller_update_diagram_description ( ctrl_diagram_controller_t *this_,
     351             :                                                                 data_row_id_t diagram_id,
     352             :                                                                 const char* new_diagram_description )
     353             : {
     354           1 :     U8_TRACE_BEGIN();
     355           1 :     u8_error_t result = U8_ERROR_NONE;
     356             :     u8_error_t data_result;
     357             :     data_diagram_t old_diagram;
     358             : 
     359           1 :     data_result = data_database_writer_update_diagram_description( (*this_).db_writer, diagram_id, new_diagram_description, &old_diagram );
     360           1 :     if  (( U8_ERROR_NONE == data_result ) || ( U8_ERROR_STRING_BUFFER_EXCEEDED == data_result ))
     361             :     {
     362             :         /* prepare the new diagram */
     363             :         data_diagram_t new_diagram;
     364           1 :         data_diagram_copy( &new_diagram, &old_diagram );
     365           1 :         data_diagram_set_description( &new_diagram, new_diagram_description );
     366             :         /* store the change of the diagram to the undo redo list */
     367           1 :         ctrl_undo_redo_list_add_update_diagram( (*this_).undo_redo_list, &old_diagram, &new_diagram );
     368           1 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     369             : 
     370           1 :         data_diagram_destroy( &new_diagram );
     371           1 :         data_diagram_destroy( &old_diagram );
     372             :     }
     373           1 :     result = (u8_error_t) data_result;
     374             : 
     375           1 :     U8_TRACE_END_ERR( result );
     376           1 :     return result;
     377             : }
     378             : 
     379           1 : u8_error_t ctrl_diagram_controller_update_diagram_list_order ( ctrl_diagram_controller_t *this_,
     380             :                                                                data_row_id_t diagram_id,
     381             :                                                                int32_t new_diagram_list_order )
     382             : {
     383           1 :     U8_TRACE_BEGIN();
     384           1 :     u8_error_t result = U8_ERROR_NONE;
     385             :     u8_error_t data_result;
     386             :     data_diagram_t old_diagram;
     387             : 
     388           1 :     data_result = data_database_writer_update_diagram_list_order( (*this_).db_writer, diagram_id, new_diagram_list_order, &old_diagram );
     389           1 :     if ( U8_ERROR_NONE == data_result )
     390             :     {
     391             :         /* prepare the new diagram */
     392             :         data_diagram_t new_diagram;
     393           1 :         data_diagram_copy( &new_diagram, &old_diagram );
     394           1 :         data_diagram_set_list_order( &new_diagram, new_diagram_list_order );
     395             :         /* store the change of the diagram to the undo redo list */
     396           1 :         ctrl_undo_redo_list_add_update_diagram( (*this_).undo_redo_list, &old_diagram, &new_diagram );
     397           1 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     398             : 
     399           1 :         data_diagram_destroy( &new_diagram );
     400           1 :         data_diagram_destroy( &old_diagram );
     401             :     }
     402           1 :     result = (u8_error_t) data_result;
     403             : 
     404           1 :     U8_TRACE_END_ERR( result );
     405           1 :     return result;
     406             : }
     407             : 
     408             : /* ================================ DIAGRAMELEMENT ================================ */
     409             : 
     410          33 : u8_error_t ctrl_diagram_controller_create_diagramelement( ctrl_diagram_controller_t *this_,
     411             :                                                           const data_diagramelement_t *new_diagramelement,
     412             :                                                           ctrl_undo_redo_action_boundary_t add_to_latest_undo_set,
     413             :                                                           data_row_id_t* out_new_id )
     414             : {
     415          33 :     U8_TRACE_BEGIN();
     416          33 :     assert( NULL != new_diagramelement );
     417             :     data_diagramelement_t to_be_created;
     418          33 :     u8_error_t result = U8_ERROR_NONE;
     419             :     u8_error_t data_result;
     420             :     data_row_id_t new_id;
     421             : 
     422          33 :     data_diagramelement_copy( &to_be_created, new_diagramelement );
     423             : 
     424          33 :     data_result = data_database_writer_create_diagramelement( (*this_).db_writer, &to_be_created, &new_id );
     425          33 :     if ( U8_ERROR_NONE == data_result )
     426             :     {
     427             :         /* store new id to data_diagramelement_t object */
     428          33 :         data_diagramelement_set_row_id( &to_be_created, new_id );
     429             : 
     430             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
     431          33 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
     432             :         {
     433             :             u8_error_t internal_err;
     434          25 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
     435          25 :             if ( U8_ERROR_NONE != internal_err )
     436             :             {
     437           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
     438             :             }
     439             :         }
     440             : 
     441             :         /* store the new diagram to the undo redo list */
     442          33 :         ctrl_undo_redo_list_add_create_diagramelement( (*this_).undo_redo_list, &to_be_created );
     443          33 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     444             : 
     445             :         /* apply policies */
     446          33 :         result |= ctrl_diagram_trigger_post_create_diagramelement( (*this_).policy_enforcer, &to_be_created );
     447             : 
     448             :         /* copy new id to out parameter */
     449          33 :         if ( NULL != out_new_id )
     450             :         {
     451          33 :             *out_new_id = new_id;
     452             :         }
     453             :     }
     454             :     else
     455             :     {
     456           0 :         result = (u8_error_t) data_result;
     457             :     }
     458             : 
     459          33 :     data_diagramelement_destroy( &to_be_created );
     460             : 
     461          33 :     U8_TRACE_END_ERR( result );
     462          33 :     return result;
     463             : }
     464             : 
     465           6 : u8_error_t ctrl_diagram_controller_delete_diagramelement( ctrl_diagram_controller_t *this_,
     466             :                                                           data_row_id_t obj_id,
     467             :                                                           ctrl_undo_redo_action_boundary_t add_to_latest_undo_set )
     468             : {
     469           6 :     U8_TRACE_BEGIN();
     470           6 :     u8_error_t result = U8_ERROR_NONE;
     471             : 
     472             :     /* delete diagramelement */
     473             :     u8_error_t current_result;
     474             :     data_diagramelement_t old_diagramelement;
     475           6 :     current_result = data_database_writer_delete_diagramelement( (*this_).db_writer,
     476             :                                                                  obj_id,
     477             :                                                                  &old_diagramelement
     478             :                                                                );
     479             : 
     480           6 :     if ( U8_ERROR_NONE == current_result )
     481             :     {
     482             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
     483           5 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
     484             :         {
     485             :             u8_error_t internal_err;
     486           1 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
     487           1 :             if ( U8_ERROR_NONE != internal_err )
     488             :             {
     489           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
     490             :             }
     491             :         }
     492             : 
     493             :         /* store the deleted classifier to the undo redo list */
     494           5 :         ctrl_undo_redo_list_add_delete_diagramelement( (*this_).undo_redo_list, &old_diagramelement );
     495           5 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     496             : 
     497             :         /* try to also delete the classifier and focused lifelines */
     498           5 :         result |= ctrl_diagram_trigger_post_delete_diagramelement( (*this_).policy_enforcer, &old_diagramelement );
     499             : 
     500           5 :         data_diagramelement_destroy( &old_diagramelement );
     501             :     }
     502             :     else
     503             :     {
     504           1 :         result |= (u8_error_t) current_result;
     505             :     }
     506             : 
     507           6 :     U8_TRACE_END_ERR( result );
     508           6 :     return result;
     509             : }
     510             : 
     511           1 : u8_error_t ctrl_diagram_controller_update_diagramelement_display_flags( ctrl_diagram_controller_t *this_,
     512             :                                                                         data_row_id_t diagramelement_id,
     513             :                                                                         data_diagramelement_flag_t new_diagramelement_display_flags,
     514             :                                                                         ctrl_undo_redo_action_boundary_t add_to_latest_undo_set )
     515             : {
     516           1 :     U8_TRACE_BEGIN();
     517           1 :     u8_error_t result = U8_ERROR_NONE;
     518             :     u8_error_t data_result;
     519             :     data_diagramelement_t old_diagramelement;
     520             : 
     521           1 :     data_result = data_database_writer_update_diagramelement_display_flags( (*this_).db_writer,
     522             :                                                                             diagramelement_id,
     523             :                                                                             new_diagramelement_display_flags,
     524             :                                                                             &old_diagramelement
     525             :                                                                           );
     526           1 :     if ( U8_ERROR_NONE == data_result )
     527             :     {
     528             :         /* prepare the new diagram */
     529             :         data_diagramelement_t new_diagramelement;
     530           1 :         data_diagramelement_copy( &new_diagramelement, &old_diagramelement );
     531           1 :         data_diagramelement_set_display_flags( &new_diagramelement, new_diagramelement_display_flags );
     532             : 
     533             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
     534           1 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
     535             :         {
     536             :             u8_error_t internal_err;
     537           0 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
     538           0 :             if ( U8_ERROR_NONE != internal_err )
     539             :             {
     540           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
     541             :             }
     542             :         }
     543             : 
     544             :         /* store the change of the diagramelement to the undo redo list */
     545           1 :         ctrl_undo_redo_list_add_update_diagramelement( (*this_).undo_redo_list, &old_diagramelement, &new_diagramelement );
     546           1 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     547             : 
     548           1 :         data_diagramelement_destroy( &new_diagramelement );
     549           1 :         data_diagramelement_destroy( &old_diagramelement );
     550             :     }
     551           1 :     result = (u8_error_t) data_result;
     552             : 
     553           1 :     U8_TRACE_END_ERR( result );
     554           1 :     return result;
     555             : }
     556             : 
     557          21 : u8_error_t ctrl_diagram_controller_update_diagramelement_focused_feature_id( ctrl_diagram_controller_t *this_,
     558             :                                                                              data_row_id_t diagramelement_id,
     559             :                                                                              data_row_id_t new_diagramelement_focused_feature_id,
     560             :                                                                              ctrl_undo_redo_action_boundary_t add_to_latest_undo_set )
     561             : {
     562          21 :     U8_TRACE_BEGIN();
     563          21 :     u8_error_t result = U8_ERROR_NONE;
     564             :     u8_error_t data_result;
     565             :     data_diagramelement_t old_diagramelement;
     566             : 
     567          21 :     data_result = data_database_writer_update_diagramelement_focused_feature_id( (*this_).db_writer,
     568             :                                                                                  diagramelement_id,
     569             :                                                                                  new_diagramelement_focused_feature_id,
     570             :                                                                                  &old_diagramelement
     571             :                                                                                );
     572          21 :     if ( U8_ERROR_NONE == data_result )
     573             :     {
     574             :         /* prepare the new diagram */
     575             :         data_diagramelement_t new_diagramelement;
     576          21 :         data_diagramelement_copy( &new_diagramelement, &old_diagramelement );
     577          21 :         data_diagramelement_set_focused_feature_row_id( &new_diagramelement, new_diagramelement_focused_feature_id );
     578             : 
     579             :         /* if this action shall be stored to the latest set of actions in the undo redo list, remove the boundary: */
     580          21 :         if ( add_to_latest_undo_set == CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND )
     581             :         {
     582             :             u8_error_t internal_err;
     583          21 :             internal_err = ctrl_undo_redo_list_remove_boundary_from_end( (*this_).undo_redo_list );
     584          21 :             if ( U8_ERROR_NONE != internal_err )
     585             :             {
     586           0 :                 U8_LOG_ERROR_HEX( "unexpected internal error", internal_err );
     587             :             }
     588             :         }
     589             : 
     590             :         /* store the change of the diagramelement to the undo redo list */
     591          21 :         ctrl_undo_redo_list_add_update_diagramelement( (*this_).undo_redo_list, &old_diagramelement, &new_diagramelement );
     592          21 :         ctrl_undo_redo_list_add_boundary( (*this_).undo_redo_list );
     593             : 
     594          21 :         data_diagramelement_destroy( &new_diagramelement );
     595          21 :         data_diagramelement_destroy( &old_diagramelement );
     596             :     }
     597          21 :     result = (u8_error_t) data_result;
     598             : 
     599          21 :     U8_TRACE_END_ERR( result );
     600          21 :     return result;
     601             : }
     602             : 
     603             : 
     604             : /*
     605             : Copyright 2016-2024 Andreas Warnke
     606             : 
     607             : Licensed under the Apache License, Version 2.0 (the "License");
     608             : you may not use this file except in compliance with the License.
     609             : You may obtain a copy of the License at
     610             : 
     611             :     http://www.apache.org/licenses/LICENSE-2.0
     612             : 
     613             : Unless required by applicable law or agreed to in writing, software
     614             : distributed under the License is distributed on an "AS IS" BASIS,
     615             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     616             : See the License for the specific language governing permissions and
     617             : limitations under the License.
     618             : */

Generated by: LCOV version 1.16