Skip to content

Commit 245def2

Browse files
committed
- Include the PubMedId in the make public URL included in the "found publication" message.
- Improve author match and title match logic
1 parent 705b09c commit 245def2

7 files changed

Lines changed: 179 additions & 66 deletions

panoramapublic/src/org/labkey/panoramapublic/PanoramaPublicController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6951,7 +6951,6 @@ public ModelAndView getView(PublicationDetailsForm form, boolean reshow, BindExc
69516951
return new SimpleErrorView(errors);
69526952
}
69536953

6954-
form.setPubmedId(_copiedExperiment.getPubmedId());
69556954
form.setLink(_copiedExperiment.getPublicationLink());
69566955
form.setCitation(_copiedExperiment.getCitation());
69576956
return getPublicationDetailsView(form, errors);

panoramapublic/src/org/labkey/panoramapublic/PanoramaPublicNotification.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,12 @@ public static String getDataStatusReminderMessage(@NotNull ExperimentAnnotations
410410
@Nullable PublicationMatch articleMatch)
411411
{
412412
String shortUrl = exptAnnotations.getShortUrl().renderShortURL();
413-
String makePublicLink = PanoramaPublicController.getMakePublicUrl(exptAnnotations.getId(), exptAnnotations.getContainer()).getURIString();
413+
ActionURL makePublicUrl = PanoramaPublicController.getMakePublicUrl(exptAnnotations.getId(), exptAnnotations.getContainer());
414+
if (articleMatch != null && articleMatch.isPubMed() && articleMatch.getPublicationId() != null)
415+
{
416+
makePublicUrl.replaceParameter("pubmedId", articleMatch.getPublicationId());
417+
}
418+
String makePublicLink = makePublicUrl.getURIString();
414419
String dateString = DateUtil.formatDateTime(js.getLatestSubmission().getCreated(), PrivateDataReminderSettings.DATE_FORMAT_PATTERN);
415420

416421
ActionURL viewMessageUrl = new ActionURL("announcements", "thread", announcementContainer)
@@ -446,6 +451,7 @@ public static String getDataStatusReminderMessage(@NotNull ExperimentAnnotations
446451
.append(NL2).append("If this is indeed your paper, congratulations! We encourage you to make your data public so the research community can access it alongside your paper. ")
447452
.append("You can do this by clicking the \"Make Public\" button in your data folder or by clicking this link: ")
448453
.append(bold(link("Make Data Public", makePublicLink))).append(".")
454+
.append(articleMatch.isPubMed() ? " Please enter " + articleMatch.getPublicationId() + " in the PubMed ID field." : "")
449455
.append(NL2).append("If this paper is not associated with your data please let us know by clicking ")
450456
.append(bold(link("Dismiss Publication Suggestion", dismissPublicationUrl.getURIString())));
451457
}

panoramapublic/src/org/labkey/panoramapublic/ncbi/MockNcbiPublicationSearchService.java

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.jetbrains.annotations.Nullable;
44
import org.json.JSONArray;
55
import org.json.JSONObject;
6-
import org.labkey.panoramapublic.ncbi.NcbiConstants.DB;
76

87
import java.io.IOException;
98
import java.util.ArrayList;
@@ -14,13 +13,12 @@
1413
/**
1514
* Mock implementation of {@link NcbiPublicationSearchService} that returns canned data registered by tests.
1615
* Used by Selenium tests when running on TeamCity.
17-
* Extends {@link NcbiPublicationSearchServiceImpl} and only overrides the two methods that make HTTP calls
18-
* to NCBI: {@link #getJson(String)} (used by ESearch/ESummary) and {@link #getCitation(String, DB)}
19-
* (used for the Citation Exporter API). All search logic, filtering, author/title verification, and
20-
* priority filtering run through the real implementation code.
16+
* Extends {@link NcbiPublicationSearchServiceImpl} and only overrides {@link #getString(String)},
17+
* the single method that makes HTTP calls to NCBI. All search logic, filtering, author/title
18+
* verification, citation parsing, and priority filtering run through the real implementation code.
2119
* Tests register mock articles via {@link #register}, providing the database, ID, search key,
2220
* metadata fields, and citation. The mock builds internal lookup maps from this data and returns
23-
* appropriate JSON responses when the real search logic calls {@code getJson()} or {@code getCitation()}.
21+
* appropriate responses when the real search logic calls {@code getString()}.
2422
*/
2523
public class MockNcbiPublicationSearchService extends NcbiPublicationSearchServiceImpl
2624
{
@@ -37,7 +35,7 @@ public class MockNcbiPublicationSearchService extends NcbiPublicationSearchServi
3735

3836
/**
3937
* Register a mock article. The mock stores the data in internal lookup maps used by
40-
* {@link #getJson(String)} and {@link #getCitation(String, DB)}.
38+
* {@link #getString(String)}.
4139
* @param database "pmc" or "pubmed" — the NCBI database this article is in
4240
* @param id the article ID in the given database (numeric ID for pmc or pubmed)
4341
* @param searchKey what ESearch query term finds this article (e.g. PXD ID for PMC, author last name for PubMed)
@@ -115,31 +113,27 @@ public void register(String database, String id, String searchKey,
115113
}
116114

117115
/**
118-
* Returns canned JSON for NCBI ESearch and ESummary API requests based on registered mock data.
116+
* Returns canned responses for NCBI API requests based on registered mock data.
117+
* Handles ESearch, ESummary, and Citation Exporter URLs.
119118
*/
120119
@Override
121-
protected JSONObject getJson(String url) throws IOException
120+
protected String getString(String url) throws IOException
122121
{
123122
if (url.contains("esearch.fcgi"))
124123
{
125-
return handleESearch(url);
124+
return handleESearch(url).toString();
126125
}
127126
else if (url.contains("esummary.fcgi"))
128127
{
129-
return handleESummary(url);
128+
return handleESummary(url).toString();
129+
}
130+
else if (url.contains("lit/ctxp"))
131+
{
132+
return handleCitation(url).toString();
130133
}
131134
throw new IOException("MockNcbiPublicationSearchService: unexpected URL: " + url);
132135
}
133136

134-
/**
135-
* Returns the registered citation for the given PubMed ID, or null if not registered.
136-
*/
137-
@Override
138-
public @Nullable String getCitation(String pubMedId, DB database)
139-
{
140-
return _citations.get(pubMedId);
141-
}
142-
143137
private JSONObject handleESearch(String url)
144138
{
145139
boolean isPmc = url.contains("db=pmc");
@@ -175,4 +169,33 @@ private JSONObject handleESummary(String url)
175169

176170
return new JSONObject().put("result", result);
177171
}
172+
173+
/**
174+
* Build a citation JSON response matching the NCBI Literature Citation Exporter format.
175+
* The real API returns {@code {"nlm":{"orig":"citation text..."}}}.
176+
* If no citation is registered for the ID, returns an empty JSON object.
177+
*/
178+
private JSONObject handleCitation(String url)
179+
{
180+
// Extract the publication ID from the URL (last segment after "id=")
181+
String id = null;
182+
int idIdx = url.indexOf("id=");
183+
if (idIdx >= 0)
184+
{
185+
id = url.substring(idIdx + 3);
186+
// Remove any trailing query parameters
187+
int ampIdx = id.indexOf('&');
188+
if (ampIdx >= 0)
189+
{
190+
id = id.substring(0, ampIdx);
191+
}
192+
}
193+
194+
String citation = id != null ? _citations.get(id) : null;
195+
if (citation != null)
196+
{
197+
return new JSONObject().put("nlm", new JSONObject().put("orig", citation));
198+
}
199+
return new JSONObject();
200+
}
178201
}

0 commit comments

Comments
 (0)