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 27, 2021
2 parents e614777 + 9504251 commit d7bd774
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 46 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.gbif.registry</groupId>
<artifactId>registry-parent</artifactId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
<name>GBIF Registry Parent</name>
<description>GBIF Registry project</description>

Expand Down Expand Up @@ -86,7 +86,7 @@
<spring-cloud-sleuth.version>2.2.8.RELEASE</spring-cloud-sleuth.version>

<!-- GBIF -->
<gbif-api.version>0.150-SNAPSHOT</gbif-api.version>
<gbif-api.version>0.152-SNAPSHOT</gbif-api.version>
<gbif-common.version>0.50</gbif-common.version>
<gbif-common-mybatis.version>1.1</gbif-common-mybatis.version>
<gbif-common-ws.version>1.15</gbif-common-ws.version>
Expand Down
2 changes: 1 addition & 1 deletion registry-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.gbif.registry</groupId>
<artifactId>registry-parent</artifactId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>

<artifactId>registry-cli</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion registry-directory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-doi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-events/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions registry-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>registry-examples</artifactId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>

<packaging>jar</packaging>

Expand Down
2 changes: 1 addition & 1 deletion registry-identity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-mail/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-messaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-metasync/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-oaipmh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-pipelines/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-search/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,19 @@ public DatasetSearchResult toSearchResult(SearchHit hit) {
getDatasetSubTypeValue(fields, "subtype").ifPresent(d::setSubtype);
getHighlightOrStringValue(fields, hit.getHighlightFields(), "description")
.ifPresent(d::setDescription);

getUuidValue(fields, "publishingOrganizationKey").ifPresent(d::setPublishingOrganizationKey);
getHighlightOrStringValue(fields, hit.getHighlightFields(), "publishingOrganizationTitle")
.ifPresent(d::setPublishingOrganizationTitle);
getCountryValue(fields, "publishingCountry").ifPresent(d::setPublishingCountry);
getUuidValue(fields, "endorsingNodeKey").ifPresent(d::setEndorsingNodeKey);

getUuidValue(fields, "hostingOrganizationKey").ifPresent(d::setHostingOrganizationKey);
getHighlightOrStringValue(fields, hit.getHighlightFields(), "hostingOrganizationTitle")
.ifPresent(d::setHostingOrganizationTitle);
getCountryValue(fields, "hostingCountry").ifPresent(d::setHostingCountry);


getCountryValue(fields, "publishingCountry").ifPresent(d::setPublishingCountry);
getLicenceValue(fields, "license").ifPresent(d::setLicense);
getStringValue(fields, "projectId").ifPresent(d::setProjectIdentifier);

Expand Down
2 changes: 1 addition & 1 deletion registry-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-surety/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-ws-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>registry-parent</artifactId>
<groupId>org.gbif.registry</groupId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion registry-ws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.gbif.registry</groupId>
<artifactId>registry-parent</artifactId>
<version>3.61-SNAPSHOT</version>
<version>3.62-SNAPSHOT</version>
</parent>
<artifactId>registry-ws</artifactId>
<name>GBIF Registry Webservices</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,10 @@ private CsvPreference csvPreference() {
@SneakyThrows
public void export(Writer writer) {
try (ICsvBeanWriter beanWriter = new CsvBeanWriter(writer, csvPreference())) {
int count = 1;
beanWriter.writeHeader(header);
for (T o : pager) {
beanWriter.write(o, fields, processors);
count++;
}
System.out.println("count export " + count);
writer.flush();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@
import org.gbif.registry.ws.export.CsvWriter;
import org.gbif.ws.NotFoundException;

import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
Expand Down Expand Up @@ -135,7 +138,9 @@ 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;

//Page size to iterate over search export service
private static final int SEARCH_EXPORT_LIMIT = 300;

private final RegistryDatasetService registryDatasetService;
private final DatasetSearchService searchService;
Expand Down Expand Up @@ -201,11 +206,12 @@ 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,
try (Writer writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream()))) {
CsvWriter.datasetSearchResultCsvWriter(Iterables.datasetSearchResults(searchRequest,
searchService,
SEARCH_EXPORT_LIMIT),
format)
.export(response.getWriter());
SEARCH_EXPORT_LIMIT), format)
.export(writer);
}
}

@GetMapping("suggest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
import org.gbif.registry.ws.provider.PartialDate;
import org.gbif.ws.WebApplicationException;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -92,16 +95,18 @@
@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;
private final DoiIssuingService doiIssuingService;
private final DownloadDoiDataCiteHandlingService doiDataCiteHandlingService;

// Page size to iterate over dataset usages
//Page size to iterate over dataset usages
private static final int BATCH_SIZE = 5_000;

//Page size to iterate over download stats export service
private static final int STATS_EXPORT_LIMIT = 7_500;

private static final Logger LOG = LoggerFactory.getLogger(OccurrenceDownloadResource.class);

private static final Marker NOTIFY_ADMIN = MarkerFactory.getMarker("NOTIFY_ADMIN");
Expand Down Expand Up @@ -390,16 +395,17 @@ public void getDownloadStatistics(
String headerValue = "attachment; filename=download_statistics." + format.name().toLowerCase();
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, headerValue);


CsvWriter.downloadStatisticsCsvWriter(Iterables.downloadStatistics(this,
fromDate,
toDate,
publishingCountry,
datasetKey,
publishingOrgKey,
STATS_EXPORT_LIMIT),
format)
.export(response.getWriter());
try (Writer writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream()))) {
CsvWriter.downloadStatisticsCsvWriter(Iterables.downloadStatistics(this,
fromDate,
toDate,
publishingCountry,
datasetKey,
publishingOrgKey,
STATS_EXPORT_LIMIT),
format)
.export(writer);
}
}

/** Aggregates the download statistics in tree structure of month grouped by year. */
Expand Down

0 comments on commit d7bd774

Please sign in to comment.