dnet-applications/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDbEntryRepository...

78 lines
2.6 KiB
Java
Raw Normal View History

2022-02-04 10:12:15 +01:00
package eu.dnetlib.openaire.dsm.dao;
2022-02-07 10:09:18 +01:00
import java.sql.Date;
2022-03-22 08:58:20 +01:00
import java.util.Optional;
2022-02-07 10:09:18 +01:00
2022-02-04 10:12:15 +01:00
import javax.transaction.Transactional;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
2022-02-07 10:09:18 +01:00
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
2022-02-04 10:12:15 +01:00
/**
* Created by claudio on 12/04/2017.
*/
@Repository
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
public interface DatasourceDbEntryRepository extends JpaRepository<DatasourceDbEntry, String>, JpaSpecificationExecutor<DatasourceDbEntry> {
2022-03-22 08:58:20 +01:00
Optional<DatasourceDbEntry> findByNamespaceprefix(String namespaceprefix);
2022-02-04 10:12:15 +01:00
@Query("select d.managed from #{#entityName} d where d.id = ?1")
boolean isManaged(String id);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.managed = ?2 where d.id = ?1")
void setManaged(String id, boolean managed);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.officialname = ?2, d.englishname = ?3 where d.id = ?1")
void setDatasourcename(String id, String officialname, String englishname);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.logourl = ?2 where d.id = ?1")
void setLogoUrl(String dsId, String logourl);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.latitude = ?2, d.longitude = ?3 where d.id = ?1")
void setCoordinates(String dsId, Double latitude, Double longitude);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.timezone = ?2 where d.id = ?1")
void setTimezone(String dsId, String timezone);
@Modifying
@Transactional
2022-03-25 10:52:19 +01:00
@Query("update #{#entityName} d set d.eoscDatasourceType = ?2 where d.id = ?1")
2022-03-24 12:26:14 +01:00
void setEoscDatasourceType(String dsId, String type);
2022-02-04 10:12:15 +01:00
@Modifying
@Transactional
@Query("update #{#entityName} d set d.registeredby = ?2 where d.id = ?1")
void setRegisteringUser(String id, String registeredby);
@Query("select case when registrationdate <> null then true else false end as hasregistrationdate from #{#entityName} where id = ?1")
Boolean hasRegistrationdate(String id);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.registrationdate = ?2 where d.id = ?1")
void setRegistrationDate(String id, Date registrationdate);
@Modifying
@Transactional
@Query("update #{#entityName} d set d.platform = ?2 where d.id = ?1")
void setPlatform(String id, String platform);
}