Skip to content

Commit

Permalink
Merge branch '#343_suggest_change_and_log' into #341_grscicoll_permis…
Browse files Browse the repository at this point in the history
…sions
  • Loading branch information
marcos-lg committed May 26, 2021
2 parents 22884cd + 850a030 commit 046d03e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public int addIdentifier(UUID entityKey, Identifier identifier) {
@Override
public void deleteIdentifier(UUID entityKey, int identifierKey) {
Identifier identifierToDelete = identifierMapper.get(identifierKey);
checkArgument(identifierToDelete != null, "Identifier to delete doesn't exist");

baseMapper.deleteIdentifier(entityKey, identifierKey);

eventManager.post(
Expand Down Expand Up @@ -156,6 +158,8 @@ public int addTag(UUID key, String value) {
@Override
public void deleteTag(UUID entityKey, int tagKey) {
Tag tagToDelete = tagMapper.get(tagKey);
checkArgument(tagToDelete != null, "Tag to delete doesn't exist");

baseMapper.deleteTag(entityKey, tagKey);
eventManager.post(
SubEntityCollectionEvent.newInstance(
Expand Down Expand Up @@ -222,6 +226,8 @@ public int addMachineTag(UUID targetEntityKey, TagName tagName, String value) {
@Override
public void deleteMachineTag(UUID targetEntityKey, int machineTagKey) {
MachineTag machineTagToDelete = machineTagMapper.get(machineTagKey);
checkArgument(machineTagToDelete != null, "Machine Tag to delete doesn't exist");

baseMapper.deleteMachineTag(targetEntityKey, machineTagKey);
eventManager.post(
SubEntityCollectionEvent.newInstance(
Expand Down Expand Up @@ -270,6 +276,7 @@ public void deleteMachineTags(UUID targetEntityKey, String namespace, String nam
.collect(Collectors.toList());

baseMapper.deleteMachineTags(targetEntityKey, namespace, name);

machineTagsToDelete.forEach(
mt ->
eventManager.post(
Expand Down Expand Up @@ -316,6 +323,8 @@ public int addComment(UUID targetEntityKey, Comment comment) {
@Override
public void deleteComment(UUID targetEntityKey, int commentKey) {
Comment commentToDelete = commentMapper.get(commentKey);
checkArgument(commentToDelete != null, "Comment to delete doesn't exist");

baseMapper.deleteComment(targetEntityKey, commentKey);
eventManager.post(
SubEntityCollectionEvent.newInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
import org.gbif.api.model.collections.PrimaryCollectionEntity;
import org.gbif.api.model.registry.Commentable;
import org.gbif.api.model.registry.Identifiable;
import org.gbif.api.model.registry.Identifier;
import org.gbif.api.model.registry.MachineTag;
import org.gbif.api.model.registry.MachineTaggable;
import org.gbif.api.model.registry.PostPersist;
import org.gbif.api.model.registry.PrePersist;
import org.gbif.api.model.registry.Tag;
import org.gbif.api.model.registry.Taggable;
import org.gbif.api.service.collections.PrimaryCollectionEntityService;
import org.gbif.registry.events.EventManager;
Expand Down Expand Up @@ -234,6 +231,8 @@ public List<OccurrenceMapping> listOccurrenceMappings(@NotNull UUID uuid) {
@Override
public void deleteOccurrenceMapping(UUID entityKey, int occurrenceMappingKey) {
OccurrenceMapping occurrenceMappingToDelete = occurrenceMappingMapper.get(occurrenceMappingKey);
checkArgument(occurrenceMappingToDelete != null, "Occurrence Mapping to delete doesn't exist");

primaryEntityMapper.deleteOccurrenceMapping(entityKey, occurrenceMappingKey);
eventManager.post(
SubEntityCollectionEvent.newInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class DatasetResource extends BaseNetworkEntityResource<Dataset>
private static final Logger LOG = LoggerFactory.getLogger(DatasetResource.class);

private static final int ALL_DATASETS_LIMIT = 200;
public static final int SEARCH_EXPORT_LIMIT = 300;

private final RegistryDatasetService registryDatasetService;
private final DatasetSearchService searchService;
Expand Down Expand Up @@ -200,7 +201,9 @@ public void search(HttpServletResponse response,
String headerValue = "attachment; filename=gbif_datasets." + format.name().toLowerCase();
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, headerValue);

CsvWriter.datasetSearchResultCsvWriter(Iterables.datasetSearchResults(searchRequest, searchService),
CsvWriter.datasetSearchResultCsvWriter(Iterables.datasetSearchResults(searchRequest,
searchService,
SEARCH_EXPORT_LIMIT),
format)
.export(response.getWriter());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
@RequestMapping(value = "occurrence/download", produces = MediaType.APPLICATION_JSON_VALUE)
public class OccurrenceDownloadResource implements OccurrenceDownloadService {

public static final int STATS_EXPORT_LIMIT = 500;
private final OccurrenceDownloadMapper occurrenceDownloadMapper;
private final DatasetOccurrenceDownloadMapper datasetOccurrenceDownloadMapper;
private final IdentityAccessService identityService;
Expand Down Expand Up @@ -395,7 +396,8 @@ public void getDownloadStatistics(
toDate,
publishingCountry,
datasetKey,
publishingOrgKey),
publishingOrgKey,
STATS_EXPORT_LIMIT),
format)
.export(response.getWriter());
}
Expand Down

0 comments on commit 046d03e

Please sign in to comment.