Skip to content

Commit

Permalink
replace hard-coded "Match", look up in bundle #4158
Browse files Browse the repository at this point in the history
"Match" was showing up because the bundle key didn't exist. We are
switching away from the deprecated "JsfHelper.localize" method.
  • Loading branch information
pdurbin committed Mar 27, 2018
1 parent 1c46b33 commit a7fd43a
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser;
import edu.harvard.iq.dataverse.authorization.users.User;
import edu.harvard.iq.dataverse.engine.command.DataverseRequest;
import edu.harvard.iq.dataverse.util.JsfHelper;
import edu.harvard.iq.dataverse.util.BundleUtil;
import edu.harvard.iq.dataverse.util.SystemConfig;
import java.io.IOException;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -76,7 +76,6 @@ public class SearchServiceBean {
@EJB
SystemConfig systemConfig;

public static final JsfHelper JH = new JsfHelper();
private SolrClient solrServer;

@PostConstruct
Expand Down Expand Up @@ -170,6 +169,7 @@ public SolrQueryResponse search(DataverseRequest dataverseRequest, Dataverse dat
solrQuery.setHighlightSimplePre("<span class=\"search-term-match\">");
solrQuery.setHighlightSimplePost("</span>");
Map<String, String> solrFieldsToHightlightOnMap = new HashMap<>();
// TODO: Do not hard code "Name" etc as English here.
solrFieldsToHightlightOnMap.put(SearchFields.NAME, "Name");
solrFieldsToHightlightOnMap.put(SearchFields.AFFILIATION, "Affiliation");
solrFieldsToHightlightOnMap.put(SearchFields.FILE_TYPE_FRIENDLY, "File Type");
Expand All @@ -178,7 +178,7 @@ public SolrQueryResponse search(DataverseRequest dataverseRequest, Dataverse dat
solrFieldsToHightlightOnMap.put(SearchFields.VARIABLE_LABEL, "Variable Label");
solrFieldsToHightlightOnMap.put(SearchFields.FILE_TYPE_SEARCHABLE, "File Type");
solrFieldsToHightlightOnMap.put(SearchFields.DATASET_PUBLICATION_DATE, "Publication Date");
solrFieldsToHightlightOnMap.put(SearchFields.DATASET_PERSISTENT_ID, localize("advanced.search.datasets.persistentId"));
solrFieldsToHightlightOnMap.put(SearchFields.DATASET_PERSISTENT_ID, BundleUtil.getStringFromBundle("dataset.metadata.persistentId"));
/**
* @todo Dataverse subject and affiliation should be highlighted but
* this is commented out right now because the "friendly" names are not
Expand Down Expand Up @@ -744,16 +744,6 @@ public SolrQueryResponse search(DataverseRequest dataverseRequest, Dataverse dat
return solrQueryResponse;
}

private static String localize(String bundleKey) {
try {
String value = JH.localize(bundleKey);
return value;
} catch (Exception e) {
// can throw MissingResourceException
return "Match";
}
}

public String getCapitalizedName(String name) {
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
Expand Down

0 comments on commit a7fd43a

Please sign in to comment.