Skip to content

Commit 335b231

Browse files
committed
Add setting to control whether kinship import is allowed during business hours
1 parent 8518391 commit 335b231

4 files changed

Lines changed: 37 additions & 6 deletions

File tree

ehr/resources/web/ehr/panel/GeneticCalculationSettingsPanel.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', {
2424
xtype: 'checkbox',
2525
fieldLabel: 'Is Enabled?',
2626
itemId: 'enabled'
27+
},{
28+
xtype: 'checkbox',
29+
fieldLabel: 'Allow Import During Business Hours?',
30+
itemId: 'allowImportDuringBusinessHours'
2731
},{
2832
xtype: 'checkbox',
2933
fieldLabel: 'Kinship validation?',
@@ -107,6 +111,7 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', {
107111
this.down('#containerPath').setValue(results.containerPath);
108112
this.down('#kinshipValidation').setValue(results.kinshipValidation);
109113
this.down('#mergeSpeciesWithHybrids').setValue(results.mergeSpeciesWithHybrids);
114+
this.down('#allowImportDuringBusinessHours').setValue(results.allowImportDuringBusinessHours)
110115
},
111116

112117
saveData: function(){
@@ -118,7 +123,8 @@ Ext4.define('EHR.panel.GeneticCalculationSettingsPanel', {
118123
enabled: this.down('#enabled').getValue(),
119124
hourOfDay: this.down('#hourOfDay').getValue(),
120125
kinshipValidation: this.down('#kinshipValidation').getValue(),
121-
mergeSpeciesWithHybrids: this.down('#mergeSpeciesWithHybrids').getValue()
126+
mergeSpeciesWithHybrids: this.down('#mergeSpeciesWithHybrids').getValue(),
127+
allowImportDuringBusinessHours: this.down('#allowImportDuringBusinessHours').getValue()
122128
},
123129
method : 'POST',
124130
scope: this,

ehr/src/org/labkey/ehr/EHRController.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import org.labkey.api.settings.AppProps;
8484
import org.labkey.api.study.DatasetTable;
8585
import org.labkey.api.util.ExceptionUtil;
86+
import org.labkey.api.util.HtmlString;
8687
import org.labkey.api.util.HtmlStringBuilder;
8788
import org.labkey.api.util.PageFlowUtil;
8889
import org.labkey.api.util.Path;
@@ -639,7 +640,7 @@ public ApiResponse execute(ScheduleGeneticCalculationForm form, BindException er
639640
errors.reject(ERROR_MSG, "Unable to find container for path: " + form.getContainerPath());
640641
return null;
641642
}
642-
GeneticCalculationsJob.setProperties(form.isEnabled(), c, form.getHourOfDay(), form.isKinshipValidation(), form.isMergeSpeciesWithHybrids());
643+
GeneticCalculationsJob.setProperties(form.isEnabled(), c, form.getHourOfDay(), form.isKinshipValidation(), form.isMergeSpeciesWithHybrids(), form.isAllowImportDuringBusinessHours());
643644

644645
return new ApiSimpleResponse("success", true);
645646
}
@@ -760,6 +761,7 @@ public static class ScheduleGeneticCalculationForm
760761

761762
private boolean _kinshipValidation;
762763
private boolean _mergeSpeciesWithHybrids;
764+
private boolean _allowImportDuringBusinessHours;
763765

764766
public boolean isEnabled()
765767
{
@@ -810,6 +812,16 @@ public void setMergeSpeciesWithHybrids(boolean mergeSpeciesWithHybrids)
810812
{
811813
_mergeSpeciesWithHybrids = mergeSpeciesWithHybrids;
812814
}
815+
816+
public boolean isAllowImportDuringBusinessHours()
817+
{
818+
return _allowImportDuringBusinessHours;
819+
}
820+
821+
public void setAllowImportDuringBusinessHours(boolean allowImportDuringBusinessHours)
822+
{
823+
_allowImportDuringBusinessHours = allowImportDuringBusinessHours;
824+
}
813825
}
814826

815827
@RequiresPermission(AdminPermission.class)
@@ -829,6 +841,7 @@ public ApiResponse execute(ScheduleGeneticCalculationForm form, BindException er
829841
ret.put("hourOfDay", GeneticCalculationsJob.getHourOfDay());
830842
ret.put("kinshipValidation", GeneticCalculationsJob.isKinshipValidation());
831843
ret.put("mergeSpeciesWithHybrids", GeneticCalculationsJob.isMergeSpeciesWithHybrids());
844+
ret.put("allowImportDuringBusinessHours", GeneticCalculationsJob.isAllowImportDuringBusinessHours());
832845

833846
return new ApiSimpleResponse(ret);
834847
}
@@ -1262,7 +1275,7 @@ public void validateCommand(Object form, Errors errors)
12621275
@Override
12631276
public ModelAndView getConfirmView(Object form, BindException errors)
12641277
{
1265-
return new HtmlView("This will cause the system to recalculate kinship and inbreeding coefficients on the colony. Do you want to continue?");
1278+
return new HtmlView(HtmlString.of("This will cause the system to recalculate kinship and inbreeding coefficients on the colony. Do you want to continue?"));
12661279
}
12671280

12681281
@Override

ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsJob.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ public static boolean isMergeSpeciesWithHybrids()
132132
return false;
133133
}
134134

135+
136+
public static boolean isAllowImportDuringBusinessHours()
137+
{
138+
Map<String, String> saved = PropertyManager.getProperties(GENETICCALCULATIONS_PROPERTY_DOMAIN);
139+
140+
if (saved.containsKey("allowImportDuringBusinessHours"))
141+
return Boolean.parseBoolean(saved.get("allowImportDuringBusinessHours"));
142+
else
143+
return false;
144+
}
145+
135146
public static boolean isEnabled()
136147
{
137148
Map<String, String> saved = PropertyManager.getProperties(GENETICCALCULATIONS_PROPERTY_DOMAIN);
@@ -162,14 +173,15 @@ public static Integer getHourOfDay()
162173
return null;
163174
}
164175

165-
public static void setProperties(Boolean isEnabled, Container c, Integer hourOfDay, Boolean isKinshipValidation, Boolean mergeSpeciesWithHybrids)
176+
public static void setProperties(Boolean isEnabled, Container c, Integer hourOfDay, Boolean isKinshipValidation, Boolean mergeSpeciesWithHybrids, Boolean allowImportDuringBusinessHours)
166177
{
167178
PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(GENETICCALCULATIONS_PROPERTY_DOMAIN, true);
168179
props.put("enabled", isEnabled.toString());
169180
props.put("container", c.getId());
170181
props.put("hourOfDay", hourOfDay.toString());
171182
props.put("kinshipValidation", isKinshipValidation.toString());
172183
props.put("mergeSpeciesWithHybrids", mergeSpeciesWithHybrids.toString());
184+
props.put("allowImportDuringBusinessHours", allowImportDuringBusinessHours.toString());
173185
props.save();
174186

175187
//unschedule in case settings have changed
@@ -193,7 +205,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException
193205
try
194206
{
195207
_log.info("Running Scheduled Genetic Calculations Job");
196-
new GeneticCalculationsRunnable().run(c, false);
208+
new GeneticCalculationsRunnable().run(c, isAllowImportDuringBusinessHours());
197209
}
198210
catch (PipelineJobException e)
199211
{

ehr/src/org/labkey/ehr/pipeline/GeneticCalculationsRunnable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private void startCalculation(User u, Container c, boolean allowRunningDuringDay
8585
String protocolName = "EHR Kinship Calculation";
8686
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
8787
"<bioml>\n" +
88-
(allowRunningDuringDay ? "\t<note label=\"allowRunningDuringDay\" type=\"input\">true</note>" : "") +
88+
"\t<note label=\"allowRunningDuringDay\" type=\"input\">" + allowRunningDuringDay + "</note>" +
8989
"\t<note label=\"kinshipValidation\" type=\"input\">" + GeneticCalculationsJob.isKinshipValidation() + "</note>" +
9090
"\t<note label=\"mergeSpeciesWithHybrids\" type=\"input\">" + GeneticCalculationsJob.isMergeSpeciesWithHybrids() + "</note>" +
9191
"</bioml>";

0 commit comments

Comments
 (0)