Skip to content

Commit

Permalink
use version to determine if tabular download #6118
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jul 16, 2020
1 parent 115353c commit 7e79f1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
26 changes: 24 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ public enum DisplayMode {
private Boolean hasRsyncScript = false;

private Boolean hasTabular = false;

/**
* If the dataset version has at least one tabular file. The "hasTabular"
* boolean is for the dataset level ("has ever had a tabular file") but
* sometimes you want to know about the current version ("no tabular files
* currently"). Like all files, tabular files can be deleted.
*/
private boolean versionHasTabular = false;

private boolean showIngestSuccess;

Expand Down Expand Up @@ -2040,7 +2048,18 @@ private String init(boolean initFull) {

displayLockInfo(dataset);

for (FileMetadata fmd : workingVersion.getFileMetadatas()) {
if (fmd.getDataFile().isTabularData()) {
versionHasTabular = true;
break;
}
}
for(DataFile f : dataset.getFiles()) {
// TODO: Consider uncommenting this optimization.
// if (versionHasTabular) {
// hasTabular = true;
// break;
// }
if(f.isTabularData()) {
hasTabular = true;
break;
Expand Down Expand Up @@ -2260,8 +2279,11 @@ private DefaultTreeNode createFileTreeNode(FileMetadata fileMetadata, TreeNode p
public boolean isHasTabular() {
return hasTabular;
}



public boolean isVersionHasTabular() {
return versionHasTabular;
}

public boolean isReadOnly() {
return readOnly;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<ui:fragment rendered="#{DatasetPage.canDownloadFiles()}">
<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.isHasTabular()}">
<li jsf:rendered="#{!DatasetPage.versionHasTabular}">
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadArchival()}" styleClass="btn-download">
#{bundle.download}
<h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
Expand All @@ -152,7 +152,7 @@
</p:commandLink>
</li>
<!-- DOWNLOAD ORIGINAL BUTTON (TABULAR FILES PRESENT) -->
<li jsf:rendered="#{DatasetPage.isHasTabular()}">
<li jsf:rendered="#{DatasetPage.versionHasTabular}">
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadOriginal()}" styleClass="btn-download">
#{bundle.downloadOriginal}
<h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
Expand All @@ -161,7 +161,7 @@
</p:commandLink>
</li>
<!-- DOWNLOAD ARCHIVAL FILES (TABULAR FILES PRESENT) -->
<li jsf:rendered="#{DatasetPage.isHasTabular()}">
<li jsf:rendered="#{DatasetPage.versionHasTabular}">
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadArchival()}" styleClass="btn-download">
#{bundle.downloadArchival}
<h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
Expand Down

0 comments on commit 7e79f1b

Please sign in to comment.