Revision 50118
Added by Claudio Atzori over 6 years ago
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/repository/DatasourceRepository.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.exporter.datasource.repository; |
2 | 2 |
|
3 |
import java.sql.Date; |
|
3 | 4 |
import javax.transaction.Transactional; |
4 | 5 |
|
5 | 6 |
import eu.dnetlib.openaire.exporter.model.datasource.db.Datasource; |
... | ... | |
87 | 88 |
|
88 | 89 |
@Modifying |
89 | 90 |
@Transactional |
90 |
@Query("update Datasource d set d.registrationdate = currentDateDate() where d.id = ?1")
|
|
91 |
void updateRegistrationdate(String id); |
|
91 |
@Query("update Datasource d set d.registrationdate = ?2 where d.id = ?1")
|
|
92 |
void updateRegistrationdate(String id, java.util.Date date);
|
|
92 | 93 |
|
94 |
@Query("select registrationdate from Datasource d where d.id = ?1") |
|
95 |
Date getRegistrationdate(String id); |
|
96 |
|
|
93 | 97 |
@Modifying |
94 | 98 |
@Transactional |
95 | 99 |
@Query("update Datasource d set d.platform = ?2 where d.id = ?1") |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/clients/DatasourceDao.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.exporter.datasource.clients; |
2 | 2 |
|
3 |
import java.time.Instant; |
|
4 |
import java.util.Date; |
|
3 | 5 |
import java.util.List; |
4 | 6 |
import java.util.Objects; |
5 | 7 |
import java.util.Queue; |
... | ... | |
118 | 120 |
|
119 | 121 |
final Page<Datasource> dsPage = dsRepository.findAll(spec, pageable); |
120 | 122 |
|
121 |
if (dsPage.getTotalElements() > 0) { |
|
123 |
if (dsPage.getTotalElements() > 0 && dsPage.getNumberOfElements() > 0) {
|
|
122 | 124 |
dsPage.forEach(d -> datasourceInfo.add(getDatasourceInfo(d, outerLatch, errors))); |
123 | 125 |
waitLatch(outerLatch, errors, config.getRequestTimeout()); |
124 | 126 |
} |
... | ... | |
377 | 379 |
log.info(String.format("updated datasource '%s' with timezone '%s'", dsId, timezone)); |
378 | 380 |
} |
379 | 381 |
|
380 |
public void updateDatasourceTypology(final String dsId, final String typology) throws ApiException {
|
|
382 |
public void updateTypology(final String dsId, final String typology) throws ApiException { |
|
381 | 383 |
|
382 | 384 |
final Vocabulary typologies = vocabularyClient.getDatasourceTypologies(); |
383 | 385 |
if (!typologies.hasCode(typology)) { |
... | ... | |
389 | 391 |
log.info(String.format("updated datasource '%s' with timezone '%s'", dsId, typology)); |
390 | 392 |
} |
391 | 393 |
|
392 |
public void updateDatasourceRegisteringUser(final String dsId, final String registeredBy) {
|
|
394 |
public void updateRegisteringUser(final String dsId, final String registeredBy) { |
|
393 | 395 |
dsRepository.setRegisteringUser(dsId, registeredBy); |
394 | 396 |
log.info(String.format("updated datasource '%s' with registeredby '%s'", dsId, registeredBy)); |
395 | 397 |
setManaged(dsId, true); |
398 |
|
|
399 |
if (dsRepository.getRegistrationdate(dsId) == null) { |
|
400 |
final Date now = Date.from(Instant.now()); |
|
401 |
dsRepository.updateRegistrationdate(dsId, now); |
|
402 |
log.info(String.format("updated datasource '%s' with registrationdate '%s'", dsId, now)); |
|
403 |
} |
|
396 | 404 |
} |
397 | 405 |
|
398 | 406 |
public void updatePlatform(final String dsId, final String platform) { |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/DatasourcesApiController.java | ||
---|---|---|
217 | 217 |
@Override |
218 | 218 |
@RequestMapping(value = "/ds/typology", method = RequestMethod.POST) |
219 | 219 |
public void updateTypology(@RequestParam final String dsId, @RequestParam final String typology) throws ApiException { |
220 |
dsDao.updateDatasourceTypology(dsId, typology);
|
|
220 |
dsDao.updateTypology(dsId, typology); |
|
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
@Override |
224 | 224 |
@RequestMapping(value = "/ds/registeredby", method = RequestMethod.POST) |
225 | 225 |
public void updateRegisteringUser(@RequestParam final String dsId, @RequestParam final String registeredBy) throws ApiException { |
226 |
dsDao.updateDatasourceRegisteringUser(dsId, registeredBy);
|
|
226 |
dsDao.updateRegisteringUser(dsId, registeredBy); |
|
227 | 227 |
} |
228 | 228 |
|
229 | 229 |
@Override |
Also available in: Unified diff
set registration date only when missing