Project

General

Profile

1
package eu.dnetlib.openaire.exporter.datasource.repository;
2

    
3
import javax.transaction.Transactional;
4

    
5
import eu.dnetlib.openaire.exporter.model.datasource.db.DatasourceDbEntry;
6
import org.springframework.data.jpa.repository.JpaRepository;
7
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
import org.springframework.data.jpa.repository.Modifying;
9
import org.springframework.data.jpa.repository.Query;
10
import org.springframework.stereotype.Repository;
11

    
12
/**
13
 * Created by claudio on 12/04/2017.
14
 */
15
@Repository
16
public interface DatasourceDbEntryRepository extends JpaRepository<DatasourceDbEntry, String>, JpaSpecificationExecutor<DatasourceDbEntry> {
17

    
18
	DatasourceDbEntry findOneById(String id);
19

    
20
	@Query("select d.managed from #{#entityName} d where d.id = ?1")
21
	boolean isManaged(String id);
22

    
23
	@Modifying
24
	@Transactional
25
	@Query("update #{#entityName} d set d.managed = ?2 where d.id = ?1")
26
	void setManaged(String id, boolean managed);
27

    
28
	@Modifying
29
	@Transactional
30
	@Query("update #{#entityName} d set d.officialname = ?2, d.englishname = ?3 where d.id = ?1")
31
	void setDatasourcename(String id, String officialname, String englishname);
32

    
33
	@Modifying
34
	@Transactional
35
	@Query("update #{#entityName} d set d.latitude = ?2, d.longitude = ?3 where d.id = ?1")
36
	void setCoordinates(String dsId, Double latitude, Double longitude);
37

    
38
	@Modifying
39
	@Transactional
40
	@Query("update #{#entityName} d set d.timezone = ?2 where d.id = ?1")
41
	void setTimezone(String dsId, String timezone);
42

    
43
	@Modifying
44
	@Transactional
45
	@Query("update #{#entityName} d set d.typology = ?2 where d.id = ?1")
46
	void setTypology(String dsId, String typology);
47

    
48
	@Modifying
49
	@Transactional
50
	@Query("update #{#entityName} d set d.registeredby = ?2 where d.id = ?1")
51
	void setRegisteringUser(String id, String registeredby);
52

    
53
	@Modifying
54
	@Transactional
55
	@Query("update #{#entityName} d set d.platform = ?2 where d.id = ?1")
56
	void setPlatform(String id, String platform);
57

    
58
}
(4-4/5)