<commit_before>package org.framed.orm.ui.command.nodes;


import org.framed.orm.model.Compartment;
import org.framed.orm.model.Rolemodel;

/**
 * Through this command the model element {@link Compartment} and the model element {@link Grouping}
 * can be created(invoked into the model tree).
 * 
 * @author <NAME>
 * */
public class ORMCompartmentGroupingCreateCommand extends ORMNodeCreateCommand {

  /**
   * The {@link Rolemodel}, which is owned be the {@link Compartment}/{@link Grouping} to be created
   */
  private Rolemodel rm;

  /**
   * Constructor of this command, where the label is set, which describes this command to the user.
   * 
   */
  public ORMCompartmentGroupingCreateCommand() {
    super.setLabel("ORMCompartmentGroupingCreate");
  }

  /**
   * {@inheritDoc} Because in this command a {@link Compartment}/{@link Grouping} is created it's
   * child {@link Rolemodel} must be setted as well .
   */
  @Override
  public void execute() {

    super.execute();
    ((Compartment) node).setRolemodel(rm);
  }

  /**
   * {@inheritDoc} Because in this command a {@link Compartment} is created it's child
   * {@link Rolemodel} must be removed as well .
   */
  @Override
  public void undo() {

    super.undo();
    ((Compartment) node).setRolemodel(null);
  }<commit_msg>added code for the correct functionality of the ORMCompartmentGroupingCreateCommand<commit_after>package org.framed.orm.ui.command.nodes;


import org.framed.orm.model.Compartment;
import org.framed.orm.model.Grouping;
import org.framed.orm.model.Rolemodel;

/**
 * Through this command the model element {@link Compartment} and the model element {@link Grouping}
 * can be created(invoked into the model tree).
 * 
 * @author <NAME>
 * */
public class ORMCompartmentGroupingCreateCommand extends ORMNodeCreateCommand {

  /**
   * The {@link Rolemodel}, which is owned be the {@link Compartment}/{@link Grouping} to be created
   */
  private Rolemodel rm;

  /**
   * Constructor of this command, where the label is set, which describes this command to the user.
   * 
   */
  public ORMCompartmentGroupingCreateCommand() {
    super.setLabel("ORMCompartmentGroupingCreate");
  }

  /**
   * {@inheritDoc} Because in this command a {@link Compartment}/{@link Grouping} is created it's
   * child {@link Rolemodel} must be setted as well .
   */
  @Override
  public void execute() {

    super.execute();
    if (node instanceof Compartment) {
      ((Compartment) node).setRolemodel(rm);
    }
    if (node instanceof Grouping) {
      ((Grouping) node).setRolemodel(rm);
    }
    
  }

  /**
   * {@inheritDoc} Because in this command a {@link Compartment} is created it's child
   * {@link Rolemodel} must be removed as well .
   */
  @Override
  public void undo() {

    super.undo();
    ((Compartment) node).setRolemodel(null);
  }
{'fraction_non_alphanumeric': 0.11592670894996476, 'fraction_numerical': 0.0, 'mean_word_length': 3.5569823434991976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '539378', 'n_tokens_mistral': 880, 'n_tokens_neox': 854, 'n_words': 266}