1
|
package eu.dnetlib.datasource.publisher.repository;
|
2
|
|
3
|
import javax.transaction.Transactional;
|
4
|
|
5
|
import eu.dnetlib.datasource.publisher.model.db.Datasource;
|
6
|
import org.springframework.data.domain.Pageable;
|
7
|
import org.springframework.data.domain.Slice;
|
8
|
import org.springframework.data.jpa.repository.JpaRepository;
|
9
|
import org.springframework.data.jpa.repository.Modifying;
|
10
|
import org.springframework.data.jpa.repository.Query;
|
11
|
import org.springframework.scheduling.annotation.Async;
|
12
|
import org.springframework.stereotype.Repository;
|
13
|
import org.springframework.util.concurrent.ListenableFuture;
|
14
|
|
15
|
/**
|
16
|
* Created by claudio on 12/04/2017.
|
17
|
*/
|
18
|
@Repository
|
19
|
public interface DatasourceRepository extends JpaRepository<Datasource, String> {
|
20
|
|
21
|
@Async
|
22
|
ListenableFuture<Datasource> findOneById(String id);
|
23
|
|
24
|
@Async
|
25
|
ListenableFuture<Slice<Datasource>> findByOfficialnameContainingOrEnglishnameContainingAllIgnoreCase(String officialname, String englishname, Pageable pageable);
|
26
|
|
27
|
@Async
|
28
|
ListenableFuture<Slice<Datasource>> findByContactemailContainingAllIgnoreCase(String contactemail, Pageable pageable);
|
29
|
|
30
|
@Async
|
31
|
ListenableFuture<Slice<Datasource>> findByOrganizationsCountryIgnoreCase(String country, Pageable pageable);
|
32
|
|
33
|
@Modifying
|
34
|
@Transactional
|
35
|
@Query("update Datasource d set d.managed = ?2 where d.id = ?1")
|
36
|
void setManaged(String id, boolean managed);
|
37
|
|
38
|
@Modifying
|
39
|
@Transactional
|
40
|
@Query("update Datasource d set d.officialname = ?2 where d.id = ?1")
|
41
|
void setOfficialname(String id, String officialname);
|
42
|
|
43
|
@Modifying
|
44
|
@Transactional
|
45
|
@Query("update Datasource d set d.englishname = ?2 where d.id = ?1")
|
46
|
void setEnglishname(String id, String englishname);
|
47
|
|
48
|
@Modifying
|
49
|
@Transactional
|
50
|
@Query("update Datasource d set d.latitude = ?2 where d.id = ?1")
|
51
|
void setLatitude(String id, Double latitude);
|
52
|
|
53
|
@Modifying
|
54
|
@Transactional
|
55
|
@Query("update Datasource d set d.longitude = ?2 where d.id = ?1")
|
56
|
void setLongitude(String id, Double longitude);
|
57
|
|
58
|
}
|