Skip to content

Commit 17d3404

Browse files
authored
Resolve LabworkTypes in module dependency order to remove need for registerLabworkOverrides (#738)
1 parent c9bfb27 commit 17d3404

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed

ehr/api-src/org/labkey/api/ehr/EHRService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ public EHRQCState getQCState(@NotNull Container c)
328328
/** The EHR expects certain QC states to exist. This will inspect the current study and create any missing QC states. **/
329329
abstract public List<String> ensureStudyQCStates(Container c, final User u, final boolean commitChanges);
330330

331-
abstract public void registerLabWorkOverrides(Module module, String fromType, LabworkType toType);
332-
333331
/**
334332
* The EHR has a built-in GeneticsCalculations pipeline job that computes inbreeding and kinship based on the pedigree.
335333
* These are normally calculated in R, saved as TSVs, and imported using java code. This method is a separate entrypoint

ehr/api-src/org/labkey/api/ehr/history/DefaultLabworkType.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class DefaultLabworkType implements LabworkType
7979
@NotNull
8080
private final Module _declaringModule;
8181

82-
public DefaultLabworkType(String name, String schemaName, String queryName, Module declaringModule)
82+
public DefaultLabworkType(String name, String schemaName, String queryName, @NotNull Module declaringModule)
8383
{
8484
_name = name;
8585
_schemaName = schemaName;
@@ -118,6 +118,11 @@ public boolean isEnabled(Container c)
118118
return c.getActiveModules().contains(_declaringModule);
119119
}
120120

121+
public Module getDeclaringModule()
122+
{
123+
return _declaringModule;
124+
}
125+
121126
@Override
122127
public List<String> getResults(Container c, User u, String runId, boolean redacted)
123128
{

ehr/src/org/labkey/ehr/EHRServiceImpl.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public class EHRServiceImpl extends EHRService
113113
private final List<DemographicsProvider> _demographicsProviders = new ArrayList<>();
114114
private final Map<REPORT_LINK_TYPE, List<ReportLink>> _reportLinks = new HashMap<>();
115115
private final MultiValuedMap<String, Pair<Module, Path>> _actionOverrides = new ArrayListValuedHashMap<>();
116-
private final Map<String, Pair<Module, LabworkType>> _labWorkOverrides = new HashMap<>();
117116
private final List<Pair<Module, Resource>> _extraTriggerScripts = new ArrayList<>();
118117
private final Map<Module, List<Supplier<ClientDependency>>> _clientDependencies = new HashMap<>();
119118
private final Map<String, Map<String, List<Pair<Module, Class<? extends TableCustomizer>>>>> _tableCustomizers = new CaseInsensitiveHashMap<>();
@@ -1055,16 +1054,6 @@ public void appendSNOMEDCols(AbstractTableInfo ti, String displayColumnName, Str
10551054
}
10561055
}
10571056

1058-
public void registerLabWorkOverrides(Module module, String fromType, LabworkType toType)
1059-
{
1060-
_labWorkOverrides.put(fromType, Pair.of(module, toType));
1061-
}
1062-
1063-
public Map<String, Pair<Module, LabworkType>> getLabWorkOverrides()
1064-
{
1065-
return _labWorkOverrides;
1066-
}
1067-
10681057
@Override
10691058
public void standaloneProcessKinshipAndInbreeding(Container c, User u, File pipelineDir, Logger log) throws PipelineJobException
10701059
{

ehr/src/org/labkey/ehr/history/LabworkManager.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Collections;
2929
import java.util.Date;
3030
import java.util.HashMap;
31+
import java.util.LinkedHashMap;
3132
import java.util.List;
3233
import java.util.Map;
3334

@@ -57,24 +58,20 @@ public void registerType(LabworkType type)
5758

5859
public Collection<LabworkType> getTypes(Container c)
5960
{
60-
List<LabworkType> result = new ArrayList<>(_types.size());
61-
Map<String, Pair<Module, LabworkType>> labworkTypeOverrides = EHRServiceImpl.get().getLabWorkOverrides();
61+
Map<String, LabworkType> map = new LinkedHashMap<>();
6262
for (LabworkType type : _types)
6363
{
64+
// NOTE: Because modules initialize in dependency order, they will be registered in order and the code below should allow
65+
// center modules to override default EHR labwork types.
66+
// Also, if it ever becomes necessary for a center module to simply eliminate a built-in labwork type we could consider making a
67+
// NoOpLabworkType. A module could register this to replace a built-in Labwork type with one that doesnt do anything.
6468
if (type.isEnabled(c))
6569
{
66-
if (labworkTypeOverrides.containsKey(type.getName()))
67-
{
68-
Pair<Module, LabworkType> override = labworkTypeOverrides.get(type.getName());
69-
result.add(override.getValue());
70-
}
71-
else
72-
{
73-
result.add(type);
74-
}
70+
map.put(type.getName(), type);
7571
}
7672
}
77-
return Collections.unmodifiableCollection(result);
73+
74+
return Collections.unmodifiableCollection(map.values());
7875
}
7976

8077
public List<String> getResults(Container c, User u, String runId, boolean redacted)

0 commit comments

Comments
 (0)