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
13 changes: 8 additions & 5 deletions api/src/org/labkey/api/exp/query/SamplesSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,17 @@ public ForeignKey materialIdForeignKey(@Nullable final ExpSampleType st, @Nullab

private TableInfo createLookupTableInfo()
{
// Hack to support lookup via RowId or Name
if (domainProperty != null && domainProperty.getPropertyType().getJdbcType().isText())
_columnName = "Name";

// GitHub Issue #688
if (st != null)
return getTable(tableName, getLookupContainerFilter());

ExpMaterialTable ret = ExperimentService.get().createMaterialTable(SamplesSchema.this, getLookupContainerFilter(), st);
ret.populate();
ret.overlayMetadata(ret.getPublicName(), SamplesSchema.this, new ArrayList<>());
if (domainProperty != null && domainProperty.getPropertyType().getJdbcType().isText())
{
// Hack to support lookup via RowId or Name
_columnName = "Name";
}
ret.setLocked(true);
return ret;
}
Expand Down
20 changes: 17 additions & 3 deletions study/test/src/org/labkey/test/tests/study/AssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ public void testSampleFieldUpdate()
clickAndWait(Locator.linkWithText("view results"));
assertElementPresent("Sample lookup failed for: OS_1", new Locator.LinkLocator("OS_1"), 1);


log("Edit assay design and change Sample field to point to created Sample Type");
goToManageAssays();
clickAndWait(Locator.LinkLocator.linkWithText(SAMPLE_FIELD_TEST_ASSAY));
Expand All @@ -222,10 +221,21 @@ public void testSampleFieldUpdate()
importAssayData(SAMPLE_FIELD_TEST_ASSAY, TEST_RUN2, "SampleField\nS_1");
goToManageAssays().clickAndWait(Locator.linkWithText(SAMPLE_FIELD_TEST_ASSAY));
clickAndWait(Locator.linkWithText("view results"));
// assertElementPresent("Sample lookup failed for: OS_1", new Locator.LinkLocator("OS_1"), 1); //TODO this becomes the RowId "<123>" after change. Issue #40047

DataRegionTable table = new DataRegionTable("Data", getDriver());
List<String> sampleFieldValues = table.getColumnDataAsText("SampleField");
assertTrue("First sample should not resolve to sample type", sampleFieldValues.get(0).startsWith("<"));
assertEquals("Second sample should resolve to sample type", "S_1", sampleFieldValues.get(1));
assertElementPresent("Sample lookup failed for: S_1", new Locator.LinkLocator("S_1"), 1);

log("GitHub Issue #688: verify sample lookup to createdBy");
_customizeViewsHelper.openCustomizeViewPanel();
_customizeViewsHelper.addColumn("SampleField/CreatedBy");
_customizeViewsHelper.applyCustomView();
table = new DataRegionTable("Data", getDriver());
List<String> createdByValues = table.getColumnDataAsText("SampleField/CreatedBy");
assertEquals("First sample should not have a createdBy since it doesn't resolve", " ", createdByValues.get(0));
assertEquals("Second sample should have a createdBy since it resolves to a sample type", getCurrentUserName(), createdByValues.get(1));

log("Edit assay design and change Sample field to point back to 'All Samples'");
goToManageAssays();
clickAndWait(Locator.LinkLocator.linkWithText(SAMPLE_FIELD_TEST_ASSAY));
Expand All @@ -247,6 +257,10 @@ public void testSampleFieldUpdate()
assertElementPresent("Sample lookup failed for: S_2", new Locator.LinkLocator("S_2"), 1);
assertElementPresent("Sample lookup failed for: OS_2", new Locator.LinkLocator("OS_2"), 1);

log("GitHub Issue #688: verify sample lookup to createdBy");
table = new DataRegionTable("Data", getDriver());
for (int i = 0; i < table.getDataRowCount(); i++)
assertEquals("Row " + i + " should have current user as createdBy since they all resolve to samples", getCurrentUserName(), table.getDataAsText(i, "SampleField/CreatedBy"));
}

private void importAssayData(String assayName, String runName, String runDataStr)
Expand Down
Loading