Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1189,18 +1189,25 @@ public void testDataClassLsidCache() throws Exception
// first lookup populates the mapping, second is served from the container's data class cache
for (int i = 0; i < 2; i++)
{
ExpDataClass fromProject = ExperimentService.get().getDataClass(projectLsid);
ExpDataClassImpl fromProject = ExperimentServiceImpl.get().getDataClass(projectLsid);
assertNotNull("Lookup " + i + " by LSID should resolve the data class", fromProject);
assertEquals("lsidCacheProject", fromProject.getName());
assertEquals(projectDataClass.getRowId(), fromProject.getRowId());
assertEquals(c.getId(), fromProject.getContainer().getId());

ExpDataClass fromSub = ExperimentService.get().getDataClass(subLsid);
ExpDataClassImpl fromSub = ExperimentServiceImpl.get().getDataClass(subLsid);
assertNotNull("Lookup " + i + " by LSID should resolve the subfolder data class", fromSub);
assertEquals("lsidCacheSub", fromSub.getName());
assertEquals(sub.getId(), fromSub.getContainer().getId());
}

assertSame("LSID lookup should be served from the data class cache",
ExperimentServiceImpl.get().getDataClass(c, "lsidCacheProject").getDataObject(),
ExperimentServiceImpl.get().getDataClass(projectLsid).getDataObject());
assertSame("Subfolder LSID lookup should be served from the data class cache",
ExperimentServiceImpl.get().getDataClass(sub, "lsidCacheSub").getDataObject(),
ExperimentServiceImpl.get().getDataClass(subLsid).getDataObject());

projectDataClass.delete(_user);
assertNull("Deleted data class should not resolve from a stale LSID mapping", ExperimentService.get().getDataClass(projectLsid));
assertNotNull("Sibling data class should be unaffected", ExperimentService.get().getDataClass(subLsid));
Expand All @@ -1223,10 +1230,14 @@ public void testFailedDataClassUpdateDoesNotCorruptCache() throws Exception
helper.insertRows(c, rows, child.getName());

// warm the mapping so the second lookup comes back from the container's data class cache
assertNotNull(ExperimentService.get().getDataClass(child.getLSID()));
final ExpDataClass toUpdate = ExperimentService.get().getDataClass(child.getLSID());
assertNotNull(ExperimentServiceImpl.get().getDataClass(child.getLSID()));
final ExpDataClassImpl toUpdate = ExperimentServiceImpl.get().getDataClass(child.getLSID());
assertNotNull(toUpdate);

assertSame("Update target should wrap the cached DataClass",
ExperimentServiceImpl.get().getDataClass(c, "failedUpdateChild").getDataObject(),
toUpdate.getDataObject());

Map<String, Object> parentAlias = new HashMap<>();
parentAlias.put("inputType", ExperimentJSONConverter.DATA_INPUTS_ALIAS_PREFIX + "failedUpdateParent");
parentAlias.put("required", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1894,12 +1894,8 @@ public ExpDataClassImpl getDataClass(long rowId)
dataClass = new ExpDataClassImpl(dc);
}

if (null != dataClass)
{
Container dcContainer = dataClass.getContainer();
if (dcContainer != null && dcContainer.getId().equals(containerId))
dataClassLsidCache.put(lsid, dataClass.getContainer().getId());
}
if (null != dataClass && null == containerId)
dataClassLsidCache.put(lsid, dataClass.getContainer().getId());

return dataClass;
}
Expand Down