Package sk.iway.iwcm.components.forms
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>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
org.springframework.data.jpa.repository.JpaSpecificationExecutor.SpecificationFluentQuery<T extends Object> -
Method Summary
Modifier and TypeMethodDescriptioncountFormName(String formName, Integer domainId) Counts all definition and response rows for a form in a domain.voiddeleteAllUserSubmitted(String formName, Integer domainId, Long userId) Deletes all submitted responses created by a user for a form in a domain.getFormAllData(String formName, Integer domainId, Date dateFrom, Date dateTo, org.springframework.data.domain.Pageable pageable) Returns submitted form data within an inclusive date range.getFormCreationDuration(String formName, Integer domainId) Finds the earliest creation timestamp stored on a form definition row.getMinFormCreateDate(String formName, Integer domainId) Finds the date of the earliest submitted response for a form in a domain.getNumberOfSubmitted(String formName, Integer domainId) Counts submitted responses for a form in a domain.voidAssigns theunknowntype to legacy form definition rows without a type.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface sk.iway.iwcm.system.datatable.spring.DomainIdRepository
findAllByDomainId, findAllByDomainId, findAllByIdInAndDomainId, findFirstByIdAndDomainIdMethods inherited from interface sk.iway.iwcm.components.forms.FormsRepositoryInterface
countAllByFormNameAndDomainId, deleteByFormNameAndDomainId, findAllByCreateDateIsNull, findAllByCreateDateIsNullAndDomainId, findAllByFormNameAndDomainIdAndCreateDateNotNull, findFirstByFormNameAndDomainIdAndCreateDateIsNullOrderByIdAsc, findTopByFormNameAndDomainIdAndCreateDateNotNullOrderByCreateDateDesc, updateLastExportDateMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, count, delete, delete, exists, exists, findAll, findAll, findAll, findAll, findAll, findBy, findBy, findOne, findOne, updateMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
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 identifierdomainId- 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 identifierdomainId- domain identifieruserId- 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 identifierdomainId- 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 theunknowntype 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 identifierdomainId- domain identifierdateFrom- earliest submission date to includedateTo- latest submission date to includepageable- 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 identifierdomainId- 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 identifierdomainId- domain identifier- Returns:
- earliest submission date, or an empty optional when no response exists
-