Interface FormsRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<FormsEntity,Long>, DomainIdRepository<FormsEntity,Long>, FormsRepositoryInterface<FormsEntity>, org.springframework.data.jpa.repository.JpaRepository<FormsEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<FormsEntity>, org.springframework.data.repository.ListCrudRepository<FormsEntity,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<FormsEntity,Long>, org.springframework.data.repository.PagingAndSortingRepository<FormsEntity,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<FormsEntity>, org.springframework.data.repository.Repository<FormsEntity,Long>

@Repository public interface FormsRepository extends FormsRepositoryInterface<FormsEntity>
Provides domain-scoped queries for form definition rows and submitted responses. A form definition row has no creation date, while submitted response rows have one.
  • Method Details

    • getNumberOfSubmitted

      @Query("SELECT COUNT(fe.id) FROM FormsEntity fe WHERE fe.formName = :formName AND fe.domainId = :domainId AND fe.createDate IS NOT NULL") Integer getNumberOfSubmitted(@Param("formName") String formName, @Param("domainId") Integer domainId)
      Counts submitted responses for a form in a domain.
      Parameters:
      formName - form identifier
      domainId - domain identifier
      Returns:
      number of rows with a submission date
    • deleteAllUserSubmitted

      @Transactional @Modifying @Query("DELETE FROM FormsEntity fe WHERE fe.formName = :formName AND fe.domainId = :domainId AND fe.userId = :userId AND fe.createDate IS NOT NULL") void deleteAllUserSubmitted(@Param("formName") String formName, @Param("domainId") Integer domainId, @Param("userId") Long userId)
      Deletes all submitted responses created by a user for a form in a domain. Form definition rows are preserved.
      Parameters:
      formName - form identifier
      domainId - domain identifier
      userId - user whose submitted responses are deleted
    • countFormName

      @Query("SELECT COUNT(fe.id) FROM FormsEntity fe WHERE fe.formName = :formName AND fe.domainId = :domainId") Integer countFormName(@Param("formName") String formName, @Param("domainId") Integer domainId)
      Counts all definition and response rows for a form in a domain.
      Parameters:
      formName - form identifier
      domainId - domain identifier
      Returns:
      total number of matching rows
    • setUnknownFormType

      @Transactional @Modifying @Query("UPDATE FormsEntity fe SET fe.formType = \'unknown\' WHERE (fe.formType IS NULL OR fe.formType = \'\') AND fe.createDate IS NULL") void setUnknownFormType()
      Assigns the unknown type to legacy form definition rows without a type.
    • getFormAllData

      @Query("SELECT fe.data FROM FormsEntity fe WHERE fe.formName = :formName AND fe.domainId = :domainId AND fe.createDate BETWEEN :dateFrom AND :dateTo") List<String> getFormAllData(@Param("formName") String formName, @Param("domainId") Integer domainId, @Param("dateFrom") Date dateFrom, @Param("dateTo") Date dateTo, org.springframework.data.domain.Pageable pageable)
      Returns submitted form data within an inclusive date range.
      Parameters:
      formName - form identifier
      domainId - domain identifier
      dateFrom - earliest submission date to include
      dateTo - latest submission date to include
      pageable - pagination and sorting configuration
      Returns:
      data payloads for the requested page of matching submissions
    • getFormCreationDuration

      @Query("SELECT MIN(fe.duration) FROM FormsEntity fe WHERE fe.formName = :formName AND fe.domainId = :domainId AND fe.createDate IS NULL") Optional<Long> getFormCreationDuration(@Param("formName") String formName, @Param("domainId") Integer domainId)
      Finds the earliest creation timestamp stored on a form definition row.
      Parameters:
      formName - form identifier
      domainId - domain identifier
      Returns:
      creation time in epoch seconds, or an empty optional when unavailable
    • getMinFormCreateDate

      @Query("SELECT MIN(fe.createDate) FROM FormsEntity fe WHERE fe.formName = :formName AND fe.domainId = :domainId AND fe.createDate IS NOT NULL") Optional<Date> getMinFormCreateDate(@Param("formName") String formName, @Param("domainId") Integer domainId)
      Finds the date of the earliest submitted response for a form in a domain.
      Parameters:
      formName - form identifier
      domainId - domain identifier
      Returns:
      earliest submission date, or an empty optional when no response exists