dnet-applications/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepos...

46 lines
2.5 KiB
Java
Raw Normal View History

2020-07-03 12:09:22 +02:00
package eu.dnetlib.organizations.repository.readonly;
import java.util.List;
2020-07-03 12:09:22 +02:00
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
2020-10-01 11:33:14 +02:00
import org.springframework.data.repository.query.Param;
2020-07-03 12:09:22 +02:00
import org.springframework.stereotype.Repository;
import eu.dnetlib.organizations.model.view.OrganizationSimpleView;
@Repository
public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<OrganizationSimpleView, String> {
// SEARCH
@Query(value = "select o.* from organizations_simple_view o left outer join org_index_search idx on (idx.id = o.id) where idx.txt @@ plainto_tsquery(:text) and o.status in :statuses order by o.name", nativeQuery = true)
Page<OrganizationSimpleView> search(@Param("text") String text, @Param("statuses") List<String> statuses, Pageable pageable);
2020-07-03 12:09:22 +02:00
// SEARCH FOR USER
@Query(value = "select o.* from organizations_simple_view o left outer join org_index_search idx on (idx.id = o.id) left outer join user_countries uc on (uc.country = o.country) where idx.txt @@ plainto_tsquery(:text) and uc.email = :email and o.status in :statuses order by o.name", nativeQuery = true)
Page<OrganizationSimpleView> searchForUser(@Param("text") String text,
@Param("email") String email,
@Param("statuses") List<String> statuses,
Pageable pageable);
2020-07-03 12:09:22 +02:00
Page<OrganizationSimpleView> findByCountryOrderByName(String country, Pageable pageable);
2020-07-03 12:09:22 +02:00
2020-10-05 12:16:49 +02:00
Iterable<OrganizationSimpleView> findByCountryOrderByName(String code);
Iterable<OrganizationSimpleView> findByCountryAndStatusOrderByName(String code, String status);
2020-10-05 12:16:49 +02:00
2020-10-13 14:48:04 +02:00
Page<OrganizationSimpleView> findByCountryAndStatusOrderByName(String code, String status, Pageable pageable);
Page<OrganizationSimpleView> findByTypeOrderByName(String type, Pageable pageable);
2020-07-03 12:09:22 +02:00
2020-10-13 14:48:04 +02:00
Page<OrganizationSimpleView> findByTypeAndStatusOrderByName(String type, String status, Pageable pageable);
@Query(value = "select o.* from organizations_simple_view o left outer join user_countries uc on (uc.country = o.country) where uc.email = ?2 and o.type = ?1 order by o.name", nativeQuery = true)
2020-07-03 12:09:22 +02:00
Page<OrganizationSimpleView> findByTypeForUser(String type, String name, Pageable pageable);
2020-10-13 14:48:04 +02:00
@Query(value = "select o.* from organizations_simple_view o left outer join user_countries uc on (uc.country = o.country) where o.type = ?1 and o.status = ?2 and uc.email = ?3 order by o.name", nativeQuery = true)
Page<OrganizationSimpleView> findByTypeAndStatusForUser(String type, String status, String name, Pageable pageable);
2020-07-03 12:09:22 +02:00
}