Skip to content

Commit 0d2b348

Browse files
committed
fix facet and title display with ' in the value
1 parent 7be6af8 commit 0d2b348

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,29 @@ 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+
{
383+
List returnList = new ArrayList();
384+
if (!datasetFieldValues.isEmpty()) {
385+
for (DatasetFieldValue dsfv : datasetFieldValues) {
386+
String value = dsfv.getDisplayValue();
387+
if (value != null) {
388+
returnList.add(value);
389+
}
390+
}
391+
} else {
392+
for (ControlledVocabularyValue cvv : controlledVocabularyValues) {
393+
if (cvv != null && cvv.getStrValue() != null) {
394+
returnList.add(cvv.getStrValue());
395+
}
396+
}
397+
}
398+
return returnList;
399+
}
377400

378401
/**
379402
* 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import edu.harvard.iq.dataverse.engine.command.impl.PublishDataverseCommand;
3939
import edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetVersionCommand;
4040
import edu.harvard.iq.dataverse.export.ExportService;
41+
import edu.harvard.iq.dataverse.util.MarkupChecker;
4142
import edu.harvard.iq.dataverse.util.cache.CacheFactoryBean;
4243
import io.gdcc.spi.export.ExportException;
4344
import io.gdcc.spi.export.Exporter;
@@ -303,6 +304,7 @@ public enum DisplayMode {
303304
private String dropBoxSelection = "";
304305
private String deaccessionReasonText = "";
305306
private String displayCitation;
307+
private String displayTitle;
306308
private String deaccessionForwardURLFor = "";
307309
private String showVersionList = "false";
308310
private List<Template> dataverseTemplates = new ArrayList<>();
@@ -1649,6 +1651,15 @@ public void setDisplayCitation(String displayCitation) {
16491651
this.displayCitation = displayCitation;
16501652
}
16511653

1654+
public String getDisplayTitle() {
1655+
//displayCitation = dataset.getCitation(false, workingVersion);
1656+
return displayTitle;
1657+
}
1658+
1659+
public void setDisplayTitle(String displayCitation) {
1660+
this.displayCitation = displayTitle;
1661+
}
1662+
16521663
public String getDropBoxSelection() {
16531664
return dropBoxSelection;
16541665
}
@@ -2112,6 +2123,8 @@ private String init(boolean initFull) {
21122123
JsfHelper.addWarningMessage(retrieveDatasetVersionResponse.getDifferentVersionMessage());//BundleUtil.getStringFromBundle("dataset.message.metadataSuccess"));
21132124
}
21142125

2126+
displayTitle = workingVersion.getTitle();
2127+
21152128
// init the citation
21162129
displayCitation = dataset.getCitation(true, workingVersion, isAnonymizedAccess());
21172130
logger.fine("Citation: " + displayCitation);

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

Lines changed: 13 additions & 9 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;
@@ -85,6 +85,8 @@
8585
import jakarta.ejb.EJBException;
8686
import jakarta.ejb.Stateless;
8787
import jakarta.ejb.TransactionAttribute;
88+
89+
import static edu.harvard.iq.dataverse.DatasetField.NA_VALUE;
8890
import static jakarta.ejb.TransactionAttributeType.REQUIRES_NEW;
8991

9092
import jakarta.inject.Inject;
@@ -235,7 +237,7 @@ public Future<String> indexDataverse(Dataverse dataverse, boolean processPaths)
235237
solrInputDocument.addField(SearchFields.RELEASE_OR_CREATE_DATE, dataverse.getCreateDate());
236238
}
237239

238-
/* We don't really have harvested dataverses yet;
240+
/* We don't really have harvested dataverses yet;
239241
(I have in fact just removed the isHarvested() method from the Dataverse object) -- L.A.
240242
if (dataverse.isHarvested()) {
241243
solrInputDocument.addField(SearchFields.IS_HARVESTED, true);
@@ -265,7 +267,7 @@ public Future<String> indexDataverse(Dataverse dataverse, boolean processPaths)
265267
Set<String> langs = settingsService.getConfiguredLanguages();
266268
for (ControlledVocabularyValue dataverseSubject : dataverse.getDataverseSubjects()) {
267269
String subject = dataverseSubject.getStrValue();
268-
if (!subject.equals(DatasetField.NA_VALUE)) {
270+
if (!subject.equals(NA_VALUE)) {
269271
// Index in all used languages (display and metadata languages
270272
for(String locale: langs) {
271273
solrInputDocument.addField(SearchFields.DATAVERSE_SUBJECT, dataverseSubject.getLocaleStrValue(locale));
@@ -1060,7 +1062,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
10601062
if (datasetVersion.isInReview()) {
10611063
solrInputDocument.addField(SearchFields.PUBLICATION_STATUS, IN_REVIEW_STRING);
10621064
}
1063-
1065+
10641066
CurationStatus status = datasetVersion.getCurrentCurationStatus();
10651067
if(status != null && Strings.isNotBlank(status.getLabel())) {
10661068
solrInputDocument.addField(SearchFields.CURATION_STATUS, status.getLabel());
@@ -1258,7 +1260,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
12581260
*/
12591261
if (dsf.getControlledVocabularyValues().isEmpty()) {
12601262
for (DatasetFieldValue dfv : dsf.getDatasetFieldValues()) {
1261-
if (dfv.getValue() == null || dfv.getValue().equals(DatasetField.NA_VALUE)) {
1263+
if (dfv.getValue() == null || dfv.getValue().equals(NA_VALUE)) {
12621264
continue;
12631265
}
12641266
solrInputDocument.addField(solrFieldSearchable, dfv.getValue());
@@ -1269,7 +1271,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
12691271
}
12701272
} else {
12711273
for (ControlledVocabularyValue controlledVocabularyValue : dsf.getControlledVocabularyValues()) {
1272-
if (controlledVocabularyValue.getStrValue().equals(DatasetField.NA_VALUE)) {
1274+
if (controlledVocabularyValue.getStrValue().equals(NA_VALUE)) {
12731275
continue;
12741276
}
12751277

@@ -1305,7 +1307,9 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
13051307
solrInputDocument.addField(solrFieldFacetable, topicClassificationTerm);
13061308
}
13071309
} else {
1308-
solrInputDocument.addField(solrFieldFacetable, dsf.getValuesWithoutNaValues());
1310+
var values = dsf.getDisplayValues(); // for proper display of facets with &apos;
1311+
values.removeAll(Arrays.asList(NA_VALUE));
1312+
solrInputDocument.addField(solrFieldFacetable, values);
13091313
}
13101314
}
13111315
}
@@ -1722,7 +1726,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
17221726
GlobalId filePid = datafile.getGlobalId();
17231727
datafileSolrInputDocument.addField(SearchFields.FILE_PERSISTENT_ID,
17241728
(filePid != null) ? filePid.toString() : null);
1725-
1729+
17261730
datafileSolrInputDocument.addField(SearchFields.SUBTREE, dataversePaths);
17271731
// datafileSolrInputDocument.addField(SearchFields.HOST_DATAVERSE,
17281732
// dataFile.getOwner().getOwner().getName());
@@ -1743,7 +1747,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
17431747
datafileSolrInputDocument.addField(SearchFields.VARIABLE_COUNT, variables.size());
17441748
datafileSolrInputDocument.addField(SearchFields.OBSERVATIONS, observations);
17451749
datafileSolrInputDocument.addField(SearchFields.UNF, dtable.getUnf());
1746-
1750+
17471751

17481752
Map<Long, VariableMetadata> variableMap = null;
17491753
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)