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: 2026-07-12 15:23:06 Functions: 0.0 % 140 0

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

Generated by: LCOV version 2.0-1