From 4f787f806f3b47a0eff6482adac61f400aa5f901 Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 24 Jun 2025 21:11:23 -0700 Subject: [PATCH 1/2] Better handling of GeneticCalculationsImportTask cancels --- .../ehr/pipeline/GeneticCalculationsImportTask.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java index 40efb24d7..15d2ed3b6 100644 --- a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java +++ b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsImportTask.java @@ -307,6 +307,14 @@ else if (kinshipTable.getSqlDialect().isPostgreSQL()) if (lineNum % 250000 == 0) { log.info("imported " + String.format("%,d", lineNum) + " rows"); + if (job != null) + { + job.updateStatusForTask(); + if (job.isCancelled()) + { + throw new CancelledException(); + } + } } } From e8a6b66cef84cbbac06ea58e2d6c477a9c4b7ddc Mon Sep 17 00:00:00 2001 From: bbimber Date: Wed, 25 Jun 2025 09:27:55 -0700 Subject: [PATCH 2/2] Allow GeneticCalculationsJob to optionally run on specified day of the week --- .../panel/GeneticCalculationSettingsPanel.js | 12 ++++++++++++ ehr/src/org/labkey/ehr/EHRController.java | 14 +++++++++++++- .../ehr/pipeline/GeneticCalculationsJob.java | 17 +++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ehr/resources/web/ehr/panel/GeneticCalculationSettingsPanel.js b/ehr/resources/web/ehr/panel/GeneticCalculationSettingsPanel.js index b5e217dd1..2a527591b 100644 --- a/ehr/resources/web/ehr/panel/GeneticCalculationSettingsPanel.js +++ b/ehr/resources/web/ehr/panel/GeneticCalculationSettingsPanel.js @@ -7,6 +7,7 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', { extend: 'Ext.panel.Panel', initComponent: function(){ + Ext4.QuickTips.init(); Ext4.apply(this, { //width: 550, border: false, @@ -48,6 +49,15 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', { fieldLabel: 'Hour Of Day', itemId: 'hourOfDay', width: 400 + },{ + xtype: 'numberfield', + hideTrigger: true, + fieldLabel: 'Day of Week', + itemId: 'dayOfWeek', + helpPopup: 'If provided, the job will run on the specified day of the week (1-7 or Sun-Sat). If blank, it will run each day.', + width: 400, + minValue: 1, + maxValue: 7 },{ xtype: 'textfield', fieldLabel: 'Container Path', @@ -96,6 +106,7 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', { this.down('#isScheduled').setValue(results.isScheduled); this.down('#enabled').setValue(results.enabled); this.down('#hourOfDay').setValue(results.hourOfDay); + this.down('#dayOfWeek').setValue(results.dayOfWeek); this.down('#containerPath').setValue(results.containerPath); this.down('#kinshipValidation').setValue(results.kinshipValidation); this.down('#allowImportDuringBusinessHours').setValue(results.allowImportDuringBusinessHours) @@ -109,6 +120,7 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', { containerPath: this.down('#containerPath').getValue(), enabled: this.down('#enabled').getValue(), hourOfDay: this.down('#hourOfDay').getValue(), + dayOfWeek: this.down('#dayOfWeek').getValue(), kinshipValidation: this.down('#kinshipValidation').getValue(), allowImportDuringBusinessHours: this.down('#allowImportDuringBusinessHours').getValue() }, diff --git a/ehr/src/org/labkey/ehr/EHRController.java b/ehr/src/org/labkey/ehr/EHRController.java index c7805f3d2..1ca7db4a8 100644 --- a/ehr/src/org/labkey/ehr/EHRController.java +++ b/ehr/src/org/labkey/ehr/EHRController.java @@ -640,7 +640,7 @@ public ApiResponse execute(ScheduleGeneticCalculationForm form, BindException er errors.reject(ERROR_MSG, "Unable to find container for path: " + form.getContainerPath()); return null; } - GeneticCalculationsJob.setProperties(form.isEnabled(), c, form.getHourOfDay(), form.isKinshipValidation(), form.isAllowImportDuringBusinessHours()); + GeneticCalculationsJob.setProperties(form.isEnabled(), c, form.getHourOfDay(), form.getDayOfWeek(), form.isKinshipValidation(), form.isAllowImportDuringBusinessHours()); return new ApiSimpleResponse("success", true); } @@ -758,6 +758,7 @@ public static class ScheduleGeneticCalculationForm private boolean _enabled; private String containerPath; private int hourOfDay; + private Integer dayOfWeek; private boolean _kinshipValidation; private boolean _allowImportDuringBusinessHours; @@ -792,6 +793,16 @@ public void setHourOfDay(int hourOfDay) this.hourOfDay = hourOfDay; } + public Integer getDayOfWeek() + { + return dayOfWeek; + } + + public void setDayOfWeek(Integer dayOfWeek) + { + this.dayOfWeek = dayOfWeek; + } + public boolean isKinshipValidation() { return _kinshipValidation; @@ -828,6 +839,7 @@ public ApiResponse execute(ScheduleGeneticCalculationForm form, BindException er ret.put("isScheduled", GeneticCalculationsJob.isScheduled()); ret.put("enabled", GeneticCalculationsJob.isEnabled()); ret.put("hourOfDay", GeneticCalculationsJob.getHourOfDay()); + ret.put("dayOfWeek", GeneticCalculationsJob.getDayOfWeek()); ret.put("kinshipValidation", GeneticCalculationsJob.isKinshipValidation()); ret.put("allowImportDuringBusinessHours", GeneticCalculationsJob.isAllowImportDuringBusinessHours()); diff --git a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsJob.java b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsJob.java index be2b92634..db3b9b1d6 100644 --- a/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsJob.java +++ b/ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsJob.java @@ -97,13 +97,15 @@ public static void schedule() if (hour == null) hour = 2; + Integer day = getDayOfWeek(); + JobDetail job = JobBuilder.newJob(GeneticCalculationsJob.class) .withIdentity(GeneticCalculationsJob.class.getCanonicalName()) .build(); Trigger trigger = TriggerBuilder.newTrigger() .withIdentity(GeneticCalculationsJob.class.getCanonicalName()) - .withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(hour, 0)) + .withSchedule(day == null ? CronScheduleBuilder.dailyAtHourAndMinute(hour, 0) : CronScheduleBuilder.weeklyOnDayAndHourAndMinute(day, hour, 0)) .forJob(job) .build(); @@ -174,12 +176,23 @@ public static Integer getHourOfDay() return null; } - public static void setProperties(Boolean isEnabled, Container c, Integer hourOfDay, Boolean isKinshipValidation, Boolean allowImportDuringBusinessHours) + public static Integer getDayOfWeek() + { + Map saved = PropertyManager.getProperties(GENETICCALCULATIONS_PROPERTY_DOMAIN); + + if (saved.containsKey("dayOfWeek") & saved.get("dayOfWeek") != null) + return Integer.parseInt(saved.get("dayOfWeek")); + + return null; + } + + public static void setProperties(Boolean isEnabled, Container c, Integer hourOfDay, @Nullable Integer dayOfWeek, Boolean isKinshipValidation, Boolean allowImportDuringBusinessHours) { WritablePropertyMap props = PropertyManager.getWritableProperties(GENETICCALCULATIONS_PROPERTY_DOMAIN, true); props.put("enabled", isEnabled.toString()); props.put("container", c.getId()); props.put("hourOfDay", hourOfDay.toString()); + props.put("dayOfWeek", dayOfWeek == null ? null : dayOfWeek.toString()); props.put("kinshipValidation", isKinshipValidation.toString()); props.put("allowImportDuringBusinessHours", allowImportDuringBusinessHours.toString()); props.save();