
package com.orientechnologies.orient.core.hook;

import com.orientechnologies.orient.core.record.ORecord;

/**
 * Hook interface to catch all events regarding records.
 * 
 * @author Luca Garulli
 * @see ORecordHookAbstract
 * 
 */
public interface ORecordHook {
  public enum DISTRIBUTED_EXECUTION_MODE {
    TARGET_NODE, SOURCE_NODE, BOTH
  }

  public enum HOOK_POSITION {
    FIRST, EARLY, REGULAR, LATE, LAST
  }

  public enum TYPE {
    ANY, BEFORE_CREATE, BEFORE_READ, BEFORE_UPDATE, BEFORE_DELETE, AFTER_CREATE, AFTER_READ, AFTER_UPDATE, AFTER_DELETE, CREATE_FAILED, READ_FAILED, UPDATE_FAILED, DELETE_FAILED, CREATE_REPLICATED, READ_REPLICATED, UPDATE_REPLICATED, DELETE_REPLICATED, BEFORE_REPLICA_ADD, AFTER_REPLICA_ADD, BEFORE_REPLICA_UPDATE, AFTER_REPLICA_UPDATE, BEFORE_REPLICA_DELETE, AFTER_REPLICA_DELETE, REPLICA_ADD_FAILED, REPLICA_UPDATE_FAILED, REPLICA_DELETE_FAILED
  }

  public enum RESULT {
    RECORD_NOT_CHANGED, RECORD_CHANGED, SKIP
  }

  public RESULT onTrigger(TYPE iType, ORecord<?> iRecord);

  public DISTRIBUTED_EXECUTION_MODE getDistributedExecutionMode();
}
