LCOV - code coverage report
Current view: top level - dbe/apps/SchemaEditor - SchemaCommand.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 759 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 140 0

            Line data    Source code
       1              : /// Including Qt
       2              : #include <QMessageBox>
       3              : /// Including Schema Editor
       4              : #include "dbe/SchemaCommand.hpp"
       5              : #include "dbe/SchemaKernelWrapper.hpp"
       6              : 
       7              : using namespace dunedaq::oks;
       8              : 
       9              : 
      10              : namespace dbse
      11              : {
      12              : 
      13            0 : SetAbstractClassCommand::SetAbstractClassCommand ( OksClass * Class, bool Value )
      14            0 :   : ClassName ( Class->get_name() ),
      15            0 :     NewValue ( Value ),
      16            0 :     OldValue ( Class->get_is_abstract() )
      17              : {
      18            0 :   setText ( QString::fromStdString("Changed abstract flag for class \"" + ClassName + "\"" ) );
      19            0 : }
      20              : 
      21            0 : SetAbstractClassCommand::~SetAbstractClassCommand()
      22              : {
      23            0 : }
      24              : 
      25            0 : void SetAbstractClassCommand::redo()
      26              : {
      27            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->set_is_abstract ( NewValue );
      28            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
      29            0 : }
      30              : 
      31            0 : void SetAbstractClassCommand::undo()
      32              : {
      33            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->set_is_abstract ( OldValue );
      34            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
      35            0 : }
      36              : 
      37            0 : SetDescriptionClassCommand::SetDescriptionClassCommand ( OksClass * Class,
      38            0 :                                                          std::string Description )
      39            0 :   : ClassName ( Class->get_name() ),
      40            0 :     NewDescription ( Description ),
      41            0 :     OldDescription ( Class->get_description() )
      42              : {
      43            0 :   setText ( QString::fromStdString("Changed description for class \"" + ClassName + "\"") );
      44            0 : }
      45              : 
      46            0 : SetDescriptionClassCommand::~SetDescriptionClassCommand()
      47              : {
      48            0 : }
      49              : 
      50            0 : void SetDescriptionClassCommand::redo()
      51              : {
      52            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->set_description ( NewDescription );
      53            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
      54            0 : }
      55              : 
      56            0 : void SetDescriptionClassCommand::undo()
      57              : {
      58            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->set_description ( OldDescription );
      59            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
      60            0 : }
      61              : 
      62            0 : CreateClassCommand::CreateClassCommand ( std::string ClassName,
      63              :                                          std::string ClassDescription,
      64            0 :                                          bool Abstract )
      65            0 :   : SchemaClass ( nullptr ),
      66            0 :     SchemaClassName ( ClassName ),
      67            0 :     SchemaClassDescription ( ClassDescription ),
      68            0 :     SchemaAbstract ( Abstract )
      69              : {
      70            0 :   setText ( QString::fromStdString("Created new class \"" + ClassName + "\"") );
      71            0 : }
      72              : 
      73            0 : CreateClassCommand::~CreateClassCommand()
      74              : {
      75            0 : }
      76              : 
      77            0 : void CreateClassCommand::redo()
      78              : {
      79            0 :   SchemaClass = new OksClass ( SchemaClassName, SchemaClassDescription, SchemaAbstract,
      80            0 :                                KernelWrapper::GetInstance().GetKernel() );
      81            0 :   emit KernelWrapper::GetInstance().ClassCreated(QString::fromStdString(SchemaClassName));
      82            0 : }
      83              : 
      84            0 : void CreateClassCommand::undo()
      85              : {
      86            0 :   try
      87              :   {
      88            0 :     OksClass::destroy ( SchemaClass );
      89            0 :     emit KernelWrapper::GetInstance().ClassRemoved(QString::fromStdString(SchemaClassName));
      90              :   }
      91            0 :   catch ( ... )
      92              :   {
      93            0 :     QMessageBox::warning ( 0, "Schema editor", QString ( "Error" ) );
      94            0 :   }
      95            0 : }
      96              : 
      97            0 : RemoveClassCommand::RemoveClassCommand ( OksClass * Class, std::string ClassName,
      98            0 :                                          std::string ClassDescription, bool Abstract )
      99            0 :   : SchemaClass ( Class ),
     100            0 :     SchemaClassName ( ClassName ),
     101            0 :     SchemaClassDescription ( ClassDescription ),
     102            0 :     SchemaAbstract ( Abstract )
     103              : {
     104            0 :   setText ( QString::fromStdString("Removed class \"" + ClassName + "\"" ));
     105            0 : }
     106              : 
     107            0 : RemoveClassCommand::~RemoveClassCommand()
     108              : {
     109            0 : }
     110              : 
     111            0 : void RemoveClassCommand::redo()
     112              : {
     113            0 :   OksClass::destroy ( SchemaClass );
     114            0 :   emit KernelWrapper::GetInstance().ClassRemoved(QString::fromStdString(SchemaClassName));
     115            0 : }
     116              : 
     117            0 : void RemoveClassCommand::undo()
     118              : {
     119            0 :   SchemaClass = new OksClass ( SchemaClassName, SchemaClassDescription, SchemaAbstract,
     120            0 :                                KernelWrapper::GetInstance().GetKernel() );
     121            0 :   emit KernelWrapper::GetInstance().ClassCreated(QString::fromStdString(SchemaClassName));
     122            0 : }
     123              : 
     124            0 : AddSuperClassCommand::AddSuperClassCommand ( OksClass * Class, std::string SuperClass )
     125            0 :   : ClassName ( Class->get_name() ),
     126            0 :     NewSuperClass ( SuperClass )
     127              : {
     128            0 :   setText ( QString::fromStdString("Added new super-class \"" + SuperClass + "\" to class \"" + ClassName + "\"") );
     129            0 : }
     130              : 
     131            0 : AddSuperClassCommand::~AddSuperClassCommand()
     132              : {
     133            0 : }
     134              : 
     135            0 : void AddSuperClassCommand::redo()
     136              : {
     137            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add_super_class ( NewSuperClass );
     138            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     139            0 : }
     140              : 
     141            0 : void AddSuperClassCommand::undo()
     142              : {
     143            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove_super_class ( NewSuperClass );
     144            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     145            0 : }
     146              : 
     147            0 : RemoveSuperClassCommand::RemoveSuperClassCommand ( OksClass * Class, std::string superClass )
     148            0 :   : ClassName ( Class->get_name() ),
     149            0 :     SuperClass ( superClass )
     150              : {
     151            0 :   setText ( QString::fromStdString("Removed super-class \"" + superClass + "\" from class \"" + ClassName + "\"" ) );
     152            0 : }
     153              : 
     154            0 : RemoveSuperClassCommand::~RemoveSuperClassCommand()
     155              : {
     156            0 : }
     157              : 
     158            0 : void RemoveSuperClassCommand::redo()
     159              : {
     160            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove_super_class ( SuperClass );
     161            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     162            0 : }
     163              : 
     164            0 : void RemoveSuperClassCommand::undo()
     165              : {
     166            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add_super_class ( SuperClass );
     167            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     168            0 : }
     169              : 
     170            0 : SetNameRelationshipCommand::SetNameRelationshipCommand ( OksClass* Class,
     171              :                                                          OksRelationship * Relationship,
     172            0 :                                                          std::string Name )
     173            0 :   : ClassName(Class->get_name()),
     174            0 :     SchemaRelationship ( Relationship ),
     175            0 :     NewRelationshipName ( Name ),
     176            0 :     OldRelationshipName ( SchemaRelationship->get_name() )
     177              : {
     178            0 :   setText ( QString::fromStdString("Changed relationship \"" + Relationship->get_name() + "\" to \"" + Name + "\" for class \"" + ClassName + "\"") );
     179            0 : }
     180              : 
     181            0 : SetNameRelationshipCommand::~SetNameRelationshipCommand()
     182              : {
     183            0 : }
     184              : 
     185            0 : void SetNameRelationshipCommand::redo()
     186              : {
     187            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(OldRelationshipName);
     188            0 :   if(r != nullptr) {
     189            0 :       SchemaRelationship = r;
     190              :   }
     191              : 
     192            0 :   SchemaRelationship->set_name ( NewRelationshipName );
     193            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     194            0 : }
     195              : 
     196            0 : void SetNameRelationshipCommand::undo()
     197              : {
     198            0 :   SchemaRelationship->set_name ( OldRelationshipName );
     199            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     200            0 : }
     201              : 
     202            0 : SetClassTypeRelationshipCommand::SetClassTypeRelationshipCommand (
     203            0 :   OksClass* Class, OksRelationship * Relationship, std::string ClassType )
     204            0 :   : ClassName(Class->get_name()),
     205            0 :     SchemaRelationship ( Relationship ),
     206            0 :     RelationshipName ( Relationship->get_name()),
     207            0 :     NewRelationshipType ( ClassType ),
     208            0 :     OldRelationshipType ( SchemaRelationship->get_type() )
     209              : {
     210            0 :     setText ( QString::fromStdString("Relationship \"" + SchemaRelationship->get_name() +
     211            0 :                                      "\" set to type \"" + NewRelationshipType + "\" for class \"" + ClassName + "\""));
     212            0 : }
     213              : 
     214            0 : SetClassTypeRelationshipCommand::~SetClassTypeRelationshipCommand()
     215              : {
     216            0 : }
     217              : 
     218            0 : void SetClassTypeRelationshipCommand::redo()
     219              : {
     220            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     221            0 :   if(r != nullptr) {
     222            0 :       SchemaRelationship = r;
     223              :   }
     224              : 
     225            0 :   SchemaRelationship->set_type ( NewRelationshipType );
     226            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     227            0 : }
     228              : 
     229            0 : void SetClassTypeRelationshipCommand::undo()
     230              : {
     231            0 :   SchemaRelationship->set_type ( OldRelationshipType );
     232            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     233            0 : }
     234              : 
     235            0 : SetDescriptionRelationshipCommand::SetDescriptionRelationshipCommand (
     236            0 :   OksClass* Class, OksRelationship * Relationship, std::string Description )
     237            0 :   : ClassName(Class->get_name()),
     238            0 :     SchemaRelationship ( Relationship ),
     239            0 :     RelationshipName (Relationship->get_name()),
     240            0 :     NewDescription ( Description ),
     241            0 :     OldDescription ( SchemaRelationship->get_description() )
     242              : {
     243            0 :     setText (QString::fromStdString("Changed description of relationship \"" + Relationship->get_name() + "\" for class \"" + ClassName + "\""));
     244            0 : }
     245              : 
     246            0 : SetDescriptionRelationshipCommand::~SetDescriptionRelationshipCommand()
     247              : {
     248            0 : }
     249              : 
     250            0 : void SetDescriptionRelationshipCommand::redo()
     251              : {
     252            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     253            0 :   if(r != nullptr) {
     254            0 :       SchemaRelationship = r;
     255              :   }
     256              : 
     257            0 :   SchemaRelationship->set_description ( NewDescription );
     258            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     259            0 : }
     260              : 
     261            0 : void SetDescriptionRelationshipCommand::undo()
     262              : {
     263            0 :   SchemaRelationship->set_description ( OldDescription );
     264            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     265            0 : }
     266              : 
     267            0 : SetLowCcRelationshipCommand::SetLowCcRelationshipCommand (
     268            0 :   OksClass * Class, OksRelationship * Relationship, OksRelationship::CardinalityConstraint NewCardinality )
     269            0 :   : ClassName(Class->get_name()),
     270            0 :     SchemaRelationship ( Relationship ),
     271            0 :     RelationshipName ( Relationship->get_name()),
     272            0 :     NewLowCc ( NewCardinality ),
     273            0 :     OldLowCc ( SchemaRelationship->get_low_cardinality_constraint() )
     274              : {
     275            0 :     setText( QString::fromStdString("Changed low cardinality constraint for relationship \"" + Relationship->get_name() + "\" of class \"" + ClassName + "\""));
     276            0 : }
     277              : 
     278            0 : SetLowCcRelationshipCommand::~SetLowCcRelationshipCommand()
     279              : {
     280            0 : }
     281              : 
     282            0 : void SetLowCcRelationshipCommand::redo()
     283              : {
     284            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     285            0 :   if(r != nullptr) {
     286            0 :       SchemaRelationship = r;
     287              :   }
     288              : 
     289            0 :   SchemaRelationship->set_low_cardinality_constraint ( NewLowCc );
     290            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     291            0 : }
     292              : 
     293            0 : void SetLowCcRelationshipCommand::undo()
     294              : {
     295            0 :   SchemaRelationship->set_low_cardinality_constraint ( OldLowCc );
     296            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     297            0 : }
     298              : 
     299            0 : SetHighCcRelationshipCommand::SetHighCcRelationshipCommand (
     300            0 :   OksClass * Class, OksRelationship * Relationship, OksRelationship::CardinalityConstraint NewCardinality )
     301            0 :   : ClassName(Class->get_name()),
     302            0 :     SchemaRelationship ( Relationship ),
     303            0 :     RelationshipName ( Relationship->get_name() ),
     304            0 :     NewHighCc ( NewCardinality ),
     305            0 :     OldHighCc ( SchemaRelationship->get_high_cardinality_constraint() )
     306              : {
     307            0 :     setText( QString::fromStdString("Changed high cardinality constraint for relationship \"" + Relationship->get_name() + "\" of class \"" + ClassName + "\""));
     308            0 : }
     309              : 
     310            0 : SetHighCcRelationshipCommand::~SetHighCcRelationshipCommand()
     311              : {
     312              : 
     313            0 : }
     314              : 
     315            0 : void SetHighCcRelationshipCommand::redo()
     316              : {
     317            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     318            0 :   if(r != nullptr) {
     319            0 :       SchemaRelationship = r;
     320              :   }
     321              : 
     322            0 :   SchemaRelationship->set_high_cardinality_constraint ( NewHighCc );
     323            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     324            0 : }
     325              : 
     326            0 : void SetHighCcRelationshipCommand::undo()
     327              : {
     328            0 :   SchemaRelationship->set_high_cardinality_constraint ( OldHighCc );
     329            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     330            0 : }
     331              : 
     332            0 : SetIsCompositeRelationshipCommand::SetIsCompositeRelationshipCommand (
     333            0 :   OksClass * Class, OksRelationship * Relationship, bool Value )
     334            0 :   : ClassName(Class->get_name()),
     335            0 :     SchemaRelationship ( Relationship ),
     336            0 :     RelationshipName ( Relationship->get_name() ),
     337            0 :     NewValue ( Value ),
     338            0 :     OldValue ( SchemaRelationship->get_is_composite() )
     339              : {
     340            0 :     setText( QString::fromStdString("Changed the \"is composite\" constraint for relationship \"" + Relationship->get_name() + "\" of class \"" + ClassName + "\""));
     341            0 : }
     342              : 
     343            0 : SetIsCompositeRelationshipCommand::~SetIsCompositeRelationshipCommand()
     344              : {
     345            0 : }
     346              : 
     347            0 : void SetIsCompositeRelationshipCommand::redo()
     348              : {
     349            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     350            0 :   if(r != nullptr) {
     351            0 :       SchemaRelationship = r;
     352              :   }
     353              : 
     354            0 :   SchemaRelationship->set_is_composite ( NewValue );
     355            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     356            0 : }
     357              : 
     358            0 : void SetIsCompositeRelationshipCommand::undo()
     359              : {
     360            0 :   SchemaRelationship->set_is_composite ( OldValue );
     361            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     362            0 : }
     363              : 
     364            0 : SetIsDependentRelationshipCommand::SetIsDependentRelationshipCommand (
     365            0 :   OksClass * Class, OksRelationship * Relationship, bool Value )
     366            0 :   : ClassName(Class->get_name()),
     367            0 :     SchemaRelationship ( Relationship ),
     368            0 :     RelationshipName ( Relationship->get_name() ),
     369            0 :     NewValue ( Value ),
     370            0 :     OldValue ( SchemaRelationship->get_is_dependent() )
     371              : {
     372            0 :     setText( QString::fromStdString("Changed the \"is dependent\" constraint for relationship \"" + Relationship->get_name() + "\" of class \"" + ClassName + "\""));
     373            0 : }
     374              : 
     375            0 : SetIsDependentRelationshipCommand::~SetIsDependentRelationshipCommand()
     376              : {
     377            0 : }
     378              : 
     379            0 : void SetIsDependentRelationshipCommand::redo()
     380              : {
     381            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     382            0 :   if(r != nullptr) {
     383            0 :       SchemaRelationship = r;
     384              :   }
     385              : 
     386            0 :   SchemaRelationship->set_is_dependent ( NewValue );
     387            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     388            0 : }
     389              : 
     390            0 : void SetIsDependentRelationshipCommand::undo()
     391              : {
     392            0 :   SchemaRelationship->set_is_dependent ( OldValue );
     393            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     394            0 : }
     395              : 
     396            0 : SetIsExclusiveRelationshipCommand::SetIsExclusiveRelationshipCommand (
     397            0 :   OksClass * Class, OksRelationship * Relationship, bool Value )
     398            0 :   : ClassName(Class->get_name()),
     399            0 :     SchemaRelationship ( Relationship ),
     400            0 :     RelationshipName ( Relationship->get_name() ),
     401            0 :     NewValue ( Value ),
     402            0 :     OldValue ( SchemaRelationship->get_is_exclusive() )
     403              : {
     404            0 :     setText( QString::fromStdString("Changed the \"is exclusive\" constraint for relationship \"" + Relationship->get_name() + "\" of class \"" + ClassName + "\""));
     405            0 : }
     406              : 
     407            0 : SetIsExclusiveRelationshipCommand::~SetIsExclusiveRelationshipCommand()
     408              : {
     409            0 : }
     410              : 
     411            0 : void SetIsExclusiveRelationshipCommand::redo()
     412              : {
     413            0 :   OksRelationship* r = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_relationship(RelationshipName);
     414            0 :   if(r != nullptr) {
     415            0 :       SchemaRelationship = r;
     416              :   }
     417              : 
     418            0 :   SchemaRelationship->set_is_exclusive ( NewValue );
     419            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     420            0 : }
     421              : 
     422            0 : void SetIsExclusiveRelationshipCommand::undo()
     423              : {
     424            0 :   SchemaRelationship->set_is_exclusive ( OldValue );
     425            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     426            0 : }
     427              : 
     428            0 : AddRelationship::AddRelationship ( OksClass * Class, std::string Name,
     429              :                                    std::string Description,
     430              :                                    std::string Type, bool Composite, bool Exclusive,
     431              :                                    bool Dependent,
     432              :                                    OksRelationship::CardinalityConstraint LowCc,
     433            0 :                                    OksRelationship::CardinalityConstraint HighCc )
     434            0 :   : ClassName ( Class->get_name() ),
     435            0 :     SchemaRelationship ( nullptr ),
     436            0 :     RelationshipName ( Name ),
     437            0 :     RelationshipDescription ( Description ),
     438            0 :     RelationshipType ( Type ),
     439            0 :     IsComposite ( Composite ),
     440            0 :     IsExclusive ( Exclusive ),
     441            0 :     IsDependent ( Dependent ),
     442            0 :     RelationshipLowCc ( LowCc ),
     443            0 :     RelationshipHighCc ( HighCc )
     444              : {
     445            0 :     setText( QString::fromStdString("Added relationship \"" + Name + "\" to class \"" + Class->get_name() + "\""));
     446            0 : }
     447              : 
     448            0 : AddRelationship::~AddRelationship()
     449              : {
     450            0 : }
     451              : 
     452            0 : void AddRelationship::redo()
     453              : {
     454            0 :   if ( SchemaRelationship == nullptr )
     455              :   {
     456            0 :       SchemaRelationship = new OksRelationship (RelationshipName, RelationshipType, RelationshipLowCc, RelationshipHighCc,
     457            0 :                                                 IsComposite, IsExclusive, IsDependent, RelationshipDescription );
     458              :   }
     459              : 
     460            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add ( SchemaRelationship );
     461            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     462            0 : }
     463              : 
     464            0 : void AddRelationship::undo()
     465              : {
     466            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove ( SchemaRelationship, false );
     467            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     468            0 : }
     469              : 
     470            0 : RemoveRelationship::RemoveRelationship ( OksClass * Class, OksRelationship * Relationship,
     471              :                                          std::string Name, std::string Description,
     472              :                                          std::string Type, bool Composite, bool Exclusive,
     473              :                                          bool Dependent,
     474              :                                          OksRelationship::CardinalityConstraint LowCc,
     475            0 :                                          OksRelationship::CardinalityConstraint HighCc )
     476            0 :   : ClassName ( Class->get_name() ),
     477            0 :     SchemaRelationship ( Relationship ),
     478            0 :     RelationshipName ( Name ),
     479            0 :     RelationshipDescription ( Description ),
     480            0 :     RelationshipType ( Type ),
     481            0 :     IsComposite ( Composite ),
     482            0 :     IsExclusive ( Exclusive ),
     483            0 :     IsDependent ( Dependent ),
     484            0 :     RelationshipLowCc ( LowCc ),
     485            0 :     RelationshipHighCc ( HighCc )
     486              : {
     487            0 :     setText( QString::fromStdString("Removed relationship \"" + Name + "\" to class \"" + Class->get_name() + "\""));
     488            0 : }
     489              : 
     490            0 : RemoveRelationship::~RemoveRelationship()
     491              : {
     492            0 : }
     493              : 
     494            0 : void RemoveRelationship::redo()
     495              : {
     496            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove ( SchemaRelationship, false );
     497            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     498            0 : }
     499              : 
     500            0 : void RemoveRelationship::undo()
     501              : {
     502            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add ( SchemaRelationship );
     503            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     504            0 : }
     505              : 
     506            0 : SetMethodImplementationLanguage::SetMethodImplementationLanguage (
     507            0 :   OksClass * Class, OksMethod* Method, OksMethodImplementation * Implementation, std::string Language )
     508            0 :   : ClassName(Class->get_name()),
     509            0 :     MethodName ( Method->get_name() ),
     510            0 :     SchemaImplementation ( Implementation ),
     511            0 :     NewLanguage ( Language ),
     512            0 :     OldLanguage ( SchemaImplementation->get_language() )
     513              : {
     514            0 :     setText( QString::fromStdString("Changed language implementation for \"" +  SchemaImplementation->get_prototype() + "\" of class \"" + Class->get_name() + "\""));
     515            0 : }
     516              : 
     517            0 : SetMethodImplementationLanguage::~SetMethodImplementationLanguage()
     518              : {
     519            0 : }
     520              : 
     521            0 : void SetMethodImplementationLanguage::redo()
     522              : {
     523            0 :   OksMethodImplementation* mi = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(MethodName)->find_implementation(OldLanguage);
     524            0 :   if(mi != nullptr) {
     525            0 :       SchemaImplementation = mi;
     526              :   }
     527              : 
     528            0 :   SchemaImplementation->set_language ( NewLanguage );
     529            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     530            0 : }
     531              : 
     532            0 : void SetMethodImplementationLanguage::undo()
     533              : {
     534            0 :   SchemaImplementation->set_language ( OldLanguage );
     535            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     536            0 : }
     537              : 
     538            0 : SetMethodImplementationPrototype::SetMethodImplementationPrototype (
     539            0 :   OksClass * Class, OksMethod * Method, OksMethodImplementation * Implementation, std::string Prototype )
     540            0 :   : ClassName(Class->get_name()),
     541            0 :     MethodName ( Method->get_name() ),
     542            0 :     SchemaImplementation ( Implementation ),
     543            0 :     ImplementationLanguage ( Implementation->get_language()),
     544            0 :     NewPrototype ( Prototype ),
     545            0 :     OldPrototype ( SchemaImplementation->get_prototype() )
     546              : {
     547            0 :     setText( QString::fromStdString("Changed prototype for method \"" +  SchemaImplementation->get_prototype() + "\" of class \"" + ClassName + "\""));
     548            0 : }
     549              : 
     550            0 : SetMethodImplementationPrototype::~SetMethodImplementationPrototype()
     551              : {
     552            0 : }
     553              : 
     554            0 : void SetMethodImplementationPrototype::redo()
     555              : {
     556            0 :   OksMethodImplementation* mi = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(MethodName)->find_implementation(ImplementationLanguage);
     557            0 :   if(mi != nullptr) {
     558            0 :       SchemaImplementation = mi;
     559              :   }
     560              : 
     561            0 :   SchemaImplementation->set_prototype ( NewPrototype );
     562            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     563            0 : }
     564              : 
     565            0 : void SetMethodImplementationPrototype::undo()
     566              : {
     567            0 :   SchemaImplementation->set_prototype ( OldPrototype );
     568            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     569            0 : }
     570              : 
     571            0 : SetMethodImplementationBody::SetMethodImplementationBody (
     572            0 :   OksClass * Class, OksMethod * Method, OksMethodImplementation * Implementation, std::string Body )
     573            0 :   : ClassName(Class->get_name()),
     574            0 :     MethodName ( Method->get_name()),
     575            0 :     SchemaImplementation ( Implementation ),
     576            0 :     ImplementationLanguage ( Implementation->get_language() ),
     577            0 :     NewBody ( Body ),
     578            0 :     OldBody ( SchemaImplementation->get_body() )
     579              : {
     580            0 :     setText( QString::fromStdString("Changed body implementation for method \"" +  SchemaImplementation->get_prototype() + "\" of class \"" + Class->get_name() + "\""));
     581            0 : }
     582              : 
     583            0 : SetMethodImplementationBody::~SetMethodImplementationBody()
     584              : {
     585            0 : }
     586              : 
     587            0 : void SetMethodImplementationBody::redo()
     588              : {
     589            0 :   OksMethodImplementation* mi = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(MethodName)->find_implementation(ImplementationLanguage);
     590            0 :   if(mi != nullptr) {
     591            0 :       SchemaImplementation = mi;
     592              :   }
     593              : 
     594            0 :   SchemaImplementation->set_body ( NewBody );
     595            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     596            0 : }
     597              : 
     598            0 : void SetMethodImplementationBody::undo()
     599              : {
     600            0 :   SchemaImplementation->set_body ( OldBody );
     601            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     602            0 : }
     603              : 
     604            0 : AddMethodImplementationComand::AddMethodImplementationComand ( OksClass * Class,
     605              :                                                                OksMethod * Method,
     606              :                                                                std::string Language,
     607              :                                                                std::string Prototype,
     608            0 :                                                                std::string Body )
     609            0 :   : ClassName(Class->get_name()),
     610            0 :     SchemaMethod ( Method ),
     611            0 :     MethodName ( Method->get_name() ),
     612            0 :     SchemaImplementationLanguage ( Language ),
     613            0 :     SchemaImplementationPrototype ( Prototype ),
     614            0 :     SchemaImplementationBody ( Body )
     615              : {
     616            0 :     setText( QString::fromStdString("Added implementation for method \"" +  SchemaMethod->get_name() + "\" for class \"" + Class->get_name() + "\""));
     617            0 : }
     618              : 
     619            0 : AddMethodImplementationComand::~AddMethodImplementationComand()
     620              : {
     621            0 : }
     622              : 
     623            0 : void AddMethodImplementationComand::redo()
     624              : {
     625            0 :   OksMethod* m = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(MethodName);
     626            0 :   if(m != nullptr) {
     627            0 :       SchemaMethod = m;
     628              :   }
     629              : 
     630            0 :   SchemaMethod->add_implementation ( SchemaImplementationLanguage,
     631            0 :                                      SchemaImplementationPrototype,
     632            0 :                                      SchemaImplementationBody );
     633            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     634            0 : }
     635              : 
     636            0 : void AddMethodImplementationComand::undo()
     637              : {
     638            0 :   SchemaMethod->remove_implementation ( SchemaImplementationLanguage );
     639            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     640            0 : }
     641              : 
     642            0 : RemoveMethodImplementationComand::RemoveMethodImplementationComand ( OksClass * Class,
     643              :                                                                      OksMethod * Method,
     644              :                                                                      std::string Language,
     645              :                                                                      std::string Prototype,
     646            0 :                                                                      std::string Body )
     647            0 :   : ClassName(Class->get_name()),
     648            0 :     SchemaMethod ( Method ),
     649            0 :     MethodName ( Method->get_name() ),
     650            0 :     SchemaImplementationLanguage ( Language ),
     651            0 :     SchemaImplementationPrototype ( Prototype ),
     652            0 :     SchemaImplementationBody ( Body )
     653              : {
     654            0 :     setText( QString::fromStdString("Removed implementation for method \"" +  SchemaMethod->get_name() + "\" for class \"" + Class->get_name() + "\""));
     655            0 : }
     656              : 
     657            0 : RemoveMethodImplementationComand::~RemoveMethodImplementationComand()
     658              : {
     659            0 : }
     660              : 
     661            0 : void RemoveMethodImplementationComand::redo()
     662              : {
     663            0 :   OksMethod* m = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(MethodName);
     664            0 :   if(m != nullptr) {
     665            0 :       SchemaMethod = m;
     666              :   }
     667              : 
     668            0 :   SchemaMethod->remove_implementation ( SchemaImplementationLanguage );
     669            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     670            0 : }
     671              : 
     672            0 : void RemoveMethodImplementationComand::undo()
     673              : {
     674            0 :   SchemaMethod->add_implementation ( SchemaImplementationLanguage,
     675            0 :                                      SchemaImplementationPrototype,
     676            0 :                                      SchemaImplementationBody );
     677            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     678            0 : }
     679              : 
     680            0 : SetNameMethodCommand::SetNameMethodCommand ( OksClass * Class, OksMethod * Method, std::string name )
     681            0 :   : ClassName(Class->get_name()),
     682            0 :     SchemaMethod ( Method ),
     683            0 :     NewMethodName ( name ),
     684            0 :     OldMethodName ( SchemaMethod->get_name() )
     685              : {
     686            0 :     setText( QString::fromStdString("Set name for method \"" +  SchemaMethod->get_name() + "\" of class \"" + Class->get_name() + "\""));
     687            0 : }
     688              : 
     689            0 : SetNameMethodCommand::~SetNameMethodCommand()
     690              : {
     691            0 : }
     692              : 
     693            0 : void SetNameMethodCommand::redo()
     694              : {
     695            0 :   OksMethod * m = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(OldMethodName);
     696            0 :   if(m != nullptr) {
     697            0 :       SchemaMethod = m;
     698              :   }
     699              : 
     700            0 :   SchemaMethod->set_name ( NewMethodName );
     701            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     702            0 : }
     703              : 
     704            0 : void SetNameMethodCommand::undo()
     705              : {
     706            0 :   SchemaMethod->set_name ( OldMethodName );
     707            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     708            0 : }
     709              : 
     710            0 : SetDescriptionMethodCommand::SetDescriptionMethodCommand ( OksClass * Class,
     711              :                                                            OksMethod * Method,
     712            0 :                                                            std::string description )
     713            0 :   : ClassName(Class->get_name()),
     714            0 :     SchemaMethod ( Method ),
     715            0 :     MethodName ( Method->get_name() ),
     716            0 :     NewMethodDescription ( description ),
     717            0 :     OldMethodDescription ( SchemaMethod->get_description() )
     718              : {
     719            0 :     setText( QString::fromStdString("Set description for method \"" +  SchemaMethod->get_name() + "\" of class \"" + Class->get_name() + "\""));
     720            0 : }
     721              : 
     722            0 : SetDescriptionMethodCommand::~SetDescriptionMethodCommand()
     723              : {
     724            0 : }
     725              : 
     726            0 : void SetDescriptionMethodCommand::redo()
     727              : {
     728            0 :   OksMethod * m = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_method(MethodName);
     729            0 :   if(m != nullptr) {
     730            0 :       SchemaMethod = m;
     731              :   }
     732            0 :   SchemaMethod->set_description ( NewMethodDescription );
     733              : 
     734            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     735            0 : }
     736              : 
     737            0 : void SetDescriptionMethodCommand::undo()
     738              : {
     739            0 :   SchemaMethod->set_description ( OldMethodDescription );
     740            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     741            0 : }
     742              : 
     743            0 : AddMethodCommand::AddMethodCommand ( OksClass * Class, std::string name,
     744            0 :                                      std::string description )
     745            0 :   : ClassName ( Class->get_name() ),
     746            0 :     SchemaMethod ( nullptr ),
     747            0 :     SchemaName ( name ),
     748            0 :     SchemaDescription ( description )
     749              : {
     750            0 :     setText( QString::fromStdString("Added method \"" + name + "\" to class \"" +  Class->get_name() + "\""));
     751            0 : }
     752              : 
     753            0 : AddMethodCommand::~AddMethodCommand()
     754              : {
     755            0 : }
     756              : 
     757            0 : void AddMethodCommand::redo()
     758              : {
     759            0 :   SchemaMethod = new OksMethod ( SchemaName, SchemaDescription );
     760            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add ( SchemaMethod );
     761            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     762            0 : }
     763              : 
     764            0 : void AddMethodCommand::undo()
     765              : {
     766              :   // Do not delete SchemaMethod (probably deleted internally by the OKS library)
     767            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove ( SchemaMethod );
     768            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     769            0 : }
     770              : 
     771            0 : RemoveMethodCommand::RemoveMethodCommand ( OksClass * Class, OksMethod * Method,
     772            0 :                                            std::string name, std::string description )
     773            0 :   : ClassName ( Class->get_name() ),
     774            0 :     SchemaMethod ( Method ),
     775            0 :     SchemaName ( name ),
     776            0 :     SchemaDescription ( description )
     777              : {
     778            0 :     setText( QString::fromStdString("Removed method \"" + name + "\" to class \"" + Class->get_name() + "\""));
     779            0 : }
     780              : 
     781            0 : RemoveMethodCommand::~RemoveMethodCommand()
     782              : {
     783            0 : }
     784              : 
     785            0 : void RemoveMethodCommand::redo()
     786              : {
     787            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove ( SchemaMethod );
     788            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     789            0 : }
     790              : 
     791            0 : void RemoveMethodCommand::undo()
     792              : {
     793            0 :   SchemaMethod = new OksMethod ( SchemaName, SchemaDescription );
     794            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add ( SchemaMethod );
     795            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     796            0 : }
     797              : 
     798            0 : SetAttributeNameCommand::SetAttributeNameCommand ( OksClass * Class,
     799              :                                                    OksAttribute * Attribute,
     800            0 :                                                    std::string NewName )
     801            0 :   : ClassName( Class->get_name() ),
     802            0 :     SchemaAttribute ( Attribute ),
     803            0 :     NewAttributeName ( NewName ),
     804            0 :     OldAttributeName ( SchemaAttribute->get_name() )
     805              : {
     806            0 :     setText( QString::fromStdString("Set new name \"" + NewName + "\" to attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
     807            0 : }
     808              : 
     809            0 : SetAttributeNameCommand::~SetAttributeNameCommand()
     810              : {
     811            0 : }
     812              : 
     813            0 : void SetAttributeNameCommand::redo()
     814              : {
     815            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(OldAttributeName);
     816            0 :   if(a != nullptr) {
     817            0 :       SchemaAttribute = a;
     818              :   }
     819              : 
     820            0 :   SchemaAttribute->set_name ( NewAttributeName );
     821            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     822            0 : }
     823              : 
     824            0 : void SetAttributeNameCommand::undo()
     825              : {
     826            0 :   SchemaAttribute->set_name ( OldAttributeName );
     827            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     828            0 : }
     829              : 
     830            0 : SetAttributeTypeCommand::SetAttributeTypeCommand ( OksClass * Class,
     831              :                                                    OksAttribute * Attribute,
     832            0 :                                                    std::string NewType )
     833            0 :   : ClassName ( Class->get_name() ),
     834            0 :     SchemaAttribute ( Attribute ),
     835            0 :     AttributeName ( Attribute->get_name() ),
     836            0 :     NewAttributeType ( NewType ),
     837            0 :     OldAttributeType ( SchemaAttribute->get_type() )
     838              : {
     839            0 :     setText( QString::fromStdString("Set new type \"" + NewType + "\" to attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
     840            0 : }
     841              : 
     842            0 : SetAttributeTypeCommand::~SetAttributeTypeCommand()
     843              : {
     844            0 : }
     845              : 
     846            0 : void SetAttributeTypeCommand::redo()
     847              : {
     848            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
     849            0 :   if(a != nullptr) {
     850            0 :       SchemaAttribute = a;
     851              :   }
     852              : 
     853            0 :   SchemaAttribute->set_type ( NewAttributeType );
     854            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     855            0 : }
     856              : 
     857            0 : void SetAttributeTypeCommand::undo()
     858              : {
     859            0 :   SchemaAttribute->set_type ( OldAttributeType );
     860            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     861            0 : }
     862              : 
     863            0 : SetAttributeRangeCommand::SetAttributeRangeCommand ( OksClass * Class,
     864              :                                                      OksAttribute * Attribute,
     865            0 :                                                      std::string NewRange )
     866            0 :   : ClassName ( Class->get_name() ),
     867            0 :     SchemaAttribute ( Attribute ),
     868            0 :     AttributeName ( Attribute->get_name() ),
     869            0 :     NewAttributeRange ( NewRange ),
     870            0 :     OldAttributeRange ( SchemaAttribute->get_range() )
     871              : {
     872            0 :     setText( QString::fromStdString("Set new range \"" + NewRange + "\" to attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
     873            0 : }
     874              : 
     875            0 : SetAttributeRangeCommand::~SetAttributeRangeCommand()
     876              : {
     877            0 : }
     878              : 
     879            0 : void SetAttributeRangeCommand::redo()
     880              : {
     881            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
     882            0 :   if(a != nullptr) {
     883            0 :       SchemaAttribute = a;
     884              :   }
     885              : 
     886            0 :   SchemaAttribute->set_range ( NewAttributeRange );
     887            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     888            0 : }
     889              : 
     890            0 : void SetAttributeRangeCommand::undo()
     891              : {
     892            0 :   SchemaAttribute->set_range ( OldAttributeRange );
     893            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     894            0 : }
     895              : 
     896            0 : SetAttributeFormatCommand::SetAttributeFormatCommand ( OksClass * Class,
     897              :                                                        OksAttribute * Attribute,
     898            0 :                                                        OksAttribute::Format NewFormat )
     899            0 :   : ClassName ( Class->get_name() ),
     900            0 :     SchemaAttribute ( Attribute ),
     901            0 :     AttributeName ( Attribute->get_name() ),
     902            0 :     NewAttributeFormat ( NewFormat ),
     903            0 :     OldAttributeFormat ( SchemaAttribute->get_format() )
     904              : {
     905            0 :     setText( QString::fromStdString("Set new format for attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
     906            0 : }
     907              : 
     908            0 : SetAttributeFormatCommand::~SetAttributeFormatCommand()
     909              : {
     910            0 : }
     911              : 
     912            0 : void SetAttributeFormatCommand::redo()
     913              : {
     914            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
     915            0 :   if(a != nullptr) {
     916            0 :       SchemaAttribute = a;
     917              :   }
     918              : 
     919            0 :   SchemaAttribute->set_format ( NewAttributeFormat );
     920            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     921            0 : }
     922              : 
     923            0 : void SetAttributeFormatCommand::undo()
     924              : {
     925            0 :   SchemaAttribute->set_format ( OldAttributeFormat );
     926            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     927            0 : }
     928              : 
     929            0 : SetAttributeMultiCommand::SetAttributeMultiCommand ( OksClass* Class,
     930              :                                                      OksAttribute * Attribute,
     931            0 :                                                      bool NewIsMulti )
     932            0 :   : ClassName ( Class->get_name() ),
     933            0 :     SchemaAttribute ( Attribute ),
     934            0 :     AttributeName ( Attribute->get_name() ),
     935            0 :     NewAttributeMulti ( NewIsMulti ),
     936            0 :     OldAttributeMulti ( SchemaAttribute->get_is_multi_values() )
     937              : {
     938            0 :     setText( QString::fromStdString("Set multiplicity for attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
     939            0 : }
     940              : 
     941            0 : SetAttributeMultiCommand::~SetAttributeMultiCommand()
     942              : {
     943            0 : }
     944              : 
     945            0 : void SetAttributeMultiCommand::redo()
     946              : {
     947            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
     948            0 :   if(a != nullptr) {
     949            0 :       SchemaAttribute = a;
     950              :   }
     951              : 
     952            0 :   SchemaAttribute->set_is_multi_values ( NewAttributeMulti );
     953            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     954            0 : }
     955              : 
     956            0 : void SetAttributeMultiCommand::undo()
     957              : {
     958            0 :   SchemaAttribute->set_is_multi_values ( OldAttributeMulti );
     959            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     960            0 : }
     961              : 
     962            0 : SetAttributeIsNullCommand::SetAttributeIsNullCommand ( OksClass* Class,
     963              :                                                        OksAttribute * Attribute,
     964            0 :                                                        bool NewIsNull )
     965            0 :   : ClassName ( Class->get_name() ),
     966            0 :     SchemaAttribute ( Attribute ),
     967            0 :     AttributeName ( Attribute->get_name() ),
     968            0 :     NewAttributeIsNull ( NewIsNull ),
     969            0 :     OldAttributeIsNull ( SchemaAttribute->get_is_no_null() )
     970              : {
     971            0 :     setText( QString::fromStdString("Set null-ness for attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
     972            0 : }
     973              : 
     974            0 : SetAttributeIsNullCommand::~SetAttributeIsNullCommand()
     975              : {
     976            0 : }
     977              : 
     978            0 : void SetAttributeIsNullCommand::redo()
     979              : {
     980            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
     981            0 :   if(a != nullptr) {
     982            0 :       SchemaAttribute = a;
     983              :   }
     984              : 
     985            0 :   SchemaAttribute->set_is_no_null ( NewAttributeIsNull );
     986            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     987            0 : }
     988              : 
     989            0 : void SetAttributeIsNullCommand::undo()
     990              : {
     991            0 :   SchemaAttribute->set_is_no_null ( OldAttributeIsNull );
     992            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
     993            0 : }
     994              : 
     995            0 : SetAttributeInitialValuesCommand::SetAttributeInitialValuesCommand (
     996              :   OksClass * Class,
     997              :   OksAttribute * Attribute,
     998            0 :   std::string NewValues )
     999            0 :   : ClassName ( Class->get_name() ),
    1000            0 :     SchemaAttribute ( Attribute ),
    1001            0 :     AttributeName ( Attribute->get_name() ),
    1002            0 :     NewAttributeInitialValues ( NewValues ),
    1003            0 :     OldAttributeInitialValues ( SchemaAttribute->get_init_value() )
    1004              : {
    1005            0 :     setText( QString::fromStdString("Set new initial values to attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
    1006            0 : }
    1007              : 
    1008            0 : SetAttributeInitialValuesCommand::~SetAttributeInitialValuesCommand()
    1009              : {
    1010            0 : }
    1011              : 
    1012            0 : void SetAttributeInitialValuesCommand::redo()
    1013              : {
    1014            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
    1015            0 :   if(a != nullptr) {
    1016            0 :       SchemaAttribute = a;
    1017              :   }
    1018              : 
    1019            0 :   SchemaAttribute->set_init_value ( NewAttributeInitialValues );
    1020            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1021            0 : }
    1022              : 
    1023            0 : void SetAttributeInitialValuesCommand::undo()
    1024              : {
    1025            0 :   SchemaAttribute->set_init_value ( OldAttributeInitialValues );
    1026            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1027            0 : }
    1028              : 
    1029            0 : AddAttributeCommand::AddAttributeCommand ( OksClass * Class, std::string name,
    1030              :                                            std::string type, bool is_mv, std::string range,
    1031              :                                            std::string init_values, std::string description,
    1032            0 :                                            bool is_null, OksAttribute::Format format )
    1033            0 :   : ClassName ( Class->get_name() ),
    1034            0 :     SchemaAttribute ( nullptr ),
    1035            0 :     SchemaName ( name ),
    1036            0 :     SchemaType ( type ),
    1037            0 :     SchemaIsMulti ( is_mv ),
    1038            0 :     SchemaRange ( range ),
    1039            0 :     SchemaInitValues ( init_values ),
    1040            0 :     SchemaDescription ( description ),
    1041            0 :     SchemaIsNull ( is_null ),
    1042            0 :     SchemaFormat ( format )
    1043              : {
    1044            0 :     setText( QString::fromStdString("Added attribute \"" + name + "\" to class \"" +  Class->get_name() + "\""));
    1045            0 : }
    1046              : 
    1047            0 : AddAttributeCommand::~AddAttributeCommand()
    1048              : {
    1049            0 : }
    1050              : 
    1051            0 : void AddAttributeCommand::redo()
    1052              : {
    1053            0 :   SchemaAttribute = new OksAttribute ( SchemaName, SchemaType, SchemaIsMulti, SchemaRange,
    1054            0 :                                        SchemaInitValues, SchemaDescription, SchemaIsNull,
    1055            0 :                                        SchemaFormat );
    1056            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add ( SchemaAttribute );
    1057            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1058            0 : }
    1059              : 
    1060            0 : void AddAttributeCommand::undo()
    1061              : {
    1062            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove ( SchemaAttribute );
    1063            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1064            0 : }
    1065              : 
    1066            0 : RemoveAttributeCommand::RemoveAttributeCommand ( OksClass * Class, OksAttribute * Attribute,
    1067              :                                                  std::string name, std::string type,
    1068              :                                                  bool is_mv, std::string range,
    1069              :                                                  std::string init_values,
    1070              :                                                  std::string description, bool is_null,
    1071            0 :                                                  OksAttribute::Format format )
    1072            0 :   : ClassName ( Class->get_name() ),
    1073            0 :     SchemaAttribute ( Attribute ),
    1074            0 :     SchemaName ( name ),
    1075            0 :     SchemaType ( type ),
    1076            0 :     SchemaIsMulti ( is_mv ),
    1077            0 :     SchemaRange ( range ),
    1078            0 :     SchemaInitValues ( init_values ),
    1079            0 :     SchemaDescription ( description ),
    1080            0 :     SchemaIsNull ( is_null ),
    1081            0 :     SchemaFormat ( format )
    1082              : {
    1083            0 :     setText( QString::fromStdString("Removed attribute \"" + name + "\" from class \"" +  Class->get_name() + "\""));
    1084            0 : }
    1085              : 
    1086            0 : RemoveAttributeCommand::~RemoveAttributeCommand()
    1087              : {
    1088            0 : }
    1089              : 
    1090            0 : void RemoveAttributeCommand::redo()
    1091              : {
    1092            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->remove ( SchemaAttribute );
    1093            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1094            0 : }
    1095              : 
    1096            0 : void RemoveAttributeCommand::undo()
    1097              : {
    1098            0 :   SchemaAttribute = new OksAttribute ( SchemaName, SchemaType, SchemaIsMulti, SchemaRange,
    1099            0 :                                        SchemaInitValues, SchemaDescription, SchemaIsNull,
    1100            0 :                                        SchemaFormat );
    1101            0 :   KernelWrapper::GetInstance().FindClass(ClassName)->add ( SchemaAttribute );
    1102            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1103            0 : }
    1104              : 
    1105            0 : SetAttributeDescriptionCommand::SetAttributeDescriptionCommand ( OksClass * Class,
    1106              :                                                                  OksAttribute * Attribute,
    1107            0 :                                                                  std::string NewDescription )
    1108            0 :   : ClassName ( Class->get_name() ),
    1109            0 :     SchemaAttribute ( Attribute ),
    1110            0 :     AttributeName ( Attribute->get_name() ),
    1111            0 :     NewAttributeDescription ( NewDescription ),
    1112            0 :     OldAttributeDescription ( SchemaAttribute->get_description() )
    1113              : {
    1114            0 :     setText( QString::fromStdString("Set description for attribute \"" +  Attribute->get_name() + "\" of class \"" + ClassName + "\""));
    1115            0 : }
    1116              : 
    1117            0 : SetAttributeDescriptionCommand::~SetAttributeDescriptionCommand()
    1118              : {
    1119              : 
    1120            0 : }
    1121              : 
    1122            0 : void SetAttributeDescriptionCommand::redo()
    1123              : {
    1124            0 :   OksAttribute * a = KernelWrapper::GetInstance().FindClass(ClassName)->find_direct_attribute(AttributeName);
    1125            0 :   if(a != nullptr) {
    1126            0 :       SchemaAttribute = a;
    1127              :   }
    1128              : 
    1129            0 :   SchemaAttribute->set_description ( NewAttributeDescription );
    1130            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1131            0 : }
    1132              : 
    1133            0 : void SetAttributeDescriptionCommand::undo()
    1134              : {
    1135            0 :   SchemaAttribute->set_description ( OldAttributeDescription );
    1136            0 :   emit KernelWrapper::GetInstance().ClassUpdated ( QString::fromStdString(ClassName) );
    1137            0 : }
    1138              : 
    1139              : } // end namespace dbse
        

Generated by: LCOV version 2.0-1