Hosts Repository

@Repository
interface HostsRepository : JpaRepository<T, ID>

The HostsRepository interface is useful to manage the queries of the BrownieHost

Author

N7ghtm4r3 - Tecknobit

See also

JpaRepository

Functions

Link copied to clipboard
abstract fun <S : T?> count(example: Example<S>): Long
Link copied to clipboard
@Query(value = ""SELECT COUNT(*) FROM " + HOSTS_KEY + _WHERE_ + "( " + "MATCH(" + NAME_KEY + "," + HOST_ADDRESS_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " + "OR :" + KEYWORDS_KEY + " = ''" + ") " + "AND " + STATUS_KEY + " IN (:" + STATUSES_KEY + ")" + "AND " + SESSION_IDENTIFIER_KEY + "=:" + SESSION_IDENTIFIER_KEY", nativeQuery = true )
abstract fun countHosts(@Param(value = "session_id") sessionId: String, @Param(value = "keywords") keywords: String, @Param(value = "statuses") statuses: List<String>): Long
Query used to count the hosts number
Link copied to clipboard
abstract fun delete(entity: T)
Link copied to clipboard
abstract fun deleteAll(entities: Iterable<out T>)
Link copied to clipboard
abstract fun deleteAllById(ids: Iterable<out ID>)
Link copied to clipboard
abstract fun deleteAllByIdInBatch(ids: Iterable<ID>)
Link copied to clipboard
abstract fun deleteAllInBatch(entities: Iterable<T>)
Link copied to clipboard
abstract fun deleteById(id: ID)
Link copied to clipboard
open fun deleteInBatch(entities: Iterable<T>)
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""UPDATE " + HOSTS_KEY + " SET " + HOST_ADDRESS_KEY + "=:" + HOST_ADDRESS_KEY + "," + NAME_KEY + "=:" + NAME_KEY + "," + SSH_USER_KEY + "= NULL," + SSH_PASSWORD_KEY + "= NULL," + BROADCAST_IP_KEY + "= NULL," + MAC_ADDRESS_KEY + "= NULL" + _WHERE_ + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true )
abstract fun editHost(@Param(value = "id") hostId: String, @Param(value = "name") name: String, @Param(value = "host_address") hostAddress: String)
@Modifying(clearAutomatically = true )
@Query(value = ""UPDATE " + HOSTS_KEY + " SET " + HOST_ADDRESS_KEY + "=:" + HOST_ADDRESS_KEY + "," + NAME_KEY + "=:" + NAME_KEY + "," + SSH_USER_KEY + "=:" + SSH_USER_KEY + "," + SSH_PASSWORD_KEY + "=:" + SSH_PASSWORD_KEY + "," + BROADCAST_IP_KEY + "=:" + BROADCAST_IP_KEY + "," + MAC_ADDRESS_KEY + "=:" + MAC_ADDRESS_KEY + _WHERE_ + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true )
abstract fun editHost(@Param(value = "id") hostId: String, @Param(value = "name") name: String, @Param(value = "host_address") hostAddress: String, @Param(value = "ssh_user") sshUser: String, @Param(value = "ssh_password") sshPassword: String, @Param(value = "broadcast_ip") broadcastIp: String, @Param(value = "mac_address") macAddress: String)
Query used to edit an existing host
Link copied to clipboard
abstract fun <S : T?> exists(example: Example<S>): Boolean
Link copied to clipboard
abstract fun existsById(id: ID): Boolean
Link copied to clipboard
abstract fun <S : T?> findAll(example: Example<S>): List<S>
abstract fun findAll(): Iterable<T>
abstract fun findAll(): List<T>
abstract fun findAll(pageable: Pageable): Page<T>
abstract fun <S : T?> findAll(example: Example<S>): Iterable<S>
abstract fun <S : T?> findAll(example: Example<S>, pageable: Pageable): Page<S>
Link copied to clipboard
abstract fun findAllById(ids: Iterable<ID>): Iterable<T>
abstract fun findAllById(ids: Iterable<ID>): List<T>
Link copied to clipboard
abstract fun <S : T?, R> findBy(example: Example<S>, queryFunction: (FluentQuery.FetchableFluentQuery<S>) -> R): R
Link copied to clipboard
abstract fun findById(id: ID): Optional<T>
Link copied to clipboard
abstract fun <S : T?> findOne(example: Example<S>): Optional<S>
Link copied to clipboard
abstract fun flush()
Link copied to clipboard
abstract fun getById(id: ID): T
Link copied to clipboard
@Query(value = "SELECT * FROM " + HOSTS_KEY + _WHERE_ + "( " + "MATCH(" + NAME_KEY + "," + HOST_ADDRESS_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " + "OR :" + KEYWORDS_KEY + " = ''" + ") " + "AND " + STATUS_KEY + " IN (:" + STATUSES_KEY + ") " + "AND " + SESSION_IDENTIFIER_KEY + "=:" + SESSION_IDENTIFIER_KEY + " ORDER BY " + INSERTION_DATE_KEY + " DESC", nativeQuery = true )
abstract fun getHosts(@Param(value = "session_id") sessionId: String, @Param(value = "keywords") keywords: String, @Param(value = "statuses") statuses: List<String>, pageable: Pageable): List<BrownieHost>
Query used to retrieve the hosts
Link copied to clipboard
@Query(value = "SELECT new com.tecknobit.brownie.services.hosts.dtos.CurrentHostStatus(" + "h." + IDENTIFIER_KEY + ", " + "h." + STATUS_KEY + ") FROM BrownieHost h" + _WHERE_ + "h." + IDENTIFIER_KEY + " IN (:" + HOSTS_KEY + ")" )
abstract fun getHostsStatus(@Param(value = "hosts") currentHosts: List<String>): List<CurrentHostStatus>
Query used to retrieve the current status of the specified hosts
Link copied to clipboard
abstract fun getOne(id: ID): T
Link copied to clipboard
abstract fun getReferenceById(id: ID): T
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""UPDATE " + HOSTS_KEY + " SET " + STATUS_KEY + "=:" + STATUS_KEY + _WHERE_ + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true )
abstract fun handleHostStatus(@Param(value = "id") hostId: String, @Param(value = "status") status: String)
Query used to handle the current status of the host
Link copied to clipboard
@Query(value = ""SELECT * FROM " + HOSTS_KEY + _WHERE_ + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY + " AND " + SESSION_IDENTIFIER_KEY + "=:" + SESSION_IDENTIFIER_KEY", nativeQuery = true )
abstract fun hostBelongsToSession(@Param(value = "id") hostId: String, @Param(value = "session_id") sessionId: String): BrownieHost
Query used to check whether a host belongs to the specified session
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = "INSERT INTO " + HOSTS_KEY + " (" + IDENTIFIER_KEY + "," + NAME_KEY + "," + HOST_ADDRESS_KEY + "," + SSH_USER_KEY + "," + SSH_PASSWORD_KEY + "," + STATUS_KEY + "," + SESSION_IDENTIFIER_KEY + "," + INSERTION_DATE_KEY + "," + BROADCAST_IP_KEY + "," + MAC_ADDRESS_KEY + ") VALUES (" + ":" + IDENTIFIER_KEY + "," + ":" + NAME_KEY + "," + ":" + HOST_ADDRESS_KEY + "," + ":" + SSH_USER_KEY + "," + ":" + SSH_PASSWORD_KEY + "," + ":" + STATUS_KEY + "," + ":" + SESSION_IDENTIFIER_KEY + "," + ":" + INSERTION_DATE_KEY + "," + ":" + BROADCAST_IP_KEY + "," + ":" + MAC_ADDRESS_KEY + ")", nativeQuery = true )
abstract fun registerHost(@Param(value = "id") hostId: String, @Param(value = "name") name: String, @Param(value = "host_address") hostAddress: String, @Param(value = "ssh_user") sshUser: String, @Param(value = "ssh_password") sshPassword: String, @Param(value = "status") status: String, @Param(value = "session_id") sessionId: String, @Param(value = "insertion_date") insertionDate: Long, @Param(value = "broadcast_ip") broadcastIp: String, @Param(value = "mac_address") macAddress: String)
Query used to register a new host
Link copied to clipboard
abstract fun <S : T?> save(entity: S): S
Link copied to clipboard
abstract fun <S : T?> saveAll(entities: Iterable<S>): Iterable<S>
abstract fun <S : T?> saveAll(entities: Iterable<S>): List<S>
Link copied to clipboard
abstract fun <S : T?> saveAllAndFlush(entities: Iterable<S>): List<S>
Link copied to clipboard
abstract fun <S : T?> saveAndFlush(entity: S): S
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""DELETE FROM " + HOSTS_KEY + _WHERE_ + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true )
abstract fun unregisterHost(@Param(value = "id") hostId: String)
Query used to unregister a host from the session