/**
   * Run as transaction.
   *
   * @param diResourceSet the di resource set
   */
  protected void runAsTransaction(final DiResourceSet diResourceSet) {
    // Get the uml element to which the newly created diagram will be attached.
    // Create the diagram
    final Resource modelResource = diResourceSet.getModelResource();
    TransactionalEditingDomain editingDomain = diResourceSet.getTransactionalEditingDomain();

    AbstractTransactionalCommand command =
        new AbstractTransactionalCommand(
            editingDomain, "Initialize model", Collections.EMPTY_LIST) {

          @Override
          protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
              throws ExecutionException {

            CommandResult commandResult =
                CommandResult.newErrorCommandResult("Error during diagram creation");
            EObject model = getRootElement(modelResource);
            attachModelToResource(model, modelResource);

            initializeModel(model);
            return CommandResult.newOKCommandResult();
          }
        };
    try {
      OperationHistoryFactory.getOperationHistory()
          .execute(command, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
      e.printStackTrace();
    }
  }