Skip to content

Commit 4cc2422

Browse files
authored
Merge pull request #37 from bimberlabinternal/24.3_fb_merge
Merge discvr-23.11 to discvr-24.3
2 parents 8819ef3 + 535fa85 commit 4cc2422

File tree

11 files changed

+261
-31
lines changed

11 files changed

+261
-31
lines changed

LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ public DefaultTableCustomizer(MultiValuedMap<String, String> props)
8383
@Override
8484
public void customize(TableInfo table)
8585
{
86+
if (table.isLocked())
87+
{
88+
_log.debug("DefaultTableCustomizer called on a locked table: " + table.getPublicSchemaName() + " / " + table.getName(), new Exception());
89+
return;
90+
}
91+
8692
if (table instanceof SchemaTableInfo)
8793
_log.error("Table customizer is being passed a SchemaTableInfo for: " + table.getPublicSchemaName() + "." + table.getPublicName());
8894
else if (table instanceof AbstractTableInfo)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package org.labkey.api.laboratory;
2+
3+
import org.jetbrains.annotations.Nullable;
4+
import org.labkey.api.data.Container;
5+
import org.labkey.api.module.Module;
6+
import org.labkey.api.security.User;
7+
8+
9+
public class DemographicsProvider
10+
{
11+
private final Module _owningModule;
12+
private final String _schemaName;
13+
private final String _queryName;
14+
private final String _subjectField;
15+
16+
public DemographicsProvider(Module owningModule, String schemaName, String queryName, String subjectField)
17+
{
18+
_owningModule = owningModule;
19+
_schemaName = schemaName;
20+
_queryName = queryName;
21+
_subjectField = subjectField;
22+
}
23+
24+
public String getSchema()
25+
{
26+
return _schemaName;
27+
}
28+
29+
public String getQuery()
30+
{
31+
return _queryName;
32+
}
33+
34+
public String getSubjectField()
35+
{
36+
return _subjectField;
37+
}
38+
39+
public @Nullable String getMotherField()
40+
{
41+
return null;
42+
}
43+
44+
public @Nullable String getFatherField()
45+
{
46+
return null;
47+
}
48+
49+
public @Nullable String getSexField()
50+
{
51+
return null;
52+
}
53+
54+
public boolean isAvailable(Container c, User u)
55+
{
56+
return c.getActiveModules().contains(_owningModule);
57+
}
58+
59+
public String getLabel()
60+
{
61+
return getSchema() + "." + getQuery();
62+
}
63+
64+
public boolean isValidForPedigree()
65+
{
66+
return getMotherField() != null && getFatherField() != null && getSexField() != null;
67+
}
68+
}

laboratory/api-src/org/labkey/api/laboratory/LaboratoryService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.labkey.api.laboratory;
1717

18+
import org.jetbrains.annotations.Nullable;
1819
import org.json.JSONObject;
1920
import org.labkey.api.assay.AssayProvider;
2021
import org.labkey.api.data.Container;
@@ -116,6 +117,12 @@ static public void setInstance(LaboratoryService instance)
116117

117118
abstract public void registerTableCustomizer(Module owner, Class<? extends TableCustomizer> customizerClass, String schemaName, String queryName);
118119

120+
abstract public void registerDemographicsProvider(DemographicsProvider provider);
121+
122+
abstract public List<DemographicsProvider> getDemographicsProviders(Container c, User u);
123+
124+
abstract public @Nullable DemographicsProvider getDemographicsProviderByName(Container c, User u, String name);
125+
119126
public static enum NavItemCategory
120127
{
121128
samples(),

laboratory/resources/web/laboratory/button/IconButton.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ Ext4.define('Laboratory.button.IconButton', {
77

88
renderTpl: [
99
'<div id="{id}-wrap" class="tool-icon">',
10-
'<a style="display: block" ' +
10+
'<a style="display: block;cursor: pointer;" ' +
1111
'<tpl if="href">href="{href}"</tpl>' +
12-
'<tpl if="!href">href="javascript:void(0)"</tpl>' +
1312
'<tpl if="tooltip"> data-qtip="{tooltip}"</tpl>' +
1413
'>' +
15-
'<tpl if="icon"><div><img id="{id}-btnIconEl" src="{icon}"/ ></div></tpl>' +
14+
'<tpl if="icon"><div><img alt="{text}" id="{id}-btnIconEl" src="{icon}"/ ></div></tpl>' +
1615
'{text}</a>',
1716
'</div>'
1817
],
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Ext4.define('Laboratory.field.PedigreeSelectorField', {
2+
extend: 'LABKEY.ext4.ComboBox',
3+
alias: 'widget.laboratory-pedigreeselectorfield',
4+
5+
forceSelection: true,
6+
typeAhead: true,
7+
queryMode: 'local',
8+
triggerAction: 'all',
9+
10+
initComponent: function(){
11+
Ext4.apply(this, {
12+
displayField: 'value',
13+
valueField: 'value',
14+
store: {
15+
type: 'array',
16+
fields: ['value']
17+
}
18+
});
19+
20+
this.callParent(arguments);
21+
22+
this.loadData();
23+
},
24+
25+
loadData: function(){
26+
LABKEY.Ajax.request({
27+
url: LABKEY.ActionURL.buildURL('laboratory', 'getDemographicsProviders', Laboratory.Utils.getQueryContainerPath()),
28+
method : 'POST',
29+
scope: this,
30+
failure: LDK.Utils.getErrorCallback(),
31+
success: LABKEY.Utils.getCallbackWrapper(function(response){
32+
console.log(response);
33+
Ext4.Array.forEach(response.providers, function(d){
34+
if (d.isValidForPedigree) {
35+
this.store.add(this.store.createModel({value: d.label}));
36+
}
37+
}, this);
38+
}, this)
39+
});
40+
},
41+
42+
getToolParameterValue : function(){
43+
return this.getSubmitValue();
44+
}
45+
});

laboratory/resources/web/laboratory/panel/WorkbookHeaderPanel.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,49 @@
66
*/
77
Ext4.define('Laboratory.panel.WorkbookHeaderPanel', {
88
extend: 'LDK.panel.WebpartPanel',
9+
panelTitle: 'Details',
10+
911
initComponent: function(){
1012
Ext4.apply(this, {
11-
title: 'Details',
13+
title: this.panelTitle,
1214
defaults: {
1315
border: false
1416
},
15-
items: [{
16-
html: 'Description:',
17-
style: 'font-weight: bold;'
18-
},
19-
this.getFieldCfg('description', this.description)
20-
,{
21-
html: 'Materials:',
22-
style: 'font-weight: bold;padding-top: 10px;'
23-
},
24-
this.getFieldCfg('materials', this.materials)
25-
,{
26-
html: 'Methods:',
27-
style: 'font-weight: bold;padding-top: 10px;'
28-
},
29-
this.getFieldCfg('methods', this.methods)
30-
,{
31-
html: 'Results:',
32-
style: 'font-weight: bold;padding-top: 10px;'
33-
},
34-
this.getFieldCfg('results', this.results)
35-
,{
36-
html: 'Tags:',
37-
style: 'font-weight: bold;padding-top: 10px;'
38-
},
39-
this.getTagFieldCfg()
40-
]
17+
items: this.getPanelItems()
4118
});
4219

4320
this.callParent(arguments);
4421
},
4522

23+
getPanelItems: function() {
24+
return [{
25+
html: 'Description:',
26+
style: 'font-weight: bold;'
27+
},
28+
this.getFieldCfg('description', this.description)
29+
,{
30+
html: 'Materials:',
31+
style: 'font-weight: bold;padding-top: 10px;'
32+
},
33+
this.getFieldCfg('materials', this.materials)
34+
,{
35+
html: 'Methods:',
36+
style: 'font-weight: bold;padding-top: 10px;'
37+
},
38+
this.getFieldCfg('methods', this.methods)
39+
,{
40+
html: 'Results:',
41+
style: 'font-weight: bold;padding-top: 10px;'
42+
},
43+
this.getFieldCfg('results', this.results)
44+
,{
45+
html: 'Tags:',
46+
style: 'font-weight: bold;padding-top: 10px;'
47+
},
48+
this.getTagFieldCfg()
49+
];
50+
},
51+
4652
getTagFieldCfg: function(){
4753
var cfg = {
4854
layout: 'hbox',

laboratory/src/org/labkey/laboratory/LaboratoryController.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,33 @@ public ApiResponse execute(UpdateWorkbookForm form, BindException errors) throws
773773
}
774774
}
775775

776+
@RequiresPermission(ReadPermission.class)
777+
public class GetDemographicsProvidersAction extends ReadOnlyApiAction<Object>
778+
{
779+
@Override
780+
public ApiResponse execute(Object form, BindException errors) throws Exception
781+
{
782+
Map<String, Object> results = new HashMap<>();
783+
784+
Container target = getContainer().isWorkbook() ? getContainer().getParent() : getContainer();
785+
786+
JSONArray providers = new JSONArray();
787+
788+
LaboratoryService.get().getDemographicsProviders(target, getUser()).forEach(d -> {
789+
JSONObject json = new JSONObject();
790+
json.put("label", d.getLabel());
791+
json.put("isValidForPedigree", d.isValidForPedigree());
792+
793+
providers.put(json);
794+
});
795+
796+
results.put("success", true);
797+
results.put("providers", providers);
798+
799+
return new ApiSimpleResponse(results);
800+
}
801+
}
802+
776803
@RequiresPermission(UpdatePermission.class)
777804
public class UpdateWorkbookTagsAction extends MutatingApiAction<UpdateWorkbookForm>
778805
{

laboratory/src/org/labkey/laboratory/LaboratoryModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.labkey.api.view.template.ClientDependency;
4949
import org.labkey.api.writer.ContainerUser;
5050
import org.labkey.laboratory.notification.LabSummaryNotification;
51+
import org.labkey.laboratory.query.LaboratoryDemographicsProvider;
5152
import org.labkey.laboratory.query.WorkbookModel;
5253
import org.labkey.laboratory.security.LaboratoryAdminRole;
5354

@@ -162,6 +163,7 @@ protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
162163
LaboratoryService.get().registerDataProvider(new LaboratoryDataProvider(this));
163164
LaboratoryService.get().registerDataProvider(new SampleTypeDataProvider());
164165
LaboratoryService.get().registerDataProvider(new ExtraDataSourcesDataProvider(this));
166+
LaboratoryService.get().registerDemographicsProvider(new LaboratoryDemographicsProvider());
165167

166168
DetailsURL details = DetailsURL.fromString("/laboratory/siteLabSettings.view");
167169
details.setContainerContext(ContainerManager.getSharedContainer());

laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.apache.logging.log4j.Logger;
1919
import org.apache.logging.log4j.LogManager;
20+
import org.jetbrains.annotations.Nullable;
2021
import org.json.JSONObject;
2122
import org.labkey.api.assay.AssayFileWriter;
2223
import org.labkey.api.assay.AssayProvider;
@@ -35,6 +36,7 @@
3536
import org.labkey.api.exp.api.ExpRun;
3637
import org.labkey.api.exp.api.ExperimentService;
3738
import org.labkey.api.laboratory.DataProvider;
39+
import org.labkey.api.laboratory.DemographicsProvider;
3840
import org.labkey.api.laboratory.LaboratoryService;
3941
import org.labkey.api.laboratory.NavItem;
4042
import org.labkey.api.laboratory.TabbedReportItem;
@@ -80,6 +82,7 @@ public class LaboratoryServiceImpl extends LaboratoryService
8082
private final Map<String, Map<String, List<ButtonConfigFactory>>> _assayButtons = new CaseInsensitiveHashMap<>();
8183
private final Map<String, DataProvider> _dataProviders = new HashMap<>();
8284
private final Map<String, Map<String, List<Pair<Module, Class<? extends TableCustomizer>>>>> _tableCustomizers = new CaseInsensitiveHashMap<>();
85+
private final List<DemographicsProvider> _demographicsProviders = new ArrayList<>();
8386

8487
public static final String DEMOGRAPHICS_PROPERTY_CATEGORY = "laboratory.demographicsSource";
8588
public static final String DATASOURCE_PROPERTY_CATEGORY = "laboratory.additionalDataSource";
@@ -677,4 +680,35 @@ private TableCustomizer instantiateCustomizer(Class<? extends TableCustomizer> c
677680

678681
return null;
679682
}
683+
684+
@Override
685+
public void registerDemographicsProvider(DemographicsProvider provider)
686+
{
687+
_demographicsProviders.add(provider);
688+
}
689+
690+
@Override
691+
public List<DemographicsProvider> getDemographicsProviders(final Container c, final User u)
692+
{
693+
return _demographicsProviders.stream().filter(d -> d.isAvailable(c, u)).toList();
694+
}
695+
696+
@Override
697+
public @Nullable DemographicsProvider getDemographicsProviderByName(Container c, User u, String name)
698+
{
699+
if (name == null)
700+
{
701+
throw new IllegalArgumentException("The DemographicsProvider name cannot be null");
702+
}
703+
704+
for (DemographicsProvider d : getDemographicsProviders(c, u))
705+
{
706+
if (name.equals(d.getLabel()))
707+
{
708+
return d;
709+
}
710+
}
711+
712+
return null;
713+
}
680714
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.labkey.laboratory.query;
2+
3+
import org.jetbrains.annotations.Nullable;
4+
import org.labkey.api.laboratory.DemographicsProvider;
5+
import org.labkey.api.module.ModuleLoader;
6+
import org.labkey.laboratory.LaboratoryModule;
7+
import org.labkey.laboratory.LaboratorySchema;
8+
9+
public class LaboratoryDemographicsProvider extends DemographicsProvider
10+
{
11+
public LaboratoryDemographicsProvider()
12+
{
13+
super(ModuleLoader.getInstance().getModule(LaboratoryModule.class), LaboratoryModule.SCHEMA_NAME, LaboratorySchema.TABLE_SUBJECTS, "subjectname");
14+
}
15+
16+
@Nullable
17+
@Override
18+
public String getMotherField()
19+
{
20+
return "mother";
21+
}
22+
23+
@Nullable
24+
@Override
25+
public String getFatherField()
26+
{
27+
return "father";
28+
}
29+
30+
@Nullable
31+
@Override
32+
public String getSexField()
33+
{
34+
return "gender";
35+
}
36+
}

0 commit comments

Comments
 (0)