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

Generated by: LCOV version 2.0-1