Skip to content

Commit ef291b5

Browse files
committed
- Updated notification messages
- Moved date calculations to PrivateDateReminderSettings. Added unit tests - Improvements to PrivateDataReminderJob - Fixed PrivateDataReminderTest
1 parent 19fc8e5 commit ef291b5

9 files changed

Lines changed: 757 additions & 269 deletions

File tree

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

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10098,23 +10098,23 @@ public void validateCommand(PrivateDataReminderSettingsForm form, Errors errors)
1009810098
}
1009910099
else if (form.getDelayUntilFirstReminder() < 0)
1010010100
{
10101-
errors.reject(ERROR_MSG, "Value for 'Delay until first reminder' must be greater than 0.");
10101+
errors.reject(ERROR_MSG, "Value for 'Delay until first reminder' cannot be less than 0.");
1010210102
}
1010310103
if (form.getReminderFrequency() == null)
1010410104
{
1010510105
errors.reject(ERROR_MSG, "Please enter a value for 'Reminder frequency'.");
1010610106
}
1010710107
else if (form.getReminderFrequency() < 0)
1010810108
{
10109-
errors.reject(ERROR_MSG, "Value for 'Reminder frequency' must be greater than 0.");
10109+
errors.reject(ERROR_MSG, "Value for 'Reminder frequency' cannot be less than 0.");
1011010110
}
1011110111
if (form.getExtensionLength() == null)
1011210112
{
1011310113
errors.reject(ERROR_MSG, "Please enter a value for 'Extension duration'.");
1011410114
}
1011510115
else if (form.getExtensionLength() < 0)
1011610116
{
10117-
errors.reject(ERROR_MSG, "Value for 'Extension duration' must be greater than 0.");
10117+
errors.reject(ERROR_MSG, "Value for 'Extension duration' cannot be less than 0.");
1011810118
}
1011910119
}
1012010120

@@ -10244,7 +10244,7 @@ public ModelAndView getView(PrivateDataSendReminderForm form, boolean reshow, Bi
1024410244
qSettings.setBaseFilter(new SimpleFilter(FieldKey.fromParts("Public"), "No"));
1024510245

1024610246
QueryView tableView = new QueryView(new PanoramaPublicSchema(getUser(), getContainer()), qSettings, null);
10247-
tableView.setTitle("Private Panorama Public Datasets");
10247+
tableView.setTitle("Private Panorama Private Datasets");
1024810248
tableView.setFrame(WebPartView.FrameType.NONE);
1024910249

1025010250
form.setDataRegionName(tableView.getDataRegionName());
@@ -10266,7 +10266,7 @@ public boolean handlePost(PrivateDataSendReminderForm form, BindException errors
1026610266
return false;
1026710267
}
1026810268
PipelineJob job = new PrivateDataReminderJob(getViewBackgroundInfo(),
10269-
PipelineService.get().getPipelineRootSetting(ContainerManager.getRoot()),
10269+
PipelineService.get().getPipelineRootSetting(getContainer()),
1027010270
JournalManager.getJournal(getContainer()),
1027110271
form.getSelectedExperimentIds(),
1027210272
form.getTestMode());
@@ -10294,7 +10294,6 @@ public static class PrivateDataSendReminderForm
1029410294
private boolean _testMode;
1029510295
private String _selectedIds;
1029610296
private String _dataRegionName = null;
10297-
private List<ExperimentAnnotations> _experiments = null;
1029810297

1029910298
public boolean getTestMode()
1030010299
{
@@ -10334,16 +10333,6 @@ public void setDataRegionName(String dataRegionName)
1033410333
{
1033510334
_dataRegionName = dataRegionName;
1033610335
}
10337-
10338-
public List<ExperimentAnnotations> getExperiments()
10339-
{
10340-
return _experiments;
10341-
}
10342-
10343-
public void setExperiments(List<ExperimentAnnotations> experiments)
10344-
{
10345-
_experiments = experiments;
10346-
}
1034710336
}
1034810337

1034910338
@RequiresAnyOf({AdminPermission.class, PanoramaPublicSubmitterPermission.class})
@@ -10355,7 +10344,6 @@ public abstract class UpdateDatasetStatusAction extends ConfirmAction<ShortUrlFo
1035510344
protected abstract void doValidationForAction(Errors errors);
1035610345
protected abstract void updateDatasetStatus(DatasetStatus datasetStatus);
1035710346
protected abstract void postNotification();
10358-
1035910347
protected abstract String getConfirmViewTitle();
1036010348
protected abstract String getConfirmViewMessage();
1036110349

@@ -10407,7 +10395,6 @@ public boolean handlePost(ShortUrlForm shortUrlForm, BindException errors) throw
1040710395
DatasetStatusManager.update(_datasetStatus, getUser());
1040810396
}
1040910397

10410-
// Post notification
1041110398
postNotification();
1041210399

1041310400
transaction.commit();
@@ -10444,10 +10431,10 @@ protected void doValidationForAction(Errors errors)
1044410431
if (_datasetStatus != null)
1044510432
{
1044610433
PrivateDataReminderSettings settings = PrivateDataReminderSettings.get();
10447-
if (_datasetStatus.isExtensionCurrent(settings))
10434+
if (settings.isExtensionValid(_datasetStatus))
1044810435
{
1044910436
errors.reject(ERROR_MSG, "An extension has already been requested for the data with short URL " + _datasetStatus.getShortUrl().renderShortURL()
10450-
+ ". The extension is valid until " + _datasetStatus.extensionValidUntilFormatted(settings));
10437+
+ ". The extension is valid until " + settings.extensionValidUntilFormatted(_datasetStatus));
1045110438
}
1045210439
else if (_datasetStatus.deletionRequested())
1045310440
{
@@ -10478,7 +10465,7 @@ public ModelAndView getSuccessView(ShortUrlForm shortUrlForm)
1047810465
setTitle("Extension Request Success");
1047910466
PrivateDataReminderSettings settings = PrivateDataReminderSettings.get();
1048010467
return new HtmlView(DIV("An extension request was successfully submitted for the data at " + _exptAnnotations.getShortUrl().renderShortURL(),
10481-
DIV("The extension is valid until " + _datasetStatus.extensionValidUntilFormatted(settings)),
10468+
DIV("The extension is valid until " + settings.extensionValidUntilFormatted(_datasetStatus)),
1048210469
BR(),
1048310470
DIV(
1048410471
LinkBuilder.labkeyLink("Data Folder", PageFlowUtil.urlProvider(ProjectUrls.class).getBeginURL(_exptAnnotations.getContainer()))

panoramapublic/src/org/labkey/panoramapublic/PanoramaPublicModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.labkey.panoramapublic.bluesky.BlueskyApiClient;
4747
import org.labkey.panoramapublic.bluesky.PanoramaPublicLogoResourceType;
4848
import org.labkey.panoramapublic.catalog.CatalogImageAttachmentType;
49+
import org.labkey.panoramapublic.message.PrivateDataReminderSettings;
4950
import org.labkey.panoramapublic.model.Journal;
5051
import org.labkey.panoramapublic.model.speclib.SpecLibKey;
5152
import org.labkey.panoramapublic.pipeline.CopyExperimentPipelineProvider;
@@ -382,6 +383,7 @@ public Set<Class> getUnitTests()
382383
set.add(Formula.TestCase.class);
383384
set.add(CatalogEntryManager.TestCase.class);
384385
set.add(BlueskyApiClient.TestCase.class);
386+
set.add(PrivateDataReminderSettings.TestCase.class);
385387
return set;
386388

387389
}

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

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.labkey.panoramapublic.datacite.DataCiteException;
2424
import org.labkey.panoramapublic.datacite.DataCiteService;
2525
import org.labkey.panoramapublic.message.PrivateDataReminderSettings;
26-
import org.labkey.panoramapublic.model.DatasetStatus;
2726
import org.labkey.panoramapublic.model.ExperimentAnnotations;
2827
import org.labkey.panoramapublic.model.Journal;
2928
import org.labkey.panoramapublic.model.JournalExperiment;
@@ -306,17 +305,13 @@ public static void postPrivateStatusExtensionMessage(@NotNull Journal journal, @
306305
throw new NotFoundException(String.format("Could not find an admin user for %s.", journal.getName()));
307306
}
308307
PrivateDataReminderSettings reminderSettings = PrivateDataReminderSettings.get();
309-
/*
310-
Thank you for your request to extend the private status of your data on Panorama Public at <short_url>.
311-
Your data has been granted an extension for an additional 6 months. You’ll receive another reminder at that time, or you may make the dataset public earlier.
312-
Please feel free to contact us if you have any questions
313-
*/
308+
314309
String messageTitle = "Private Status Extended" +" - " + je.getShortAccessUrl().renderShortURL();
315310
StringBuilder messageBody = new StringBuilder();
316311
messageBody.append("Dear ").append(getUserName(submitter)).append(",").append(NL2);
317312
messageBody.append("Thank you for your request to extend the private status of your data on Panorama Public. ")
318313
.append("Your data has been granted a " + reminderSettings.getExtensionLength() + " month extension. ")
319-
.append("You’ll receive another reminder when this period ends. ")
314+
.append("You will receive another reminder when this period ends. ")
320315
.append("If you'd like to make your data public sooner, you can do so at any time ")
321316
.append("by clicking the \"Make Public\" button in your data folder, or by clicking this link: ")
322317
.append(bold(link("Make Data Public", PanoramaPublicController.getMakePublicUrl(expAnnotations.getId(), expAnnotations.getContainer()).getURIString())))
@@ -354,7 +349,7 @@ public static void postDataDeletionRequestMessage(@NotNull Journal journal, @Not
354349
messageBody.append("We were unable to locate the source folder for this data in your project. ")
355350
.append("The folder at the path ")
356351
.append(expAnnotations.getSourceExperimentPath())
357-
.append("may have been deleted.");
352+
.append(" may have been deleted.");
358353
}
359354

360355
messageBody.append(NL2).append("Best regards,");
@@ -369,25 +364,14 @@ public static void postPrivateDataReminderMessage(@NotNull Journal journal, @Not
369364
@NotNull Announcement announcement, @NotNull Container announcementsContainer, @NotNull User journalAdmin)
370365
{
371366
String message = getDataStatusReminderMessage(expAnnotations, submitter, js, announcement, announcementsContainer, journalAdmin);
372-
String title = "Action Required: Status Update for Your Private Dataset on Panorama Public";
367+
String title = "Action Required: Status Update for Your Private Data on Panorama Public";
373368
postNotificationFullTitle(journal, js.getJournalExperiment(), message, messagePoster, title, StatusOption.Closed, notifyUsers);
374369
}
375370

376371
public static String getDataStatusReminderMessage(@NotNull ExperimentAnnotations exptAnnotations, @NotNull User submitter,
377372
@NotNull JournalSubmission js,@NotNull Announcement announcement,
378373
@NotNull Container announcementContainer, @NotNull User journalAdmin)
379374
{
380-
/*
381-
We are reaching out regarding your dataset on Panorama Public (https://panoramaweb.org/polyjuice.url), which has been private since January 1, 2024.
382-
Is the paper associated with this work already published?
383-
If yes: Please make your data public by clicking the "Make Public" button in your folder or by clicking [Make Data Public] here. This helps ensure that your valuable research is easily accessible to the community.
384-
If not: You have a couple of options:
385-
Request an Extension - If your paper is still under review, or you need additional time, please let us know by clicking [Request Extension]
386-
Delete from Panorama Public - If you no longer wish to host your data on Panorama Public, please click [Request Deletion]. We will remove your dataset from Panorama Public. However, your source folder (/Hogwarts/Gryffindor/magic-potion) will remain intact, allowing you to resubmit your data in the future if you wish.
387-
If you have any questions or need further assistance, please do not hesitate to respond to this message by clicking here.
388-
Thank you for sharing your research on Panorama Public. We appreciate your commitment to open science and your contributions to the research community.
389-
*/
390-
391375
String shortUrl = exptAnnotations.getShortUrl().renderShortURL();
392376
String makePublicLink = PanoramaPublicController.getMakePublicUrl(exptAnnotations.getId(), exptAnnotations.getContainer()).getURIString();
393377
String dateString = DateUtil.formatDateTime(js.getLatestSubmission().getCreated(), "MMMM d, yyyy");
@@ -410,18 +394,18 @@ We are reaching out regarding your dataset on Panorama Public (https://panoramaw
410394

411395
StringBuilder message = new StringBuilder();
412396
message.append("Dear ").append(getUserName(submitter)).append(",").append(NL2)
413-
.append("We are reaching out regarding your dataset on Panorama Public (").append(shortUrl).append("), which has been private since ")
397+
.append("We are reaching out regarding your data on Panorama Public (").append(shortUrl).append("), which has been private since ")
414398
.append(dateString).append(".")
415399
.append("\n\n**Is the paper associated with this work already published?**")
416-
.append("\n- If yes: Please make your data public by clicking the \"Make Public\" button in your folder or by clicking ")
400+
.append("\n- If yes: Please make your data public by clicking the \"Make Public\" button in your folder or by clicking this link: ")
417401
.append(bold(link("Make Data Public", makePublicLink)))
418402
.append(". This helps ensure that your valuable research is easily accessible to the community.")
419403
.append("\n- If not: You have a couple of options:")
420404
.append("\n - **Request an Extension** - If your paper is still under review, or you need additional time, please let us know by clicking ")
421405
.append(bold(link("Request Extension", requestExtensionUrl.getURIString()))).append(".")
422406
.append("\n - **Delete from Panorama Public** - If you no longer wish to host your data on Panorama Public, please click ")
423407
.append(bold(link("Request Deletion", requesDeletionUrl.getURIString()))).append(". ")
424-
.append("We will remove your dataset from Panorama Public.");
408+
.append("We will remove your data from Panorama Public.");
425409
if (sourceExperiment != null)
426410
{
427411
message.append(" However, your source folder (")
@@ -594,7 +578,7 @@ private static String escape(String text)
594578
{
595579
// https://www.markdownguide.org/basic-syntax/#characters-you-can-escape
596580
// Escape Markdown special characters. Some character combinations can result in
597-
// unintended Markdown styling, e.g. "+_Italics_+" will result in "Italics" to be italicized.
581+
// unintended Markdown styling, e.g. "+_Italics_+" results in "Italics" to be italicized.
598582
// This can be seen with the tricky characters used for project names in labkey tests.
599583
// 8/13/25 - Escape tilde (~) as well. In the LabKey Markdown flavor, text between
600584
// single tildes (e.g., ~strikethrough~) is rendered as strikethrough.

panoramapublic/src/org/labkey/panoramapublic/message/PrivateDataMessageScheduler.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
import org.labkey.api.pipeline.PipelineService;
1010
import org.labkey.api.security.User;
1111
import org.labkey.api.util.ConfigurationException;
12+
import org.labkey.api.util.ExceptionUtil;
1213
import org.labkey.api.util.logging.LogHelper;
1314
import org.labkey.api.view.ViewBackgroundInfo;
15+
import org.labkey.panoramapublic.model.Journal;
1416
import org.labkey.panoramapublic.pipeline.PrivateDataReminderJob;
17+
import org.labkey.panoramapublic.query.JournalManager;
1518
import org.quartz.DateBuilder;
1619
import org.quartz.Job;
1720
import org.quartz.JobBuilder;
@@ -88,40 +91,42 @@ protected Trigger getTrigger()
8891

8992
public static class PrivateDataMessageSchedulerJob implements Job
9093
{
91-
private final @Nullable User _user;
92-
9394
@SuppressWarnings("unused")
94-
public PrivateDataMessageSchedulerJob()
95-
{
96-
this(null);
97-
}
98-
99-
public PrivateDataMessageSchedulerJob(@Nullable User user)
100-
{
101-
_user = user;
102-
}
95+
public PrivateDataMessageSchedulerJob() {}
10396

10497
@Override
10598
public void execute(JobExecutionContext context)
10699
{
107100
try
108101
{
109-
Container c = ContainerManager.getRoot();
110-
ViewBackgroundInfo vbi = new ViewBackgroundInfo(c, _user, null);
102+
Journal panoramaPublic = JournalManager.getJournal(JournalManager.PANORAMA_PUBLIC);
103+
if (panoramaPublic == null)
104+
{
105+
throw new ConfigurationException("Server does not have a Panorama Public project.");
106+
}
107+
108+
Container c = panoramaPublic.getProject();
109+
110+
User panoramaPublicAdmin = JournalManager.getJournalAdminUser(panoramaPublic);
111+
if (panoramaPublicAdmin == null)
112+
{
113+
throw new ConfigurationException("Unable to find an admin user in the Panorama Public project.");
114+
}
115+
ViewBackgroundInfo vbi = new ViewBackgroundInfo(c, panoramaPublicAdmin, null);
111116
PipeRoot root = PipelineService.get().findPipelineRoot(c);
112117

113118
if (root == null || !root.isValid())
114119
{
115-
throw new ConfigurationException("No valid pipeline root found in the root container");
120+
throw new ConfigurationException("No valid pipeline root found in the container " + c.getName());
116121
}
117122

118-
PipelineJob job = new PrivateDataReminderJob(vbi, PipelineService.get().getPipelineRootSetting(ContainerManager.getRoot()), false);
123+
PipelineJob job = new PrivateDataReminderJob(vbi, PipelineService.get().getPipelineRootSetting(c), false);
119124
PipelineService.get().queueJob(job);
120125
}
121126
catch(Exception e)
122127
{
123128
_log.error("Error queuing PrivateDataReminderJob", e);
124-
// ExceptionUtil.logExceptionToMothership(null, e);
129+
ExceptionUtil.logExceptionToMothership(null, e);
125130

126131
}
127132
}

0 commit comments

Comments
 (0)