|
17 | 17 |
|
18 | 18 | import org.apache.logging.log4j.Logger; |
19 | 19 | import org.apache.logging.log4j.LogManager; |
| 20 | +import org.jetbrains.annotations.Nullable; |
20 | 21 | import org.json.JSONObject; |
21 | 22 | import org.labkey.api.assay.AssayFileWriter; |
22 | 23 | import org.labkey.api.assay.AssayProvider; |
|
35 | 36 | import org.labkey.api.exp.api.ExpRun; |
36 | 37 | import org.labkey.api.exp.api.ExperimentService; |
37 | 38 | import org.labkey.api.laboratory.DataProvider; |
| 39 | +import org.labkey.api.laboratory.DemographicsProvider; |
38 | 40 | import org.labkey.api.laboratory.LaboratoryService; |
39 | 41 | import org.labkey.api.laboratory.NavItem; |
40 | 42 | import org.labkey.api.laboratory.TabbedReportItem; |
@@ -80,6 +82,7 @@ public class LaboratoryServiceImpl extends LaboratoryService |
80 | 82 | private final Map<String, Map<String, List<ButtonConfigFactory>>> _assayButtons = new CaseInsensitiveHashMap<>(); |
81 | 83 | private final Map<String, DataProvider> _dataProviders = new HashMap<>(); |
82 | 84 | private final Map<String, Map<String, List<Pair<Module, Class<? extends TableCustomizer>>>>> _tableCustomizers = new CaseInsensitiveHashMap<>(); |
| 85 | + private final List<DemographicsProvider> _demographicsProviders = new ArrayList<>(); |
83 | 86 |
|
84 | 87 | public static final String DEMOGRAPHICS_PROPERTY_CATEGORY = "laboratory.demographicsSource"; |
85 | 88 | public static final String DATASOURCE_PROPERTY_CATEGORY = "laboratory.additionalDataSource"; |
@@ -677,4 +680,35 @@ private TableCustomizer instantiateCustomizer(Class<? extends TableCustomizer> c |
677 | 680 |
|
678 | 681 | return null; |
679 | 682 | } |
| 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 | + } |
680 | 714 | } |
0 commit comments