private HookOperationMode applyScenario(
      GeneralChangeProcessorScenarioType scenarioType,
      GcpScenarioBean scenarioBean,
      ModelContext context,
      Task taskFromModel,
      OperationResult result) {

    try {
      // ========== preparing root task ===========

      JobCreationInstruction rootInstruction =
          baseModelInvocationProcessingHelper.createInstructionForRoot(
              this, context, taskFromModel);
      Job rootJob =
          baseModelInvocationProcessingHelper.createRootJob(rootInstruction, taskFromModel, result);

      // ========== preparing child task, starting WF process ===========

      JobCreationInstruction instruction =
          scenarioBean.prepareJobCreationInstruction(
              scenarioType, (LensContext<?>) context, rootJob, taskFromModel, result);
      jobController.createJob(instruction, rootJob, result);

      // ========== complete the action ===========

      baseModelInvocationProcessingHelper.logJobsBeforeStart(rootJob, result);
      rootJob.startWaitingForSubtasks(result);

      return HookOperationMode.BACKGROUND;

    } catch (SchemaException
        | ObjectNotFoundException
        | CommunicationException
        | ConfigurationException
        | RuntimeException e) {
      LoggingUtils.logException(LOGGER, "Workflow process(es) could not be started", e);
      result.recordFatalError("Workflow process(es) could not be started: " + e, e);
      return HookOperationMode.ERROR;
      // todo rollback - at least close open tasks, maybe stop workflow process instances
    }
  }
  // region Finalizing the processing
  @Override
  public void onProcessEnd(ProcessEvent event, Job job, OperationResult result)
      throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {

    Task task = job.getTask();
    // we simply put model context back into parent task
    // (or if it is null, we set the task to skip model context processing)

    // it is safe to directly access the parent, because (1) it is in waiting state, (2) we are its
    // only child

    Task rootTask = task.getParentTask(result);

    SerializationSafeContainer<LensContextType> contextContainer =
        (SerializationSafeContainer<LensContextType>)
            event.getVariable(GcpProcessVariableNames.VARIABLE_MODEL_CONTEXT);
    LensContextType lensContextType = null;
    if (contextContainer != null) {
      contextContainer.setPrismContext(prismContext);
      lensContextType = contextContainer.getValue();
    }

    if (lensContextType == null) {
      LOGGER.debug(
          GcpProcessVariableNames.VARIABLE_MODEL_CONTEXT
              + " not present in process, this means we should stop processing. Task = {}",
          rootTask);
      wfTaskUtil.setSkipModelContextProcessingProperty(rootTask, true, result);
    } else {
      LOGGER.debug(
          "Putting (changed or unchanged) value of {} into the task {}",
          GcpProcessVariableNames.VARIABLE_MODEL_CONTEXT,
          rootTask);
      wfTaskUtil.storeModelContext(
          rootTask, lensContextType.asPrismContainerValue().getContainer());
    }

    rootTask.savePendingModifications(result);
    LOGGER.trace("onProcessEnd ending for task {}", task);
  }