1
|
package eu.dnetlib.organizations.repository;
|
2
|
|
3
|
import java.time.OffsetDateTime;
|
4
|
|
5
|
import org.springframework.data.jpa.repository.JpaRepository;
|
6
|
import org.springframework.data.jpa.repository.Modifying;
|
7
|
import org.springframework.data.jpa.repository.Query;
|
8
|
|
9
|
import eu.dnetlib.organizations.model.Organization;
|
10
|
|
11
|
public interface OrganizationRepository extends JpaRepository<Organization, String> {
|
12
|
|
13
|
@Modifying
|
14
|
@Query("update Organization set created_by = ?2, creation_date = ?3 where id = ?1")
|
15
|
void updateCreationDate(String id, String user, OffsetDateTime now);
|
16
|
|
17
|
@Modifying
|
18
|
@Query("update Organization set modified_by = ?2, modification_date = ?3 where id = ?1")
|
19
|
void updateModificationDate(String id, String user, OffsetDateTime now);
|
20
|
|
21
|
@Query(value = "select count(o.country) > 0 from organizations o left outer join user_countries uc on (o.country = uc.country) where o.id = ?1 and uc.email = ?2", nativeQuery = true)
|
22
|
boolean verifyAuthorizationForId(String id, String user);
|
23
|
|
24
|
@Query(value = "select count(country) > 0 from user_countries where country = ?1 and email = ?2", nativeQuery = true)
|
25
|
boolean verifyAuthorizationForCountry(String country, String user);
|
26
|
|
27
|
}
|