Skip to content

Commit 49925e0

Browse files
committed
- Moved check for isNcbiReachable to PublicationSearchTest.java
- Added API action class to register mock publication data with the MockNcbiPublicationSearchService - Updated PublicationSearchTest - test one more dataset
1 parent e2b3637 commit 49925e0

9 files changed

Lines changed: 478 additions & 266 deletions

File tree

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

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@
183183
import org.labkey.panoramapublic.proteomexchange.ChemElement;
184184
import org.labkey.panoramapublic.proteomexchange.ExperimentModificationGetter;
185185
import org.labkey.panoramapublic.proteomexchange.Formula;
186-
import org.labkey.panoramapublic.ncbi.NcbiConstants;
187186
import org.labkey.panoramapublic.ncbi.NcbiConstants.DB;
188187
import org.labkey.panoramapublic.proteomexchange.NcbiUtils;
189188
import org.labkey.panoramapublic.proteomexchange.ProteomeXchangeService;
@@ -10458,7 +10457,7 @@ public abstract static class UpdateDatasetStatusAction extends ConfirmAction<Sho
1045810457
protected abstract void updateDatasetStatus(DatasetStatus datasetStatus);
1045910458
protected abstract void postNotification();
1046010459
protected abstract String getConfirmViewTitle();
10461-
protected abstract String getConfirmViewMessage();
10460+
protected abstract HtmlString getConfirmViewMessage();
1046210461

1046310462
@Override
1046410463
public ModelAndView getConfirmView(ShortUrlForm shortUrlForm, BindException errors) throws Exception
@@ -10535,9 +10534,9 @@ protected String getConfirmViewTitle()
1053510534
}
1053610535

1053710536
@Override
10538-
protected String getConfirmViewMessage()
10537+
protected HtmlString getConfirmViewMessage()
1053910538
{
10540-
return "You are requesting an extension for the private data on Panorama Public at " + _exptAnnotations.getShortUrl().renderShortURL();
10539+
return HtmlString.of("You are requesting an extension for the private data on Panorama Public at " + _exptAnnotations.getShortUrl().renderShortURL());
1054110540
}
1054210541

1054310542
@Override
@@ -10599,9 +10598,9 @@ protected String getConfirmViewTitle()
1059910598
}
1060010599

1060110600
@Override
10602-
protected String getConfirmViewMessage()
10601+
protected HtmlString getConfirmViewMessage()
1060310602
{
10604-
return "You are requesting deletion of the private data on Panorama Public at " + _exptAnnotations.getShortUrl().renderShortURL();
10603+
return HtmlString.of("You are requesting deletion of the private data on Panorama Public at " + _exptAnnotations.getShortUrl().renderShortURL());
1060510604
}
1060610605

1060710606
@Override
@@ -10657,15 +10656,15 @@ protected String getConfirmViewTitle()
1065710656
}
1065810657

1065910658
@Override
10660-
protected String getConfirmViewMessage()
10659+
protected HtmlString getConfirmViewMessage()
1066110660
{
1066210661
String publicationRef = _publicationMatch.getCitation() != null
1066310662
? _publicationMatch.getCitation()
10664-
: _publicationMatch.getPublicationLabel();
10665-
return "You are dismissing the publication suggestion for your data on Panorama Public at "
10663+
: _publicationMatch.getPublicationIdLabel();
10664+
return HtmlString.of("You are dismissing the publication suggestion for your data on Panorama Public at "
1066610665
+ _exptAnnotations.getShortUrl().renderShortURL() +
10667-
". We will no longer suggest the following publication for this dataset - "
10668-
+ "\n\n" + publicationRef;
10666+
". We will no longer suggest the following publication for this dataset - " +
10667+
HtmlString.BR + publicationRef);
1066910668
}
1067010669

1067110670
@Override
@@ -10930,7 +10929,7 @@ public boolean handlePost(NotifySubmitterForm form, BindException errors) throws
1093010929
&& form.getPublicationId().equals(datasetStatus.getPotentialPublicationId()))
1093110930
{
1093210931
errors.reject(ERROR_MSG, "The user has already dismissed the publication suggestion "
10933-
+ datasetStatus.getPublicationLabel() + " " + datasetStatus.getPotentialPublicationId()
10932+
+ datasetStatus.getPublicationIdLabel()
1093410933
+ " for this dataset.");
1093510934
return false;
1093610935
}
@@ -11186,49 +11185,94 @@ public static ActionURL getCatalogImageDownloadUrl(ExperimentAnnotations expAnno
1118611185
.addParameter("name", filename);
1118711186
}
1118811187

11189-
// ======================== Test support actions for Selenium tests ========================
11188+
// ======================== Support actions for Selenium tests ========================
1119011189

1119111190
@RequiresSiteAdmin
11192-
public static class SetupMockNcbiServiceAction extends ReadOnlyApiAction<SetupMockForm>
11191+
public static class SetupMockNcbiServiceAction extends ReadOnlyApiAction<Object>
1119311192
{
1119411193
@Override
11195-
public Object execute(SetupMockForm form, BindException errors)
11194+
public Object execute(Object form, BindException errors)
1119611195
{
11197-
if (form.isCheckNcbiReachable() && NcbiPublicationSearchServiceImpl.isNcbiReachable())
11198-
{
11199-
return new ApiSimpleResponse("mock", false);
11200-
}
1120111196
NcbiPublicationSearchServiceImpl.setInstance(new MockNcbiPublicationSearchService());
1120211197
return new ApiSimpleResponse("mock", true);
1120311198
}
1120411199
}
1120511200

11206-
public static class SetupMockForm
11201+
@RequiresSiteAdmin
11202+
public static class RestoreNcbiServiceAction extends ReadOnlyApiAction<Object>
1120711203
{
11208-
private boolean _checkNcbiReachable;
11209-
11210-
public boolean isCheckNcbiReachable()
11211-
{
11212-
return _checkNcbiReachable;
11213-
}
11214-
11215-
public void setCheckNcbiReachable(boolean checkNcbiReachable)
11204+
@Override
11205+
public Object execute(Object form, BindException errors)
1121611206
{
11217-
_checkNcbiReachable = checkNcbiReachable;
11207+
NcbiPublicationSearchServiceImpl.setInstance(new NcbiPublicationSearchServiceImpl());
11208+
return new ApiSimpleResponse("restored", true);
1121811209
}
1121911210
}
1122011211

1122111212
@RequiresSiteAdmin
11222-
public static class RestoreNcbiServiceAction extends ReadOnlyApiAction<Object>
11213+
public static class RegisterMockPublicationAction extends ReadOnlyApiAction<RegisterMockPublicationForm>
1122311214
{
1122411215
@Override
11225-
public Object execute(Object form, BindException errors)
11216+
public Object execute(RegisterMockPublicationForm form, BindException errors)
1122611217
{
11227-
NcbiPublicationSearchServiceImpl.setInstance(new NcbiPublicationSearchServiceImpl());
11228-
return new ApiSimpleResponse("restored", true);
11218+
NcbiPublicationSearchService service = NcbiPublicationSearchServiceImpl.getInstance();
11219+
if (!(service instanceof MockNcbiPublicationSearchService mock))
11220+
{
11221+
errors.reject(ERROR_MSG, "Mock NCBI service is not available. Call setupMockNcbiService first.");
11222+
return null;
11223+
}
11224+
mock.register(form.getDatabase(), form.getId(), form.getSearchKey(),
11225+
form.getPmid(), form.getTitle(), form.getAuthors(),
11226+
form.getPubDate(), form.getSource(), form.getJournalFull(),
11227+
form.getCitation());
11228+
return new ApiSimpleResponse("registered", true);
1122911229
}
1123011230
}
1123111231

11232+
public static class RegisterMockPublicationForm
11233+
{
11234+
private String _database;
11235+
private String _id;
11236+
private String _searchKey;
11237+
private String _pmid;
11238+
private String _title;
11239+
private String _authors;
11240+
private String _pubDate;
11241+
private String _source;
11242+
private String _journalFull;
11243+
private String _citation;
11244+
11245+
public String getDatabase() { return _database; }
11246+
public void setDatabase(String database) { _database = database; }
11247+
11248+
public String getId() { return _id; }
11249+
public void setId(String id) { _id = id; }
11250+
11251+
public String getSearchKey() { return _searchKey; }
11252+
public void setSearchKey(String searchKey) { _searchKey = searchKey; }
11253+
11254+
public String getPmid() { return _pmid; }
11255+
public void setPmid(String pmid) { _pmid = pmid; }
11256+
11257+
public String getTitle() { return _title; }
11258+
public void setTitle(String title) { _title = title; }
11259+
11260+
public String getAuthors() { return _authors; }
11261+
public void setAuthors(String authors) { _authors = authors; }
11262+
11263+
public String getPubDate() { return _pubDate; }
11264+
public void setPubDate(String pubDate) { _pubDate = pubDate; }
11265+
11266+
public String getSource() { return _source; }
11267+
public void setSource(String source) { _source = source; }
11268+
11269+
public String getJournalFull() { return _journalFull; }
11270+
public void setJournalFull(String journalFull) { _journalFull = journalFull; }
11271+
11272+
public String getCitation() { return _citation; }
11273+
public void setCitation(String citation) { _citation = citation; }
11274+
}
11275+
1123211276
public static class TestCase extends AbstractActionPermissionTest
1123311277
{
1123411278
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static void postPublicationDismissalMessage(@NotNull Journal journal, @No
374374
messageBody.append("Dear ").append(getUserName(submitter)).append(",").append(NL2);
375375
messageBody.append("Thank you for letting us know that the suggested paper is not associated with your data on Panorama Public.");
376376

377-
messageBody.append(NL2).append(bold("Dismissed Publication:")).append(" ").append(publicationMatch.getPublicationLabel());
377+
messageBody.append(NL2).append(bold("Dismissed Publication:")).append(" ").append(publicationMatch.getPublicationIdLabel());
378378
if (!StringUtils.isBlank(publicationMatch.getCitation()))
379379
{
380380
messageBody.append(NL).append(publicationMatch.getCitation());
@@ -437,12 +437,12 @@ public static String getDataStatusReminderMessage(@NotNull ExperimentAnnotations
437437
if (articleMatch != null)
438438
{
439439
// Message variant when a publication was found
440-
message.append("We found a paper that appears to be associated with your private data on Panorama Public.")
440+
message.append("We found a paper that appears to be associated with your private data on Panorama Public (").append(shortUrl).append(").")
441441
.append(NL2).append(bold("Title:")).append(" ").append(escape(exptAnnotations.getTitle()))
442442
.append(NL2).append(bold("Publication Found:")).append(" ")
443443
.append(articleMatch.getCitation() != null
444444
? link(articleMatch.getCitation(), articleMatch.getPublicationUrl())
445-
: link(articleMatch.getPublicationLabel(), articleMatch.getPublicationUrl()))
445+
: link(articleMatch.getPublicationIdLabel(), articleMatch.getPublicationUrl()))
446446
.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. ")
447447
.append("You can do this by clicking the \"Make Public\" button in your data folder or by clicking this link: ")
448448
.append(bold(link("Make Data Public", makePublicLink))).append(".")

panoramapublic/src/org/labkey/panoramapublic/model/DatasetStatus.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ public void setPublicationType(String publicationType)
9898
_publicationType = publicationType;
9999
}
100100

101-
public String getPublicationLabel()
101+
public String getPublicationIdLabel()
102102
{
103103
NcbiConstants.DB type = NcbiConstants.DB.fromString(_publicationType);
104-
if (type == null)
105-
{
106-
return _publicationType != null ? _publicationType : "";
107-
}
108-
return type.getLabel();
104+
String label = type == null ? (_publicationType != null ? _publicationType : "") : type.getLabel();
105+
return label + " ID " + getPotentialPublicationId();
109106
}
110107

111108
public String getPublicationMatchInfo()

0 commit comments

Comments
 (0)