Interface FormItemsRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<FormItemEntity,,Long> DomainIdRepository<FormItemEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<FormItemEntity,,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<FormItemEntity>,org.springframework.data.repository.ListCrudRepository<FormItemEntity,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<FormItemEntity,,Long> org.springframework.data.repository.PagingAndSortingRepository<FormItemEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<FormItemEntity>,org.springframework.data.repository.Repository<FormItemEntity,Long>
Persists multistep form items and provides queries for editing, validation,
duplication, and validation-error statistics within a domain.
-
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 TypeMethodDescriptioncountByFormNameAndStepIdAndSortPriorityAndIdNot(String formName, Long stepId, Integer sortPriority, Integer id) countItemsByIdAndItemFormId(String formName, Long id, String itemFormId, Integer domainId) Checks whether an item has the requested logical identifier and belongs to the form and domain.intcountItemsThatHasType(String formName, Integer domainId, List<String> fieldTypes) Counts items whose configured type matches any of the supplied types.voiddeleteAllByFormNameAndDomainId(String formName, Integer domainId) voiddeleteAllByFormNameAndStepIdAndDomainId(String formName, Long stepId, Integer domainId) voiddeleteAllByStepIdAndDomainId(Long stepId, Integer domainId) findAllByFormNameAndDomainId(String formName, Integer domainId) findAllByFormNameAndIdInAndDomainId(String formName, List<Long> ids, Integer domainId) findAllByFormNameAndStepIdInAndDomainId(String formName, List<Long> stepIds, Integer domainId) findAllForValidation(String formName, Integer domainId) Loads items whose steps belong to the same form and domain, in form display order.findFirstByFormNameAndItemFormIdAndDomainIdOrderBySortPriorityAsc(String formName, String itemFormId, Integer domainId) Resolves the first item for a logical field, which can be shared by several radio options.findItemsToDuplicate(String formName, Long stepId, Integer domainId) Loads the source items to copy when duplicating a form step.getAllStepItems(Long stepId, Integer domainId) Loads all items of a step in their configured display order.getItemFormIds(String formName, Integer domainId) Loads the logical field identifiers used to detect identifier collisions in a form.getMaxSortPriority(String formName, Long stepId, Integer domainId) Returns the last item position in a step, including items hidden by administration filters.intincrementErrorCountByItemFormIds(String formName, Integer domainId, List<String> itemFormIds) Increments the validation-error counter of every item matching the supplied field identifiers.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 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
-
deleteAllByStepIdAndDomainId
-
getAllStepItems
@Query("SELECT fie FROM FormItemEntity fie WHERE fie.stepId = :stepId AND fie.domainId = :domainId ORDER BY fie.sortPriority ASC") List<FormItemEntity> getAllStepItems(@Param("stepId") Long stepId, @Param("domainId") Integer domainId) Loads all items of a step in their configured display order.- Parameters:
stepId- step identifierdomainId- domain owning the items- Returns:
- items ordered by ascending sort priority, including layout items and radio options
-
getItemFormIds
@Query("SELECT fie.itemFormId FROM FormItemEntity fie WHERE fie.formName = :formName AND fie.domainId = :domainId") List<String> getItemFormIds(@Param("formName") String formName, @Param("domainId") Integer domainId) Loads the logical field identifiers used to detect identifier collisions in a form.- Parameters:
formName- logical form namedomainId- domain owning the form- Returns:
- identifiers across all field types and steps, including duplicate radio identifiers
-
countItemsThatHasType
@Query("SELECT count(fie.id) FROM FormItemEntity fie WHERE fie.formName = :formName AND fie.domainId = :domainId AND fie.fieldType IN :fieldTypes") int countItemsThatHasType(@Param("formName") String formName, @Param("domainId") Integer domainId, @Param("fieldTypes") List<String> fieldTypes) Counts items whose configured type matches any of the supplied types.- Parameters:
formName- logical form namedomainId- domain owning the formfieldTypes- field types to include in the count- Returns:
- number of matching item entities across the form
-
deleteAllByFormNameAndStepIdAndDomainId
-
deleteAllByFormNameAndDomainId
-
findItemsToDuplicate
@Query("SELECT fie FROM FormItemEntity fie WHERE fie.formName = :formName AND fie.stepId = :stepId AND fie.domainId = :domainId") List<FormItemEntity> findItemsToDuplicate(@Param("formName") String formName, @Param("stepId") Long stepId, @Param("domainId") Integer domainId) Loads the source items to copy when duplicating a form step.- Parameters:
formName- logical form namestepId- source step identifierdomainId- domain owning the form- Returns:
- existing source entities; no copies are created by this query
-
findAllByFormNameAndDomainId
-
findAllForValidation
@Query("SELECT fie FROM FormItemEntity fie, FormStepEntity step WHERE fie.formName = :formName AND fie.domainId = :domainId AND fie.stepId = step.id AND step.formName = :formName AND step.domainId = :domainId ORDER BY step.sortPriority ASC, fie.sortPriority ASC") List<FormItemEntity> findAllForValidation(@Param("formName") String formName, @Param("domainId") Integer domainId) Loads items whose steps belong to the same form and domain, in form display order.- Parameters:
formName- logical form namedomainId- domain owning both the items and their steps- Returns:
- all matching items ordered by step and item sort priority, including individual radio options
-
findFirstByFormNameAndItemFormIdAndDomainIdOrderBySortPriorityAsc
FormItemEntity findFirstByFormNameAndItemFormIdAndDomainIdOrderBySortPriorityAsc(String formName, String itemFormId, Integer domainId) Resolves the first item for a logical field, which can be shared by several radio options.- Parameters:
formName- logical form nameitemFormId- logical field identifierdomainId- domain owning the form- Returns:
- matching item with the lowest sort priority, or
nullwhen none exists
-
incrementErrorCountByItemFormIds
@Transactional @Modifying @Query("UPDATE FormItemEntity fie SET fie.errorCount = COALESCE(fie.errorCount, 0) + 1 WHERE fie.formName = :formName AND fie.domainId = :domainId AND fie.itemFormId IN :itemFormIds") int incrementErrorCountByItemFormIds(@Param("formName") String formName, @Param("domainId") Integer domainId, @Param("itemFormIds") List<String> itemFormIds) Increments the validation-error counter of every item matching the supplied field identifiers. A missing counter is treated as zero; radio options sharing an identifier are all updated.- Parameters:
formName- logical form namedomainId- domain owning the formitemFormIds- logical identifiers of fields with validation errors- Returns:
- number of item entities updated
-
countByFormNameAndStepIdAndSortPriorityAndIdNot
-
getMaxSortPriority
@Query("SELECT COALESCE(MAX(fie.sortPriority), 0) FROM FormItemEntity fie WHERE fie.formName = :formName AND fie.stepId = :stepId AND fie.domainId = :domainId") Integer getMaxSortPriority(@Param("formName") String formName, @Param("stepId") Long stepId, @Param("domainId") Integer domainId) Returns the last item position in a step, including items hidden by administration filters. -
findAllByFormNameAndStepIdInAndDomainId
-
countItemsByIdAndItemFormId
@Query("SELECT COUNT(fie.id) FROM FormItemEntity fie WHERE fie.formName = :formName AND fie.id = :id AND fie.itemFormId = :itemFormId AND fie.domainId = :domainId") Optional<Integer> countItemsByIdAndItemFormId(@Param("formName") String formName, @Param("id") Long id, @Param("itemFormId") String itemFormId, @Param("domainId") Integer domainId) Checks whether an item has the requested logical identifier and belongs to the form and domain.- Parameters:
formName- logical form nameid- item entity identifieritemFormId- expected logical field identifierdomainId- domain owning the form- Returns:
- count wrapped in an optional: one for a match, zero otherwise
-
findAllByFormNameAndIdInAndDomainId
-