Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class DownloadSearchResultsRequest {
@JsonProperty
private final DownloadSearchResultFileType fileType;
@JsonProperty
private final boolean downloadAllTables;
@JsonProperty
private final boolean sample;
@JsonProperty
private final int percent;
Expand All @@ -39,11 +41,13 @@ public class DownloadSearchResultsRequest {
public DownloadSearchResultsRequest(@JsonProperty("searchRequest") final DashboardSearchRequest searchRequest,
@JsonProperty("componentId") final String componentId,
@JsonProperty("fileType") final DownloadSearchResultFileType fileType,
@JsonProperty("downloadAllTables") final boolean downloadAllTables,
@JsonProperty("sample") final boolean sample,
@JsonProperty("percent") final int percent) {
this.searchRequest = searchRequest;
this.componentId = componentId;
this.fileType = fileType;
this.downloadAllTables = downloadAllTables;
this.sample = sample;
this.percent = percent;
}
Expand All @@ -60,6 +64,10 @@ public DownloadSearchResultFileType getFileType() {
return fileType;
}

public boolean isDownloadAllTables() {
return downloadAllTables;
}

public boolean isSample() {
return sample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
@JsonPropertyOrder({
"componentId",
"fetch",
"tableName",
"tableSettings",
"requestedRange",
"openGroups"})
@JsonInclude(Include.NON_NULL)
public class TableResultRequest extends ComponentResultRequest {

@JsonProperty
private final String tableName;
@JsonProperty
private final TableSettings tableSettings;
@JsonProperty
Expand All @@ -49,10 +52,12 @@ public class TableResultRequest extends ComponentResultRequest {
@JsonCreator
public TableResultRequest(@JsonProperty("componentId") final String componentId,
@JsonProperty("fetch") final Fetch fetch,
@JsonProperty("tableName") final String tableName,
@JsonProperty("tableSettings") final TableSettings tableSettings,
@JsonProperty("requestedRange") final OffsetRange requestedRange,
@JsonProperty("openGroups") final Set<String> openGroups) {
super(componentId, fetch);
this.tableName = tableName;
this.tableSettings = tableSettings;
this.requestedRange = requestedRange;
this.openGroups = openGroups;
Expand All @@ -62,6 +67,10 @@ public static Builder builder() {
return new Builder();
}

public String getTableName() {
return tableName;
}

public TableSettings getTableSettings() {
return tableSettings;
}
Expand All @@ -87,20 +96,26 @@ public boolean equals(final Object o) {
return false;
}
final TableResultRequest that = (TableResultRequest) o;
return Objects.equals(tableSettings, that.tableSettings) &&
return Objects.equals(tableName, that.tableName) &&
Objects.equals(tableSettings, that.tableSettings) &&
Objects.equals(requestedRange, that.requestedRange) &&
Objects.equals(openGroups, that.openGroups);
}

@Override
public int hashCode() {
return Objects.hash(tableSettings, requestedRange, openGroups);
return Objects.hash(
tableName,
tableSettings,
requestedRange,
openGroups);
}

@Override
public String toString() {
return "TableResultRequest{" +
"tableSettings=" + tableSettings +
"tableName='" + tableName + '\'' +
",tableSettings=" + tableSettings +
", requestedRange=" + requestedRange +
", openGroups=" + openGroups +
'}';
Expand All @@ -114,6 +129,7 @@ public static final class Builder {

private String componentId;
private Fetch fetch;
private String tableName;
private TableSettings tableSettings;
private OffsetRange requestedRange = new OffsetRange(0, 100);
private Set<String> openGroups;
Expand All @@ -124,6 +140,7 @@ private Builder() {
private Builder(final TableResultRequest tableResultRequest) {
this.componentId = tableResultRequest.getComponentId();
this.fetch = tableResultRequest.getFetch();
this.tableName = tableResultRequest.tableName;
this.tableSettings = tableResultRequest.tableSettings;
this.requestedRange = tableResultRequest.requestedRange;
this.openGroups = tableResultRequest.openGroups;
Expand All @@ -139,6 +156,11 @@ public Builder fetch(final Fetch fetch) {
return this;
}

public Builder tableName(final String tableName) {
this.tableName = tableName;
return this;
}

public Builder tableSettings(final TableSettings tableSettings) {
this.tableSettings = tableSettings;
return this;
Expand Down Expand Up @@ -169,7 +191,13 @@ public Builder openGroup(final String group, final boolean open) {
}

public TableResultRequest build() {
return new TableResultRequest(componentId, fetch, tableSettings, requestedRange, openGroups);
return new TableResultRequest(
componentId,
fetch,
tableName,
tableSettings,
requestedRange,
openGroups);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public DownloadSearchResultFileType getFileType() {
return getView().getFileType();
}

public boolean downloadAllTables() {
return getView().downloadAllTables();
}

public boolean isSample() {
return getView().isSample();
}
Expand All @@ -46,6 +50,8 @@ public interface DownloadView extends View {

DownloadSearchResultFileType getFileType();

boolean downloadAllTables();

boolean isSample();

int getPercent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class DownloadViewImpl extends ViewImpl implements DownloadView {
@UiField
ItemListBox<DownloadSearchResultFileType> fileType;
@UiField
TickBox downloadAllTables;
@UiField
TickBox sample;
@UiField
ValueSpinner percent;
Expand All @@ -55,6 +57,18 @@ public DownloadViewImpl(final Binder binder) {
fileType.addItem(DownloadSearchResultFileType.TSV);

fileType.setSelectedItem(DownloadSearchResultFileType.EXCEL);

downloadAllTables.setEnabled(isExcelFileTypeSelected());
fileType.addSelectionHandler(event -> {
downloadAllTables.setEnabled(isExcelFileTypeSelected());
if (!isExcelFileTypeSelected()) {
downloadAllTables.setBooleanValue(false);
}
});
}

private boolean isExcelFileTypeSelected() {
return DownloadSearchResultFileType.EXCEL.equals(fileType.getSelectedItem());
}

@Override
Expand All @@ -67,6 +81,11 @@ public DownloadSearchResultFileType getFileType() {
return fileType.getSelectedItem();
}

@Override
public boolean downloadAllTables() {
return downloadAllTables.getBooleanValue();
}

@Override
public boolean isSample() {
return sample.getBooleanValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,19 @@ private void download() {
@Override
public void onHideRequest(final boolean autoClose, final boolean ok) {
if (ok) {
final TableResultRequest tableResultRequest = TableResultRequest
.builder()
.componentId(getComponentConfig().getId())
.requestedRange(new OffsetRange(0, Integer.MAX_VALUE))
.tableSettings(TablePresenter.this.tableResultRequest.getTableSettings())
.fetch(Fetch.ALL)
.build();

final List<ComponentResultRequest> requests = new ArrayList<>();
requests.add(tableResultRequest);
currentSearch.getComponentSettingsMap().entrySet()
.stream()
.filter(settings -> settings.getValue() instanceof TableComponentSettings)
.forEach(tableSettings -> requests.add(TableResultRequest
.builder()
.componentId(tableSettings.getKey())
.requestedRange(new OffsetRange(0, Integer.MAX_VALUE))
.tableName(getTableName(tableSettings.getKey()))
.tableSettings(((TableComponentSettings) tableSettings.getValue()).copy()
.buildTableSettings())
.fetch(Fetch.ALL)
.build()));

final Search search = Search
.builder()
Expand All @@ -472,6 +475,7 @@ public void onHideRequest(final boolean autoClose, final boolean ok) {
searchRequest,
getComponentConfig().getId(),
downloadPresenter.getFileType(),
downloadPresenter.downloadAllTables(),
downloadPresenter.isSample(),
downloadPresenter.getPercent());
final Rest<ResourceGeneration> rest = restFactory.create();
Expand All @@ -497,6 +501,12 @@ public void onHide(final boolean autoClose, final boolean ok) {
}
}

private String getTableName(final String componentId) {
return Optional.ofNullable(getComponents().get(componentId))
.map(component -> component.getComponentConfig().getName())
.orElse(null);
}

private DateTimeSettings getDateTimeSettings() {
final UserPreferences userPreferences = userPreferencesManager.getCurrentPreferences();
return DateTimeSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<list:ItemListBox ui:field="fileType" />
</g:customCell>
</g:row>
<g:row>
<g:cell>Download All Tables:</g:cell>
<g:customCell>
<view:TickBox ui:field="downloadAllTables" />
</g:customCell>
</g:row>
<g:row>
<g:cell>Sample Only:</g:cell>
<g:customCell>
Expand Down
Loading