org.silverpeas.resourcemanager.repository
Interface ResourceRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Resource,Long>, org.springframework.data.jpa.repository.JpaRepository<Resource,Long>, org.springframework.data.repository.PagingAndSortingRepository<Resource,Long>, org.springframework.data.repository.Repository<Resource,Long>

public interface ResourceRepository
extends org.springframework.data.jpa.repository.JpaRepository<Resource,Long>


Method Summary
 void deleteResourcesFromCategory(Long categoryId)
           
 List<Resource> findAllBookableResources(String instanceId)
           
 List<Resource> findAllReservedResources(Long reservationIdToSkip, List<Long> aimedResourceIds, String startPeriod, String endPeriod)
           
 List<Resource> findAllResourcesByCategory(Long categoryId)
           
 List<Resource> findAllResourcesForReservation(Long reservationId)
           
 ResourceValidator getResourceValidator(Long currentResourceId, Long currentUserId)
           
 
Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllInBatch, deleteInBatch, findAll, findAll, flush, save, saveAndFlush
 
Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAll
 
Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, delete, delete, deleteAll, exists, findAll, findOne, save
 

Method Detail

findAllResourcesByCategory

@Query(value="from Resource resource WHERE resource.category.id = :categoryId")
List<Resource> findAllResourcesByCategory(@Param(value="categoryId")
                                                Long categoryId)

findAllBookableResources

@Query(value="from Resource resource WHERE resource.instanceId = :instanceId AND resource.bookable = 1 AND resource.category.bookable = 1 ORDER BY resource.name")
List<Resource> findAllBookableResources(@Param(value="instanceId")
                                              String instanceId)

findAllResourcesForReservation

@Query(value="SELECT DISTINCT reservedResource.resource FROM ReservedResource reservedResource WHERE reservedResource.reservedResourcePk.reservationId = :reservationId")
List<Resource> findAllResourcesForReservation(@Param(value="reservationId")
                                                    Long reservationId)

findAllReservedResources

@Query(value="SELECT DISTINCT reservedResource.resource FROM ReservedResource reservedResource WHERE reservedResource.reservation.id != :reservationIdToSkip AND reservedResource.status != \'R\'AND reservedResource.resource.id IN :aimedResourceIds AND reservedResource.reservation.beginDate < :endPeriod AND reservedResource.reservation.endDate > :startPeriod ")
List<Resource> findAllReservedResources(@Param(value="reservationIdToSkip")
                                              Long reservationIdToSkip,
                                              @Param(value="aimedResourceIds")
                                              List<Long> aimedResourceIds,
                                              @Param(value="startPeriod")
                                              String startPeriod,
                                              @Param(value="endPeriod")
                                              String endPeriod)

getResourceValidator

@Query(value="SELECT DISTINCT resourceValidator FROM ResourceValidator resourceValidator WHERE resourceValidator.resourceValidatorPk.managerId = :currentUserId AND resourceValidator.resourceValidatorPk.resourceId = :reservationId")
ResourceValidator getResourceValidator(@Param(value="reservationId")
                                             Long currentResourceId,
                                             @Param(value="currentUserId")
                                             Long currentUserId)

deleteResourcesFromCategory

@Modifying
@Query(value="DELETE Resource resource WHERE resource.category.id = :categoryId")
void deleteResourcesFromCategory(@Param(value="categoryId")
                                                 Long categoryId)


Copyright © 2016 Silverpeas. All Rights Reserved.