1
|
package eu.dnetlib.openaire.dsm.dao;
|
2
|
|
3
|
import java.util.List;
|
4
|
import javax.transaction.Transactional;
|
5
|
|
6
|
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
|
7
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
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.stereotype.Repository;
|
12
|
|
13
|
/**
|
14
|
* Created by claudio on 15/06/2017.
|
15
|
*/
|
16
|
@Repository
|
17
|
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
|
18
|
public interface ApiDbEntryRepository extends JpaRepository<ApiDbEntry, String> {
|
19
|
|
20
|
@Query("select a from #{#entityName} a where a.datasource = ?1")
|
21
|
List<ApiDbEntry> findByDatasource(String dsId);
|
22
|
|
23
|
@Modifying
|
24
|
@Transactional
|
25
|
@Query("update #{#entityName} a set a.baseurl = ?2 where a.id = ?1")
|
26
|
void setBaseurl(String id, String baseurl);
|
27
|
|
28
|
@Modifying
|
29
|
@Transactional
|
30
|
@Query("update #{#entityName} a set a.compatibility = ?2 where a.id = ?1")
|
31
|
void updateCompatibility(String apiId, String compatibility);
|
32
|
|
33
|
@Modifying
|
34
|
@Transactional
|
35
|
@Query("update #{#entityName} a set a.compatibilityOverride = ?2 where a.id = ?1")
|
36
|
void updateCompatibilityOverride(String apiId, String compatibility);
|
37
|
|
38
|
@Modifying
|
39
|
@Transactional
|
40
|
@Query(value = "update dsm_apiparams ap set value = ?2 where ap.param = 'set' and ap.api = ?1", nativeQuery = true)
|
41
|
void updateOaiSet(String apiId, String oaiSet);
|
42
|
|
43
|
@Modifying
|
44
|
@Transactional
|
45
|
@Query(value = "insert into dsm_apiparams(api, param, value, _dnet_resource_identifier_) values(?1, ?2, ?3, ?1||'@@'||?2)", nativeQuery = true)
|
46
|
void addApiParam(String apiId, String param, String value);
|
47
|
|
48
|
@Modifying
|
49
|
@Transactional
|
50
|
@Query("update #{#entityName} d set d.removable = ?2 where d.datasource = ?1")
|
51
|
void setRemovable(String id, boolean removable);
|
52
|
|
53
|
}
|