package com.oguerreiro.resilient.domain.enumeration;

import com.oguerreiro.resilient.activities.period.close.PeriodCloseActivity;
import com.oguerreiro.resilient.activities.period.open.PeriodOpenActivity;
import com.oguerreiro.resilient.activities.period.process.PeriodProcessOutputsActivity;
import com.oguerreiro.resilient.activities.period.reopen.PeriodReopenActivity;
import com.oguerreiro.resilient.activity.Activity;
import com.oguerreiro.resilient.domain.PeriodVersion;

/**
 * <b>Period Status Enum</b> <br>
 * Enumeration of possible {@link Period} states. This states are set
 * automatically by the {@link Activity Activity engine}
 * <ul>
 * <li>{@link #CREATED}</li>
 * <li>{@link #OPENED}</li>
 * <li>{@link #CLOSED}</li>
 * <li>{@link #PROCESSING}</li>
 * <li>{@link #ENDED}</li>
 * </ul>
 * Standard expected state transitions:<br>
 * {@link #CREATED} » {@link #OPENED} » {@link #CLOSED} » {@link #PROCESSING} »
 * {@link #ENDED} <br>
 * <br>
 * Transitions allowed:
 * <ul>
 * <li>CREATED » OPENED - Manual activity {@link PeriodOpenActivity Open})</li>
 * <li>OPENED » CLOSED - Manual activity {@link PeriodCloseActivity Close})</li>
 * <li>CLOSED » PROCESSING - Manual activity {@link PeriodProcessOutputsActivity
 * Process Outputs})</li>
 * <li>PROCESSING » ENDED - Automatically. Changed by activity
 * {@link PeriodProcessOutputsActivity Process Outputs}), if successful.</li>
 * <li>ENDED * OPEN - Manual activity {@link PeriodReopenActivity Reopen})</li>
 * </ul>
 * 
 */
public enum PeriodStatus {
  /**
   * Default when the Period is created.<br>
   * Activities allowed:
   * <ul>
   * <li>Open - Changes Period State to {@link #OPENED}</li>
   * </ul>
   */
  CREATED,

  /**
   * The Period is ready for data insertion values (InputData). It's open for data
   * input. Activities allowed:
   * <ul>
   * <li>Close - Changes Period State to {@link #CLOSED}</li>
   * </ul>
   */
  OPENED,
  /**
   * The Period is closed for data input. No more info can be inserted into the
   * period. Activities allowed:
   * <ul>
   * <li>Process Outputs - Changes Period State to {@link #PROCESSING}. Will
   * create a new {@link PeriodVersion} and do the actual Output generation.</li>
   * </ul>
   */
  CLOSED,
  /**
   * The Period is calculating output's. Activities allowed:
   * <ul>
   * <li>End - Changes Period State to {@link #ENDED}. This is done internally by
   * the PeriodVersion, when it finishes the processing without error's.</li>
   * </ul>
   */
  PROCESSING,
  /**
   * The Period has finished. This means that it has, at least, one PeriodVersion
   * created and fully processed with generated outputs. This is considered a
   * terminal state. Activities allowed:
   * <ul>
   * <li>Reopen - Changes Period State to {@link #OPEN}. This allows for InputData
   * corrections. The Period must be processed again.</li>
   * </ul>
   */
  ENDED,
}
