Skip to content

Commit

Permalink
from cards, link to specific dataset versions #3937
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed May 7, 2014
1 parent 82b8ba2 commit 9995095
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/IndexServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ private String addOrUpdateDataset(IndexableDataset indexableDataset) {
datafileSolrInputDocument.addField(SearchFields.NAME_SORT, filenameCompleteFinal);
datafileSolrInputDocument.addField(SearchFields.FILE_NAME, filenameCompleteFinal);

datafileSolrInputDocument.addField(SearchFields.DATASET_VERSION_ID, datasetVersion.getId());

/**
* for rules on sorting files see
* https://docs.google.com/a/harvard.edu/document/d/1DWsEqT8KfheKZmMB3n_VhJpl9nIxiUjai_AIQPAjiyA/edit?usp=sharing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ public SolrQueryResponse search(DataverseUser dataverseUser, Dataverse dataverse
} else if (type.equals("files")) {
solrSearchResult.setName(name);
solrSearchResult.setFiletype(filetype);
solrSearchResult.setDatasetVersionId(datasetVersionId);
}
/**
* @todo store PARENT_ID as a long instead and cast as such
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/SolrSearchResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,12 @@ public void setDatasetVersionId(long datasetVersionId) {
this.datasetVersionId = datasetVersionId;
}

public String getDatasetUrl() {
return "/dataset.xhtml?id=" + entityId + "&versionId=" + datasetVersionId;
}

public String getFileUrl() {
return "/dataset.xhtml?id=" + parent.get(SearchFields.ID) + "&versionId=" + datasetVersionId;
}

}
10 changes: 5 additions & 5 deletions src/main/webapp/search-include-fragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
<!--DATASET CARDS-->
<ui:fragment rendered="#{result.type == 'datasets'}">
<div>
<h:outputLink value="/dataset.xhtml?id=#{result.entityId}">
<h:outputLink value="#{result.datasetUrl}">
<h:outputText value="#{result.title}" style="padding:4px 0;" rendered="#{result.titleHighlightSnippet == null}"/>
<h:outputText value="#{result.titleHighlightSnippet}" style="padding:4px 0;" rendered="#{result.titleHighlightSnippet != null}" escape="false"/>
<h:outputText value=" (#{result.status})" style="padding:4px 0;" rendered="#{SearchIncludeFragment.debug == true}"/>
Expand All @@ -514,7 +514,7 @@
<!--<span class="label label-default">Default</span>-->
<div style="width:48px; float:left; margin:4px 12px 6px 0;">
<!-- img src="/resources/images/icon_dataset.png" style="width:48px;" border="0" alt="Dataset"/ -->
<h:outputLink value="/dataset.xhtml?id=#{result.entityId}" style="display:block; clear:left; margin-bottom: .5em;">
<h:outputLink value="#{result.datasetUrl}" style="display:block; clear:left; margin-bottom: .5em;">
<p:graphicImage value="/api/access/dsPreview/#{result.entityId}"/>
</h:outputLink>
</div>
Expand Down Expand Up @@ -560,7 +560,7 @@
<ui:fragment rendered="#{result.type == 'files'}">
<div>
<!--FIXME: have a landing page for each file?-->
<h:outputLink value="/dataset.xhtml?id=#{result.parent.get('id')}">
<h:outputLink value="#{result.fileUrl}">
<h:outputText value="#{result.name}" style="padding:4px 0;" rendered="#{result.nameHighlightSnippet == null}"/>
<h:outputText value="#{result.nameHighlightSnippet}" style="padding:4px 0;" rendered="#{result.nameHighlightSnippet != null}" escape="false"/>
<h:outputText value=" (#{result.status})" style="padding:4px 0;" rendered="#{SearchIncludeFragment.debug == true}"/>
Expand All @@ -572,14 +572,14 @@
</div>
<div style="width:48px; float:left; margin:4px 12px 6px 0">
<!-- img src="/resources/images/icon_file.png" style="width:48px;" border="0" alt="Data File"/ -->
<h:outputLink value="/dataset.xhtml?id=#{result.parent.get('id')}" style="display:block; clear:left; margin-bottom: .5em;">
<h:outputLink value="#{result.fileUrl}" style="display:block; clear:left; margin-bottom: .5em;">
<p:graphicImage value="/api/access/preview/#{result.entityId}"/>
</h:outputLink>
</div>

<h:outputText value="#{result.dateToDisplayOnCard}" style="color:#999999; margin-right: .5em;"/>

<h:outputLink value="/dataset.xhtml?id=#{result.parent.get('id')}">
<h:outputLink value="#{result.fileUrl}">
<h:outputText value="Dataset: #{result.parent.get('name')}"/>
</h:outputLink>

Expand Down

0 comments on commit 9995095

Please sign in to comment.