package com.oguerreiro.resilient.domain.enumeration;

import com.oguerreiro.resilient.activities.period.process.PeriodProcessOutputsActivity;
import com.oguerreiro.resilient.activity.Activity;
import com.oguerreiro.resilient.domain.OutputData;
import com.oguerreiro.resilient.domain.PeriodVersion;

/**
 * <b>Period Version Status Enum</b> <br>
 * Enumeration of possible {@link PeriodVersion} states. This states are set
 * automatically by the {@link Activity Activity engine}
 * <ul>
 * <li>{@link #PROCESSING}</li>
 * <li>{@link #ERROR}</li>
 * <li>{@link #ENDED}</li>
 * </ul>
 * Standard expected state transitions:<br>
 * {@link #PROCESSING} » {@link #ENDED} <br>
 * <br>
 * Transitions allowed:
 * <ul>
 * <li>PROCESSING - Startup state. The {@link PeriodVersion} is created to
 * process outputs, and so, it's starts with PROCESSING state.</li>
 * <li>PROCESSING » ERROR - Automatically. Changed by activity
 * {@link PeriodVersionProcessOutputsActivity Process} if an error occurs</li>
 * <li>PROCESSING » ENDED - Automatically, when invoked by Period activity
 * {@link PeriodProcessOutputsActivity Process Outputs}. Or manually, by calling
 * {@link PeriodVersionProcessOutputsActivity Process}. In both cases, only if
 * processed without error. See the state {@link #ERROR}</li>
 * </ul>
 * 
 */
public enum PeriodVersionStatus {
  /**
   * Default when the PeriodVersion is created.<br>
   * The PeriodVersion is calculating output's. No Activities allowed, this means
   * that an activity is running.
   */
  PROCESSING,

  /**
   * An error occurred when the PeriodVersion was calculating output's. Activities
   * allowed:
   * <ul>
   * <li>Process Outputs - Re-attempts to process outputs. Calls activity
   * {@link PeriodVersionProcessOutputsActivity Process}.</li>
   * </ul>
   */
  ERROR,

  /**
   * The PeriodVersion has finished. This means that all configured output
   * variables where calculated and the {@link OutputData} where created. This is
   * considered a terminal state. <br>
   * No activities are allowed.
   */
  ENDED,
}
