Skip to content

Commit 195a584

Browse files
authored
Merge pull request #11750 from DANS-KNAW-jp/11737-encoded-facet-and-title-values
fix facet and title display with ' in the value
2 parents 407e9f9 + f8771c5 commit 195a584

File tree

6 files changed

+45
-10
lines changed

6 files changed

+45
-10
lines changed

src/main/java/edu/harvard/iq/dataverse/DatasetField.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,28 @@ public List<String> getValues_nondisplay()
374374
}
375375
return returnList;
376376
}
377+
/**
378+
* list of values (as opposed to display values).
379+
* used for passing to solr for indexing
380+
*/
381+
public List<String> getDisplayValues() {
382+
List returnList = new ArrayList();
383+
if (!datasetFieldValues.isEmpty()) {
384+
for (DatasetFieldValue dsfv : datasetFieldValues) {
385+
String value = dsfv.getDisplayValue();
386+
if (value != null) {
387+
returnList.add(value);
388+
}
389+
}
390+
} else {
391+
for (ControlledVocabularyValue cvv : controlledVocabularyValues) {
392+
if (cvv != null && cvv.getStrValue() != null) {
393+
returnList.add(cvv.getStrValue());
394+
}
395+
}
396+
}
397+
return returnList;
398+
}
377399

378400
/**
379401
* appears to be only used for sending info to solr; changed to return values

src/main/java/edu/harvard/iq/dataverse/DatasetPage.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ public enum DisplayMode {
303303
private String dropBoxSelection = "";
304304
private String deaccessionReasonText = "";
305305
private String displayCitation;
306+
private String displayTitle;
306307
private String deaccessionForwardURLFor = "";
307308
private String showVersionList = "false";
308309
private List<Template> dataverseTemplates = new ArrayList<>();
@@ -1649,6 +1650,14 @@ public void setDisplayCitation(String displayCitation) {
16491650
this.displayCitation = displayCitation;
16501651
}
16511652

1653+
public String getDisplayTitle() {
1654+
return displayTitle;
1655+
}
1656+
1657+
public void setDisplayTitle(String displayTitle) {
1658+
this.displayTitle = displayTitle;
1659+
}
1660+
16521661
public String getDropBoxSelection() {
16531662
return dropBoxSelection;
16541663
}
@@ -2112,6 +2121,8 @@ private String init(boolean initFull) {
21122121
JsfHelper.addWarningMessage(retrieveDatasetVersionResponse.getDifferentVersionMessage());//BundleUtil.getStringFromBundle("dataset.message.metadataSuccess"));
21132122
}
21142123

2124+
displayTitle = workingVersion.getTitle();
2125+
21152126
// init the citation
21162127
displayCitation = dataset.getCitation(true, workingVersion, isAnonymizedAccess());
21172128
logger.fine("Citation: " + displayCitation);

src/main/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ private List<Path> listCachedFiles() throws IOException {
608608
datasetDirectoryPath = Paths.get(getDatasetDirectory());
609609
}
610610

611-
if (datasetDirectoryPath == null) {
611+
if (datasetDirectoryPath == null) {
612612
throw new IOException("Could not determine the filesystem directory of the parent dataset.");
613613
}
614614

src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import java.time.format.DateTimeFormatter;
6060
import java.time.format.DateTimeParseException;
6161
import java.util.ArrayList;
62-
62+
import java.util.Arrays;
6363
import java.util.Calendar;
6464
import java.util.Collection;
6565
import java.util.Date;
@@ -86,6 +86,7 @@
8686
import jakarta.ejb.EJBException;
8787
import jakarta.ejb.Stateless;
8888
import jakarta.ejb.TransactionAttribute;
89+
8990
import static jakarta.ejb.TransactionAttributeType.REQUIRES_NEW;
9091

9192
import jakarta.inject.Inject;
@@ -236,7 +237,7 @@ public Future<String> indexDataverse(Dataverse dataverse, boolean processPaths)
236237
solrInputDocument.addField(SearchFields.RELEASE_OR_CREATE_DATE, dataverse.getCreateDate());
237238
}
238239

239-
/* We don't really have harvested dataverses yet;
240+
/* We don't really have harvested dataverses yet;
240241
(I have in fact just removed the isHarvested() method from the Dataverse object) -- L.A.
241242
if (dataverse.isHarvested()) {
242243
solrInputDocument.addField(SearchFields.IS_HARVESTED, true);
@@ -1061,7 +1062,6 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
10611062
if (datasetVersion.isInReview()) {
10621063
solrInputDocument.addField(SearchFields.PUBLICATION_STATUS, IN_REVIEW_STRING);
10631064
}
1064-
10651065
CurationStatus status = datasetVersion.getCurrentCurationStatus();
10661066
if(status != null && Strings.isNotBlank(status.getLabel())) {
10671067
solrInputDocument.addField(SearchFields.CURATION_STATUS, status.getLabel());
@@ -1306,7 +1306,9 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
13061306
solrInputDocument.addField(solrFieldFacetable, topicClassificationTerm);
13071307
}
13081308
} else {
1309-
solrInputDocument.addField(solrFieldFacetable, dsf.getValuesWithoutNaValues());
1309+
var values = dsf.getDisplayValues(); // for proper display of facets with &apos;
1310+
values.removeAll(Arrays.asList(DatasetField.NA_VALUE));
1311+
solrInputDocument.addField(solrFieldFacetable, values);
13101312
}
13111313
}
13121314
}
@@ -1753,7 +1755,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
17531755
GlobalId filePid = datafile.getGlobalId();
17541756
datafileSolrInputDocument.addField(SearchFields.FILE_PERSISTENT_ID,
17551757
(filePid != null) ? filePid.toString() : null);
1756-
1758+
17571759
datafileSolrInputDocument.addField(SearchFields.SUBTREE, dataversePaths);
17581760
// datafileSolrInputDocument.addField(SearchFields.HOST_DATAVERSE,
17591761
// dataFile.getOwner().getOwner().getName());
@@ -1774,7 +1776,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
17741776
datafileSolrInputDocument.addField(SearchFields.VARIABLE_COUNT, variables.size());
17751777
datafileSolrInputDocument.addField(SearchFields.OBSERVATIONS, observations);
17761778
datafileSolrInputDocument.addField(SearchFields.UNF, dtable.getUnf());
1777-
1779+
17781780

17791781
Map<Long, VariableMetadata> variableMap = null;
17801782
Collection<VariableMetadata> variablesByMetadata = fileMetadata.getVariableMetadatas();

src/main/webapp/dataset.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@
161161
<div class="row" jsf:rendered="#{empty DatasetPage.editMode}">
162162
<div class="col-xs-12">
163163
<div id="datasetVersionBlock" class="row">
164-
<div id="title-block" class="col-xs-12 margin-bottom-half" jsf:rendered="#{!empty DatasetPage.datasetVersionUI.title.value}">
165-
<h1 id="title">#{DatasetPage.datasetVersionUI.title.value}</h1>
164+
<div id="title-block" class="col-xs-12 margin-bottom-half" jsf:rendered="#{!empty DatasetPage.displayTitle}">
165+
<h1 id="title">#{DatasetPage.displayTitle}</h1>
166166
<div id="title-label-block" class="margin-top-half">
167167
<!-- DATASET Publication Status -->
168168
<h:outputText value="#{bundle['dataset.versionUI.draft']}" styleClass="label label-primary" rendered="#{version.draft}"/>

src/main/webapp/search-include-fragment.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@
570570
<span class="glyphicon glyphicon-new-window text-info pull-right" title="#{bundle.harvested}" jsf:rendered="#{result.harvested}"/>
571571
<span class="icon-dataset text-info pull-right" title="#{bundle.dataset}"/>
572572
<a href="#{!SearchIncludeFragment.rootDv and !result.isInTree ? result.datasetUrl : widgetWrapper.wrapURL(result.datasetUrl)}" target="#{(!SearchIncludeFragment.rootDv and !result.isInTree and widgetWrapper.widgetView) or result.harvested ? '_blank' : ''}">
573-
<h:outputText value="#{result.title}" style="padding:4px 0;" rendered="#{result.titleHighlightSnippet == null}"/>
573+
<h:outputText value="#{result.nameSort}" style="padding:4px 0;" rendered="#{result.titleHighlightSnippet == null}"/>
574574
<h:outputText value="#{result.titleHighlightSnippet}" style="padding:4px 0;" rendered="#{result.titleHighlightSnippet != null}" escape="false"/>
575575
<h:outputText value=" (#{result.entityId})" style="padding:4px 0;" rendered="#{dataverseSession.debug}"/></a>
576576

0 commit comments

Comments
 (0)