Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit fac4bc4

Browse files
author
sowerstl
committed
Remove DOI from Search data if no Release Date; (DOECODE-542)
1 parent 32954bb commit fac4bc4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/gov/osti/services/SearchService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public Response getSingleRecord(@PathParam("codeId") Long codeId, @QueryParam("f
185185
// convert it to a POJO
186186
DOECodeMetadata md = DOECodeMetadata.parseJson(new StringReader(doc.getJson()));
187187

188+
// if no release date, don't return the DOI for display in search results.
189+
if (!StringUtils.isBlank(md.getDoi()) && md.getReleaseDate() == null)
190+
md.setDoi(null);
191+
188192
// if YAML is requested, return that; otherwise, default to JSON
189193
if ("yaml".equals(format)) {
190194
// return the YAML
@@ -376,7 +380,14 @@ private Response search(String parameters, String format) {
376380
// if there are matched documents, load them in
377381
if ( null!=result.getSearchResponse().getDocuments() ) {
378382
for ( SolrDocument doc : result.getSearchResponse().getDocuments() ) {
379-
query.add(JSON_MAPPER.readValue(doc.getJson(), DOECodeMetadata.class));
383+
// convert it to a POJO
384+
DOECodeMetadata md = JSON_MAPPER.readValue(doc.getJson(), DOECodeMetadata.class);
385+
386+
// if no release date, don't return the DOI for display in search results.
387+
if (!StringUtils.isBlank(md.getDoi()) && md.getReleaseDate() == null)
388+
md.setDoi(null);
389+
390+
query.add(md);
380391
}
381392
// check out the FACETS
382393
query.setFacets(result.getSolrFacet().getValues());

0 commit comments

Comments
 (0)