Skip to content
Snippets Groups Projects

feat(batch update): [AOU-2007] check its last update date before updating a publication in batch

Merged Nicolas.Rod requested to merge rodn-2007-add-last-update-in-export into master
4 files
+ 45
23
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -29,6 +29,9 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import ch.unige.aou.business.PersonService;
import ch.unige.aou.business.UserService;
import ch.unige.aou.model.security.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
@@ -37,6 +40,8 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -74,17 +79,23 @@ public class UpdateMetadataController extends IndexDataSearchController<Publicat
private final IndexResourceService<String, PublicationIndexEntry> indexResourceService;
private final UpdateMetadataService updateMetadataService;
private final PersonService personService;
private final UserService userService;
private final String indexPublishedPublications;
private final String exportDataUrl;
public UpdateMetadataController(IndexResourceService<String, PublicationIndexEntry> indexResourceService,
IndexingService<PublicationIndexEntry> indexingService,
IndexFieldAliasInfoProvider indexFieldAliasInfoProvider, UpdateMetadataService updateMetadataService, AouProperties aouProperties) {
IndexingService<PublicationIndexEntry> indexingService, IndexFieldAliasInfoProvider indexFieldAliasInfoProvider,
UpdateMetadataService updateMetadataService, AouProperties aouProperties, PersonService personService,
UserService userService) {
super(indexingService, indexFieldAliasInfoProvider);
this.indexResourceService = indexResourceService;
this.indexPublishedPublications = aouProperties.getIndexing().getPublishedPublicationsIndexName();
this.updateMetadataService = updateMetadataService;
this.exportDataUrl = aouProperties.getParameters().getExportDataUrlTemplate();
this.personService = personService;
this.userService = userService;
}
@PostMapping(AouActionName.EXPORT)
@@ -129,7 +140,10 @@ public class UpdateMetadataController extends IndexDataSearchController<Publicat
@PostMapping(AouActionName.IMPORT)
public ResponseEntity<Void> importPublicationsMetadata(@RequestBody String metadata) {
this.updateMetadataService.importPublications(metadata);
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
final User userImporting = this.userService.findByExternalUid(authentication.getName());
this.updateMetadataService.importPublications(metadata, userImporting);
return new ResponseEntity<>(HttpStatus.OK);
}
Loading