1
|
package eu.dnetlib.organizations.repository.readonly;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import org.springframework.data.domain.Page;
|
6
|
import org.springframework.data.domain.Pageable;
|
7
|
import org.springframework.data.jpa.repository.Query;
|
8
|
import org.springframework.stereotype.Repository;
|
9
|
|
10
|
import eu.dnetlib.organizations.model.BrowseEntry;
|
11
|
import eu.dnetlib.organizations.model.OrganizationSimpleView;
|
12
|
|
13
|
@Repository
|
14
|
public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<OrganizationSimpleView, String> {
|
15
|
|
16
|
Page<OrganizationSimpleView> findByNameContainingIgnoreCase(String name, Pageable pageable);
|
17
|
|
18
|
Page<OrganizationSimpleView> findByCountry(String country, Pageable pageable);
|
19
|
|
20
|
@Query(value = "select * from organizations_simple_view where ?1 = any(types)", countQuery = "select count(*) from types where type = ?1", nativeQuery = true)
|
21
|
Page<OrganizationSimpleView> findByType(String type, Pageable pageable);
|
22
|
|
23
|
@Query(value = "select country as value, count(*) as count from organizations group by country order by count desc", nativeQuery = true)
|
24
|
List<BrowseEntry> browseCountries();
|
25
|
|
26
|
@Query(value = "select type as value, count(*) as count from types group by type order by count desc", nativeQuery = true)
|
27
|
List<BrowseEntry> browseTypes();
|
28
|
|
29
|
}
|