Skip to content

Commit d2da682

Browse files
Use EHR Study Container Entity Id instead of Study Entity Id to generate cache key (#1029)
* Use EHR Study container to get cache key instead of study (study is not present when trying to populate lookups but goes through this code path when registering and unregistering lookups trigger script causing test failures).
1 parent 908be2e commit d2da682

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ehr/src/org/labkey/ehr/security/EHRSecurityManager.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,29 +224,25 @@ public Map<String, EHRQCState> getQCStateInfo(Container c)
224224
if (targetContainer == null)
225225
return Collections.emptyMap();
226226

227-
Study study = StudyService.get().getStudy(targetContainer);
228-
if (study == null)
229-
return Collections.emptyMap();
230-
231-
String cacheKey = getCacheKey(study, QCSTATE_CACHE_ID);
227+
String cacheKey = getCacheKey(targetContainer, QCSTATE_CACHE_ID);
232228
Map<String, EHRQCState> qcStates = (Map<String, EHRQCState>) DataEntryManager.get().getCache().get(cacheKey);
233-
if (qcStates != null)
229+
if (qcStates != null && !qcStates.isEmpty())
234230
return qcStates;
235231

236232
qcStates = new HashMap<>();
237-
for (EHRQCState qc : EHRManager.get().getQCStates(study.getContainer()))
233+
for (EHRQCState qc : EHRManager.get().getQCStates(targetContainer))
238234
{
239235
qcStates.put(qc.getLabel(), qc);
240236
}
241237

242238
qcStates = Collections.unmodifiableMap(qcStates);
243-
DataEntryManager.get().getCache().put(getCacheKey(study, QCSTATE_CACHE_ID), qcStates);
239+
DataEntryManager.get().getCache().put(getCacheKey(targetContainer, QCSTATE_CACHE_ID), qcStates);
244240

245241
return qcStates;
246242
}
247243

248-
private String getCacheKey(Study s, String suffix)
244+
private String getCacheKey(Container c, String suffix)
249245
{
250-
return getClass().getName() + "||" + s.getEntityId() + "||" + suffix;
246+
return getClass().getName() + "||" + c.getEntityId() + "||" + suffix;
251247
}
252248
}

0 commit comments

Comments
 (0)