Revision 49900
Added by Claudio Atzori over 6 years ago
ApiDbEntryRepository.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.exporter.datasource.repository; |
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 |
import javax.transaction.Transactional; |
|
4 | 5 |
|
6 |
import eu.dnetlib.openaire.exporter.model.datasource.db.ApiDbEntry; |
|
5 | 7 |
import org.apache.commons.lang3.RandomStringUtils; |
6 | 8 |
import org.springframework.data.jpa.repository.JpaRepository; |
9 |
import org.springframework.data.jpa.repository.Modifying; |
|
7 | 10 |
import org.springframework.data.jpa.repository.Query; |
8 | 11 |
import org.springframework.stereotype.Repository; |
9 | 12 |
|
10 |
import eu.dnetlib.openaire.exporter.model.datasource.db.ApiDbEntry; |
|
11 |
|
|
12 | 13 |
/** |
13 | 14 |
* Created by claudio on 15/06/2017. |
14 | 15 |
*/ |
15 | 16 |
@Repository |
16 | 17 |
public interface ApiDbEntryRepository extends JpaRepository<ApiDbEntry, String> { |
17 | 18 |
|
18 |
static String ID_PREFIX = "api_________::";
|
|
19 |
String ID_PREFIX = "api_________::"; |
|
19 | 20 |
|
20 | 21 |
static String createId(ApiDbEntry api) { |
21 | 22 |
return ID_PREFIX + api.getDatasource() + "::" + RandomStringUtils.randomAlphanumeric(8); |
22 | 23 |
} |
23 | 24 |
|
24 |
@Query("select a from Api a where a.datasource = ?1")
|
|
25 |
@Query("select a from #{#entityName} a where a.datasource = ?1")
|
|
25 | 26 |
List<ApiDbEntry> findByDatasource(String dsId); |
26 | 27 |
|
28 |
@Modifying |
|
29 |
@Transactional |
|
30 |
@Query("update #{#entityName} a set a.baseurl = ?2 where a.id = ?1") |
|
31 |
void setBaseurl(String id, String baseurl); |
|
32 |
|
|
33 |
@Modifying |
|
34 |
@Transactional |
|
35 |
@Query("update #{#entityName} a set a.compatibility = ?2 where a.id = ?1") |
|
36 |
void updateCompatibility(String apiId, String compliance); |
|
37 |
|
|
27 | 38 |
} |
Also available in: Unified diff
work in progress, the application starts