Package net.solarnetwork.node.reactor
Interface InstructionDao
public interface InstructionDao
DAO API for Instructor entities.
- Version:
- 2.0
- Author:
- matt
-
Method Summary
Modifier and TypeMethodDescriptionbooleancompareAndStoreInstructionStatus(Long instructionId, String instructorId, net.solarnetwork.domain.InstructionStatus.InstructionState expectedState, InstructionStatus status) Update an instruction status only if it currently has an expected state.intdeleteHandledInstructionsOlderThan(int hours) Delete Instruction entities that are not in the Received or Executing state and are older than a specified number of hours.Find all instructions needing acknowledgement.findInstructionsForState(net.solarnetwork.domain.InstructionStatus.InstructionState state) Find all instructions in a given state.getInstruction(Long id, String instructorId) Get an Instruction instance by the remote ID.voidstoreInstruction(Instruction instruction) Store an Instruction instance.voidstoreInstructionStatus(Long instructionId, String instructorId, InstructionStatus status) Update an instruction status.
-
Method Details
-
storeInstruction
Store an Instruction instance.- Parameters:
instruction- the instruction to store
-
getInstruction
Get an Instruction instance by the remote ID.- Parameters:
id- the instruction IDinstructorId- the instructor ID- Returns:
- the Instruction, or null if not found
-
storeInstructionStatus
Update an instruction status.- Parameters:
instructionId- the ID of the instruction to update the status forinstructorId- the instructor IDstatus- 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
statusonly if the instruction withinstructionIdexists and has theexpectedStatestate.- Parameters:
instructionId- the ID of the instruction to update the status forinstructorId- the instructor IDexpectedState- the expected state of the instructionstatus- 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
-