Interface InstructionDao


public interface InstructionDao
DAO API for Instructor entities.
Version:
2.0
Author:
matt
  • Method Details

    • storeInstruction

      void storeInstruction(Instruction instruction)
      Store an Instruction instance.
      Parameters:
      instruction - the instruction to store
    • getInstruction

      Instruction getInstruction(Long id, String instructorId)
      Get an Instruction instance by the remote ID.
      Parameters:
      id - the instruction ID
      instructorId - the instructor ID
      Returns:
      the Instruction, or null if not found
    • storeInstructionStatus

      void storeInstructionStatus(Long instructionId, String instructorId, InstructionStatus status)
      Update an instruction status.
      Parameters:
      instructionId - the ID of the instruction to update the status for
      instructorId - the instructor ID
      status - the status
      Since:
      2.0
    • compareAndStoreInstructionStatus

      boolean compareAndStoreInstructionStatus(Long instructionId, String instructorId, net.solarnetwork.domain.InstructionStatus.InstructionState expectedState, InstructionStatus status)
      Update an instruction status only if it currently has an expected state.

      This is equivalent to an atomic compare-and-set operation. The status of the given instruction will be set to status only if the instruction with instructionId exists and has the expectedState state.

      Parameters:
      instructionId - the ID of the instruction to update the status for
      instructorId - the instructor ID
      expectedState - the expected state of the instruction
      status - the desired status
      Returns:
      true if the instruction status was updated
      Since:
      2.0
    • findInstructionsForState

      List<Instruction> findInstructionsForState(net.solarnetwork.domain.InstructionStatus.InstructionState state)
      Find all instructions in a given state.
      Parameters:
      state - the instruction state
      Returns:
      the found instructions, or empty list if none available
    • findInstructionsForAcknowledgement

      List<Instruction> findInstructionsForAcknowledgement()
      Find all instructions needing acknowledgement.
      Returns:
      the found instructions, or empty list if none available
    • deleteHandledInstructionsOlderThan

      int deleteHandledInstructionsOlderThan(int hours)
      Delete Instruction entities that are not in the Received or Executing state and are older than a specified number of hours.

      This is designed to free up space from local database storage for devices with limited storage capacity.

      Parameters:
      hours - the minimum number of hours old the data must be to delete
      Returns:
      the number of Instruction entities deleted