Skip to content

Commit

Permalink
#7714 CR feedback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Apr 16, 2021
1 parent b013581 commit 8225e18
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 68 deletions.
89 changes: 44 additions & 45 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,11 @@ private String init(boolean initFull) {
displayWorkflowComments();


if (initFull) {
if (initFull) {
tooLargeToDownload = getSizeOfDatasetNumeric() > settingsWrapper.getZipDownloadLimit();
tooLargeToDownloadOriginal = getSizeOfDatasetOrigNumeric() > settingsWrapper.getZipDownloadLimit();
tooLargeToDownloadArchival = getSizeOfDatasetArchivalNumeric() > settingsWrapper.getZipDownloadLimit();

// init the list of FileMetadatas
if (workingVersion.isDraft() && canUpdateDataset()) {
readOnly = false;
Expand Down Expand Up @@ -2852,52 +2856,75 @@ public String getSizeOfDataset() {
return DatasetUtil.getDownloadSize(workingVersion, original);
}

private boolean tooLargeToDownload;
private boolean tooLargeToDownloadArchival;
private boolean tooLargeToDownloadOriginal;

public boolean isTooLargeToDownloadOriginal() {
return tooLargeToDownloadOriginal;
}

public void setTooLargeToDownloadOriginal(boolean tooLargeToDownloadOriginal) {
this.tooLargeToDownloadOriginal = tooLargeToDownloadOriginal;
}

public boolean isTooLargeToDownloadArchival() {
return tooLargeToDownloadArchival;
}

public void setTooLargeToDownloadArchival(boolean tooLargeToDownloadArchival) {
this.tooLargeToDownloadArchival = tooLargeToDownloadArchival;
}

public boolean isTooLargeToDownload() {
return tooLargeToDownload;
}

public void setTooLargeToDownload(boolean tooLargeToDownload) {
this.tooLargeToDownload = tooLargeToDownload;
}

public Long getSizeOfDatasetNumeric() {
//get min of orig/archival
return Math.min(DatasetUtil.getDownloadSizeNumeric(workingVersion, true), DatasetUtil.getDownloadSizeNumeric(workingVersion, false)) ;
if (this.hasTabular){
return Math.min(getSizeOfDatasetOrigNumeric(), getSizeOfDatasetArchivalNumeric());
}
return getSizeOfDatasetOrigNumeric();
}

public Long getSizeOfDatasetOrigNumeric() {
boolean original = true;
return DatasetUtil.getDownloadSizeNumeric(workingVersion, original);
return DatasetUtil.getDownloadSizeNumeric(workingVersion, true);
}

public Long getSizeOfDatasetArchivalNumeric() {
boolean original = false;
return DatasetUtil.getDownloadSizeNumeric(workingVersion, original);
return DatasetUtil.getDownloadSizeNumeric(workingVersion, false);
}

public String getSizeOfSelectedAsString(){
return FileSizeChecker.bytesToHumanReadable(getSizeOfSelectedOrigNumeric());
}

public String getSizeOfSelectedMaxAsString(){
return FileSizeChecker.bytesToHumanReadable(Math.max(getSizeOfSelectedOrigNumeric(), getSizeOfDatasetArchivalNumeric()) );
return FileSizeChecker.bytesToHumanReadable(Math.max(getSizeOfSelectedOrigNumeric(), getSizeOfSelectedArchivalNumeric()) );
}

public String getZipDownloadLimitAsString(){
return FileSizeChecker.bytesToHumanReadable(settingsWrapper.getZipDownloadLimit());
}

public Long getSizeOfSelectedOrigNumeric(){
boolean original = true;
return DatasetUtil.getDownloadSizeNumericBySelectedFiles(selectedFiles, original);

return DatasetUtil.getDownloadSizeNumericBySelectedFiles(selectedFiles, true);
}

public Long getSizeOfSelectedArchivalNumeric(){
boolean original = false;
return DatasetUtil.getDownloadSizeNumericBySelectedFiles(selectedFiles, original);

return DatasetUtil.getDownloadSizeNumericBySelectedFiles(selectedFiles, false);
}

public Long getSizeOfSelectedMaxNumeric(){
return Math.max(DatasetUtil.getDownloadSizeNumericBySelectedFiles(selectedFiles, true), DatasetUtil.getDownloadSizeNumericBySelectedFiles(selectedFiles, false)) ;
return Math.max(getSizeOfSelectedOrigNumeric(), getSizeOfSelectedArchivalNumeric()) ;
}

public String getSizeOfDatasetOrig() {
boolean original = true;
return DatasetUtil.getDownloadSize(workingVersion, original);
return DatasetUtil.getDownloadSize(workingVersion, true);
}

public void validateAllFilesForDownloadArchival() {
Expand Down Expand Up @@ -2946,7 +2973,6 @@ public void validateFilesForDownload(boolean guestbookRequired, boolean download

//if there are two or more files with a total size
//over the zip limit post a "too large" popup
System.out.print("bytes: " + bytes);
if (bytes > settingsWrapper.getZipDownloadLimit() && selectedDownloadableFiles.size() > 1 ){
PrimeFaces.current().executeScript("PF('downloadTooLarge').show()");
return;
Expand Down Expand Up @@ -3010,11 +3036,6 @@ public boolean isSelectAllFiles() {
public void setSelectAllFiles(boolean selectAllFiles) {
this.selectAllFiles = selectAllFiles;
}

public void handleFileSelectClick(){
setSelectAllFiles(false);

}

public void toggleAllSelected(){
//This is here so that if the user selects all on the dataset page
Expand Down Expand Up @@ -3063,28 +3084,6 @@ public void updateFileCounts(){
}
}
}


private Long originalSelectedFileSize;

private Long archivalSelectedFileSize;

public Long getOriginalSelectedFileSize() {
return originalSelectedFileSize;
}

public void setOriginalSelectedFileSize(Long originalSelectedFileSize) {
this.originalSelectedFileSize = originalSelectedFileSize;
}

public Long getArchivalSelectedFileSize() {
return archivalSelectedFileSize;
}

public void setArchivalSelectedFileSize(Long archivalSelectedFileSize) {
this.archivalSelectedFileSize = archivalSelectedFileSize;
}


private List<String> getSuccessMessageArguments() {
List<String> arguments = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void writeGuestbookAndStartBatchDownload(GuestbookResponse guestbookRespo
}

public void writeGuestbookAndStartBatchDownload(GuestbookResponse guestbookResponse, Boolean doNotSaveGuestbookRecord){
System.out.print(guestbookResponse.getSelectedFileIds());

if (guestbookResponse == null || guestbookResponse.getSelectedFileIds() == null) {
return;
}
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,7 @@ public static String getDownloadSize(DatasetVersion dsv, boolean original) {
}

public static Long getDownloadSizeNumeric(DatasetVersion dsv, boolean original) {
long bytes = 0l;
for (FileMetadata fileMetadata : dsv.getFileMetadatas()) {
DataFile dataFile = fileMetadata.getDataFile();
if (original && dataFile.isTabularData()) {
bytes += dataFile.getOriginalFileSize() == null ? 0 : dataFile.getOriginalFileSize();
} else {
bytes += dataFile.getFilesize();
}
}
return bytes;
return getDownloadSizeNumericBySelectedFiles(dsv.getFileMetadatas(), original);
}

public static Long getDownloadSizeNumericBySelectedFiles(List<FileMetadata> fileMetadatas, boolean original) {
Expand Down
19 changes: 7 additions & 12 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,20 @@
</button>
<ul class="dropdown-menu pull-right text-left" style="padding-left:1em; padding-right:1em;" >
<!-- DOWNLOAD -->
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and !(DatasetPage.sizeOfDatasetNumeric > settingsWrapper.zipDownloadLimit) }">
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and !(DatasetPage.tooLargeToDownload) }">
<li class="dropdown-header">#{bundle['dataset.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li>
<!-- NORMAL DOWNLOAD BUTTON (NO TABULAR FILES) -->
<li jsf:rendered="#{!DatasetPage.versionHasTabular and !(DatasetPage.sizeOfDatasetNumeric > settingsWrapper.zipDownloadLimit)}">
<li jsf:rendered="#{!DatasetPage.versionHasTabular and !(DatasetPage.tooLargeToDownload)}">
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadArchival()}" styleClass="btn-download">
#{bundle.download}
<h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
<f:param value="#{DatasetPage.sizeOfDataset}" />
</h:outputFormat>
</p:commandLink>
</li>

<li jsf:rendered="#{DatasetPage.canDownloadFiles() and (DatasetPage.sizeOfDatasetOrigNumeric > settingsWrapper.zipDownloadLimit) }" style="margin-left: 3.5em;">
<h:outputText value="#{bundle['dataset.accessBtn.too.big']}" >
</h:outputText>
</li>

<!-- DOWNLOAD ORIGINAL BUTTON (TABULAR FILES PRESENT) -->
<li jsf:rendered="#{DatasetPage.versionHasTabular and DatasetPage.sizeOfDatasetOrig != '0 B' and !(DatasetPage.sizeOfDatasetOrigNumeric > settingsWrapper.zipDownloadLimit) }">
<li jsf:rendered="#{DatasetPage.versionHasTabular and DatasetPage.sizeOfDatasetOrig != '0 B' and !(DatasetPage.tooLargeToDownloadOriginal) }">
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadOriginal()}"
oncomplete="bind_bsui_components();"
styleClass="btn-download">
Expand All @@ -174,12 +169,12 @@
</h:outputFormat>
</p:commandLink>
</li>
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and (DatasetPage.sizeOfDatasetOrigNumeric > settingsWrapper.zipDownloadLimit) }">
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and (DatasetPage.tooLargeToDownloadOriginal) }">
<h:outputText value="#{bundle['dataset.accessBtn.original.too.big']}">
</h:outputText>
</ui:fragment>
<!-- DOWNLOAD ARCHIVAL FILES (TABULAR FILES PRESENT) -->
<li jsf:rendered="#{DatasetPage.versionHasTabular and !(DatasetPage.sizeOfDatasetArchivalNumeric > settingsWrapper.zipDownloadLimit)}">
<li jsf:rendered="#{DatasetPage.versionHasTabular and !(DatasetPage.tooLargeToDownloadArchival)}">
<p:commandLink update="@form" oncomplete="bind_bsui_components();"
actionListener="#{DatasetPage.validateAllFilesForDownloadArchival()}" styleClass="btn-download">
#{bundle.downloadArchival}
Expand All @@ -188,7 +183,7 @@
</h:outputFormat>
</p:commandLink>
</li>
<ui:fragment rendered="#{DatasetPage.versionHasTabular and (DatasetPage.sizeOfDatasetArchivalNumeric > settingsWrapper.zipDownloadLimit) }">
<ui:fragment rendered="#{DatasetPage.versionHasTabular and (DatasetPage.tooLargeToDownloadArchival) }">
<h:outputText value="#{bundle['dataset.accessBtn.archival.too.big']}">
</h:outputText>
</ui:fragment>
Expand All @@ -198,7 +193,7 @@
<!-- END: DOWNLOAD -->

<!-- Download either format too big-->
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and (DatasetPage.sizeOfDatasetNumeric > settingsWrapper.zipDownloadLimit) }">
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and (DatasetPage.tooLargeToDownload) }">
<h:outputText value="#{bundle['dataset.accessBtn.too.big']}">
</h:outputText>
</ui:fragment>
Expand Down

0 comments on commit 8225e18

Please sign in to comment.